Extra tests for @constructor.

This commit is contained in:
Michael Mathews 2010-07-09 21:34:10 +01:00
parent 33ef0da73c
commit 6db800da84
2 changed files with 31 additions and 10 deletions

View File

@ -16,3 +16,8 @@ function Pez() {
/** @constructor */ /** @constructor */
Qux = function() { Qux = function() {
} }
var somevar,
/** @constructor */
Blap = function(a, b) {
};

View File

@ -10,19 +10,21 @@
tag: require('jsdoc/tag'), tag: require('jsdoc/tag'),
parser: require('jsdoc/parser') parser: require('jsdoc/parser')
}; };
jsdoc.parser.parseFiles(BASEDIR + 'test/samples/tag_constructor.js'); jsdoc.parser.parseFiles(BASEDIR + 'test/samples/tag_constructor.js');
doclets = jsdoc.parser.result;
doclets = jsdoc.parser.result.map(function($){ return $.toObject(); });
}); });
describe('A doclet from a constructor tag with a name tag and no code', function() { describe('A doclet from a constructor tag with a name tag and no code', function() {
it('should have an `isa` property set to "constructor"', function() { it('should have an `isa` property set to "constructor"', function() {
var doclet = doclets[0].toObject(); var doclet = doclets[0];
expect(doclet).to(have_property, 'isa'); expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'constructor'); expect(doclet.isa).to(eql, 'constructor');
}); });
it('should have a `name` property set to the given name"', function() { it('should have a `name` property set to the given name"', function() {
var doclet = doclets[0].toObject(); var doclet = doclets[0];
expect(doclet).to(have_property, 'name'); expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'Foo'); expect(doclet.name).to(eql, 'Foo');
}); });
@ -30,13 +32,13 @@
describe('A doclet from a named constructor tag and no code', function() { describe('A doclet from a named constructor tag and no code', function() {
it('should have an `isa` property set to "constructor"', function() { it('should have an `isa` property set to "constructor"', function() {
var doclet = doclets[1].toObject(); var doclet = doclets[1];
expect(doclet).to(have_property, 'isa'); expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'constructor'); expect(doclet.isa).to(eql, 'constructor');
}); });
it('should have a `name` property set to the given name"', function() { it('should have a `name` property set to the given name"', function() {
var doclet = doclets[1].toObject(); var doclet = doclets[1];
expect(doclet).to(have_property, 'name'); expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'Bar'); expect(doclet.name).to(eql, 'Bar');
}); });
@ -44,13 +46,13 @@
describe('A doclet from a constructor tag and named code', function() { describe('A doclet from a constructor tag and named code', function() {
it('should have an `isa` property set to "constructor"', function() { it('should have an `isa` property set to "constructor"', function() {
var doclet = doclets[2].toObject(); var doclet = doclets[2];
expect(doclet).to(have_property, 'isa'); expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'constructor'); expect(doclet.isa).to(eql, 'constructor');
}); });
it('should have a `name` property set to the given name"', function() { it('should have a `name` property set to the given name"', function() {
var doclet = doclets[2].toObject(); var doclet = doclets[2];
expect(doclet).to(have_property, 'name'); expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'Pez'); expect(doclet.name).to(eql, 'Pez');
}); });
@ -58,17 +60,31 @@
describe('A doclet from a constructor tag and named anonymous function', function() { describe('A doclet from a constructor tag and named anonymous function', function() {
it('should have an `isa` property set to "constructor"', function() { it('should have an `isa` property set to "constructor"', function() {
var doclet = doclets[3].toObject(); var doclet = doclets[3];
expect(doclet).to(have_property, 'isa'); expect(doclet).to(have_property, 'isa');
expect(doclet.isa).to(eql, 'constructor'); expect(doclet.isa).to(eql, 'constructor');
}); });
it('should have a `name` property set to the given name"', function() { it('should have a `name` property set to the given name"', function() {
var doclet = doclets[3].toObject(); var doclet = doclets[3];
expect(doclet).to(have_property, 'name'); expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'Qux'); expect(doclet.name).to(eql, 'Qux');
}); });
}); });
describe('A doclet from a constructor tag and named anonymous function part of a var', function() {
it('should have an `isa` property set to "constructor"', function() {
var doclet = doclets[4];
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[4];
expect(doclet).to(have_property, 'name');
expect(doclet.name).to(eql, 'Blap');
});
});
}); });
})(); })();