Added tests for @method and @member.

This commit is contained in:
Michael Mathews 2010-07-02 07:19:59 +01:00
parent e3f6d5a3e5
commit 666dd53143
14 changed files with 161 additions and 13 deletions

View File

@ -219,7 +219,7 @@
// other tags that can provide the memberof
var memberofs = {methodof: 'method', propertyof: 'property', eventof: 'event'};
// other tags that can provide the symbol name
var nameables = ['constructor', 'const', 'module', 'event', 'namespace', 'method', 'property', 'function', 'variable', 'enum'];
var nameables = ['constructor', 'const', 'module', 'event', 'namespace', 'method', 'property', 'enum'];
/**
Expand some shortcut tags. Modifies the tags argument in-place.

View File

@ -145,8 +145,9 @@
exports.synonyms = {
'description': 'desc',
'function': 'method',
'variable': 'member',
'return': 'returns'
'variable': 'property',
'return': 'returns',
'member': 'memberof'
}
//TODO: move into a shared module?

View File

@ -8,6 +8,8 @@ load(BASEDIR + '/test/tests/06_jsdoc_tag.js');
load(BASEDIR + '/test/tests/10_tag_constructor.js');
load(BASEDIR + '/test/tests/11_tag_namespace.js');
load(BASEDIR + '/test/tests/12_tag_property.js');
load(BASEDIR + '/test/tests/13_tag_method.js');
load(BASEDIR + '/test/tests/14_tag_member.js');
// see http://visionmedia.github.com/jspec/
JSpec.run({

View File

@ -3,7 +3,7 @@
JSpec.describe('jsdoc/opts.js', function() {
before_each(function() {
before(function() {
jsdoc = { opts: require('jsdoc/opts') };
});

View File

@ -3,7 +3,7 @@
JSpec.describe('jsdoc/src.js', function() {
before_each(function() {
before(function() {
jsdoc = { src: require('jsdoc/src') };
});

View File

@ -3,7 +3,7 @@
JSpec.describe('jsdoc/parser.js', function() {
before_each(function() {
before(function() {
jsdoc = { parser: require('jsdoc/parser') };
});

View File

@ -3,7 +3,7 @@
JSpec.describe('jsdoc/docset.js', function() {
before_each(function() {
before(function() {
// docsets can only be created by parsers
jsdoc = { parser: require('jsdoc/parser') };
jsdoc.parser.parseFiles(BASEDIR + 'test/tests/04_jsdoc_docset.js');

View File

@ -4,7 +4,7 @@
JSpec.describe('jsdoc/doclet.js', function() {
before_each(function() {
before(function() {
// docsets can only be created by parsers
jsdoc = { parser: require('jsdoc/parser') };
jsdoc.parser.parseFiles(BASEDIR + 'test/tests/05_jsdoc_doclet.js');

View File

@ -4,7 +4,7 @@
JSpec.describe('jsdoc/tag.js', function() {
before_each(function() {
before(function() {
// docsets can only be created by parsers
jsdoc = {
tag: require('jsdoc/tag'),

View File

@ -4,7 +4,7 @@
JSpec.describe('@constructor', function() {
before_each(function() {
before(function() {
// docsets can only be created by parsers
jsdoc = {
tag: require('jsdoc/tag'),

View File

@ -4,7 +4,7 @@
JSpec.describe('@namespace', function() {
before_each(function() {
before(function() {
// docsets can only be created by parsers
jsdoc = {
tag: require('jsdoc/tag'),

View File

@ -4,7 +4,7 @@
JSpec.describe('@property', function() {
before_each(function() {
before(function() {
// docsets can only be created by parsers
jsdoc = {
tag: require('jsdoc/tag'),
@ -12,7 +12,6 @@
};
jsdoc.parser.parseFiles(BASEDIR + 'test/tests/12_tag_property.js');
doclets = jsdoc.parser.result;
});
describe('A doclet with a named property tag attached to a namespace', function() {

View File

@ -0,0 +1,70 @@
(function() {
var jsdoc,
doclets;
JSpec.describe('@method', function() {
before(function() {
// docsets can only be created by parsers
jsdoc = {
tag: require('jsdoc/tag'),
parser: require('jsdoc/parser')
};
jsdoc.parser.parseFiles(BASEDIR + 'test/tests/13_tag_method.js');
doclets = jsdoc.parser.result;
});
describe('A doclet with a named method tag attached to a namespace', function() {
it('should have an `isa` property set to "method"', function() {
var doclet = doclets[2].toObject();
expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'method');
});
it('should have a `name` property set to the given name"', function() {
var doclet = doclets[2].toObject();
expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'fah');
});
it('should have a `memberof` property set to the parent object name', function() {
var doclet = doclets[2].toObject();
expect(doclet).to(have_property, 'memberof');
expect(doclet.memberof).to(eql, 'foo');
});
});
describe('A doclet with a named method tag attached to a constructor', function() {
it('should have an `isa` property set to "method"', function() {
var doclet = doclets[3].toObject();
expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'method');
});
it('should have a `name` property set to the given name"', function() {
var doclet = doclets[3].toObject();
expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'bah');
});
it('should have a `memberof` property set to the parent object name', function() {
var doclet = doclets[3].toObject();
expect(doclet).to(have_property, 'memberof');
expect(doclet.memberof).to(eql, 'bar');
});
});
});
})();
(function testarea() {
/** @namespace foo */
/** @constructor bar */
/** @method foo.fah */
/** @method bar.bah */
})();

View File

@ -0,0 +1,76 @@
(function() {
var jsdoc,
doclets;
JSpec.describe('@member', function() {
before(function() {
// docsets can only be created by parsers
jsdoc = {
tag: require('jsdoc/tag'),
parser: require('jsdoc/parser')
};
jsdoc.parser.parseFiles(BASEDIR + 'test/tests/14_tag_member.js');
doclets = jsdoc.parser.result;
});
describe('A doclet with a method tag and a memberof tag', function() {
it('should have an `isa` property set to "method"', function() {
var doclet = doclets[2].toObject();
expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'method');
});
it('should have a `name` property set to the given name"', function() {
var doclet = doclets[2].toObject();
expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'fah');
});
it('should have a `memberof` property set to the given member name', function() {
var doclet = doclets[2].toObject();
expect(doclet).to(have_property, 'memberof');
expect(doclet.memberof).to(eql, 'foo');
});
});
describe('A doclet with a property tag and a member tag', function() {
it('should have an `isa` property set to "property"', function() {
var doclet = doclets[3].toObject();
expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'property');
});
it('should have a `name` property set to the given name"', function() {
var doclet = doclets[3].toObject();
expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'bah');
});
it('should have a `memberof` property set to the given member name', function() {
var doclet = doclets[3].toObject();
expect(doclet).to(have_property, 'memberof');
expect(doclet.memberof).to(eql, 'bar');
});
});
});
})();
(function testarea() {
/** @namespace foo */
/** @constructor bar */
/**
@method fah
@memberof foo
*/
/**
@property bah
@member bar
*/
})();