From f5b2ef38f29476568c22d725b1c5a9a2aca2127a Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Wed, 30 Jun 2010 22:11:55 +0100 Subject: [PATCH] Added tests for @namespace. --- test/runall.js | 1 + test/tests/10_tag_constructor.js | 21 +++++++- test/tests/11_tag_namespace.js | 93 ++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 test/tests/11_tag_namespace.js diff --git a/test/runall.js b/test/runall.js index 1dab98a5..1bba2528 100644 --- a/test/runall.js +++ b/test/runall.js @@ -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({ diff --git a/test/tests/10_tag_constructor.js b/test/tests/10_tag_constructor.js index 5044ae48..e3d76103 100644 --- a/test/tests/10_tag_constructor.js +++ b/test/tests/10_tag_constructor.js @@ -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() { + } })(); \ No newline at end of file diff --git a/test/tests/11_tag_namespace.js b/test/tests/11_tag_namespace.js new file mode 100644 index 00000000..dd06cc40 --- /dev/null +++ b/test/tests/11_tag_namespace.js @@ -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() { } +})(); \ No newline at end of file