diff --git a/test/fixtures/classdesctag.js b/test/fixtures/classdesctag.js new file mode 100644 index 00000000..707a79e6 --- /dev/null +++ b/test/fixtures/classdesctag.js @@ -0,0 +1,7 @@ +/** + * Asdf. + * @class + * @classdesc A description of the class. + */ +function Foo () { +} diff --git a/test/fixtures/descriptiontag.js b/test/fixtures/descriptiontag.js new file mode 100644 index 00000000..78d9d05a --- /dev/null +++ b/test/fixtures/descriptiontag.js @@ -0,0 +1,7 @@ +/** Blah Blah Blah + * @desc halb halb halb + */ +var x; + +/** @description lkjasdf */ +var y; diff --git a/test/fixtures/exampletag.js b/test/fixtures/exampletag.js new file mode 100644 index 00000000..b20f7530 --- /dev/null +++ b/test/fixtures/exampletag.js @@ -0,0 +1,14 @@ +/** @example + * console.log("foo"); + * console.log("bar"); + */ +var x; + +/** @example + * console.log("foo"); + * console.log("bar"); + * @example + * Example 2 + * 1 + 2; + */ +var y; diff --git a/test/fixtures/functiontag.js b/test/fixtures/functiontag.js new file mode 100644 index 00000000..9783268f --- /dev/null +++ b/test/fixtures/functiontag.js @@ -0,0 +1,7 @@ +/** @func Foo */ +function Foo() { +} + +/** @method */ +function Bar() { +} diff --git a/test/fixtures/kindtag.js b/test/fixtures/kindtag.js new file mode 100644 index 00000000..72c5682f --- /dev/null +++ b/test/fixtures/kindtag.js @@ -0,0 +1,2 @@ +/** @kind function */ +var x; diff --git a/test/fixtures/licensetag.js b/test/fixtures/licensetag.js new file mode 100644 index 00000000..e9d852f5 --- /dev/null +++ b/test/fixtures/licensetag.js @@ -0,0 +1,2 @@ +/** @license GPL v2 */ +var x; diff --git a/test/fixtures/membertag.js b/test/fixtures/membertag.js new file mode 100644 index 00000000..66aee08d --- /dev/null +++ b/test/fixtures/membertag.js @@ -0,0 +1,5 @@ +/** @member */ +var x; + +/** @var foobar */ +/** @var {string} baz */ diff --git a/test/fixtures/namespacetag.js b/test/fixtures/namespacetag.js new file mode 100644 index 00000000..82dc1081 --- /dev/null +++ b/test/fixtures/namespacetag.js @@ -0,0 +1,5 @@ +/** @namespace */ +var x = { +}; +/** @namespace Foo */ +/** @namespace {function} Bar */ diff --git a/test/fixtures/scopetags.js b/test/fixtures/scopetags.js new file mode 100644 index 00000000..1eeeb204 --- /dev/null +++ b/test/fixtures/scopetags.js @@ -0,0 +1,10 @@ +/** (scope tags for global objects do not override globalness hence need a container class) + * @module scopetags */ +/** @inner */ +var myInner; + +/** @instance */ +var myInstance; + +/** @static */ +var myStatic; diff --git a/test/fixtures/summarytag.js b/test/fixtures/summarytag.js new file mode 100644 index 00000000..b1f4c496 --- /dev/null +++ b/test/fixtures/summarytag.js @@ -0,0 +1,3 @@ +/** @summary I do not like green eggs and ham! */ +function Sam() { +} diff --git a/test/fixtures/todotag.js b/test/fixtures/todotag.js new file mode 100644 index 00000000..5ecfac4b --- /dev/null +++ b/test/fixtures/todotag.js @@ -0,0 +1,6 @@ +/** A function. + * @todo something + * @todo something else + */ +function x() { +} diff --git a/test/fixtures/tutorialtag.js b/test/fixtures/tutorialtag.js new file mode 100644 index 00000000..b0124dbe --- /dev/null +++ b/test/fixtures/tutorialtag.js @@ -0,0 +1,5 @@ +/** Some documentation. + * @tutorial tute1 + * @tutorial tute2 + */ +var x; diff --git a/test/fixtures/undocumentedtag.js b/test/fixtures/undocumentedtag.js new file mode 100644 index 00000000..01ab4fc3 --- /dev/null +++ b/test/fixtures/undocumentedtag.js @@ -0,0 +1,3 @@ +/** Undocumented doclet. + * @undocumented */ +var x; diff --git a/test/specs/tags/aliastag.js b/test/specs/tags/aliastag.js index 7fea8ac1..4b2396ef 100644 --- a/test/specs/tags/aliastag.js +++ b/test/specs/tags/aliastag.js @@ -1,10 +1,11 @@ describe("@alias tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @name Foo\n@alias Bar */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/alias.js'), + // there are two doclets with longname myObject, we want the second one + myObject = docSet.getByLongname('myObject')[1]; it("adds an 'alias' property to the doclet with the tag's value", function() { - expect(doc.alias).toBeDefined(); - expect(doc.alias).toBe('Bar'); + expect(myObject.alias).toBeDefined(); + expect(myObject.alias).toBe('myObject'); }); // further tests (ensuring alias has the proper effect): documentation/alias.js }); diff --git a/test/specs/tags/classdesctag.js b/test/specs/tags/classdesctag.js index 6bac5852..2a369cf1 100644 --- a/test/specs/tags/classdesctag.js +++ b/test/specs/tags/classdesctag.js @@ -1,6 +1,7 @@ describe("@classdesc tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** Asdf. @class Foo\n@classdesc A description of the class. */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/classdesctag.js'), + doc = docSet.getByLongname('Foo')[0]; + it('adds a classdesc property to the doclet with the description', function() { expect(doc.classdesc).toBe('A description of the class.'); }); diff --git a/test/specs/tags/descriptiontag.js b/test/specs/tags/descriptiontag.js index 4c004e75..855280dc 100644 --- a/test/specs/tags/descriptiontag.js +++ b/test/specs/tags/descriptiontag.js @@ -1,7 +1,7 @@ describe("@description tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** Blah Blah Blah\n @desc halb halb halb */', {}), - doc2 = new doclet.Doclet('/** @description lkjasdf */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/descriptiontag.js'), + doc = docSet.getByLongname('x')[0], + doc2 = docSet.getByLongname('y')[0]; it("sets the doclet's 'description' property to the description", function() { expect(doc2.description).toBeDefined(); diff --git a/test/specs/tags/exampletag.js b/test/specs/tags/exampletag.js index 01ce8214..8d1673c6 100644 --- a/test/specs/tags/exampletag.js +++ b/test/specs/tags/exampletag.js @@ -1,9 +1,9 @@ describe("@example tag", function() { - var doclet = require('jsdoc/doclet'), + var docSet = jasmine.getDocSetFromFile('test/fixtures/exampletag.js'), + doc = docSet.getByLongname('x')[0], + doc2 = docSet.getByLongname('y')[0], txt = 'console.log("foo");\nconsole.log("bar");', - txt2 = '1 + 2;', - doc = new doclet.Doclet('/** @example\n' + txt + '*/', {}), - doc2 = new doclet.Doclet('/** @example\n' + txt + '\n@example\n' + txt2 + '*/', {}); + txt2 = 'Example 2\n1 + 2;'; it("creates an 'examples' property on the doclet with the example", function() { expect(doc.examples).toBeDefined(); diff --git a/test/specs/tags/functiontag.js b/test/specs/tags/functiontag.js index ecd8e202..df63f6b9 100644 --- a/test/specs/tags/functiontag.js +++ b/test/specs/tags/functiontag.js @@ -1,7 +1,7 @@ describe("@function tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @func Foo */', {}), - doc2 = new doclet.Doclet('/** @method */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/functiontag.js'), + doc = docSet.getByLongname('Foo')[0], + doc2 = docSet.getByLongname('Bar')[0]; it("sets the doclet's kind to 'function'", function() { expect(doc.kind).toBe('function'); @@ -10,7 +10,7 @@ describe("@function tag", function() { it("sets the doclet's name to the tag value, if provided", function() { expect(doc.name).toBe('Foo'); - expect(doc2.name).toBeFalsy(); + expect(doc2.name).toBe('Bar'); }); // parameter etc tests take place elsewhere: on its own, all @func does is diff --git a/test/specs/tags/kindtag.js b/test/specs/tags/kindtag.js index f47cf4fb..49d9cd5d 100644 --- a/test/specs/tags/kindtag.js +++ b/test/specs/tags/kindtag.js @@ -1,6 +1,6 @@ describe("@kind tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @kind function */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/kindtag.js'), + doc = docSet.getByLongname('x')[0]; it("sets the doclet's 'kind' property to the tag value", function() { expect(doc.kind).toBeDefined(); expect(doc.kind).toBe('function'); diff --git a/test/specs/tags/licensetag.js b/test/specs/tags/licensetag.js index 0944ae86..e37b1c63 100644 --- a/test/specs/tags/licensetag.js +++ b/test/specs/tags/licensetag.js @@ -1,6 +1,6 @@ describe("@license tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @license GPL v2 */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/licensetag.js'), + doc = docSet.getByLongname('x')[0]; it("sets the doclet's 'license' property to the tag value", function() { expect(doc.license).toBe('GPL v2'); diff --git a/test/specs/tags/membertag.js b/test/specs/tags/membertag.js index 8479d762..cfea6de3 100644 --- a/test/specs/tags/membertag.js +++ b/test/specs/tags/membertag.js @@ -1,8 +1,8 @@ describe("@member tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @member */', {}), - doc2 = new doclet.Doclet('/** @var foobar */', {}), - doc3 = new doclet.Doclet('/** @var {string} baz */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/membertag.js'), + doc = docSet.getByLongname('x')[0], + doc2 = docSet.getByLongname('foobar')[0], + doc3 = docSet.getByLongname('baz')[0]; it("sets the doclet's 'kind' property to 'member'", function() { expect(doc.kind).toBe('member'); @@ -11,7 +11,7 @@ describe("@member tag", function() { }); it("If specified with a name, sets the doclet's name property", function() { - expect(doc.name).toBeFalsy(); + expect(doc.name).toBe('x'); expect(doc2.name).toBe('foobar'); expect(doc3.name).toBe('baz'); }); diff --git a/test/specs/tags/namespacetag.js b/test/specs/tags/namespacetag.js index f8131b3c..182ce0f3 100644 --- a/test/specs/tags/namespacetag.js +++ b/test/specs/tags/namespacetag.js @@ -1,8 +1,8 @@ describe("@namespace tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @namespace */', {}), - doc2 = new doclet.Doclet('/** @namespace Foo */', {}), - doc3 = new doclet.Doclet('/** @namespace {function} Bar */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/namespacetag.js'), + doc = docSet.getByLongname('x')[0], + doc2 = docSet.getByLongname('Foo')[0], + doc3 = docSet.getByLongname('Bar')[0]; it("sets the doclet's kind to 'namespace'", function () { expect(doc.kind).toBe('namespace'); @@ -11,7 +11,7 @@ describe("@namespace tag", function() { }); it("sets the doclet's name to the tag value (if provided)", function() { - expect(doc.name).toBeFalsy(); + expect(doc.name).toBe('x'); expect(doc2.name).toBe('Foo'); expect(doc3.name).toBe('Bar'); }); diff --git a/test/specs/tags/scopetags.js b/test/specs/tags/scopetags.js index c91ba254..0b18a58c 100644 --- a/test/specs/tags/scopetags.js +++ b/test/specs/tags/scopetags.js @@ -1,30 +1,31 @@ -// @inner, @instance, @static (@global has its own file) -describe("@inner tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @name Foo\n@scope inner */', {}); +describe('scope tags', function () { + var docSet = jasmine.getDocSetFromFile('test/fixtures/scopetags.js'); - it("sets the doclet's 'scope' property to 'inner'", function() { - expect(doc.scope).toBeDefined(); - expect(doc.scope).toBe('inner'); - }); -}); - -describe("@instance tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @name Foo\n@scope instance */', {}); - - it("sets the doclet's 'scope' property to 'instance'", function() { - expect(doc.scope).toBeDefined(); - expect(doc.scope).toBe('instance'); - }); -}); - -describe("@static tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @name Foo\n@scope static */', {}); - - it("sets the doclet's 'scope' property to 'static'", function() { - expect(doc.scope).toBeDefined(); - expect(doc.scope).toBe('static'); + // @inner, @instance, @static (@global has its own file) + describe("@inner tag", function() { + var doc = docSet.getByLongname('module:scopetags~myInner')[0]; + + it("sets the doclet's 'scope' property to 'inner'", function() { + expect(doc.scope).toBeDefined(); + expect(doc.scope).toBe('inner'); + }); + }); + + describe("@instance tag", function() { + var doc = docSet.getByLongname('module:scopetags#myInstance')[0]; + + it("sets the doclet's 'scope' property to 'instance'", function() { + expect(doc.scope).toBeDefined(); + expect(doc.scope).toBe('instance'); + }); + }); + + describe("@static tag", function() { + var doc = docSet.getByLongname('module:scopetags.myStatic')[0]; + + it("sets the doclet's 'scope' property to 'static'", function() { + expect(doc.scope).toBeDefined(); + expect(doc.scope).toBe('static'); + }); }); }); diff --git a/test/specs/tags/summarytag.js b/test/specs/tags/summarytag.js index aa4d4147..a4627153 100644 --- a/test/specs/tags/summarytag.js +++ b/test/specs/tags/summarytag.js @@ -1,6 +1,6 @@ describe("@summary tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @summary I do not like green eggs and ham! */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/summarytag.js'), + doc = docSet.getByLongname('Sam')[0]; it("sets the doclet's 'summary' property to the tag value", function() { expect(doc.summary).toBe('I do not like green eggs and ham!'); }); diff --git a/test/specs/tags/todotag.js b/test/specs/tags/todotag.js index 807c76be..410bb55f 100644 --- a/test/specs/tags/todotag.js +++ b/test/specs/tags/todotag.js @@ -1,6 +1,6 @@ describe("@todo tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @todo something\n@todo something else */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/todotag.js'), + doc = docSet.getByLongname('x')[0]; it("adds the entries into a 'todo' array on the doclet", function() { expect(doc.todo).toBeDefined(); diff --git a/test/specs/tags/tutorialtag.js b/test/specs/tags/tutorialtag.js index ea345ccd..b334a266 100644 --- a/test/specs/tags/tutorialtag.js +++ b/test/specs/tags/tutorialtag.js @@ -1,7 +1,7 @@ describe("@tutorial tag", function() { // these are tests for the block usage, not the inline usage. see util/templateHelper for that. - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** @tutorial tute1\n@tutorial tute2 */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/tutorialtag.js'), + doc = docSet.getByLongname('x')[0]; it("adds the listed tutorials to a 'tutorials' array on the doclet", function () { expect(Array.isArray(doc.tutorials)).toBeTruthy(); diff --git a/test/specs/tags/undocumentedtag.js b/test/specs/tags/undocumentedtag.js index 5dc85b56..90052234 100644 --- a/test/specs/tags/undocumentedtag.js +++ b/test/specs/tags/undocumentedtag.js @@ -1,6 +1,6 @@ describe("@undocumented tag", function() { - var doclet = require('jsdoc/doclet'), - doc = new doclet.Doclet('/** Foo bar\n@undocumented */', {}); + var docSet = jasmine.getDocSetFromFile('test/fixtures/undocumentedtag.js'), + doc = docSet.getByLongname('x')[0]; it("sets the doclet's 'undocumented' property to true", function () { expect(doc.undocumented).toBeTruthy();