mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Added tests for @method and @member.
This commit is contained in:
parent
e3f6d5a3e5
commit
666dd53143
@ -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.
|
||||
|
||||
@ -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?
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
JSpec.describe('jsdoc/opts.js', function() {
|
||||
|
||||
before_each(function() {
|
||||
before(function() {
|
||||
jsdoc = { opts: require('jsdoc/opts') };
|
||||
});
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
JSpec.describe('jsdoc/src.js', function() {
|
||||
|
||||
before_each(function() {
|
||||
before(function() {
|
||||
jsdoc = { src: require('jsdoc/src') };
|
||||
});
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
JSpec.describe('jsdoc/parser.js', function() {
|
||||
|
||||
before_each(function() {
|
||||
before(function() {
|
||||
jsdoc = { parser: require('jsdoc/parser') };
|
||||
});
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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'),
|
||||
|
||||
@ -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'),
|
||||
|
||||
@ -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'),
|
||||
|
||||
@ -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() {
|
||||
|
||||
70
test/tests/13_tag_method.js
Normal file
70
test/tests/13_tag_method.js
Normal 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 */
|
||||
|
||||
})();
|
||||
76
test/tests/14_tag_member.js
Normal file
76
test/tests/14_tag_member.js
Normal 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
|
||||
*/
|
||||
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user