Added tests for jsdoc.tag.

This commit is contained in:
Michael Mathews 2010-06-27 22:56:16 +01:00
parent 0965910fa5
commit 0a0e35cfd7
4 changed files with 101 additions and 1 deletions

View File

@ -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.

View File

@ -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({

View File

@ -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);

View File

@ -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
*/
})();