diff --git a/modules/jsdoc/doclet.js b/modules/jsdoc/doclet.js index 2efa202a..7bad4223 100644 --- a/modules/jsdoc/doclet.js +++ b/modules/jsdoc/doclet.js @@ -79,7 +79,7 @@ } /** - Return the text of the first tag with the given name. + Return the text of the last tag with the given name. @method Doclet#tagText @param {String} tagName @returns {String} The text of the found tag. diff --git a/test/runall.js b/test/runall.js index 2b5177fd..b5b87ee9 100644 --- a/test/runall.js +++ b/test/runall.js @@ -3,6 +3,7 @@ load(BASEDIR + '/test/tests/02_jsdoc_src.js'); load(BASEDIR + '/test/tests/03_jsdoc_parser.js'); load(BASEDIR + '/test/tests/04_jsdoc_docset.js'); load(BASEDIR + '/test/tests/05_jsdoc_doclet.js'); +load(BASEDIR + '/test/tests/06_jsdoc_tag.js'); // see http://visionmedia.github.com/jspec/ JSpec.run({ diff --git a/test/tests/05_jsdoc_doclet.js b/test/tests/05_jsdoc_doclet.js index 1e5bde38..94866d50 100644 --- a/test/tests/05_jsdoc_doclet.js +++ b/test/tests/05_jsdoc_doclet.js @@ -24,6 +24,11 @@ expect(doclet).to(respond_to, 'toObject'); }); + it('should have a `tags` property which is an array', function() { + expect(doclet).to(have_property, 'tags'); + expect(doclet.tags).to(be_an, Array); + }); + it('should have a `meta` property which is an object', function() { expect(doclet).to(have_property, 'meta'); expect(doclet.meta).to(be_an, Object); diff --git a/test/tests/06_jsdoc_tag.js b/test/tests/06_jsdoc_tag.js new file mode 100644 index 00000000..82e33347 --- /dev/null +++ b/test/tests/06_jsdoc_tag.js @@ -0,0 +1,94 @@ +(function() { + var jsdoc, + tags; + + JSpec.describe('jsdoc/tag.js', function() { + + before_each(function() { + // docsets can only be created by parsers + jsdoc = { + tag: require('jsdoc/tag'), + parser: require('jsdoc/parser') + }; + jsdoc.parser.parseFiles(BASEDIR + 'test/tests/06_jsdoc_tag.js'); + tags = jsdoc.parser.result[0].tags; + }); + + describe('The object exported by the jsdoc/tag module', function() { + it('should be an object', function() { + expect(jsdoc.tag).to(be_an, Object); + }); + + it('should have a `fromTagText` method', function() { + expect(jsdoc.tag).to(respond_to, 'fromTagText'); + }); + + it('should have a `parse` method', function() { + expect(jsdoc.tag).to(respond_to, 'parse'); + }); + }); + + describe('The tag object', function() { + it('should be a Tag', function() { + var tag = tags[0]; + expect(tag.constructor.name).to(eql, 'Tag'); + }); + + it('should have a `raw` property which is an string', function() { + var tag = tags[0]; + expect(tag).to(have_property, 'raw'); + expect(tag.raw).to(be_an, String); + }); + + it('should have a `name` property which is an string', function() { + var tag = tags[0]; + expect(tag).to(have_property, 'name'); + expect(tag.name).to(be_an, String); + }); + + it('should have a `text` property which is an string', function() { + var tag = tags[0]; + expect(tag).to(have_property, 'text'); + expect(tag.text).to(be_an, String); + }); + + it('should have a `type` property which is an array', function() { + var tag = tags[0]; + expect(tag).to(have_property, 'type'); + expect(tag.type).to(be_an, Array); + }); + }); + + describe('The tag#raw property', function() { + it('should be set to all the characters after the leading @', function() { + var tag = tags[0]; + expect(tag.raw).to(include, 'desc Hello world'); + }); + }); + + describe('The tag#name property', function() { + it('should be set to the text after the leading @', function() { + var tag = tags[0]; + expect(tag.name).to(eql, 'desc'); + }); + }); + + describe('The tag#text property', function() { + it('should be set to the text after the @name', function() { + var tag = tags[0]; + expect(tag.text).to(eql, 'Hello world'); + }); + }); + + }); +})(); + +(function testarea() { + + /** + @desc Hello world + @name Foo + @constructor + */ + +})(); \ No newline at end of file