Added tests for @namespace.

This commit is contained in:
Michael Mathews 2010-06-30 22:11:55 +01:00
parent e81f89cfbd
commit f5b2ef38f2
3 changed files with 114 additions and 1 deletions

View File

@ -6,6 +6,7 @@ load(BASEDIR + '/test/tests/05_jsdoc_doclet.js');
load(BASEDIR + '/test/tests/06_jsdoc_tag.js');
load(BASEDIR + '/test/tests/10_tag_constructor.js');
load(BASEDIR + '/test/tests/11_tag_namespace.js');
// see http://visionmedia.github.com/jspec/
JSpec.run({

View File

@ -56,6 +56,20 @@
});
});
describe('A doclet from a constructor tag and named anonymous function', function() {
it('should have an `isa` property set to "constructor"', function() {
var doclet = doclets[3].toObject();
expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'constructor');
});
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, 'Qux');
});
});
});
})();
@ -75,5 +89,10 @@
*/
function Pez() {
}
/**
@constructor
*/
Qux = function() {
}
})();

View File

@ -0,0 +1,93 @@
(function() {
var jsdoc,
doclets;
JSpec.describe('@namespace', 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/11_tag_namespace.js');
doclets = jsdoc.parser.result;
});
describe('A doclet from a namespace tag with a name tag and no code', function() {
it('should have an `isa` property set to "namespace"', function() {
var doclet = doclets[0].toObject();
expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'namespace');
});
it('should have a `name` property set to the given name"', function() {
var doclet = doclets[0].toObject();
expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'foo');
});
});
describe('A doclet from a named namespace tag and no code', function() {
it('should have an `isa` property set to "namespace"', function() {
var doclet = doclets[1].toObject();
expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'namespace');
});
it('should have a `name` property set to the given name"', function() {
var doclet = doclets[1].toObject();
expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'bar');
});
});
describe('A doclet from a namespace tag and named code', function() {
it('should have an `isa` property set to "namespace"', function() {
var doclet = doclets[2].toObject();
expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'namespace');
});
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, 'pez');
});
});
describe('A doclet from a namespace tag and named anonymous function', function() {
it('should have an `isa` property set to "namespace"', function() {
var doclet = doclets[3].toObject();
expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'namespace');
});
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, 'qux');
});
});
});
})();
(function testarea() {
/**
@name foo
@namespace
*/
/**
@namespace bar
*/
/** @namespace */
pez = {
}
/** @namespace */
var qux = function() { }
})();