diff --git a/test/fixtures/augmentstag3.js b/test/fixtures/augmentstag3.js new file mode 100644 index 00000000..80851817 --- /dev/null +++ b/test/fixtures/augmentstag3.js @@ -0,0 +1,18 @@ +// test to see that we can @augment multiple things (code allows for it) +/** @class */ +function Foo() { +} +/** A method. */ +Foo.prototype.method1 = function () {}; + +/** @class */ +function Bar() { +} +/** Another method. */ +Bar.prototype.method2 = function () {} + +/** @class + * @augments Foo + * @augments Bar */ +function FooBar() { +} diff --git a/test/fixtures/authortag.js b/test/fixtures/authortag.js index 155bb570..3bba0f0f 100644 --- a/test/fixtures/authortag.js +++ b/test/fixtures/authortag.js @@ -2,5 +2,9 @@ @author Michael Mathews */ function Thingy() { - -} \ No newline at end of file +} + +/** @author John Doe + * @author Jane Doe */ +function Thingy2() { +} 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/constanttag.js b/test/fixtures/constanttag.js new file mode 100644 index 00000000..a9f78058 --- /dev/null +++ b/test/fixtures/constanttag.js @@ -0,0 +1,6 @@ +/** @constant */ +var FOO = 1; + +/** @const BAR */ + +/** @const {string} BAZ */ 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/mixintag.js b/test/fixtures/mixintag.js new file mode 100644 index 00000000..07dc085d --- /dev/null +++ b/test/fixtures/mixintag.js @@ -0,0 +1,27 @@ +/** + * This provides methods used for event handling. It's not meant to + * be used directly, except as a provider of related methods. + * + * @mixin + */ +var Eventful = { + /** fires something. */ + fires: function () {}, + /** handles a signal. */ + on: function () {} +}; + +/** + * @constructor + * @mixes Eventful + */ +var FormButton = function() { +}; + +/** @mixin AnotherMixin*/ + +/** I mix in multiple things + * @constructor MyClass + * @mixes Eventful + * @mixes AnotherMixin */ + 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/abstracttag.js b/test/specs/tags/abstracttag.js index 4d6c7e19..be2b7862 100644 --- a/test/specs/tags/abstracttag.js +++ b/test/specs/tags/abstracttag.js @@ -8,13 +8,13 @@ describe("@abstract tag", function() { }); it("should set the doclet's 'virtual' property to true when ' @abstract tag is present", function() { - expect(pez.virtual).toEqual(true); + expect(pez.virtual).toBe(true); }); // same as... it("should set the doclet's 'virtual' property to true when ' @abstract tag is present", function() { pez = docSet.getByLongname('OtherThingy#pez')[0]; - expect(pez.virtual).toEqual(true); + expect(pez.virtual).toBe(true); }); }); \ No newline at end of file diff --git a/test/specs/tags/accesstag.js b/test/specs/tags/accesstag.js index 8f260ade..3bfa3973 100644 --- a/test/specs/tags/accesstag.js +++ b/test/specs/tags/accesstag.js @@ -8,13 +8,13 @@ describe("@access tag", function() { pez2 = docSet.getByLongname('OtherThingy#pez')[0]; it("should set the doclet's 'access' property to 'private' when there is an @access private tag", function() { - expect(foo.access).toEqual('private'); - expect(foo2.access).toEqual('private'); + expect(foo.access).toBe('private'); + expect(foo2.access).toBe('private'); }); it("should set the doclet's 'access' property to 'protected' when there is an @access protected tag", function() { - expect(_bar.access).toEqual('protected'); - expect(_bar2.access).toEqual('protected'); + expect(_bar.access).toBe('protected'); + expect(_bar2.access).toBe('protected'); }); it("should set no 'access' property on the doclet when there is an @access public tag", function() { diff --git a/test/specs/tags/aliastag.js b/test/specs/tags/aliastag.js new file mode 100644 index 00000000..4b2396ef --- /dev/null +++ b/test/specs/tags/aliastag.js @@ -0,0 +1,11 @@ +describe("@alias tag", function() { + 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(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/augmentstag.js b/test/specs/tags/augmentstag.js index 56d5faaa..fabc2ee0 100644 --- a/test/specs/tags/augmentstag.js +++ b/test/specs/tags/augmentstag.js @@ -24,11 +24,17 @@ bazMethod3 = docSet.getByLongname('Baz#method3')[0], docSet2 = jasmine.getDocSetFromFile('test/fixtures/augmentstag2.js'), - qux = docSet2.getByLongname('Qux')[0]; + qux = docSet2.getByLongname('Qux')[0], + + docSet3 = jasmine.getDocSetFromFile('test/fixtures/augmentstag3.js'), + FooMethod1 = docSet3.getByLongname('Foo#method1')[0], + BarMethod2 = docSet3.getByLongname('Bar#method2')[0], + FooBarMethod1 = docSet3.getByLongname('FooBar#method1')[0], + FooBarMethod2 = docSet3.getByLongname('FooBar#method2')[0]; it('When a symbol has an @augments tag, the doclet has a augments property that includes that value.', function() { - expect(typeof bar.augments).toEqual('object'); - expect(bar.augments[0]).toEqual('Foo'); + expect(typeof bar.augments).toBe('object'); + expect(bar.augments[0]).toBe('Foo'); }); it('When an object is extended, the original is not modified', function() { @@ -36,50 +42,58 @@ }); it('When an object is extended, it inherits properties set in parent constructor', function() { - expect(fooProp1.memberof).toEqual("Foo"); - expect(barProp1.memberof).toEqual("Bar"); - expect(barProp1.description).toEqual(fooProp1.description); + expect(fooProp1.memberof).toBe("Foo"); + expect(barProp1.memberof).toBe("Bar"); + expect(barProp1.description).toBe(fooProp1.description); }); it('When an object is extended, it inherits properties set on parent prototype', function() { - expect(fooProp2.memberof).toEqual("Foo"); - expect(barProp2.memberof).toEqual("Bar"); - expect(barProp2.description).toEqual(fooProp2.description); + expect(fooProp2.memberof).toBe("Foo"); + expect(barProp2.memberof).toBe("Bar"); + expect(barProp2.description).toBe(fooProp2.description); }); it('When an object is extended, it inherits methods set on parent prototype', function() { - expect(fooMethod1.memberof).toEqual("Foo"); - expect(barMethod1.memberof).toEqual("Bar"); - expect(barMethod1.description).toEqual(fooMethod1.description); + expect(fooMethod1.memberof).toBe("Foo"); + expect(barMethod1.memberof).toBe("Bar"); + expect(barMethod1.description).toBe(fooMethod1.description); }); it('When an object is extended, it may override methods set on parent prototype', function() { - expect(fooMethod2.memberof).toEqual("Foo"); - expect(fooMethod2.description).toEqual("Second parent method."); - expect(barMethod2.memberof).toEqual("Bar"); - expect(barMethod2.description).toEqual("Second child method."); + expect(fooMethod2.memberof).toBe("Foo"); + expect(fooMethod2.description).toBe("Second parent method."); + expect(barMethod2.memberof).toBe("Bar"); + expect(barMethod2.description).toBe("Second child method."); }); it('When an object is extended, and it overrides an ancestor method, the child does not include docs for the ancestor method.', function() { - expect(barMethod2All.length).toEqual(1); + expect(barMethod2All.length).toBe(1); }); it('When an object is extended, it inherits properties set on grandparent prototype', function() { - expect(fooProp1.memberof).toEqual("Foo"); - expect(barProp1.memberof).toEqual("Bar"); - expect(bazProp1.memberof).toEqual("Baz"); - expect(bazProp1.description).toEqual("Override prop1"); - expect(bazMethod1.memberof).toEqual("Baz"); - expect(bazMethod2.memberof).toEqual("Baz"); - expect(bazMethod3.memberof).toEqual("Baz"); + expect(fooProp1.memberof).toBe("Foo"); + expect(barProp1.memberof).toBe("Bar"); + expect(bazProp1.memberof).toBe("Baz"); + expect(bazProp1.description).toBe("Override prop1"); + expect(bazMethod1.memberof).toBe("Baz"); + expect(bazMethod2.memberof).toBe("Baz"); + expect(bazMethod3.memberof).toBe("Baz"); }); it('When an object is extended, and it overrides an ancestor property, the child does not include docs for the ancestor property.', function() { - expect(bazProp1All.length).toEqual(1); + expect(bazProp1All.length).toBe(1); }); it('When a symbol has an @augments tag, and the parent is not documented, the doclet still has an augments property', function() { - expect(typeof qux.augments).toEqual('object'); - expect(qux.augments[0]).toEqual('UndocumentedThing'); + expect(typeof qux.augments).toBe('object'); + expect(qux.augments[0]).toBe('UndocumentedThing'); + }); + + + it('When a symbol @augments multiple parents, it inherits methods from all parents', function() { + expect(FooBarMethod1).toBeDefined(); + expect(FooBarMethod2).toBeDefined(); + expect(FooBarMethod1.description).toBe(FooMethod1.description); + expect(FooBarMethod2.description).toBe(BarMethod2.description); }); }); diff --git a/test/specs/tags/authortag.js b/test/specs/tags/authortag.js index 4db3fb37..1a84b336 100644 --- a/test/specs/tags/authortag.js +++ b/test/specs/tags/authortag.js @@ -1,8 +1,18 @@ describe("@author tag", function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/authortag.js'), - Thingy = docSet.getByLongname('Thingy')[0]; + Thingy = docSet.getByLongname('Thingy')[0], + Thingy2 = docSet.getByLongname('Thingy2')[0]; it('When a symbol has a @author tag, the doclet has a author property with that value.', function() { - expect(Thingy.author[0]).toEqual('Michael Mathews '); + expect(Thingy.author).toBeDefined(); + expect(Array.isArray(Thingy.author)).toBe(true); + expect(Thingy.author[0]).toBe('Michael Mathews '); }); -}); \ No newline at end of file + + it('When a symbol has multiple @author tags, the doclet has a author property, an array with those values.', function() { + expect(Thingy2.author).toBeDefined(); + expect(Array.isArray(Thingy2.author)).toBe(true); + expect(Thingy2.author).toContain('Jane Doe '); + expect(Thingy2.author).toContain('John Doe '); + }); +}); diff --git a/test/specs/tags/borrowstag.js b/test/specs/tags/borrowstag.js index 6b0d2316..4a6fdf57 100644 --- a/test/specs/tags/borrowstag.js +++ b/test/specs/tags/borrowstag.js @@ -4,9 +4,9 @@ describe("@borrows tag", function() { util = docSet.getByLongname('util').filter(function($) { return ! $.undocumented; })[0]; - expect(util.borrowed.length).toEqual(1); - expect(util.borrowed[0].from).toEqual('trstr'); - expect(util.borrowed[0].as).toEqual('trim'); + expect(util.borrowed.length).toBe(1); + expect(util.borrowed[0].from).toBe('trstr'); + expect(util.borrowed[0].as).toBe('trim'); }); it('When a symbol has a @borrows tag, the borrowed symbol is added to the symbol.', function() { @@ -19,6 +19,6 @@ describe("@borrows tag", function() { return ! $.undocumented; })[0]; - expect(typeof str_rtrim).toEqual('object'); + expect(typeof str_rtrim).toBe('object'); }); }); \ No newline at end of file diff --git a/test/specs/tags/classdesctag.js b/test/specs/tags/classdesctag.js new file mode 100644 index 00000000..2a369cf1 --- /dev/null +++ b/test/specs/tags/classdesctag.js @@ -0,0 +1,8 @@ +describe("@classdesc tag", function() { + 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/classtag.js b/test/specs/tags/classtag.js index 2a54a1d8..0a28a54d 100644 --- a/test/specs/tags/classtag.js +++ b/test/specs/tags/classtag.js @@ -4,11 +4,11 @@ describe("@class tag", function() { news = docSet.getByLongname('NewsSource')[0]; it('When a symbol has a @class tag, the doclet has a kind property set to "class".', function() { - expect(ticker.kind).toEqual('class'); + expect(ticker.kind).toBe('class'); }); it('When a symbol has a @class tag with a value, the doclet has a name property set to that value.', function() { - expect(news.kind).toEqual('class'); - expect(news.longname).toEqual('NewsSource'); + expect(news.kind).toBe('class'); + expect(news.longname).toBe('NewsSource'); }); }); \ No newline at end of file diff --git a/test/specs/tags/constanttag.js b/test/specs/tags/constanttag.js new file mode 100644 index 00000000..e33ae980 --- /dev/null +++ b/test/specs/tags/constanttag.js @@ -0,0 +1,28 @@ +describe("@constant tag", function() { + var docSet = jasmine.getDocSetFromFile('test/fixtures/constanttag.js'), + FOO = docSet.getByLongname('FOO')[0], + BAR = docSet.getByLongname('BAR')[0], + BAZ = docSet.getByLongname('BAZ')[0]; + + it("sets the doclet's 'kind' property to 'constant'", function() { + expect(FOO.kind).toBe('constant'); + expect(BAR.kind).toBe('constant'); + expect(BAZ.kind).toBe('constant'); + }); + + it("If used as a standalone, takes the name from the code", function() { + expect(FOO.name).toBe('FOO'); + }); + + it("If used with just a name, sets the doclet's name to that", function() { + expect(BAR.name).toBe('BAR'); + }); + + it("If used with a name and a type, sets the doclet's name and type appropriately", function() { + expect(BAZ.name).toBe('BAZ'); + expect(typeof BAZ.type).toBe('object'); + expect(BAZ.type.names).toBeDefined(); + expect(BAZ.type.names.length).toBe(1); + expect(BAZ.type.names[0]).toBe('string'); + }); +}); diff --git a/test/specs/tags/constructortag.js b/test/specs/tags/constructortag.js index 48ec7ea4..dd2bedad 100644 --- a/test/specs/tags/constructortag.js +++ b/test/specs/tags/constructortag.js @@ -3,11 +3,11 @@ describe("@constructor tag", function() { feed = docSet.getByLongname('Feed')[0]; it('When a symbol has an @constructor tag, it is documented as a class.', function() { - expect(feed.kind).toEqual('class'); + expect(feed.kind).toBe('class'); }); it('When a symbol has an @constructor tag and a @class tag, the value of the @class tag becomes the classdesc property.', function() { - expect(feed.classdesc).toEqual('Describe your class here.'); - expect(feed.description).toEqual('Describe your constructor function here.'); + expect(feed.classdesc).toBe('Describe your class here.'); + expect(feed.description).toBe('Describe your constructor function here.'); }); }); \ No newline at end of file diff --git a/test/specs/tags/constructstag.js b/test/specs/tags/constructstag.js index 661267fb..a7198a4c 100644 --- a/test/specs/tags/constructstag.js +++ b/test/specs/tags/constructstag.js @@ -4,24 +4,24 @@ describe("@constructs tag", function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/constructstag.js'), textblock = docSet.getByLongname('TextBlock')[0]; - expect(textblock.kind).toEqual('class'); - expect(textblock.longname).toEqual('TextBlock'); + expect(textblock.kind).toBe('class'); + expect(textblock.longname).toBe('TextBlock'); }); it('When a symbol has an @constructs tag, it is documented as a class.', function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/constructstag2.js'), menu = docSet.getByLongname('Menu')[0]; - expect(menu.name).toEqual('Menu'); - expect(menu.kind).toEqual('class'); + expect(menu.name).toBe('Menu'); + expect(menu.kind).toBe('class'); }); it('When a function symbol has an @constructs tag, any this-variables are ducumented as instance members of the class.', function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/constructstag3.js'), personName = docSet.getByLongname('Person#name')[0]; - expect(personName.memberof).toEqual('Person'); - expect(personName.scope).toEqual('instance'); + expect(personName.memberof).toBe('Person'); + expect(personName.scope).toBe('instance'); }); it('When a function symbol has an @constructs tag with no value, in a @lends block with a "Name#" value, the function is documented as a constructor of "Name".', function() { @@ -30,15 +30,15 @@ describe("@constructs tag", function() { return ! $.undocumented; })[0]; - expect(person.kind).toEqual('class'); + expect(person.kind).toBe('class'); }); it('When a function symbol has an @constructs tag with no value, any this-variables are documented as instance members of the class.', function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/constructstag4.js'), personName = docSet.getByLongname('Person#name')[0]; - expect(personName.memberof).toEqual('Person'); - expect(personName.scope).toEqual('instance'); + expect(personName.memberof).toBe('Person'); + expect(personName.scope).toBe('instance'); }); it('When a object literal property has an @constructs tag with no value, and the object has a @lends, the property is documented as the lent class.', function() { @@ -47,8 +47,8 @@ describe("@constructs tag", function() { return ! $.undocumented; })[0]; - expect(duck.longname).toEqual('Duck'); - expect(duck.kind).toEqual('class'); - expect(duck.description).toEqual('Constructs a duck.'); + expect(duck.longname).toBe('Duck'); + expect(duck.kind).toBe('class'); + expect(duck.description).toBe('Constructs a duck.'); }); }); \ No newline at end of file diff --git a/test/specs/tags/copyrighttag.js b/test/specs/tags/copyrighttag.js index f63a3fdd..c9c7a5f1 100644 --- a/test/specs/tags/copyrighttag.js +++ b/test/specs/tags/copyrighttag.js @@ -3,6 +3,6 @@ describe("@copyright tag", function() { Thingy = docSet.getByLongname('Thingy')[0]; it('When a symbol has a @copyright tag, the doclet has a copyright property with that value.', function() { - expect(Thingy.copyright).toEqual('(c) 2011 Michael Mathews'); + expect(Thingy.copyright).toBe('(c) 2011 Michael Mathews'); }); }); \ No newline at end of file diff --git a/test/specs/tags/defaulttag.js b/test/specs/tags/defaulttag.js index 77ff096b..ca4b086b 100644 --- a/test/specs/tags/defaulttag.js +++ b/test/specs/tags/defaulttag.js @@ -9,23 +9,23 @@ describe("@default tag", function() { header = (docSet.getByLongname('header') || [])[0]; it('When symbol set to null has a @default tag with no text, the doclet\'s defaultValue property should be: null', function() { - expect(request.defaultvalue).toEqual('null'); + expect(request.defaultvalue).toBe('null'); }); it('When symbol set to a string has a @default tag with no text, the doclet\'s defaultValue property should be that quoted string', function() { - expect(response.defaultvalue).toEqual('"ok"'); + expect(response.defaultvalue).toBe('"ok"'); }); it('When symbol set to a number has a @default tag with no text, the doclet\'s defaultValue property should be that number.', function() { - expect(rcode.defaultvalue).toEqual('200'); + expect(rcode.defaultvalue).toBe('200'); }); it('When symbol has a @default tag with text, the doclet\'s defaultValue property should be that text.', function() { - expect(win.defaultvalue).toEqual('the parent window'); + expect(win.defaultvalue).toBe('the parent window'); }); it('When symbol has a @default tag with true.', function() { - expect(rvalid.defaultvalue).toEqual('true'); + expect(rvalid.defaultvalue).toBe('true'); }); it('When symbol has a @default tag with false.', function() { diff --git a/test/specs/tags/deprecatedtag.js b/test/specs/tags/deprecatedtag.js index b87a1111..0e60ce29 100644 --- a/test/specs/tags/deprecatedtag.js +++ b/test/specs/tags/deprecatedtag.js @@ -4,11 +4,11 @@ describe("@deprecated tag", function() { bar = docSet.getByLongname('bar')[0]; it('When a symbol has a @deprecated tag with no value, the doclet has a deprecated property set to true.', function() { - expect(foo.deprecated).toEqual(true); + expect(foo.deprecated).toBe(true); }); it('When a symbol has a @deprecated tag with a value, the doclet has a deprecated property set to that value.', function() { - expect(bar.deprecated).toEqual('since version 2.0'); + expect(bar.deprecated).toBe('since version 2.0'); }); }); \ No newline at end of file diff --git a/test/specs/tags/descriptiontag.js b/test/specs/tags/descriptiontag.js new file mode 100644 index 00000000..855280dc --- /dev/null +++ b/test/specs/tags/descriptiontag.js @@ -0,0 +1,15 @@ +describe("@description tag", function() { + 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(); + expect(doc2.description).toBe('lkjasdf'); + }); + + it("overrides the default description", function() { + expect(doc.description).toBeDefined(); + expect(doc.description).toBe('halb halb halb'); + }); +}); diff --git a/test/specs/tags/enumtag.js b/test/specs/tags/enumtag.js index a7c32a28..4f48727e 100644 --- a/test/specs/tags/enumtag.js +++ b/test/specs/tags/enumtag.js @@ -3,24 +3,24 @@ describe("@enum tag", function() { tristate = docSet.getByLongname('TriState')[0]; it('When a symbol has a @enum tag, it has a properties array.', function() { - expect(typeof tristate.properties).toEqual('object'); + expect(typeof tristate.properties).toBe('object'); }); it('If no @type is given for the property it is inherted from the enum.', function() { - expect(tristate.properties[0].type.names.join(', ')).toEqual('number'); + expect(tristate.properties[0].type.names.join(', ')).toBe('number'); }); it('If no no comment is given for the property it is still included in the enum.', function() { - expect(tristate.properties[1].longname).toEqual('TriState.FALSE'); + expect(tristate.properties[1].longname).toBe('TriState.FALSE'); expect(tristate.properties[1].undocumented).toBeUndefined(); }); it('A property of an enum gets its defaultvalue set.', function() { - expect(tristate.properties[1].defaultvalue).toEqual('-1'); + expect(tristate.properties[1].defaultvalue).toBe('-1'); }); it('If a @type is given for the property it is reflected in the property value.', function() { - expect(tristate.properties[2].type.names.join(', ')).toEqual('boolean'); + expect(tristate.properties[2].type.names.join(', ')).toBe('boolean'); }); it('An enum does not contain any circular references.', function() { diff --git a/test/specs/tags/exampletag.js b/test/specs/tags/exampletag.js new file mode 100644 index 00000000..8d1673c6 --- /dev/null +++ b/test/specs/tags/exampletag.js @@ -0,0 +1,22 @@ +describe("@example tag", function() { + 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 = 'Example 2\n1 + 2;'; + + it("creates an 'examples' property on the doclet with the example", function() { + expect(doc.examples).toBeDefined(); + expect(Array.isArray(doc.examples)).toBe(true); + expect(doc.examples.length).toBe(1); + expect(doc.examples).toContain(txt); + }); + + it("can be specified multiple times on one doclet", function() { + expect(doc2.examples).toBeDefined(); + expect(Array.isArray(doc2.examples)).toBe(true); + expect(doc2.examples.length).toBe(2); + expect(doc2.examples).toContain(txt); + expect(doc2.examples).toContain(txt2); + }); +}); diff --git a/test/specs/tags/exceptiontag.js b/test/specs/tags/exceptiontag.js index e24405bf..40d3a0c4 100644 --- a/test/specs/tags/exceptiontag.js +++ b/test/specs/tags/exceptiontag.js @@ -5,13 +5,13 @@ describe("@exception tag", function() { pez = docSet.getByLongname('pez')[0]; it('When a symbol has an @exception tag, the doclet has a exception property set to that value.', function() { - expect(typeof foo.exceptions).toEqual('object'); - expect(foo.exceptions.length).toEqual(1); + expect(typeof foo.exceptions).toBe('object'); + expect(foo.exceptions.length).toBe(1); - expect(typeof bar.exceptions).toEqual('object'); - expect(bar.exceptions.length).toEqual(1); + expect(typeof bar.exceptions).toBe('object'); + expect(bar.exceptions.length).toBe(1); - expect(typeof pez.exceptions).toEqual('object'); - expect(pez.exceptions.length).toEqual(1); + expect(typeof pez.exceptions).toBe('object'); + expect(pez.exceptions.length).toBe(1); }); }); \ No newline at end of file diff --git a/test/specs/tags/functiontag.js b/test/specs/tags/functiontag.js new file mode 100644 index 00000000..df63f6b9 --- /dev/null +++ b/test/specs/tags/functiontag.js @@ -0,0 +1,18 @@ +describe("@function tag", function() { + 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'); + expect(doc2.kind).toBe('function'); + }); + + it("sets the doclet's name to the tag value, if provided", function() { + expect(doc.name).toBe('Foo'); + expect(doc2.name).toBe('Bar'); + }); + + // parameter etc tests take place elsewhere: on its own, all @func does is + // set doclet.kind to function and sets the doclet's name. +}); diff --git a/test/specs/tags/globaltag.js b/test/specs/tags/globaltag.js index 4c245c95..3aeb34d8 100644 --- a/test/specs/tags/globaltag.js +++ b/test/specs/tags/globaltag.js @@ -5,10 +5,10 @@ describe("@global tag", function() { var found = docSet.getByLongname('foo').filter(function($) { return ! $.undocumented; }); - expect(found[0].name).toEqual('foo'); - expect(found[0].longname).toEqual('foo'); + expect(found[0].name).toBe('foo'); + expect(found[0].longname).toBe('foo'); expect(found[0].memberof).toBeUndefined(); - expect(found[0].scope).toEqual('global'); + expect(found[0].scope).toBe('global'); }); @@ -16,9 +16,9 @@ describe("@global tag", function() { var found = docSet.getByLongname('Bar').filter(function($) { return ! $.undocumented; }); - expect(found[0].name).toEqual('Bar'); - expect(found[0].longname).toEqual('Bar'); + expect(found[0].name).toBe('Bar'); + expect(found[0].longname).toBe('Bar'); expect(found[0].memberof).toBeUndefined(); - expect(found[0].scope).toEqual('global'); + expect(found[0].scope).toBe('global'); }); }); \ No newline at end of file diff --git a/test/specs/tags/ignoretag.js b/test/specs/tags/ignoretag.js index 73d25468..cc78f416 100644 --- a/test/specs/tags/ignoretag.js +++ b/test/specs/tags/ignoretag.js @@ -3,7 +3,7 @@ describe("@ignore tag", function() { foo = docSet.getByLongname('foo')[0]; it('When a symbol has an @ignore tag, the doclet has a ignore property set to true.', function() { - expect(foo.ignore).toEqual(true); + expect(foo.ignore).toBe(true); }); it('When a symbol has an @ignore tag with a value an error is thrown', function() { @@ -11,7 +11,7 @@ describe("@ignore tag", function() { docSet = jasmine.getDocSetFromFile('test/fixtures/ignoretag2.js'); foo = docSet.getByLongname('foo')[0]; } catch (e) { - expect(e.name).toEqual('TagValueNotPermittedError'); + expect(e.name).toBe('TagValueNotPermittedError'); }; }); }); \ No newline at end of file diff --git a/test/specs/tags/kindtag.js b/test/specs/tags/kindtag.js new file mode 100644 index 00000000..49d9cd5d --- /dev/null +++ b/test/specs/tags/kindtag.js @@ -0,0 +1,8 @@ +describe("@kind tag", 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/lendstag.js b/test/specs/tags/lendstag.js new file mode 100644 index 00000000..0f4a685d --- /dev/null +++ b/test/specs/tags/lendstag.js @@ -0,0 +1,16 @@ +describe("@lends tag", function() { + // see also specs/documentation/lends.js for tests on @lends behaviour. + var doclet = require('jsdoc/doclet'), + doc = new doclet.Doclet('/** @lends */', {}), + doc2 = new doclet.Doclet('/** @lends MyClass# */', {}); + + it("sets the doclet's 'alias' property to the tag value or ", function() { + expect(doc.alias).toBe(''); + expect(doc2.alias).toBe('MyClass#'); + }); + + it("sets the doclet's 'undocumented' property to 'true'", function() { + expect(doc.undocumented).toBeTruthy(); + expect(doc2.undocumented).toBeTruthy(); + }); +}); diff --git a/test/specs/tags/licensetag.js b/test/specs/tags/licensetag.js new file mode 100644 index 00000000..e37b1c63 --- /dev/null +++ b/test/specs/tags/licensetag.js @@ -0,0 +1,8 @@ +describe("@license tag", function() { + 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/memberoftag.js b/test/specs/tags/memberoftag.js index 15653a11..46d61201 100644 --- a/test/specs/tags/memberoftag.js +++ b/test/specs/tags/memberoftag.js @@ -6,11 +6,11 @@ describe("@memberof tag", function() { Data = docSet.getByLongname('mathlib.Data')[0], point = docSet.getByLongname('mathlib.Data#point')[0]; - expect(typeof Data).toEqual('object'); - expect(typeof point).toEqual('object'); + expect(typeof Data).toBe('object'); + expect(typeof point).toBe('object'); - expect(Data.memberof).toEqual('mathlib'); - expect(Data.name).toEqual('Data'); + expect(Data.memberof).toBe('mathlib'); + expect(Data.name).toBe('Data'); }); it('A symbol within a namespace for which no scope is specified.', function() { @@ -18,7 +18,7 @@ describe("@memberof tag", function() { doOtherStuff = docSet.getByLongname('doStuff.doOtherStuff')[0]; expect(doOtherStuff).toBeDefined(); - expect(doOtherStuff.scope).toEqual('static'); + expect(doOtherStuff.scope).toBe('static'); }); it('A symbol in which name === memberof.', function() { @@ -26,7 +26,7 @@ describe("@memberof tag", function() { doStuff = docSet.getByLongname('doStuff.doStuff')[0]; expect(doStuff).toBeDefined(); - expect(doStuff.scope).toEqual('static'); + expect(doStuff.scope).toBe('static'); }); describe ("static", function() { @@ -36,20 +36,20 @@ describe("@memberof tag", function() { it('A symbol is documented as a static @memberof a class.', function() { //it should appear as a static member of that class - expect(typeof cache).toEqual('object'); - expect(cache.memberof).toEqual('Observable'); - expect(cache.scope).toEqual('static'); - expect(cache.name).toEqual('cache'); - expect(cache.longname).toEqual('Observable.cache'); + expect(typeof cache).toBe('object'); + expect(cache.memberof).toBe('Observable'); + expect(cache.scope).toBe('static'); + expect(cache.name).toBe('cache'); + expect(cache.longname).toBe('Observable.cache'); }); it('A symbol is documented as a static @memberof a class prototype.', function() { //it should appear as an instance member of that class - expect(typeof publish).toEqual('object'); - expect(publish.memberof).toEqual('Observable'); - expect(publish.scope).toEqual('instance'); - expect(publish.name).toEqual('publish'); - expect(publish.longname).toEqual('Observable#publish'); + expect(typeof publish).toBe('object'); + expect(publish.memberof).toBe('Observable'); + expect(publish.scope).toBe('instance'); + expect(publish.name).toBe('publish'); + expect(publish.longname).toBe('Observable#publish'); }); }); diff --git a/test/specs/tags/membertag.js b/test/specs/tags/membertag.js new file mode 100644 index 00000000..cfea6de3 --- /dev/null +++ b/test/specs/tags/membertag.js @@ -0,0 +1,25 @@ +describe("@member tag", function() { + 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'); + expect(doc2.kind).toBe('member'); + expect(doc3.kind).toBe('member'); + }); + + it("If specified with a name, sets the doclet's name property", function() { + expect(doc.name).toBe('x'); + expect(doc2.name).toBe('foobar'); + expect(doc3.name).toBe('baz'); + }); + + it("If specified with a type and name, sets the doclet's type appropriately", function() { + expect(doc3.type).toBeDefined(); + expect(Array.isArray(doc3.type.names)).toBeTruthy(); + expect(doc3.type.names.length).toBe(1); + expect(doc3.type.names[0]).toBe('string'); + }); +}); diff --git a/test/specs/tags/mixestag.js b/test/specs/tags/mixestag.js new file mode 100644 index 00000000..6bb4f827 --- /dev/null +++ b/test/specs/tags/mixestag.js @@ -0,0 +1,19 @@ +describe("@mixes tag", function() { + var docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag.js'), + FormButton = docSet.getByLongname('FormButton')[0], + MyClass = docSet.getByLongname('MyClass')[0]; + + it("When a symbol has a @mixes tag, it gets an array property 'mixes' with the name of the mixin", function() { + expect(FormButton.mixes).toBeDefined(); + expect(Array.isArray(FormButton.mixes)).toBe(true); + expect(FormButton.mixes.length).toBe(1); + expect(FormButton.mixes[0]).toBe('Eventful'); + }); + + it("A symbol can @mixes multiple mixins and they are all added.", function() { + expect(MyClass.mixes).toBeDefined(); + expect(MyClass.mixes.length).toBe(2); + expect(MyClass.mixes).toContain('Eventful'); + expect(MyClass.mixes).toContain('AnotherMixin'); + }); +}); diff --git a/test/specs/tags/mixintag.js b/test/specs/tags/mixintag.js new file mode 100644 index 00000000..4c928fb2 --- /dev/null +++ b/test/specs/tags/mixintag.js @@ -0,0 +1,13 @@ +describe("@mixin tag", function() { + var docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag.js'), + Eventful = docSet.getByLongname('Eventful')[0], + Mixin = docSet.getByLongname('AnotherMixin')[0]; + + it("When a symbol has a @mixin tag, the doclet's 'kind' property is set to 'mixin'", function() { + expect(Eventful.kind).toBe('mixin'); + }); + + it("When a symbol has a @mixin tag, its name is set to the tag's value (if present)", function() { + expect(Mixin).toBeDefined(); + }); +}); diff --git a/test/specs/tags/moduletag.js b/test/specs/tags/moduletag.js index edee26c1..e2b44e30 100644 --- a/test/specs/tags/moduletag.js +++ b/test/specs/tags/moduletag.js @@ -5,13 +5,13 @@ describe("@module tag", function() { title = docSet.getByLongname('module:bookshelf.Book#title')[0]; it('When a global symbol starts with "this" and is in a file with a @module tag, the symbol is documented as a member of that module.', function() { - expect(typeof book).toEqual('object'); - expect(book.memberof).toEqual('module:bookshelf'); + expect(typeof book).toBe('object'); + expect(book.memberof).toBe('module:bookshelf'); }); it('When an inner symbol starts with "this" and is in a file with a @module tag, the symbol is documented as a member of its enclosing constructor.', function() { - expect(typeof title).toEqual('object'); - expect(title.memberof).toEqual('module:bookshelf.Book'); + expect(typeof title).toBe('object'); + expect(title.memberof).toBe('module:bookshelf.Book'); }); }); @@ -24,18 +24,18 @@ describe("@module tag", function() { darken = docSet.getByLongname('module:color/mixer.darken')[0]; it('When a @module tag defines a module module, a symbol of kind "module" is documented', function() { - expect(typeof mixer).toEqual('object'); - expect(mixer.kind).toEqual('module'); + expect(typeof mixer).toBe('object'); + expect(mixer.kind).toBe('module'); }); it('When an object literal is lent to a module with a @lends tag, A member of that object literal is documented as a member of the module', function() { - expect(typeof blend).toEqual('object'); - expect(blend.kind).toEqual('function'); + expect(typeof blend).toBe('object'); + expect(blend.kind).toBe('function'); }); it('When a documented symbol is a member of a namespace "exports", it is documented as a member of the module', function() { - expect(typeof darken).toEqual('object'); - expect(darken.kind).toEqual('function'); + expect(typeof darken).toBe('object'); + expect(darken.kind).toBe('function'); }); }); }); \ No newline at end of file diff --git a/test/specs/tags/namespacetag.js b/test/specs/tags/namespacetag.js new file mode 100644 index 00000000..182ce0f3 --- /dev/null +++ b/test/specs/tags/namespacetag.js @@ -0,0 +1,25 @@ +describe("@namespace tag", function() { + 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'); + expect(doc2.kind).toBe('namespace'); + expect(doc3.kind).toBe('namespace'); + }); + + it("sets the doclet's name to the tag value (if provided)", function() { + expect(doc.name).toBe('x'); + expect(doc2.name).toBe('Foo'); + expect(doc3.name).toBe('Bar'); + }); + + it("sets the doclet's type (if provided in @namespace)", function() { + expect(doc3.type).toBeDefined(); + expect(Array.isArray(doc3.type.names)).toBeTruthy(); + expect(doc3.type.names.length).toBe(1); + expect(doc3.type.names[0]).toBe('function'); + }); +}); diff --git a/test/specs/tags/overviewtag.js b/test/specs/tags/overviewtag.js index 67f09130..6087be5b 100644 --- a/test/specs/tags/overviewtag.js +++ b/test/specs/tags/overviewtag.js @@ -13,6 +13,6 @@ describe("@overview tag", function() { }); it("The name and longname should be equal", function() { - expect(doclets[0].name).toEqual(doclets[0].longname); + expect(doclets[0].name).toBe(doclets[0].longname); }); -}); \ No newline at end of file +}); diff --git a/test/specs/tags/paramtag.js b/test/specs/tags/paramtag.js index 14d628ad..3e7b2696 100644 --- a/test/specs/tags/paramtag.js +++ b/test/specs/tags/paramtag.js @@ -9,60 +9,60 @@ describe("@param tag", function() { commit = docSet.getByLongname('commit')[0]; it('When a symbol has an @param tag with a type before the name, the doclet has a params property that includes that param.', function() { - expect(typeof find.params).toEqual('object'); - expect(find.params.length).toEqual(1); - expect(find.params[0].type.names.join(', ')).toEqual('String, Array'); - expect(find.params[0].name).toEqual('targetName'); - expect(find.params[0].description).toEqual('The name (or names) of what to find.'); + expect(typeof find.params).toBe('object'); + expect(find.params.length).toBe(1); + expect(find.params[0].type.names.join(', ')).toBe('String, Array'); + expect(find.params[0].name).toBe('targetName'); + expect(find.params[0].description).toBe('The name (or names) of what to find.'); }); it('When a symbol has an @param tag with only a type and name, the doclet has a params property that includes that param.', function() { - expect(typeof bind.params).toEqual('object'); - expect(bind.params.length).toEqual(1); - expect(bind.params[0].type.names.join(', ')).toEqual('function'); - expect(bind.params[0].name).toEqual('callback'); + expect(typeof bind.params).toBe('object'); + expect(bind.params.length).toBe(1); + expect(bind.params[0].type.names.join(', ')).toBe('function'); + expect(bind.params[0].name).toBe('callback'); expect(bind.params[0].description).toBeUndefined(); }); it('When a symbol has an @param tag with only a type, the doclet has a params property that includes that param.', function() { - expect(typeof unbind.params).toEqual('object'); - expect(unbind.params.length).toEqual(1); - expect(unbind.params[0].type.names.join(', ')).toEqual('function'); + expect(typeof unbind.params).toBe('object'); + expect(unbind.params.length).toBe(1); + expect(unbind.params[0].type.names.join(', ')).toBe('function'); expect(unbind.params[0].description).toBeUndefined(); }); it('When a symbol has an @param tag with no type, the doclet has a params property that includes that param.', function() { - expect(typeof getElement.params).toEqual('object'); - expect(getElement.params.length).toEqual(1); + expect(typeof getElement.params).toBe('object'); + expect(getElement.params.length).toBe(1); expect(getElement.params[0].type).toBeUndefined(); - expect(getElement.params[0].name).toEqual('id'); - expect(getElement.params[0].description).toEqual('The id of the element.'); + expect(getElement.params[0].name).toBe('id'); + expect(getElement.params[0].description).toBe('The id of the element.'); }); it('When a symbol has an @param tag with a non-alpha name like "...", the doclet has a params property that includes that param.', function() { - expect(typeof combine.params).toEqual('object'); - expect(combine.params.length).toEqual(1); + expect(typeof combine.params).toBe('object'); + expect(combine.params.length).toBe(1); expect(combine.params[0].type).toBeUndefined(); - expect(combine.params[0].name).toEqual('...'); - expect(combine.params[0].description).toEqual('Two or more elements.'); + expect(combine.params[0].name).toBe('...'); + expect(combine.params[0].description).toBe('Two or more elements.'); }); it('When a symbol has an @param tag with name followed by a dash, the doclet has a params property that includes that param.', function() { - expect(typeof split.params).toEqual('object'); - expect(split.params.length).toEqual(1); + expect(typeof split.params).toBe('object'); + expect(split.params.length).toBe(1); expect(split.params[0].type).toBeUndefined(); - expect(split.params[0].name).toEqual('delimiter'); - expect(split.params[0].description).toEqual('What to split on.'); + expect(split.params[0].name).toBe('delimiter'); + expect(split.params[0].description).toBe('What to split on.'); }); it('When a symbol has an @param tag with no name or type, the doclet has a params property that includes that param.', function() { - expect(typeof commit.params).toEqual('object'); - expect(commit.params.length).toEqual(1); + expect(typeof commit.params).toBe('object'); + expect(commit.params.length).toBe(1); expect(commit.params[0].type).toBeUndefined(); - expect(commit.params[0].description).toEqual('If true make the commit atomic.'); + expect(commit.params[0].description).toBe('If true make the commit atomic.'); }); it('When a symbol has an @param tag with no name and a name is given in the code, the doclet has a params property that includes that param with the name from the code.', function() { - expect(commit.params[0].name).toEqual('atomic'); + expect(commit.params[0].name).toBe('atomic'); }); }); \ No newline at end of file diff --git a/test/specs/tags/privatetag.js b/test/specs/tags/privatetag.js index 6c7f71f2..a4d5aceb 100644 --- a/test/specs/tags/privatetag.js +++ b/test/specs/tags/privatetag.js @@ -4,6 +4,6 @@ describe("@private tag", function() { bar = docSet.getByLongname('Foo#bar')[0]; it('When a symbol has an @private tag, the doclet has an access property that is "private".', function() { - expect(foo.access).toEqual('private'); + expect(foo.access).toBe('private'); }); }); \ No newline at end of file diff --git a/test/specs/tags/propertytag.js b/test/specs/tags/propertytag.js index 374c64ed..5ef94231 100644 --- a/test/specs/tags/propertytag.js +++ b/test/specs/tags/propertytag.js @@ -3,13 +3,13 @@ describe("@property tag", function() { myobject = docSet.getByLongname('myobject')[0]; it('When a symbol has an @property tag with a those properties appear in the parsed object.', function() { - expect(typeof myobject.properties).toEqual('object'); - expect(myobject.properties.length).toEqual(3); - expect(myobject.properties[0].name).toEqual('defaults'); - expect(myobject.properties[1].name).toEqual('defaults.a'); - expect(myobject.properties[2].name).toEqual('defaults.b'); - expect(myobject.properties[0].description).toEqual('The default values.'); - expect(myobject.properties[0].type.names[0]).toEqual('Object'); + expect(typeof myobject.properties).toBe('object'); + expect(myobject.properties.length).toBe(3); + expect(myobject.properties[0].name).toBe('defaults'); + expect(myobject.properties[1].name).toBe('defaults.a'); + expect(myobject.properties[2].name).toBe('defaults.b'); + expect(myobject.properties[0].description).toBe('The default values.'); + expect(myobject.properties[0].type.names[0]).toBe('Object'); }); }); \ No newline at end of file diff --git a/test/specs/tags/readonlytag.js b/test/specs/tags/readonlytag.js index 403c984a..8465cb80 100644 --- a/test/specs/tags/readonlytag.js +++ b/test/specs/tags/readonlytag.js @@ -4,6 +4,6 @@ describe("@readonly tag", function() { length = docSet.getByLongname('Collection#length')[0]; it('When a symbol has an @readonly tag, the doclet has an readonly property that is true.', function() { - expect(length.readonly).toEqual(true); + expect(length.readonly).toBe(true); }); }); \ No newline at end of file diff --git a/test/specs/tags/requirestag.js b/test/specs/tags/requirestag.js index 662a8f8e..40eae164 100644 --- a/test/specs/tags/requirestag.js +++ b/test/specs/tags/requirestag.js @@ -4,11 +4,11 @@ describe("@requires tag", function() { bar = docSet.getByLongname('bar')[0]; it('When a symbol has an @requires tag, the doclet has a requires property that includes that value, with the "module:" namespace added.', function() { - expect(typeof foo.requires).toEqual('object'); - expect(foo.requires[0]).toEqual('module:foo/helper'); + expect(typeof foo.requires).toBe('object'); + expect(foo.requires[0]).toBe('module:foo/helper'); - expect(typeof bar.requires).toEqual('object'); - expect(bar.requires[0]).toEqual('module:foo'); - expect(bar.requires[1]).toEqual('module:Pez#blat'); + expect(typeof bar.requires).toBe('object'); + expect(bar.requires[0]).toBe('module:foo'); + expect(bar.requires[1]).toBe('module:Pez#blat'); }); }); \ No newline at end of file diff --git a/test/specs/tags/returnstag.js b/test/specs/tags/returnstag.js index 9b3750c9..f459b236 100644 --- a/test/specs/tags/returnstag.js +++ b/test/specs/tags/returnstag.js @@ -4,15 +4,15 @@ describe("@returns tag", function() { bind = docSet.getByLongname('bind')[0]; it('When a symbol has an @returns tag with a type and description, the doclet has a returns array that includes that return.', function() { - expect(typeof find.returns).toEqual('object'); - expect(find.returns.length).toEqual(1); - expect(find.returns[0].type.names.join(', ')).toEqual('String, Array'); - expect(find.returns[0].description).toEqual('The names of the found item(s).'); + expect(typeof find.returns).toBe('object'); + expect(find.returns.length).toBe(1); + expect(find.returns[0].type.names.join(', ')).toBe('String, Array'); + expect(find.returns[0].description).toBe('The names of the found item(s).'); }); - it('When a symbol has an @param tag with only a type and name, the doclet has a returns array property that includes that param.', function() { - expect(typeof bind.returns).toEqual('object'); - expect(bind.returns.length).toEqual(1); - expect(bind.returns[0].description).toEqual('The binding id.'); + it('When a symbol has an @returns tag with only a description, the doclet has a returns array property that includes that return.', function() { + expect(typeof bind.returns).toBe('object'); + expect(bind.returns.length).toBe(1); + expect(bind.returns[0].description).toBe('The binding id.'); }); -}); \ No newline at end of file +}); diff --git a/test/specs/tags/scopetags.js b/test/specs/tags/scopetags.js new file mode 100644 index 00000000..0b18a58c --- /dev/null +++ b/test/specs/tags/scopetags.js @@ -0,0 +1,31 @@ +describe('scope tags', function () { + var docSet = jasmine.getDocSetFromFile('test/fixtures/scopetags.js'); + + // @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/seetag.js b/test/specs/tags/seetag.js index 96626a46..d6228a59 100644 --- a/test/specs/tags/seetag.js +++ b/test/specs/tags/seetag.js @@ -4,10 +4,10 @@ describe("@see tag", function() { bar = docSet.getByLongname('bar')[0]; it('When a symbol has an @see tag, the doclet has a see property that includes that value.', function() { - expect(typeof foo.see).toEqual('object'); - expect(foo.see[0]).toEqual('{@link bar}'); + expect(typeof foo.see).toBe('object'); + expect(foo.see[0]).toBe('{@link bar}'); - expect(typeof bar.see).toEqual('object'); - expect(bar.see[0]).toEqual('http://example.com/someref'); + expect(typeof bar.see).toBe('object'); + expect(bar.see[0]).toBe('http://example.com/someref'); }); }); \ No newline at end of file diff --git a/test/specs/tags/sincetag.js b/test/specs/tags/sincetag.js index 4e2228e7..91ab3d83 100644 --- a/test/specs/tags/sincetag.js +++ b/test/specs/tags/sincetag.js @@ -3,6 +3,6 @@ describe("@since tag", function() { foo = docSet.getByLongname('foo')[0]; it('When a symbol has an @since tag, the doclet has a since property set to true.', function() { - expect(foo.since).toEqual('1.2.3'); + expect(foo.since).toBe('1.2.3'); }); }); \ No newline at end of file diff --git a/test/specs/tags/summarytag.js b/test/specs/tags/summarytag.js new file mode 100644 index 00000000..a4627153 --- /dev/null +++ b/test/specs/tags/summarytag.js @@ -0,0 +1,8 @@ +describe("@summary tag", function() { + 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/thistag.js b/test/specs/tags/thistag.js index d02c57d4..5fac4ae6 100644 --- a/test/specs/tags/thistag.js +++ b/test/specs/tags/thistag.js @@ -4,13 +4,13 @@ describe("@this tag", function() { fooName = docSet.getByLongname('Foo#name')[0]; it('When a symbol has a @this tag, the doclet has a this property that is set to that value.', function() { - expect(setName['this']).toEqual('Foo'); + expect(setName['this']).toBe('Foo'); }); it('When a this symbol is documented inside a function with a @this tag, the symbol is documented as a member of that tags value.', function() { - expect(typeof fooName).toEqual('object'); - expect(fooName.name).toEqual('name'); - expect(fooName.memberof).toEqual('Foo'); - expect(fooName.scope).toEqual('instance'); + expect(typeof fooName).toBe('object'); + expect(fooName.name).toBe('name'); + expect(fooName.memberof).toBe('Foo'); + expect(fooName.scope).toBe('instance'); }); }); \ No newline at end of file diff --git a/test/specs/tags/todotag.js b/test/specs/tags/todotag.js new file mode 100644 index 00000000..410bb55f --- /dev/null +++ b/test/specs/tags/todotag.js @@ -0,0 +1,13 @@ +describe("@todo tag", function() { + 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(); + expect(Array.isArray(doc.todo)).toBeTruthy(); + expect(doc.todo.length).toBe(2); + + expect(doc.todo).toContain('something'); + expect(doc.todo).toContain('something else'); + }); +}); diff --git a/test/specs/tags/tutorialtag.js b/test/specs/tags/tutorialtag.js new file mode 100644 index 00000000..b334a266 --- /dev/null +++ b/test/specs/tags/tutorialtag.js @@ -0,0 +1,13 @@ +describe("@tutorial tag", function() { + // these are tests for the block usage, not the inline usage. see util/templateHelper for that. + 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(); + expect(doc.tutorials.length).toBe(2); + expect(doc.tutorials).toContain('tute1'); + expect(doc.tutorials).toContain('tute2'); + }); +}); + diff --git a/test/specs/tags/typedeftag.js b/test/specs/tags/typedeftag.js index 193e972b..3ace0fa0 100644 --- a/test/specs/tags/typedeftag.js +++ b/test/specs/tags/typedeftag.js @@ -3,19 +3,19 @@ describe("@typedef tag", function() { numberlike = docSet.getByLongname('calc.NumberLike')[0]; it('When a symbol has an @typedef tag, the doclet has a kind property set to "typedef".', function() { - expect(numberlike.kind).toEqual('typedef'); + expect(numberlike.kind).toBe('typedef'); }); it('When a symbol has an @typedef tag with a type, the doclet has a type property set to that type.', function() { - expect(typeof numberlike.type).toEqual('object'); - expect(typeof numberlike.type.names).toEqual('object'); - expect(numberlike.type.names.length).toEqual(2); - expect(numberlike.type.names[0]).toEqual('string'); - expect(numberlike.type.names[1]).toEqual('number'); + expect(typeof numberlike.type).toBe('object'); + expect(typeof numberlike.type.names).toBe('object'); + expect(numberlike.type.names.length).toBe(2); + expect(numberlike.type.names[0]).toBe('string'); + expect(numberlike.type.names[1]).toBe('number'); }); it('When a symbol has an @typedef tag with a name, the doclet has a name property set to that name.', function() { - expect(numberlike.name).toEqual('NumberLike'); - expect(numberlike.longname).toEqual('calc.NumberLike'); + expect(numberlike.name).toBe('NumberLike'); + expect(numberlike.longname).toBe('calc.NumberLike'); }); }); \ No newline at end of file diff --git a/test/specs/tags/typekind.js b/test/specs/tags/typekind.js index 65fd8389..aea60db0 100644 --- a/test/specs/tags/typekind.js +++ b/test/specs/tags/typekind.js @@ -4,12 +4,12 @@ describe("@kind tag with type", function() { port = docSet.getByLongname('module:blog/server.port')[0]; it('When a module symbol has an kind tag, that includes a {type} clause, the doclet has a type property set to that {type} clause', function() { - expect(typeof blog.type).toEqual('object'); - expect(blog.type.names.join(', ')).toEqual('ConnectServer'); + expect(typeof blog.type).toBe('object'); + expect(blog.type.names.join(', ')).toBe('ConnectServer'); }); it('When a property symbol has an kind tag, that includes a {type} clause, the doclet has a type property set to that {type} clause', function() { - expect(typeof port.type).toEqual('object'); - expect(port.type.names.join(', ')).toEqual('number'); + expect(typeof port.type).toBe('object'); + expect(port.type.names.join(', ')).toBe('number'); }); }); \ No newline at end of file diff --git a/test/specs/tags/typetag.js b/test/specs/tags/typetag.js index 1bf7062d..eb48b9c7 100644 --- a/test/specs/tags/typetag.js +++ b/test/specs/tags/typetag.js @@ -4,12 +4,12 @@ describe("@type tag", function() { bar = docSet.getByLongname('bar')[0]; it('When a symbol has an @type tag, the doclet has a type property set to that value\'s type.', function() { - expect(typeof foo.type).toEqual('object'); - expect(typeof foo.type.names).toEqual('object'); - expect(foo.type.names.join(', ')).toEqual('string, Array'); + expect(typeof foo.type).toBe('object'); + expect(typeof foo.type.names).toBe('object'); + expect(foo.type.names.join(', ')).toBe('string, Array'); }); it('When a symbol has an @type tag set to a plain string, the doclet has a type property set to that string as if it were a type.', function() { - expect(bar.type.names.join(', ')).toEqual('integer'); + expect(bar.type.names.join(', ')).toBe('integer'); }); }); \ No newline at end of file diff --git a/test/specs/tags/undocumentedtag.js b/test/specs/tags/undocumentedtag.js new file mode 100644 index 00000000..90052234 --- /dev/null +++ b/test/specs/tags/undocumentedtag.js @@ -0,0 +1,13 @@ +describe("@undocumented tag", function() { + 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(); + }); + + it("clears the doclet's 'comment' property", function () { + expect(doc.comment).toBe(''); + }); +}); + diff --git a/test/specs/tags/versiontag.js b/test/specs/tags/versiontag.js index 0db924a2..1b50ada2 100644 --- a/test/specs/tags/versiontag.js +++ b/test/specs/tags/versiontag.js @@ -3,6 +3,6 @@ describe("@version tag", function() { foo = docSet.getByLongname('foo')[0]; it('When a symbol has an @version tag, the doclet has a version property set to that value.', function() { - expect(foo.version).toEqual('1.2.3'); + expect(foo.version).toBe('1.2.3'); }); }); \ No newline at end of file