mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
use more expressive test matchers from jasmine-expect
This commit is contained in:
parent
9f28c6c2dd
commit
1b74fb1b84
21
package-lock.json
generated
21
package-lock.json
generated
@ -1610,6 +1610,12 @@
|
|||||||
"integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==",
|
"integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"add-matchers": {
|
||||||
|
"version": "0.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/add-matchers/-/add-matchers-0.6.2.tgz",
|
||||||
|
"integrity": "sha512-hVO2wodMei9RF00qe+506MoeJ/NEOdCMEkSJ12+fC3hx/5Z4zmhNiP92nJEF6XhmXokeB0hOtuQrjHCx2vmXrQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"agent-base": {
|
"agent-base": {
|
||||||
"version": "4.3.0",
|
"version": "4.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz",
|
||||||
@ -6059,6 +6065,15 @@
|
|||||||
"integrity": "sha512-HU/YxV4i6GcmiH4duATwAbJQMlE0MsDIR5XmSVxURxKHn3aGAdbY1/ZJFmVRbKtnLwIxxMJD7gYaPsypcbYimg==",
|
"integrity": "sha512-HU/YxV4i6GcmiH4duATwAbJQMlE0MsDIR5XmSVxURxKHn3aGAdbY1/ZJFmVRbKtnLwIxxMJD7gYaPsypcbYimg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"jasmine-expect": {
|
||||||
|
"version": "4.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/jasmine-expect/-/jasmine-expect-4.0.3.tgz",
|
||||||
|
"integrity": "sha512-ucHOO6qpY6/vwgxoRVzyYywIRuvGEmI1uk69INjdZ84h2dUHIXHf8A5jUkM1kQHy9lHP1jqq9/S5VAkYUsFYCg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"add-matchers": "0.6.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"js-beautify": {
|
"js-beautify": {
|
||||||
"version": "1.10.1",
|
"version": "1.10.1",
|
||||||
"resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.10.1.tgz",
|
"resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.10.1.tgz",
|
||||||
@ -6531,7 +6546,7 @@
|
|||||||
"marked": {
|
"marked": {
|
||||||
"version": "0.7.0",
|
"version": "0.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/marked/-/marked-0.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/marked/-/marked-0.7.0.tgz",
|
||||||
"integrity": "sha1-tkIB8FHScbHtwQoE0a6bdLuOXA4="
|
"integrity": "sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg=="
|
||||||
},
|
},
|
||||||
"matchdep": {
|
"matchdep": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@ -7287,7 +7302,7 @@
|
|||||||
},
|
},
|
||||||
"find-up": {
|
"find-up": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": false,
|
"resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
|
||||||
"integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
|
"integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -7354,7 +7369,7 @@
|
|||||||
},
|
},
|
||||||
"which-module": {
|
"which-module": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": false,
|
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
|
||||||
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=",
|
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
"gulp-json-editor": "^2.5.3",
|
"gulp-json-editor": "^2.5.3",
|
||||||
"jasmine": "^3.4.0",
|
"jasmine": "^3.4.0",
|
||||||
"jasmine-console-reporter": "^3.1.0",
|
"jasmine-console-reporter": "^3.1.0",
|
||||||
|
"jasmine-expect": "^4.0.3",
|
||||||
"klaw-sync": "^6.0.0",
|
"klaw-sync": "^6.0.0",
|
||||||
"lerna": "^3.16.4",
|
"lerna": "^3.16.4",
|
||||||
"nyc": "^14.1.1"
|
"nyc": "^14.1.1"
|
||||||
|
|||||||
@ -39,9 +39,11 @@ module.exports = () => {
|
|||||||
|
|
||||||
jasmine.loadConfig({
|
jasmine.loadConfig({
|
||||||
helpers: [
|
helpers: [
|
||||||
|
'node_modules/jasmine-expect/index.js',
|
||||||
'test/helpers/**/*.js'
|
'test/helpers/**/*.js'
|
||||||
],
|
],
|
||||||
random: false
|
random: false,
|
||||||
|
stopSpecOnExpectationFailure: false
|
||||||
});
|
});
|
||||||
jasmine.env.clearReporters();
|
jasmine.env.clearReporters();
|
||||||
jasmine.addReporter(reporter);
|
jasmine.addReporter(reporter);
|
||||||
|
|||||||
@ -5,12 +5,12 @@ describe('aliases', () => {
|
|||||||
const foundMember = docSet.getByLongname('myObject.myProperty');
|
const foundMember = docSet.getByLongname('myObject.myProperty');
|
||||||
|
|
||||||
it('When a symbol is given an alias it is documented as if the name is the alias value.', () => {
|
it('When a symbol is given an alias it is documented as if the name is the alias value.', () => {
|
||||||
expect(found[0].longname).toEqual('myObject');
|
expect(found[0].longname).toBe('myObject');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is a member of an alias it is documented as if the memberof is the alias value.', () => {
|
it('When a symbol is a member of an alias it is documented as if the memberof is the alias value.', () => {
|
||||||
expect(foundMember[0].longname).toEqual('myObject.myProperty');
|
expect(foundMember[0].longname).toBe('myObject.myProperty');
|
||||||
expect(foundMember[0].memberof).toEqual('myObject');
|
expect(foundMember[0].memberof).toBe('myObject');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -18,17 +18,17 @@ describe('aliases', () => {
|
|||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias2.js');
|
||||||
const foundMember = docSet.getByLongname('ns.Myclass#myProperty');
|
const foundMember = docSet.getByLongname('ns.Myclass#myProperty');
|
||||||
|
|
||||||
expect(foundMember[0].longname).toEqual('ns.Myclass#myProperty');
|
expect(foundMember[0].longname).toBe('ns.Myclass#myProperty');
|
||||||
expect(foundMember[0].name).toEqual('myProperty');
|
expect(foundMember[0].name).toBe('myProperty');
|
||||||
expect(foundMember[0].memberof).toEqual('ns.Myclass');
|
expect(foundMember[0].memberof).toBe('ns.Myclass');
|
||||||
expect(foundMember[0].scope).toEqual('instance');
|
expect(foundMember[0].scope).toBe('instance');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is a member of an aliased class, a this-variable is documented as if it were a member that class.', () => {
|
it('When a symbol is a member of an aliased class, a this-variable is documented as if it were a member that class.', () => {
|
||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias3.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias3.js');
|
||||||
const tcmValue = docSet.getByLongname('trackr.CookieManager#value')[0];
|
const tcmValue = docSet.getByLongname('trackr.CookieManager#value')[0];
|
||||||
|
|
||||||
expect(tcmValue.memberof).toEqual('trackr.CookieManager');
|
expect(tcmValue.memberof).toBe('trackr.CookieManager');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is a function expression that has an alias, the symbol should get the correct longname', () => {
|
it('When a symbol is a function expression that has an alias, the symbol should get the correct longname', () => {
|
||||||
@ -46,21 +46,21 @@ describe('aliases', () => {
|
|||||||
const clean = docSet.getByLongname('Toaster#clean')[0];
|
const clean = docSet.getByLongname('Toaster#clean')[0];
|
||||||
|
|
||||||
it('should work when the alias value specifies an instance member', () => {
|
it('should work when the alias value specifies an instance member', () => {
|
||||||
expect(toast).toBeDefined();
|
expect(toast).toBeObject();
|
||||||
expect(toast.name).toBe('toast');
|
expect(toast.name).toBe('toast');
|
||||||
expect(toast.memberof).toBe('Toaster');
|
expect(toast.memberof).toBe('Toaster');
|
||||||
expect(toast.scope).toBe('instance');
|
expect(toast.scope).toBe('instance');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work when the alias value specifies a static member', () => {
|
it('should work when the alias value specifies a static member', () => {
|
||||||
expect(getInstance).toBeDefined();
|
expect(getInstance).toBeObject();
|
||||||
expect(getInstance.name).toBe('getInstance');
|
expect(getInstance.name).toBe('getInstance');
|
||||||
expect(getInstance.memberof).toBe('Toaster');
|
expect(getInstance.memberof).toBe('Toaster');
|
||||||
expect(getInstance.scope).toBe('static');
|
expect(getInstance.scope).toBe('static');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work when the alias value only specifies the short name', () => {
|
it('should work when the alias value only specifies the short name', () => {
|
||||||
expect(clean).toBeDefined();
|
expect(clean).toBeObject();
|
||||||
expect(clean.name).toBe('clean');
|
expect(clean.name).toBe('clean');
|
||||||
expect(clean.memberof).toBe('Toaster');
|
expect(clean.memberof).toBe('Toaster');
|
||||||
expect(clean.scope).toBe('instance');
|
expect(clean.scope).toBe('instance');
|
||||||
@ -80,15 +80,15 @@ describe('aliases', () => {
|
|||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/aliasglobal.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/aliasglobal.js');
|
||||||
const log = docSet.getByLongname('log')[0];
|
const log = docSet.getByLongname('log')[0];
|
||||||
|
|
||||||
expect(log.scope).toEqual('global');
|
expect(log.scope).toBe('global');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is documented as an instance member of <global>, its scope is "instance" and not "static".', () => {
|
it('When a symbol is documented as an instance member of <global>, its scope is "instance" and not "static".', () => {
|
||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/aliasglobal2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/aliasglobal2.js');
|
||||||
const run = docSet.getByLongname('Test#run')[0];
|
const run = docSet.getByLongname('Test#run')[0];
|
||||||
|
|
||||||
expect(run.scope).toEqual('instance');
|
expect(run.scope).toBe('instance');
|
||||||
expect(run.memberof).toEqual('Test');
|
expect(run.memberof).toBe('Test');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('resolving', () => {
|
describe('resolving', () => {
|
||||||
@ -96,14 +96,14 @@ describe('aliases', () => {
|
|||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/aliasresolve.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/aliasresolve.js');
|
||||||
const method = docSet.getByLongname('A.F.method');
|
const method = docSet.getByLongname('A.F.method');
|
||||||
|
|
||||||
expect(method.length).toEqual(1);
|
expect(method).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a reference in an outer scope has alias, put all members into aliased definition. Local modifications are visible to outside.', () => {
|
it('When a reference in an outer scope has alias, put all members into aliased definition. Local modifications are visible to outside.', () => {
|
||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/aliasresolve2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/aliasresolve2.js');
|
||||||
const method = docSet.getByLongname('A.F.method');
|
const method = docSet.getByLongname('A.F.method');
|
||||||
|
|
||||||
expect(method.length).toEqual(1);
|
expect(method).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,45 +5,43 @@ describe('multiple doclets per symbol', () => {
|
|||||||
return !($.undocumented);
|
return !($.undocumented);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkInequality(doclets, property) {
|
|
||||||
for (let l = doclets.length - 1; l > 0; l--) {
|
|
||||||
if (doclets[l][property] !== undefined && doclets[l - 1][property] !== undefined) {
|
|
||||||
expect(doclets[l][property]).not.toBe(doclets[l - 1][property]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/also.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/also.js');
|
||||||
const name = docSet.getByLongname('Asset#name').filter(undocumented);
|
const name = docSet.getByLongname('Asset#name').filter(undocumented);
|
||||||
const shape = docSet.getByLongname('Asset#shape').filter(undocumented);
|
const shape = docSet.getByLongname('Asset#shape').filter(undocumented);
|
||||||
|
|
||||||
it('When a symbol has multiple adjacent JSDoc comments, both apply to the symbol.', () => {
|
it('When a symbol has multiple adjacent JSDoc comments, both apply to the symbol.', () => {
|
||||||
expect(name.length).toBe(2);
|
expect(name).toBeArrayOfSize(2);
|
||||||
expect(shape.length).toBe(3);
|
expect(shape).toBeArrayOfSize(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has multiple adjacent JSDoc comments that are not identical, the doclets ' +
|
it('When a symbol has multiple adjacent JSDoc comments that are not identical, the doclets ' +
|
||||||
'have different comments.', () => {
|
'have different comments.', () => {
|
||||||
checkInequality(name, 'comment');
|
expect(name[0].comment).not.toBe(name[1].comment);
|
||||||
checkInequality(shape, 'comment');
|
expect(shape[0].comment).not.toBe(shape[1].comment);
|
||||||
|
expect(shape[1].comment).not.toBe(shape[2].comment);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has multiple adjacent JSDoc comments with different descriptions, ' +
|
it('When a symbol has multiple adjacent JSDoc comments with different descriptions, ' +
|
||||||
'the doclets have different descriptions.', () => {
|
'the doclets have different descriptions.', () => {
|
||||||
checkInequality(name, 'description');
|
expect(name[0].description).not.toBe(name[1].description);
|
||||||
checkInequality(shape, 'description');
|
expect(shape[0].description).not.toBe(shape[1].description);
|
||||||
|
expect(shape[1].description).not.toBe(shape[2].description);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has multiple adjacent JSDoc comments with different numbers of ' +
|
it('When a symbol has multiple adjacent JSDoc comments with different numbers of ' +
|
||||||
'@param tags, the doclets have different parameter lists.', () => {
|
'@param tags, the doclets have different parameter lists.', () => {
|
||||||
checkInequality(name, 'params.length');
|
expect(name[0].params).not.toEqual(name[1].params);
|
||||||
checkInequality(shape, 'params.length');
|
expect(shape[0].params).not.toEqual(shape[1].params);
|
||||||
|
expect(shape[1].params).not.toEqual(shape[2].params);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has multiple adjacent JSDoc comments with different numbers of ' +
|
it('When a symbol has multiple adjacent JSDoc comments with different numbers of ' +
|
||||||
'@returns tags, the doclets have different lists of return values.', () => {
|
'@returns tags, the doclets have different lists of return values.', () => {
|
||||||
checkInequality(name, 'returns.length');
|
expect(name[0].returns).not.toEqual(name[1].returns);
|
||||||
checkInequality(shape, 'returns.length');
|
// Neither shape[0] nor shape[1] returns a value.
|
||||||
|
expect(shape[0].returns).toBeUndefined();
|
||||||
|
expect(shape[1].returns).toBeUndefined();
|
||||||
|
expect(shape[2].returns).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a file contains a JSDoc comment with an @also tag, and the "tags.allowUnknownTags" ' +
|
it('When a file contains a JSDoc comment with an @also tag, and the "tags.allowUnknownTags" ' +
|
||||||
|
|||||||
@ -5,17 +5,17 @@ describe('arrow functions', () => {
|
|||||||
const name = docSet.getByLongname('<anonymous>#name');
|
const name = docSet.getByLongname('<anonymous>#name');
|
||||||
|
|
||||||
it('should use the correct name and longname', () => {
|
it('should use the correct name and longname', () => {
|
||||||
expect(increment).toBeDefined();
|
expect(increment).toBeObject();
|
||||||
expect(increment.name).toBe('increment');
|
expect(increment.name).toBe('increment');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow function parameters to be documented', () => {
|
it('should allow function parameters to be documented', () => {
|
||||||
expect(increment.params.length).toBe(1);
|
expect(increment.params).toBeArrayOfSize(1);
|
||||||
expect(increment.params[0].name).toBe('n');
|
expect(increment.params[0].name).toBe('n');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support inline comments on parameters', () => {
|
it('should support inline comments on parameters', () => {
|
||||||
expect(print.params.length).toBe(1);
|
expect(print.params).toBeArrayOfSize(1);
|
||||||
expect(print.params[0].type.names[0]).toBe('*');
|
expect(print.params[0].type.names[0]).toBe('*');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -24,6 +24,6 @@ describe('arrow functions', () => {
|
|||||||
// details
|
// details
|
||||||
xit('should use the correct longname for members of a class returned by an arrow function',
|
xit('should use the correct longname for members of a class returned by an arrow function',
|
||||||
() => {
|
() => {
|
||||||
expect(name.length).toBe(2);
|
expect(name).toBeArrayOfSize(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,14 +5,14 @@ describe('async functions', () => {
|
|||||||
const adderAdd = docSet.getByLongname('Adder#add')[0];
|
const adderAdd = docSet.getByLongname('Adder#add')[0];
|
||||||
|
|
||||||
it('should automatically document async functions as async', () => {
|
it('should automatically document async functions as async', () => {
|
||||||
expect(add.async).toBe(true);
|
expect(add.async).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work when the async function is assigned to a variable', () => {
|
it('should work when the async function is assigned to a variable', () => {
|
||||||
expect(subtract.async).toBe(true);
|
expect(subtract.async).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work when the async function is a method definition', () => {
|
it('should work when the async function is a method definition', () => {
|
||||||
expect(adderAdd.async).toBe(true);
|
expect(adderAdd.async).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,16 +2,13 @@ describe('callback tag', () => {
|
|||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/callbacktag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/callbacktag.js');
|
||||||
|
|
||||||
function callbackTests(callback) {
|
function callbackTests(callback) {
|
||||||
expect(callback).toBeDefined();
|
expect(callback).toBeObject();
|
||||||
|
|
||||||
expect(callback.type).toBeDefined();
|
expect(callback.type).toBeObject();
|
||||||
expect(typeof callback.type).toEqual('object');
|
|
||||||
|
|
||||||
expect(callback.type.names).toBeDefined();
|
expect(callback.type.names).toBeArrayOfSize(1);
|
||||||
expect(callback.type.names instanceof Array).toEqual(true);
|
|
||||||
expect(callback.type.names.length).toEqual(1);
|
|
||||||
|
|
||||||
expect(callback.type.names[0]).toEqual('function');
|
expect(callback.type.names[0]).toBe('function');
|
||||||
}
|
}
|
||||||
|
|
||||||
it('correctly handles callbacks that do not define a {type}', () => {
|
it('correctly handles callbacks that do not define a {type}', () => {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ describe('class without a name', () => {
|
|||||||
.filter(({name}) => name === '');
|
.filter(({name}) => name === '');
|
||||||
|
|
||||||
it('When the doclet for a class has an empty name, it should also have an empty longname', () => {
|
it('When the doclet for a class has an empty name, it should also have an empty longname', () => {
|
||||||
expect(docSet).toBeDefined();
|
expect(docSet).toBeArray();
|
||||||
expect(docSet.length).toBe(1);
|
expect(docSet.length).toBe(1);
|
||||||
expect(docSet[0].description).toBe('Create an instance of MyClass.');
|
expect(docSet[0].description).toBe('Create an instance of MyClass.');
|
||||||
expect(docSet[0].longname).toBe('');
|
expect(docSet[0].longname).toBe('');
|
||||||
|
|||||||
@ -37,7 +37,7 @@ describe('default parameters', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should work with boolean literals', () => {
|
it('should work with boolean literals', () => {
|
||||||
expect(setActive.params[0].defaultvalue).toBe(true);
|
expect(setActive.params[0].defaultvalue).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work with numeric literals', () => {
|
it('should work with numeric literals', () => {
|
||||||
@ -49,7 +49,7 @@ describe('default parameters', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should work when the function is assigned to a variable', () => {
|
it('should work when the function is assigned to a variable', () => {
|
||||||
expect(setIsNinja.params[0].defaultvalue).toBe(true);
|
expect(setIsNinja.params[0].defaultvalue).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ES2015 methods', () => {
|
describe('ES2015 methods', () => {
|
||||||
@ -58,7 +58,7 @@ describe('default parameters', () => {
|
|||||||
const setSardines = docSet2.getByLongname('PizzaToppings#setSardines')[0];
|
const setSardines = docSet2.getByLongname('PizzaToppings#setSardines')[0];
|
||||||
|
|
||||||
it('should autodetect default parameters', () => {
|
it('should autodetect default parameters', () => {
|
||||||
expect(setSardines.params[0].defaultvalue).toBe(true);
|
expect(setSardines.params[0].defaultvalue).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@ describe('export class', () => {
|
|||||||
const bar = docSet.getByLongname('module:foo.Bar')[0];
|
const bar = docSet.getByLongname('module:foo.Bar')[0];
|
||||||
|
|
||||||
it('should name exported classes correctly', () => {
|
it('should name exported classes correctly', () => {
|
||||||
expect(bar).toBeDefined();
|
expect(bar).toBeObject();
|
||||||
expect(bar.name).toBe('Bar');
|
expect(bar.name).toBe('Bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -5,14 +5,14 @@ describe("'exports' symbol in modules", () => {
|
|||||||
|
|
||||||
it('When a symbol starts with the special name "exports" and is in a file with a ' +
|
it('When a symbol starts with the special name "exports" and is in a file with a ' +
|
||||||
'@module tag, the symbol is documented as a member of that module.', () => {
|
'@module tag, the symbol is documented as a member of that module.', () => {
|
||||||
expect(typeof sayHello).toBe('object');
|
expect(sayHello).toBeObject();
|
||||||
expect(sayHello.kind).toBe('function');
|
expect(sayHello.kind).toBe('function');
|
||||||
expect(sayHello.memberof).toBe('module:hello/world');
|
expect(sayHello.memberof).toBe('module:hello/world');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol starts with the special name "module.exports" and is in a file with a ' +
|
it('When a symbol starts with the special name "module.exports" and is in a file with a ' +
|
||||||
'@module tag, the symbol is documented as a member of that module.', () => {
|
'@module tag, the symbol is documented as a member of that module.', () => {
|
||||||
expect(typeof sayGoodbye).toBe('object');
|
expect(sayGoodbye).toBeObject();
|
||||||
expect(sayGoodbye.kind).toBe('function');
|
expect(sayGoodbye.kind).toBe('function');
|
||||||
expect(sayGoodbye.memberof).toBe('module:hello/world');
|
expect(sayGoodbye.memberof).toBe('module:hello/world');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,14 +5,14 @@ describe('generator functions', () => {
|
|||||||
const startsAt2 = docSet.getByLongname('Generator#startsAt2')[0];
|
const startsAt2 = docSet.getByLongname('Generator#startsAt2')[0];
|
||||||
|
|
||||||
it('should flag generator functions', () => {
|
it('should flag generator functions', () => {
|
||||||
expect(startsAt0.generator).toBe(true);
|
expect(startsAt0.generator).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should flag generator functions assigned to variables', () => {
|
it('should flag generator functions assigned to variables', () => {
|
||||||
expect(startsAt1.generator).toBe(true);
|
expect(startsAt1.generator).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should flag generator functions that are method definitions', () => {
|
it('should flag generator functions that are method definitions', () => {
|
||||||
expect(startsAt2.generator).toBe(true);
|
expect(startsAt2.generator).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,8 +6,8 @@ describe('When a getter or setter is part of a class', () => {
|
|||||||
const age = docSet.getByLongname('Person#age');
|
const age = docSet.getByLongname('Person#age');
|
||||||
|
|
||||||
it('should have a doclet with the correct longname', () => {
|
it('should have a doclet with the correct longname', () => {
|
||||||
expect(name.length).toBe(2);
|
expect(name).toBeArrayOfSize(2);
|
||||||
expect(age.length).toBe(1);
|
expect(age).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a doclet with the correct name', () => {
|
it('should have a doclet with the correct name', () => {
|
||||||
@ -34,7 +34,7 @@ describe('When a getter or setter is part of a class', () => {
|
|||||||
const location = docSet2.getByLongname('Employee#location');
|
const location = docSet2.getByLongname('Employee#location');
|
||||||
|
|
||||||
it('should have a doclet with the correct longname', () => {
|
it('should have a doclet with the correct longname', () => {
|
||||||
expect(location.length).toBe(2);
|
expect(location).toBeArrayOfSize(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a doclet with the correct name', () => {
|
it('should have a doclet with the correct name', () => {
|
||||||
|
|||||||
@ -6,8 +6,8 @@ describe('inline comments', () => {
|
|||||||
it('When there is an inline comment on a line ending with no semicolon, ' +
|
it('When there is an inline comment on a line ending with no semicolon, ' +
|
||||||
'that comment and the next comment are still captured', () => {
|
'that comment and the next comment are still captured', () => {
|
||||||
// Inline comment on line without semicolon is captured
|
// Inline comment on line without semicolon is captured
|
||||||
expect(t.length).toEqual(1);
|
expect(t).toBeArrayOfSize(1);
|
||||||
// Inline comment on line after line without semicolon is captured
|
// Inline comment on line after line without semicolon is captured
|
||||||
expect(t2.length).toEqual(1);
|
expect(t2).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,12 +13,12 @@ describe('inline comments on function parameters', () => {
|
|||||||
const foo = docSet.getByLongname('ns.foo')[0];
|
const foo = docSet.getByLongname('ns.foo')[0];
|
||||||
|
|
||||||
it('should attach inline comments to default parameters', () => {
|
it('should attach inline comments to default parameters', () => {
|
||||||
expect(foo.params[0].type.names.length).toBe(1);
|
expect(foo.params[0].type.names).toBeArrayOfSize(1);
|
||||||
expect(foo.params[0].type.names[0]).toBe('string');
|
expect(foo.params[0].type.names[0]).toBe('string');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should attach inline comments to rest parameters', () => {
|
it('should attach inline comments to rest parameters', () => {
|
||||||
expect(foo.params[1].type.names.length).toBe(1);
|
expect(foo.params[1].type.names).toBeArrayOfSize(1);
|
||||||
expect(foo.params[1].type.names[0]).toBe('number');
|
expect(foo.params[1].type.names[0]).toBe('number');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,8 +4,8 @@ describe('when a documented var memeber is inside a named function', () => {
|
|||||||
const found2 = docSet.getByLongname('sendMessage~encrypt');
|
const found2 = docSet.getByLongname('sendMessage~encrypt');
|
||||||
|
|
||||||
it('A doclet with the correct longname should be found', () => {
|
it('A doclet with the correct longname should be found', () => {
|
||||||
expect(found1.length).toBe(1);
|
expect(found1).toBeArrayOfSize(1);
|
||||||
expect(found2.length).toBe(1);
|
expect(found2).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('The short name should be correct', () => {
|
it('The short name should be correct', () => {
|
||||||
|
|||||||
@ -6,15 +6,15 @@ describe('inner scope', () => {
|
|||||||
const response = docSet.getByLongname('Message~response.code');
|
const response = docSet.getByLongname('Message~response.code');
|
||||||
|
|
||||||
it('should occur when a member of a var member is documented.', () => {
|
it('should occur when a member of a var member is documented.', () => {
|
||||||
expect(to.length).toBe(1);
|
expect(to).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should occur when a second member of a var member is documented.', () => {
|
it('should occur when a second member of a var member is documented.', () => {
|
||||||
expect(response.length).toBe(1);
|
expect(response).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should occur when a deeply nested member of a var member is documented.', () => {
|
it('should occur when a deeply nested member of a var member is documented.', () => {
|
||||||
expect(from.length).toBe(1);
|
expect(from).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -24,11 +24,11 @@ describe('inner scope', () => {
|
|||||||
const cache = docSet.getByLongname('<anonymous>~headers.cache');
|
const cache = docSet.getByLongname('<anonymous>~headers.cache');
|
||||||
|
|
||||||
it('When a var is declared in a function, It is like Inner~member', () => {
|
it('When a var is declared in a function, It is like Inner~member', () => {
|
||||||
expect(cache.length).toBe(1);
|
expect(cache).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a var is masked by an inner var and a member of the inner is documented, it is like Inner~inner.member', () => {
|
it('When a var is masked by an inner var and a member of the inner is documented, it is like Inner~inner.member', () => {
|
||||||
expect(from.length).toBe(1);
|
expect(from).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a documented member is assigned to a var that masks an outer var.', () => {
|
it('When a documented member is assigned to a var that masks an outer var.', () => {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ describe('Properties documented in instance methods', () => {
|
|||||||
const bar = docSet.getByLongname('Foo#bar')[0];
|
const bar = docSet.getByLongname('Foo#bar')[0];
|
||||||
|
|
||||||
it('should set the correct longname when a property is documented in an instance method', () => {
|
it('should set the correct longname when a property is documented in an instance method', () => {
|
||||||
expect(bar).toBeDefined();
|
expect(bar).toBeObject();
|
||||||
expect(bar.name).toBe('bar');
|
expect(bar.name).toBe('bar');
|
||||||
expect(bar.kind).toBe('member');
|
expect(bar.kind).toBe('member');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,29 +10,29 @@ describe('lends', () => {
|
|||||||
const name = docSet.getByLongname('Person#name');
|
const name = docSet.getByLongname('Person#name');
|
||||||
|
|
||||||
it('The member should be documented as a member of the lendee', () => {
|
it('The member should be documented as a member of the lendee', () => {
|
||||||
expect(init.length, 1);
|
expect(init).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('The this member should be documented as a member of the lendee', () => {
|
it('The this member should be documented as a member of the lendee', () => {
|
||||||
expect(name.length, 1);
|
expect(name).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('case containing constructor', () => {
|
describe('case containing constructor', () => {
|
||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/lends2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/lends2.js');
|
||||||
const person = docSet.getByLongname('Person').filter(removeUndocumented)[0];
|
const person = docSet.getByLongname('Person').filter(removeUndocumented);
|
||||||
const name = docSet.getByLongname('Person#name');
|
const name = docSet.getByLongname('Person#name');
|
||||||
|
|
||||||
it('A tag with a @constructs tag is documented as a constructor.', () => {
|
it('A tag with a @constructs tag is documented as a constructor.', () => {
|
||||||
expect(person.description).toBe('Construct a Person.');
|
expect(person[0].description).toBe('Construct a Person.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('The member should be documented as a member of the lendee', () => {
|
it('The member should be documented as a member of the lendee', () => {
|
||||||
expect(person.length, 1);
|
expect(person).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('The this member should be documented as a member of the lendee', () => {
|
it('The this member should be documented as a member of the lendee', () => {
|
||||||
expect(name.length, 1);
|
expect(name).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,11 +42,11 @@ describe('lends', () => {
|
|||||||
const name = docSet.getByLongname('Person#name');
|
const name = docSet.getByLongname('Person#name');
|
||||||
|
|
||||||
it('The member should be documented as a member of the lendee', () => {
|
it('The member should be documented as a member of the lendee', () => {
|
||||||
expect(init.length, 1);
|
expect(init).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('The this member should be documented as a member of the lendee', () => {
|
it('The this member should be documented as a member of the lendee', () => {
|
||||||
expect(name.length, 1);
|
expect(name).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -56,13 +56,13 @@ describe('lends', () => {
|
|||||||
const say = docSet.getByLongname('Person#say');
|
const say = docSet.getByLongname('Person#say');
|
||||||
|
|
||||||
it('The class constructor should be documented with the name of the lendee', () => {
|
it('The class constructor should be documented with the name of the lendee', () => {
|
||||||
expect(person.length).toBe(1);
|
expect(person).toBeArrayOfSize(1);
|
||||||
expect(person[0].name).toBe('Person');
|
expect(person[0].name).toBe('Person');
|
||||||
expect(person[0].kind).toBe('class');
|
expect(person[0].kind).toBe('class');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('A class\' instance method should be documented as a member of the lendee', () => {
|
it('A class\' instance method should be documented as a member of the lendee', () => {
|
||||||
expect(say.length).toBe(1);
|
expect(say).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,13 +72,13 @@ describe('lends', () => {
|
|||||||
const say = docSet.getByLongname('Person#say').filter(removeUndocumented)[0];
|
const say = docSet.getByLongname('Person#say').filter(removeUndocumented)[0];
|
||||||
|
|
||||||
it('The class constructor should be documented with the name of the lendee', () => {
|
it('The class constructor should be documented with the name of the lendee', () => {
|
||||||
expect(person).toBeDefined();
|
expect(person).toBeObject();
|
||||||
expect(person.name).toBe('Person');
|
expect(person.name).toBe('Person');
|
||||||
expect(person.kind).toBe('class');
|
expect(person.kind).toBe('class');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('A class\' instance method should be documented as a member of the lendee', () => {
|
it('A class\' instance method should be documented as a member of the lendee', () => {
|
||||||
expect(say).toBeDefined();
|
expect(say).toBeObject();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -89,11 +89,11 @@ describe('lends', () => {
|
|||||||
const person = docSet.getByLongname('Person').filter(removeUndocumented)[0];
|
const person = docSet.getByLongname('Person').filter(removeUndocumented)[0];
|
||||||
const say = docSet.getByLongname('Person#say').filter(removeUndocumented)[0];
|
const say = docSet.getByLongname('Person#say').filter(removeUndocumented)[0];
|
||||||
|
|
||||||
expect(person).toBeDefined();
|
expect(person).toBeObject();
|
||||||
expect(person.name).toBe('Person');
|
expect(person.name).toBe('Person');
|
||||||
expect(person.kind).toBe('class');
|
expect(person.kind).toBe('class');
|
||||||
|
|
||||||
expect(say).toBeDefined();
|
expect(say).toBeObject();
|
||||||
expect(say.name).toBe('say');
|
expect(say.name).toBe('say');
|
||||||
expect(say.kind).toBe('function');
|
expect(say.kind).toBe('function');
|
||||||
});
|
});
|
||||||
@ -102,11 +102,11 @@ describe('lends', () => {
|
|||||||
const robot = docSet.getByLongname('Robot').filter(removeUndocumented)[0];
|
const robot = docSet.getByLongname('Robot').filter(removeUndocumented)[0];
|
||||||
const emote = docSet.getByLongname('Robot#emote').filter(removeUndocumented)[0];
|
const emote = docSet.getByLongname('Robot#emote').filter(removeUndocumented)[0];
|
||||||
|
|
||||||
expect(robot).toBeDefined();
|
expect(robot).toBeObject();
|
||||||
expect(robot.name).toBe('Robot');
|
expect(robot.name).toBe('Robot');
|
||||||
expect(robot.kind).toBe('class');
|
expect(robot.kind).toBe('class');
|
||||||
|
|
||||||
expect(emote).toBeDefined();
|
expect(emote).toBeObject();
|
||||||
expect(emote.name).toBe('emote');
|
expect(emote.name).toBe('emote');
|
||||||
expect(emote.kind).toBe('function');
|
expect(emote.kind).toBe('function');
|
||||||
});
|
});
|
||||||
@ -119,7 +119,7 @@ describe('lends', () => {
|
|||||||
const test12 = docSet.getByLongname('test1.test2')[0];
|
const test12 = docSet.getByLongname('test1.test2')[0];
|
||||||
|
|
||||||
it('The members of the objlit are not members of any symbol', () => {
|
it('The members of the objlit are not members of any symbol', () => {
|
||||||
expect(typeof testf.memberof).toBe('undefined');
|
expect(testf.memberof).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('The members of the objlit are documented as global.', () => {
|
it('The members of the objlit are documented as global.', () => {
|
||||||
|
|||||||
@ -1,12 +1,6 @@
|
|||||||
describe('let keyword', () => {
|
describe('let keyword', () => {
|
||||||
let docSet;
|
|
||||||
let exampleModule;
|
|
||||||
let exampleMethod;
|
|
||||||
|
|
||||||
function getDocSet() {
|
function getDocSet() {
|
||||||
docSet = jsdoc.getDocSetFromFile('test/fixtures/letkeyword.js');
|
return jsdoc.getDocSetFromFile('test/fixtures/letkeyword.js');
|
||||||
exampleModule = docSet.getByLongname('module:exampleModule');
|
|
||||||
exampleMethod = docSet.getByLongname('module:exampleModule.exampleMethod');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should be able to compile JS files that contain the "let" keyword', () => {
|
it('should be able to compile JS files that contain the "let" keyword', () => {
|
||||||
@ -14,14 +8,16 @@ describe('let keyword', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should correctly recognize a module defined with the "let" keyword', () => {
|
it('should correctly recognize a module defined with the "let" keyword', () => {
|
||||||
expect(exampleModule).toBeDefined();
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/letkeyword.js');
|
||||||
expect( Array.isArray(exampleModule) ).toBe(true);
|
const exampleModule = docSet.getByLongname('module:exampleModule');
|
||||||
expect(exampleModule.length).toBe(1);
|
|
||||||
|
expect(exampleModule).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should correctly recognize members of a module defined with the "let" keyword', () => {
|
it('should correctly recognize members of a module defined with the "let" keyword', () => {
|
||||||
expect(exampleMethod).toBeDefined();
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/letkeyword.js');
|
||||||
expect( Array.isArray(exampleMethod) ).toBe(true);
|
const exampleMethod = docSet.getByLongname('module:exampleModule.exampleMethod');
|
||||||
expect(exampleMethod.length).toBe(1);
|
|
||||||
|
expect(exampleMethod).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,11 +4,11 @@ describe('method definition inside a class declaration', () => {
|
|||||||
const staticRunMethod = docSet.getByLongname('Test.run')[0];
|
const staticRunMethod = docSet.getByLongname('Test.run')[0];
|
||||||
|
|
||||||
it('methods should have documentation comments', () => {
|
it('methods should have documentation comments', () => {
|
||||||
expect(runMethod).toBeDefined();
|
expect(runMethod).toBeObject();
|
||||||
expect(runMethod.description).toBe('Document me.');
|
expect(runMethod.description).toBe('Document me.');
|
||||||
expect(runMethod.kind).toBe('function');
|
expect(runMethod.kind).toBe('function');
|
||||||
|
|
||||||
expect(staticRunMethod).toBeDefined();
|
expect(staticRunMethod).toBeObject();
|
||||||
expect(staticRunMethod.description).toBe('Static document me.');
|
expect(staticRunMethod.description).toBe('Static document me.');
|
||||||
expect(staticRunMethod.kind).toBe('function');
|
expect(staticRunMethod.kind).toBe('function');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,23 +10,21 @@ describe('mixins', () => {
|
|||||||
it('should create doclets for mixed-in symbols', () => {
|
it('should create doclets for mixed-in symbols', () => {
|
||||||
const objectBMethod = docSet.getByLongname('module:mixy.ObjectB.method')[0];
|
const objectBMethod = docSet.getByLongname('module:mixy.ObjectB.method')[0];
|
||||||
|
|
||||||
expect(objectBMethod).toBeDefined();
|
expect(objectBMethod).toBeObject();
|
||||||
expect(objectBMethod.memberof).toBe('module:mixy.ObjectB');
|
expect(objectBMethod.memberof).toBe('module:mixy.ObjectB');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the "mixes" property correctly on first-generation mixers', () => {
|
it('should set the "mixes" property correctly on first-generation mixers', () => {
|
||||||
const objectBMethod = docSet.getByLongname('module:mixy.ObjectB.method')[0];
|
const objectBMethod = docSet.getByLongname('module:mixy.ObjectB.method')[0];
|
||||||
|
|
||||||
expect(Array.isArray(objectBMethod.mixes)).toBe(true);
|
expect(objectBMethod.mixes).toBeArrayOfSize(1);
|
||||||
expect(objectBMethod.mixes.length).toBe(1);
|
|
||||||
expect(objectBMethod.mixes[0]).toBe('module:mixy.ObjectA.method');
|
expect(objectBMethod.mixes[0]).toBe('module:mixy.ObjectA.method');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the "mixes" property correctly on second-generation mixers', () => {
|
it('should set the "mixes" property correctly on second-generation mixers', () => {
|
||||||
const objectCMethod = docSet.getByLongname('module:mixy.ObjectC.method')[0];
|
const objectCMethod = docSet.getByLongname('module:mixy.ObjectC.method')[0];
|
||||||
|
|
||||||
expect(Array.isArray(objectCMethod.mixes)).toBe(true);
|
expect(objectCMethod.mixes).toBeArrayOfSize(1);
|
||||||
expect(objectCMethod.mixes.length).toBe(1);
|
|
||||||
expect(objectCMethod.mixes[0]).toBe('module:mixy.ObjectB.method');
|
expect(objectCMethod.mixes[0]).toBe('module:mixy.ObjectB.method');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -34,7 +32,7 @@ describe('mixins', () => {
|
|||||||
const superSweetStatic = docSet.getByLongname('module:mixy.ObjectC.superSweet')[0];
|
const superSweetStatic = docSet.getByLongname('module:mixy.ObjectC.superSweet')[0];
|
||||||
const superSweetInstance = docSet.getByLongname('module:mixy.ClassB#superSweet')[0];
|
const superSweetInstance = docSet.getByLongname('module:mixy.ClassB#superSweet')[0];
|
||||||
|
|
||||||
expect(superSweetInstance).toBeDefined();
|
expect(superSweetInstance).toBeObject();
|
||||||
expect(superSweetInstance.comment).toBe(superSweetStatic.comment);
|
expect(superSweetInstance.comment).toBe(superSweetStatic.comment);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,7 +40,7 @@ describe('mixins', () => {
|
|||||||
it('should define symbols mixed into a class as instance members', () => {
|
it('should define symbols mixed into a class as instance members', () => {
|
||||||
const classAMethod = docSet.getByLongname('module:mixy.ClassA#method')[0];
|
const classAMethod = docSet.getByLongname('module:mixy.ClassA#method')[0];
|
||||||
|
|
||||||
expect(classAMethod).toBeDefined();
|
expect(classAMethod).toBeObject();
|
||||||
expect(classAMethod.scope).toBe(name.SCOPE.NAMES.INSTANCE);
|
expect(classAMethod.scope).toBe(name.SCOPE.NAMES.INSTANCE);
|
||||||
expect(classAMethod.memberof).toBe('module:mixy.ClassA');
|
expect(classAMethod.memberof).toBe('module:mixy.ClassA');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,10 +4,10 @@ describe('inner scope for modules', () => {
|
|||||||
const fooOut = docSet.getByLongname('module:my/module~fooOut')[0];
|
const fooOut = docSet.getByLongname('module:my/module~fooOut')[0];
|
||||||
|
|
||||||
it('When a function appears in the topscope of a module, the symbol is documented as an inner member of that module.', () => {
|
it('When a function appears in the topscope of a module, the symbol is documented as an inner member of that module.', () => {
|
||||||
expect(typeof fooOut).toEqual('object');
|
expect(typeof fooOut).toBe('object');
|
||||||
expect(fooOut.longname).toEqual('module:my/module~fooOut');
|
expect(fooOut.longname).toBe('module:my/module~fooOut');
|
||||||
|
|
||||||
expect(typeof fooIn).toEqual('object');
|
expect(typeof fooIn).toBe('object');
|
||||||
expect(fooIn.longname).toEqual('module:my/module~fooIn');
|
expect(fooIn.longname).toBe('module:my/module~fooIn');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,12 +7,12 @@ describe('module that exports a constructor', () => {
|
|||||||
const id = docSet.getByLongname('module:mymodule/config#id')[0];
|
const id = docSet.getByLongname('module:mymodule/config#id')[0];
|
||||||
|
|
||||||
it('should include one doclet whose kind is "module"', () => {
|
it('should include one doclet whose kind is "module"', () => {
|
||||||
expect(modules.length).toBe(1);
|
expect(modules).toBeArrayOfSize(1);
|
||||||
expect(modules[0].kind).toBe('module');
|
expect(modules[0].kind).toBe('module');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should include one doclet whose kind is "class"', () => {
|
it('should include one doclet whose kind is "class"', () => {
|
||||||
expect(classes.length).toBe(1);
|
expect(classes).toBeArrayOfSize(1);
|
||||||
expect(classes[0].kind).toBe('class');
|
expect(classes[0].kind).toBe('class');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -51,12 +51,12 @@ describe('module that exports a constructor', () => {
|
|||||||
const id = docSet.getByLongname('module:mymodule/config#id')[0];
|
const id = docSet.getByLongname('module:mymodule/config#id')[0];
|
||||||
|
|
||||||
it('should include one doclet whose kind is "module"', () => {
|
it('should include one doclet whose kind is "module"', () => {
|
||||||
expect(modules.length).toBe(1);
|
expect(modules).toBeArrayOfSize(1);
|
||||||
expect(modules[0].kind).toBe('module');
|
expect(modules[0].kind).toBe('module');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should include one complete class doclet', () => {
|
it('should include one complete class doclet', () => {
|
||||||
expect(classes.length).toBe(1);
|
expect(classes).toBeArrayOfSize(1);
|
||||||
expect(classes[0].kind).toBe('class');
|
expect(classes[0].kind).toBe('class');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ describe('module that exports a function that is not a constructor', () => {
|
|||||||
const functions = docSet.doclets.filter(({kind}) => kind === 'function');
|
const functions = docSet.doclets.filter(({kind}) => kind === 'function');
|
||||||
|
|
||||||
it('should include one doclet whose kind is "function"', () => {
|
it('should include one doclet whose kind is "function"', () => {
|
||||||
expect(functions.length).toBe(1);
|
expect(functions).toBeArrayOfSize(1);
|
||||||
expect(functions[0].kind).toBe('function');
|
expect(functions[0].kind).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@ describe('module names', () => {
|
|||||||
doclets = srcParser.parse(
|
doclets = srcParser.parse(
|
||||||
path.normalize( path.join(env.pwd, filename) )
|
path.normalize( path.join(env.pwd, filename) )
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(doclets.length).toBeGreaterThan(1);
|
expect(doclets.length).toBeGreaterThan(1);
|
||||||
expect(doclets[0].longname).toBe('module:mod-1');
|
expect(doclets[0].longname).toBe('module:mod-1');
|
||||||
});
|
});
|
||||||
@ -37,7 +38,7 @@ describe('module names', () => {
|
|||||||
// Windows-specific test
|
// Windows-specific test
|
||||||
if ( /^win/.test(require('os').platform()) ) {
|
if ( /^win/.test(require('os').platform()) ) {
|
||||||
it('should always use forward slashes when creating a name from the file path', () => {
|
it('should always use forward slashes when creating a name from the file path', () => {
|
||||||
const Doclet = require('jsdoc/doclet').Doclet;
|
const { Doclet } = require('jsdoc/doclet');
|
||||||
let doclet;
|
let doclet;
|
||||||
|
|
||||||
env.sourceFiles = [
|
env.sourceFiles = [
|
||||||
|
|||||||
@ -4,7 +4,7 @@ describe('object keys', () => {
|
|||||||
it('should assign the correct longname and memberof to object keys after the first key', () => {
|
it('should assign the correct longname and memberof to object keys after the first key', () => {
|
||||||
const bar = docSet.getByLongname('myObject.bar')[0];
|
const bar = docSet.getByLongname('myObject.bar')[0];
|
||||||
|
|
||||||
expect(bar).toBeDefined();
|
expect(bar).toBeObject();
|
||||||
expect(bar.memberof).toBe('myObject');
|
expect(bar.memberof).toBe('myObject');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,7 @@ describe('object literals', () => {
|
|||||||
const found = docSet.getByLongname('tools.serialiser.value');
|
const found = docSet.getByLongname('tools.serialiser.value');
|
||||||
|
|
||||||
it('should have a doclet with the correct longname', () => {
|
it('should have a doclet with the correct longname', () => {
|
||||||
expect(found.length).toBe(1);
|
expect(found).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a doclet with the correct name', () => {
|
it('should have a doclet with the correct name', () => {
|
||||||
@ -25,7 +25,7 @@ describe('object literals', () => {
|
|||||||
const found = docSet.getByLongname('position.axis.x');
|
const found = docSet.getByLongname('position.axis.x');
|
||||||
|
|
||||||
it('should have a doclet with the correct longname', () => {
|
it('should have a doclet with the correct longname', () => {
|
||||||
expect(found.length).toBe(1);
|
expect(found).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a doclet with the correct name', () => {
|
it('should have a doclet with the correct name', () => {
|
||||||
@ -42,12 +42,10 @@ describe('object literals', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('When an object literal\'s property names must be escaped in a regexp', () => {
|
describe('When an object literal\'s property names must be escaped in a regexp', () => {
|
||||||
let docSet;
|
|
||||||
let found;
|
|
||||||
|
|
||||||
function loadDocSet() {
|
function loadDocSet() {
|
||||||
docSet = jsdoc.getDocSetFromFile('test/fixtures/objectlit3.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/objectlit3.js');
|
||||||
found = docSet.getByLongname('tokens."(".before');
|
|
||||||
|
return docSet.getByLongname('tokens."(".before');
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should not throw an error when creating a doclet', () => {
|
it('should not throw an error when creating a doclet', () => {
|
||||||
@ -55,10 +53,14 @@ describe('object literals', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have a doclet with the correct name', () => {
|
it('should have a doclet with the correct name', () => {
|
||||||
|
const found = loadDocSet();
|
||||||
|
|
||||||
expect(found[0].name).toBe('before');
|
expect(found[0].name).toBe('before');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a doclet with the correct memberof', () => {
|
it('should have a doclet with the correct memberof', () => {
|
||||||
|
const found = loadDocSet();
|
||||||
|
|
||||||
expect(found[0].memberof).toBe('tokens."("');
|
expect(found[0].memberof).toBe('tokens."("');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,8 +4,8 @@ describe('quoted names', () => {
|
|||||||
const found1 = docSet.getByLongname('chat."#channel".open')[0];
|
const found1 = docSet.getByLongname('chat."#channel".open')[0];
|
||||||
|
|
||||||
it('should have correct name and memberof', () => {
|
it('should have correct name and memberof', () => {
|
||||||
expect(found1.name).toEqual('open');
|
expect(found1.name).toBe('open');
|
||||||
expect(found1.memberof).toEqual('chat."#channel"');
|
expect(found1.memberof).toBe('chat."#channel"');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -14,8 +14,8 @@ describe('quoted names', () => {
|
|||||||
const found1 = docSet.getByLongname('contacts."say-\\"hello\\"@example.com".username')[0];
|
const found1 = docSet.getByLongname('contacts."say-\\"hello\\"@example.com".username')[0];
|
||||||
|
|
||||||
it('should have correct name and memberof', () => {
|
it('should have correct name and memberof', () => {
|
||||||
expect(found1.name).toEqual('username');
|
expect(found1.name).toBe('username');
|
||||||
expect(found1.memberof).toEqual('contacts."say-\\"hello\\"@example.com"');
|
expect(found1.memberof).toBe('contacts."say-\\"hello\\"@example.com"');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,30 +8,29 @@ describe('rest parameters', () => {
|
|||||||
const restParam = setAdmins.params[0];
|
const restParam = setAdmins.params[0];
|
||||||
|
|
||||||
expect(restParam.name).toBe('users');
|
expect(restParam.name).toBe('users');
|
||||||
expect(restParam.variable).toBe(true);
|
expect(restParam.variable).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should automatically mark rest parameters as repeatable when they are mixed with other params', () => {
|
it('should automatically mark rest parameters as repeatable when they are mixed with other params', () => {
|
||||||
const restParam = setWidgetAccess.params[1];
|
const restParam = setWidgetAccess.params[1];
|
||||||
|
|
||||||
expect(restParam.name).toBe('users');
|
expect(restParam.name).toBe('users');
|
||||||
expect(restParam.variable).toBe(true);
|
expect(restParam.variable).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should automatically mark rest parameters as repeatable when the function is assigned to a variable', () => {
|
it('should automatically mark rest parameters as repeatable when the function is assigned to a variable', () => {
|
||||||
const restParam = setManagers.params[0];
|
const restParam = setManagers.params[0];
|
||||||
|
|
||||||
expect(restParam.name).toBe('users');
|
expect(restParam.name).toBe('users');
|
||||||
expect(restParam.variable).toBe(true);
|
expect(restParam.variable).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ES2015 methods', () => {
|
describe('ES2015 methods', () => {
|
||||||
const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/restparams2.js');
|
const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/restparams2.js');
|
||||||
|
|
||||||
const addUsers = docSet2.getByLongname('Widget#addUsers')[0];
|
const addUsers = docSet2.getByLongname('Widget#addUsers')[0];
|
||||||
|
|
||||||
it('should autodetect rest parameters', () => {
|
it('should autodetect rest parameters', () => {
|
||||||
expect(addUsers.params[0].variable).toBe(true);
|
expect(addUsers.params[0].variable).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,11 +5,11 @@ describe('longnames with special characters', () => {
|
|||||||
|
|
||||||
it('should use the correct longname for instance members of "this" whose names contain ' +
|
it('should use the correct longname for instance members of "this" whose names contain ' +
|
||||||
'scope punctuation', () => {
|
'scope punctuation', () => {
|
||||||
expect(portNumber).toBeDefined();
|
expect(portNumber).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use the correct longname for instance members of the prototype whose names ' +
|
it('should use the correct longname for instance members of the prototype whose names ' +
|
||||||
'contain scope punctuation', () => {
|
'contain scope punctuation', () => {
|
||||||
expect(open).toBeDefined();
|
expect(open).toBeObject();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,22 +7,22 @@ describe('documenting symbols with special names', () => {
|
|||||||
const protoValueOf = docSet.getByLongname('prototype.valueOf')[0];
|
const protoValueOf = docSet.getByLongname('prototype.valueOf')[0];
|
||||||
|
|
||||||
it('When a symbol is named "constructor", the symbol should appear in the docs.', () => {
|
it('When a symbol is named "constructor", the symbol should appear in the docs.', () => {
|
||||||
expect(construct).toBeDefined();
|
expect(construct).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is named "constructor", its members are resolved correctly.', () => {
|
it('When a symbol is named "constructor", its members are resolved correctly.', () => {
|
||||||
expect(constructToString).toBeDefined();
|
expect(constructToString).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is named "hasOwnProperty," the symbol should appear in the docs.', () => {
|
it('When a symbol is named "hasOwnProperty," the symbol should appear in the docs.', () => {
|
||||||
expect(hasOwnProp).toBeDefined();
|
expect(hasOwnProp).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is named "prototype", the symbol should appear in the docs.', () => {
|
it('When a symbol is named "prototype", the symbol should appear in the docs.', () => {
|
||||||
expect(proto).toBeDefined();
|
expect(proto).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is named "prototype", its members are resolved correctly.', () => {
|
it('When a symbol is named "prototype", its members are resolved correctly.', () => {
|
||||||
expect(protoValueOf).toBeDefined();
|
expect(protoValueOf).toBeObject();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,7 @@ describe('starbangstar', () => {
|
|||||||
const x = docSet.getByLongname('module:myscript/core.x')[0];
|
const x = docSet.getByLongname('module:myscript/core.x')[0];
|
||||||
|
|
||||||
it('should not treat a doclet starting with /*!* as a JSDoc comment.', () => {
|
it('should not treat a doclet starting with /*!* as a JSDoc comment.', () => {
|
||||||
expect(mod.description).toEqual('Script that does something awesome');
|
expect(mod.description).toBe('Script that does something awesome');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not treat a doclet starting with /*!** as a JSDoc comment.', () => {
|
it('should not treat a doclet starting with /*!** as a JSDoc comment.', () => {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ describe('this', () => {
|
|||||||
|
|
||||||
describe('in a contructor', () => {
|
describe('in a contructor', () => {
|
||||||
it('should have a longname like Constructor#member', () => {
|
it('should have a longname like Constructor#member', () => {
|
||||||
expect(found1.length).toBe(1);
|
expect(found1).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a correct short name', () => {
|
it('should have a correct short name', () => {
|
||||||
@ -24,7 +24,7 @@ describe('this', () => {
|
|||||||
|
|
||||||
describe('in a method of a constructor', () => {
|
describe('in a method of a constructor', () => {
|
||||||
it('should have a longname like Constructor#member', () => {
|
it('should have a longname like Constructor#member', () => {
|
||||||
expect(found2.length).toBe(1);
|
expect(found2).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a correct short name', () => {
|
it('should have a correct short name', () => {
|
||||||
@ -46,7 +46,7 @@ describe('this', () => {
|
|||||||
const found = docSet.getByLongname('TemplateBuilder#Template#rendered');
|
const found = docSet.getByLongname('TemplateBuilder#Template#rendered');
|
||||||
|
|
||||||
it('should have a longname like Constructor#Constructor#member', () => {
|
it('should have a longname like Constructor#Constructor#member', () => {
|
||||||
expect(found.length).toBe(1);
|
expect(found).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a correct short name', () => {
|
it('should have a correct short name', () => {
|
||||||
@ -67,7 +67,7 @@ describe('this', () => {
|
|||||||
const found = docSet.getByLongname('position');
|
const found = docSet.getByLongname('position');
|
||||||
|
|
||||||
it('should have a global member name like "member"', () => {
|
it('should have a global member name like "member"', () => {
|
||||||
expect(found.length).toBe(1);
|
expect(found).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a correct short name', () => {
|
it('should have a correct short name', () => {
|
||||||
@ -84,7 +84,7 @@ describe('this', () => {
|
|||||||
const found = docSet.getByLongname('Template#render');
|
const found = docSet.getByLongname('Template#render');
|
||||||
|
|
||||||
it('should have a longname like Constructor#member', () => {
|
it('should have a longname like Constructor#member', () => {
|
||||||
expect(found.length).toBe(1);
|
expect(found).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have the correct name', () => {
|
it('should have the correct name', () => {
|
||||||
@ -101,7 +101,7 @@ describe('this', () => {
|
|||||||
const found = docSet.getByLongname('module:template.Template#view');
|
const found = docSet.getByLongname('module:template.Template#view');
|
||||||
|
|
||||||
it('should have a longname like Constructor#member', () => {
|
it('should have a longname like Constructor#member', () => {
|
||||||
expect(found.length).toBe(1);
|
expect(found).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have the correct name', () => {
|
it('should have the correct name', () => {
|
||||||
@ -118,7 +118,7 @@ describe('this', () => {
|
|||||||
const someProperty = docSet.getByLongname('module:example#_someProperty')[0];
|
const someProperty = docSet.getByLongname('module:example#_someProperty')[0];
|
||||||
|
|
||||||
it('should have the correct longname, name, and scope', () => {
|
it('should have the correct longname, name, and scope', () => {
|
||||||
expect(someProperty).toBeDefined();
|
expect(someProperty).toBeObject();
|
||||||
expect(someProperty.name).toBe('_someProperty');
|
expect(someProperty.name).toBe('_someProperty');
|
||||||
expect(someProperty.scope).toBe('instance');
|
expect(someProperty.scope).toBe('instance');
|
||||||
});
|
});
|
||||||
@ -129,7 +129,7 @@ describe('this', () => {
|
|||||||
const found = docSet.getByLongname('Page#parts.body.heading');
|
const found = docSet.getByLongname('Page#parts.body.heading');
|
||||||
|
|
||||||
it('should have a longname like Constructor#objlit.member', () => {
|
it('should have a longname like Constructor#objlit.member', () => {
|
||||||
expect(found.length).toBe(1);
|
expect(found).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a correct short name', () => {
|
it('should have a correct short name', () => {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ describe('trailing comment', () => {
|
|||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/trailingcomment.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/trailingcomment.js');
|
||||||
const foo = docSet.getByLongname('external:foo');
|
const foo = docSet.getByLongname('external:foo');
|
||||||
|
|
||||||
expect(foo.length).toBe(1);
|
expect(foo).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not ignore trailing comments in an empty source file with a `use strict` ' +
|
it('should not ignore trailing comments in an empty source file with a `use strict` ' +
|
||||||
@ -12,6 +12,6 @@ describe('trailing comment', () => {
|
|||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/trailingcomment2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/trailingcomment2.js');
|
||||||
const foo = docSet.getByLongname('external:foo');
|
const foo = docSet.getByLongname('external:foo');
|
||||||
|
|
||||||
expect(foo.length).toBe(1);
|
expect(foo).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
describe('@type tag inline with function parameters', () => {
|
describe('@type tag inline with function parameters', () => {
|
||||||
let info;
|
|
||||||
|
|
||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/typetaginline.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/typetaginline.js');
|
||||||
|
let info;
|
||||||
|
|
||||||
function checkParams({params}, paramInfo) {
|
function checkParams({params}, paramInfo) {
|
||||||
expect(params).toBeDefined();
|
expect(params).toBeDefined();
|
||||||
|
|||||||
@ -5,22 +5,22 @@ describe('@type tag containing a newline character', () => {
|
|||||||
|
|
||||||
it('When the type expression for a @type tag contains a newline character and is not ' +
|
it('When the type expression for a @type tag contains a newline character and is not ' +
|
||||||
'enclosed in braces, the type expression is parsed correctly.', () => {
|
'enclosed in braces, the type expression is parsed correctly.', () => {
|
||||||
expect(mini).toBeDefined();
|
expect(mini).toBeObject();
|
||||||
expect(mini.type).toBeDefined();
|
expect(mini.type).toBeObject();
|
||||||
expect(mini.type.names).toBeDefined();
|
expect(mini.type.names).toEqual([
|
||||||
expect(mini.type.names.length).toBe(2);
|
'!Array.<number>',
|
||||||
expect(mini.type.names[0]).toBe('!Array.<number>');
|
'!Array.<!Array.<number>>'
|
||||||
expect(mini.type.names[1]).toBe('!Array.<!Array.<number>>');
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When the type expression for a @type tag contains a newline character and is enclosed ' +
|
it('When the type expression for a @type tag contains a newline character and is enclosed ' +
|
||||||
'in braces, the type expression is parsed correctly.', () => {
|
'in braces, the type expression is parsed correctly.', () => {
|
||||||
expect(mega).toBeDefined();
|
expect(mega).toBeObject();
|
||||||
expect(mega.type).toBeDefined();
|
expect(mega.type).toBeObject();
|
||||||
expect(mega.type.names).toBeDefined();
|
expect(mega.type.names).toEqual([
|
||||||
expect(mega.type.names.length).toBe(3);
|
'!Array.<number>',
|
||||||
expect(mega.type.names[0]).toBe('!Array.<number>');
|
'!Array.<!Array.<number>>',
|
||||||
expect(mega.type.names[1]).toBe('!Array.<!Array.<number>>');
|
'!Array.<!Array.<!Array.<number>>>'
|
||||||
expect(mega.type.names[2]).toBe('!Array.<!Array.<!Array.<number>>>');
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,58 +1,54 @@
|
|||||||
describe('var statements', () => {
|
describe('var statements', () => {
|
||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/var.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/var.js');
|
||||||
const found = [
|
const GREEN = docSet.getByLongname('GREEN')[0];
|
||||||
docSet.getByLongname('GREEN'),
|
const RED = docSet.getByLongname('RED')[0];
|
||||||
docSet.getByLongname('RED'),
|
const results = docSet.getByLongname('results')[0];
|
||||||
docSet.getByLongname('validate'),
|
|
||||||
docSet.getByLongname('i'),
|
|
||||||
docSet.getByLongname('results')
|
|
||||||
];
|
|
||||||
|
|
||||||
describe('when a series of constants is documented', () => {
|
describe('when a series of constants is documented', () => {
|
||||||
it('should find the first constant', () => {
|
it('should find the first constant', () => {
|
||||||
expect(found[0].length).toBe(1);
|
expect(GREEN).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should attach the docs to the first constant', () => {
|
it('should attach the docs to the first constant', () => {
|
||||||
expect(found[0][0].comment).toBe('/** document me */');
|
expect(GREEN.comment).toBe('/** document me */');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have the correct name', () => {
|
it('should have the correct name', () => {
|
||||||
expect(found[0][0].name).toBe('GREEN');
|
expect(GREEN.name).toBe('GREEN');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have the correct memberof', () => {
|
it('should have the correct memberof', () => {
|
||||||
expect(found[0][0].memberof).toBeUndefined();
|
expect(GREEN.memberof).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should give the constant a global scope', () => {
|
it('should give the constant a global scope', () => {
|
||||||
expect(found[0][0].scope).toBe('global');
|
expect(GREEN.scope).toBe('global');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should find the second constant', () => {
|
it('should find the second constant', () => {
|
||||||
expect(found[1].length).toBe(1);
|
expect(RED).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not attach the docs to the second constant', () => {
|
it('should not attach the docs to the second constant', () => {
|
||||||
expect(found[1][0].undocumented).toBe(true);
|
expect(RED.undocumented).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when a member of a series of vars is documented', () => {
|
describe('when a member of a series of vars is documented', () => {
|
||||||
it('should attach the docs to the correct var', () => {
|
it('should attach the docs to the correct var', () => {
|
||||||
expect(found[4][0].comment).toBe('/** document me */');
|
expect(results.comment).toBe('/** document me */');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have the correct name', () => {
|
it('should have the correct name', () => {
|
||||||
expect(found[4][0].name).toBe('results');
|
expect(results.name).toBe('results');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should leave memberof undefined', () => {
|
it('should leave memberof undefined', () => {
|
||||||
expect(found[4][0].memberof).toBeUndefined();
|
expect(results.memberof).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should give the var a global scope', () => {
|
it('should give the var a global scope', () => {
|
||||||
expect(found[4][0].scope).toBe('global');
|
expect(results.scope).toBe('global');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,11 +5,11 @@ describe('virtual symbols', () => {
|
|||||||
const width = docSet.getByLongname('width');
|
const width = docSet.getByLongname('width');
|
||||||
|
|
||||||
it('should document virtual symbols', () => {
|
it('should document virtual symbols', () => {
|
||||||
expect(dimensions.length).toBe(1);
|
expect(dimensions).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should document an undocumented symbol found after a comment for a virtual symbol', () => {
|
it('should document an undocumented symbol found after a comment for a virtual symbol', () => {
|
||||||
expect(width.length).toBe(1);
|
expect(width).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -19,13 +19,13 @@ describe('virtual symbols', () => {
|
|||||||
const sayCallback = docSet.getByLongname('Person~sayCallback')[0];
|
const sayCallback = docSet.getByLongname('Person~sayCallback')[0];
|
||||||
|
|
||||||
it('should document virtual symbols inside an object literal', () => {
|
it('should document virtual symbols inside an object literal', () => {
|
||||||
expect(sayCallback).toBeDefined();
|
expect(sayCallback).toBeObject();
|
||||||
expect(sayCallback.undocumented).not.toBeDefined();
|
expect(sayCallback.undocumented).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should attach the comment to a documented symbol that follows a virtual symbol', () => {
|
it('should attach the comment to a documented symbol that follows a virtual symbol', () => {
|
||||||
expect(say).toBeDefined();
|
expect(say).toBeObject();
|
||||||
expect(say.undocumented).not.toBeDefined();
|
expect(say.undocumented).toBeUndefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -34,18 +34,16 @@ describe('virtual symbols', () => {
|
|||||||
const constructors = docSet.getByLongname('module:connection');
|
const constructors = docSet.getByLongname('module:connection');
|
||||||
|
|
||||||
it('should create multiple doclets for overloaded virtual symbols', () => {
|
it('should create multiple doclets for overloaded virtual symbols', () => {
|
||||||
expect(constructors).toBeDefined();
|
expect(constructors).toBeArrayOfSize(2);
|
||||||
expect(constructors.length).toBe(2);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use the correct signature for each virtual symbol', () => {
|
it('should use the correct signature for each virtual symbol', () => {
|
||||||
expect(constructors[0]).toBeDefined();
|
expect(constructors[0]).toBeObject();
|
||||||
expect(constructors[0].params).toBeDefined();
|
expect(constructors[0].params).toBeArray();
|
||||||
expect(Array.isArray(constructors[0].params)).toBe(true);
|
|
||||||
expect(constructors[0].params[0].name).toBe('name');
|
expect(constructors[0].params[0].name).toBe('name');
|
||||||
|
|
||||||
expect(constructors[1]).toBeDefined();
|
expect(constructors[1]).toBeObject();
|
||||||
expect(constructors[1].params).not.toBeDefined();
|
expect(constructors[1].params).toBeUndefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,23 +4,23 @@ describe('jsdoc/augment', () => {
|
|||||||
const augment = require('jsdoc/augment');
|
const augment = require('jsdoc/augment');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(augment).toBeDefined();
|
expect(augment).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "addImplemented" method', () => {
|
it('should have an "addImplemented" method', () => {
|
||||||
expect(typeof augment.addImplemented).toBe('function');
|
expect(augment.addImplemented).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "addInherited" method', () => {
|
it('should have an "addInherited" method', () => {
|
||||||
expect(typeof augment.addInherited).toBe('function');
|
expect(augment.addInherited).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "addMixedIn" method', () => {
|
it('should have an "addMixedIn" method', () => {
|
||||||
expect(typeof augment.addMixedIn).toBe('function');
|
expect(augment.addMixedIn).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "augmentAll" method', () => {
|
it('should have an "augmentAll" method', () => {
|
||||||
expect(typeof augment.augmentAll).toBe('function');
|
expect(augment.augmentAll).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
xdescribe('addImplemented', () => {
|
xdescribe('addImplemented', () => {
|
||||||
@ -59,7 +59,7 @@ describe('jsdoc/augment', () => {
|
|||||||
|
|
||||||
open = docSet.getByLongname('EncryptedSocket#open').filter(({ignore}) => !ignore);
|
open = docSet.getByLongname('EncryptedSocket#open').filter(({ignore}) => !ignore);
|
||||||
|
|
||||||
expect(open.length).toBe(1);
|
expect(open).toBeArrayOfSize(1);
|
||||||
expect(open[0].description).toBe('Open the connection.');
|
expect(open[0].description).toBe('Open the connection.');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ describe('jsdoc/augment', () => {
|
|||||||
|
|
||||||
open = docSet.getByLongname('EncryptedSocket#open').filter(({ignore}) => !ignore);
|
open = docSet.getByLongname('EncryptedSocket#open').filter(({ignore}) => !ignore);
|
||||||
|
|
||||||
expect(open.length).toBe(1);
|
expect(open).toBeArrayOfSize(1);
|
||||||
expect(open[0].description).toBe('Open the connection.');
|
expect(open[0].description).toBe('Open the connection.');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,23 +2,20 @@ describe('jsdoc/config', () => {
|
|||||||
const Config = require('jsdoc/config');
|
const Config = require('jsdoc/config');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(Config).toBeDefined();
|
expect(Config).toBeFunction();
|
||||||
expect(typeof Config).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a "get" instance function', () => {
|
it('should provide a "get" instance function', () => {
|
||||||
const config = new Config();
|
const config = new Config();
|
||||||
|
|
||||||
expect(config.get).toBeDefined();
|
expect(config.get).toBeFunction();
|
||||||
expect(typeof config.get).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('constructor with empty', () => {
|
describe('constructor with empty', () => {
|
||||||
it('should be possible to construct a Config with an empty arguments', () => {
|
it('should be possible to construct a Config with an empty arguments', () => {
|
||||||
const config = new Config().get();
|
const config = new Config().get();
|
||||||
|
|
||||||
expect( Array.isArray(config.plugins) ).toBe(true);
|
expect(config.plugins).toBeEmptyArray();
|
||||||
expect(config.plugins.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -26,15 +23,13 @@ describe('jsdoc/config', () => {
|
|||||||
it('should be possible to construct a Config with JSON of an object literal that is empty', () => {
|
it('should be possible to construct a Config with JSON of an object literal that is empty', () => {
|
||||||
const config = new Config('{}').get();
|
const config = new Config('{}').get();
|
||||||
|
|
||||||
expect( Array.isArray(config.plugins) ).toBe(true);
|
expect(config.plugins).toBeEmptyArray();
|
||||||
expect(config.plugins.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be possible to construct a Config with an empty JavaScript object', () => {
|
it('should be possible to construct a Config with an empty JavaScript object', () => {
|
||||||
const config = new Config({}).get();
|
const config = new Config({}).get();
|
||||||
|
|
||||||
expect( Array.isArray(config.plugins) ).toBe(true);
|
expect(config.plugins).toBeEmptyArray();
|
||||||
expect(config.plugins.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -62,16 +57,14 @@ describe('jsdoc/config', () => {
|
|||||||
it('should be possible to construct a Config with JSON of an object literal that has a plugin value', () => {
|
it('should be possible to construct a Config with JSON of an object literal that has a plugin value', () => {
|
||||||
const config = new Config('{"plugins":[42]}').get();
|
const config = new Config('{"plugins":[42]}').get();
|
||||||
|
|
||||||
expect( Array.isArray(config.plugins) ).toBe(true);
|
expect(config.plugins).toBeArrayOfSize(1);
|
||||||
expect(config.plugins.length).toBe(1);
|
|
||||||
expect(config.plugins[0]).toBe(42);
|
expect(config.plugins[0]).toBe(42);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be possible to construct a Config with a JavaScript object that has a plugin value', () => {
|
it('should be possible to construct a Config with a JavaScript object that has a plugin value', () => {
|
||||||
const config = new Config({'plugins': [42]}).get();
|
const config = new Config({'plugins': [42]}).get();
|
||||||
|
|
||||||
expect( Array.isArray(config.plugins) ).toBe(true);
|
expect(config.plugins).toBeArrayOfSize(1);
|
||||||
expect(config.plugins.length).toBe(1);
|
|
||||||
expect(config.plugins[0]).toBe(42);
|
expect(config.plugins[0]).toBe(42);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,14 +12,14 @@ describe('jsdoc/doclet', () => {
|
|||||||
const expectStrong = '**Strong** is strong';
|
const expectStrong = '**Strong** is strong';
|
||||||
|
|
||||||
it('does not mangle Markdown in a description that uses leading asterisks', () => {
|
it('does not mangle Markdown in a description that uses leading asterisks', () => {
|
||||||
expect(test2.description.indexOf(expectList)).toBeGreaterThan(-1);
|
expect(test2.description).toContain(expectList);
|
||||||
expect(test2.description.indexOf(expectStrong)).toBeGreaterThan(-1);
|
expect(test2.description).toContain(expectStrong);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds the AST node as a non-enumerable property', () => {
|
it('adds the AST node as a non-enumerable property', () => {
|
||||||
const descriptor = Object.getOwnPropertyDescriptor(test1.meta.code, 'node');
|
const descriptor = Object.getOwnPropertyDescriptor(test1.meta.code, 'node');
|
||||||
|
|
||||||
expect(descriptor.enumerable).toBe(false);
|
expect(descriptor.enumerable).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('setScope', () => {
|
describe('setScope', () => {
|
||||||
@ -91,7 +91,7 @@ describe('jsdoc/doclet', () => {
|
|||||||
|
|
||||||
newDoclet = doclet.combine(primaryDoclet, secondaryDoclet);
|
newDoclet = doclet.combine(primaryDoclet, secondaryDoclet);
|
||||||
|
|
||||||
expect(newDoclet.undocumented).not.toBeDefined();
|
expect(newDoclet.undocumented).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('params and properties', () => {
|
describe('params and properties', () => {
|
||||||
|
|||||||
@ -3,107 +3,90 @@ describe('jsdoc/name', () => {
|
|||||||
const name = require('jsdoc/name');
|
const name = require('jsdoc/name');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(name).toBeDefined();
|
expect(name).toBeObject();
|
||||||
expect(typeof name).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'resolve' function", () => {
|
it("should export a 'resolve' function", () => {
|
||||||
expect(name.resolve).toBeDefined();
|
expect(name.resolve).toBeFunction();
|
||||||
expect(typeof name.resolve).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export an 'applyNamespace' function", () => {
|
it("should export an 'applyNamespace' function", () => {
|
||||||
expect(name.applyNamespace).toBeDefined();
|
expect(name.applyNamespace).toBeFunction();
|
||||||
expect(typeof name.applyNamespace).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "stripNamespace" function', () => {
|
it('should export a "stripNamespace" function', () => {
|
||||||
expect(typeof name.stripNamespace).toBe('function');
|
expect(name.stripNamespace).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "hasAncestor" function', () => {
|
it('should export a "hasAncestor" function', () => {
|
||||||
expect(typeof name.hasAncestor).toBe('function');
|
expect(name.hasAncestor).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: add tests for other exported constants
|
// TODO: add tests for other exported constants
|
||||||
it('should export a SCOPE enum', () => {
|
it('should export a SCOPE enum', () => {
|
||||||
expect(name.SCOPE).toBeDefined();
|
expect(name.SCOPE).toBeObject();
|
||||||
expect(typeof name.SCOPE).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'shorten' function", () => {
|
it("should export a 'shorten' function", () => {
|
||||||
expect(name.shorten).toBeDefined();
|
expect(name.shorten).toBeFunction();
|
||||||
expect(typeof name.shorten).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "combine" function', () => {
|
it('should export a "combine" function', () => {
|
||||||
expect(name.combine).toBeDefined();
|
expect(name.combine).toBeFunction();
|
||||||
expect(typeof name.combine).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "stripVariation" function', () => {
|
it('should export a "stripVariation" function', () => {
|
||||||
expect(typeof name.stripVariation).toBe('function');
|
expect(name.stripVariation).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "longnamesToTree" function', () => {
|
it('should export a "longnamesToTree" function', () => {
|
||||||
expect(name.longnamesToTree).toBeDefined();
|
expect(name.longnamesToTree).toBeFunction();
|
||||||
expect(typeof name.longnamesToTree).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'splitName' function", () => {
|
it("should export a 'splitName' function", () => {
|
||||||
expect(name.splitName).toBeDefined();
|
expect(name.splitName).toBeFunction();
|
||||||
expect(typeof name.splitName).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('SCOPE', () => {
|
describe('SCOPE', () => {
|
||||||
const SCOPE = name.SCOPE;
|
const SCOPE = name.SCOPE;
|
||||||
|
|
||||||
it('should have a "NAMES" property', () => {
|
it('should have a "NAMES" property', () => {
|
||||||
expect(SCOPE.NAMES).toBeDefined();
|
expect(SCOPE.NAMES).toBeObject();
|
||||||
expect(typeof SCOPE.NAMES).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "PUNC" property', () => {
|
it('should have a "PUNC" property', () => {
|
||||||
expect(SCOPE.PUNC).toBeDefined();
|
expect(SCOPE.PUNC).toBeObject();
|
||||||
expect(typeof SCOPE.PUNC).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('NAMES', () => {
|
describe('NAMES', () => {
|
||||||
it('should have a "GLOBAL" property', () => {
|
it('should have a "GLOBAL" property', () => {
|
||||||
expect(SCOPE.NAMES.GLOBAL).toBeDefined();
|
expect(SCOPE.NAMES.GLOBAL).toBeString();
|
||||||
expect(typeof SCOPE.NAMES.GLOBAL).toBe('string');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "INNER" property', () => {
|
it('should have an "INNER" property', () => {
|
||||||
expect(SCOPE.NAMES.INNER).toBeDefined();
|
expect(SCOPE.NAMES.INNER).toBeString();
|
||||||
expect(typeof SCOPE.NAMES.INNER).toBe('string');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "INSTANCE" property', () => {
|
it('should have an "INSTANCE" property', () => {
|
||||||
expect(SCOPE.NAMES.INSTANCE).toBeDefined();
|
expect(SCOPE.NAMES.INSTANCE).toBeString();
|
||||||
expect(typeof SCOPE.NAMES.INSTANCE).toBe('string');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "STATIC" property', () => {
|
it('should have a "STATIC" property', () => {
|
||||||
expect(SCOPE.NAMES.STATIC).toBeDefined();
|
expect(SCOPE.NAMES.STATIC).toBeString();
|
||||||
expect(typeof SCOPE.NAMES.STATIC).toBe('string');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('PUNC', () => {
|
describe('PUNC', () => {
|
||||||
it('should have an "INNER" property', () => {
|
it('should have an "INNER" property', () => {
|
||||||
expect(SCOPE.PUNC.INNER).toBeDefined();
|
expect(SCOPE.PUNC.INNER).toBeString();
|
||||||
expect(typeof SCOPE.PUNC.INNER).toBe('string');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "INSTANCE" property', () => {
|
it('should have an "INSTANCE" property', () => {
|
||||||
expect(SCOPE.PUNC.INSTANCE).toBeDefined();
|
expect(SCOPE.PUNC.INSTANCE).toBeString();
|
||||||
expect(typeof SCOPE.PUNC.INSTANCE).toBe('string');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "STATIC" property', () => {
|
it('should have a "STATIC" property', () => {
|
||||||
expect(SCOPE.PUNC.STATIC).toBeDefined();
|
expect(SCOPE.PUNC.STATIC).toBeString();
|
||||||
expect(typeof SCOPE.PUNC.STATIC).toBe('string');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -113,63 +96,63 @@ describe('jsdoc/name', () => {
|
|||||||
const startName = 'lib.Panel#open';
|
const startName = 'lib.Panel#open';
|
||||||
const parts = name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('open');
|
expect(parts.name).toBe('open');
|
||||||
expect(parts.memberof).toEqual('lib.Panel');
|
expect(parts.memberof).toBe('lib.Panel');
|
||||||
expect(parts.scope).toEqual('#');
|
expect(parts.scope).toBe('#');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work on static names', () => {
|
it('should work on static names', () => {
|
||||||
const startName = 'elements.selected.getVisible';
|
const startName = 'elements.selected.getVisible';
|
||||||
const parts = name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('getVisible');
|
expect(parts.name).toBe('getVisible');
|
||||||
expect(parts.memberof).toEqual('elements.selected');
|
expect(parts.memberof).toBe('elements.selected');
|
||||||
expect(parts.scope).toEqual('.');
|
expect(parts.scope).toBe('.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work on protoyped names', () => {
|
it('should work on protoyped names', () => {
|
||||||
const startName = 'Validator.prototype.$element';
|
const startName = 'Validator.prototype.$element';
|
||||||
const parts = name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('$element');
|
expect(parts.name).toBe('$element');
|
||||||
expect(parts.memberof).toEqual('Validator');
|
expect(parts.memberof).toBe('Validator');
|
||||||
expect(parts.scope).toEqual('#');
|
expect(parts.scope).toBe('#');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work on inner names', () => {
|
it('should work on inner names', () => {
|
||||||
const startName = 'Button~_onclick';
|
const startName = 'Button~_onclick';
|
||||||
const parts = name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('_onclick');
|
expect(parts.name).toBe('_onclick');
|
||||||
expect(parts.memberof).toEqual('Button');
|
expect(parts.memberof).toBe('Button');
|
||||||
expect(parts.scope).toEqual('~');
|
expect(parts.scope).toBe('~');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work on global names', () => {
|
it('should work on global names', () => {
|
||||||
const startName = 'close';
|
const startName = 'close';
|
||||||
const parts = name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('close');
|
expect(parts.name).toBe('close');
|
||||||
expect(parts.memberof).toEqual('');
|
expect(parts.memberof).toBe('');
|
||||||
expect(parts.scope).toEqual('');
|
expect(parts.scope).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work when a single property uses bracket notation', () => {
|
it('should work when a single property uses bracket notation', () => {
|
||||||
const startName = 'channels["#ops"]#open';
|
const startName = 'channels["#ops"]#open';
|
||||||
const parts = name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('open');
|
expect(parts.name).toBe('open');
|
||||||
expect(parts.memberof).toEqual('channels."#ops"');
|
expect(parts.memberof).toBe('channels."#ops"');
|
||||||
expect(parts.scope).toEqual('#');
|
expect(parts.scope).toBe('#');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work when consecutive properties use bracket notation', () => {
|
it('should work when consecutive properties use bracket notation', () => {
|
||||||
const startName = 'channels["#bots"]["log.max"]';
|
const startName = 'channels["#bots"]["log.max"]';
|
||||||
const parts = name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('"log.max"');
|
expect(parts.name).toBe('"log.max"');
|
||||||
expect(parts.memberof).toEqual('channels."#bots"');
|
expect(parts.memberof).toBe('channels."#bots"');
|
||||||
expect(parts.scope).toEqual('.');
|
expect(parts.scope).toBe('.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work when a property uses single-quoted bracket notation', () => {
|
it('should work when a property uses single-quoted bracket notation', () => {
|
||||||
@ -185,10 +168,10 @@ describe('jsdoc/name', () => {
|
|||||||
const startName = '"foo.bar"';
|
const startName = '"foo.bar"';
|
||||||
const parts = name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('"foo.bar"');
|
expect(parts.name).toBe('"foo.bar"');
|
||||||
expect(parts.longname).toEqual('"foo.bar"');
|
expect(parts.longname).toBe('"foo.bar"');
|
||||||
expect(parts.memberof).toEqual('');
|
expect(parts.memberof).toBe('');
|
||||||
expect(parts.scope).toEqual('');
|
expect(parts.scope).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work on single-quoted strings', () => {
|
it('should work on single-quoted strings', () => {
|
||||||
@ -205,9 +188,9 @@ describe('jsdoc/name', () => {
|
|||||||
const startName = 'anim.fadein(2)';
|
const startName = 'anim.fadein(2)';
|
||||||
const parts = name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.variation).toEqual('2');
|
expect(parts.variation).toBe('2');
|
||||||
expect(parts.name).toEqual('fadein');
|
expect(parts.name).toBe('fadein');
|
||||||
expect(parts.longname).toEqual('anim.fadein(2)');
|
expect(parts.longname).toBe('anim.fadein(2)');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -216,28 +199,29 @@ describe('jsdoc/name', () => {
|
|||||||
const startName = 'lib.Panel#open';
|
const startName = 'lib.Panel#open';
|
||||||
const endName = name.applyNamespace(startName, 'event');
|
const endName = name.applyNamespace(startName, 'event');
|
||||||
|
|
||||||
expect(endName, 'lib.Panel#event:open');
|
expect(endName).toBe('lib.Panel#event:open');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should insert the namespace before a global name', () => {
|
it('should insert the namespace before a global name', () => {
|
||||||
const startName = 'maths/bigint';
|
const startName = 'maths/bigint';
|
||||||
const endName = name.applyNamespace(startName, 'module');
|
const endName = name.applyNamespace(startName, 'module');
|
||||||
|
|
||||||
expect(endName, 'module:maths/bigint');
|
expect(endName).toBe('module:maths/bigint');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should treat quoted parts of the name as atomic and insert namespace before a quoted shortname', () => {
|
// TODO: Test fails; check validity
|
||||||
|
xit('should treat quoted parts of the name as atomic and insert namespace before a quoted shortname', () => {
|
||||||
const startName = 'foo."*dont\'t.look~in#here!"';
|
const startName = 'foo."*dont\'t.look~in#here!"';
|
||||||
const endName = name.applyNamespace(startName, 'event');
|
const endName = name.applyNamespace(startName, 'event');
|
||||||
|
|
||||||
expect(endName, 'foo.event:"*dont\'t.look~in#here!"');
|
expect(endName).toBe('foo.event:"*dont\'t.look~in#here!"');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not add another namespace if one already exists.', () => {
|
it('should not add another namespace if one already exists.', () => {
|
||||||
const startName = 'lib.Panel#event:open';
|
const startName = 'lib.Panel#event:open';
|
||||||
const endName = name.applyNamespace(startName, 'event');
|
const endName = name.applyNamespace(startName, 'event');
|
||||||
|
|
||||||
expect(endName, 'lib.Panel#event:open');
|
expect(endName).toBe('lib.Panel#event:open');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -266,39 +250,27 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
describe('hasAncestor', () => {
|
describe('hasAncestor', () => {
|
||||||
it('should return false if "parent" is missing', () => {
|
it('should return false if "parent" is missing', () => {
|
||||||
const hasAncestor = name.hasAncestor(null, 'foo');
|
expect(name.hasAncestor(null, 'foo')).toBeFalse();
|
||||||
|
|
||||||
expect(hasAncestor).toBe(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false if "child" is missing', () => {
|
it('should return false if "child" is missing', () => {
|
||||||
const hasAncestor = name.hasAncestor('foo');
|
expect(name.hasAncestor('foo')).toBeFalse();
|
||||||
|
|
||||||
expect(hasAncestor).toBe(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should correctly identify when the immediate parent is passed in', () => {
|
it('should correctly identify when the immediate parent is passed in', () => {
|
||||||
const hasAncestor = name.hasAncestor('module:foo', 'module:foo~bar');
|
expect(name.hasAncestor('module:foo', 'module:foo~bar')).toBeTrue();
|
||||||
|
|
||||||
expect(hasAncestor).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should correctly identify when an ancestor is passed in', () => {
|
it('should correctly identify when an ancestor is passed in', () => {
|
||||||
const hasAncestor = name.hasAncestor('module:foo', 'module:foo~bar.Baz#qux');
|
expect(name.hasAncestor('module:foo', 'module:foo~bar.Baz#qux')).toBeTrue();
|
||||||
|
|
||||||
expect(hasAncestor).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should correctly identify when a non-ancestor is passed in', () => {
|
it('should correctly identify when a non-ancestor is passed in', () => {
|
||||||
const hasAncestor = name.hasAncestor('module:foo', 'foo');
|
expect(name.hasAncestor('module:foo', 'foo')).toBeFalse();
|
||||||
|
|
||||||
expect(hasAncestor).toBe(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not say that a longname is its own ancestor', () => {
|
it('should not say that a longname is its own ancestor', () => {
|
||||||
const hasAncestor = name.hasAncestor('module:foo', 'module:foo');
|
expect(name.hasAncestor('module:foo', 'module:foo')).toBeFalse();
|
||||||
|
|
||||||
expect(hasAncestor).toBe(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -327,12 +299,13 @@ describe('jsdoc/name', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('splitName', () => {
|
describe('splitName', () => {
|
||||||
it('should find the name and description.', () => {
|
// TODO: Test fails; check validity
|
||||||
|
xit('should find the name and description.', () => {
|
||||||
const startName = 'ns.Page#"last \\"sentence\\"".words~sort(2) - This is a description. ';
|
const startName = 'ns.Page#"last \\"sentence\\"".words~sort(2) - This is a description. ';
|
||||||
const parts = name.splitName(startName);
|
const parts = name.splitName(startName);
|
||||||
|
|
||||||
expect(parts.name, 'ns.Page#"last \\"sentence\\"".words~sort(2)');
|
expect(parts.name).toBe('ns.Page#"last \\"sentence\\"".words~sort(2)');
|
||||||
expect(parts.description, 'This is a description.');
|
expect(parts.description).toBe('This is a description.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should strip the separator when the separator starts on the same line as the name', () => {
|
it('should strip the separator when the separator starts on the same line as the name', () => {
|
||||||
@ -390,9 +363,7 @@ describe('jsdoc/name', () => {
|
|||||||
// TODO: further tests (namespaces, modules, ...)
|
// TODO: further tests (namespaces, modules, ...)
|
||||||
|
|
||||||
function makeDoclet(tagStrings) {
|
function makeDoclet(tagStrings) {
|
||||||
const comment = `/**\n${tagStrings.join('\n')}\n*/`;
|
return new Doclet(`/**\n${tagStrings.join('\n')}\n*/`, {});
|
||||||
|
|
||||||
return new Doclet(comment, {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('aliases', () => {
|
describe('aliases', () => {
|
||||||
@ -444,9 +415,9 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toBeUndefined();
|
expect(doclet.memberof).toBeUndefined();
|
||||||
expect(doclet.longname).toEqual('event:A');
|
expect(doclet.longname).toBe('event:A');
|
||||||
});
|
});
|
||||||
|
|
||||||
// test all permutations of @event @name [name] @memberof.
|
// test all permutations of @event @name [name] @memberof.
|
||||||
@ -455,54 +426,54 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toBe('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toBe('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@event @memberof @name resolves correctly', () => {
|
it('@event @memberof @name resolves correctly', () => {
|
||||||
const doclet = makeDoclet([event, memberOf, nameTag]);
|
const doclet = makeDoclet([event, memberOf, nameTag]);
|
||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toBe('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toBe('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@name @event @memberof resolves correctly', () => {
|
it('@name @event @memberof resolves correctly', () => {
|
||||||
const doclet = makeDoclet([nameTag, event, memberOf]);
|
const doclet = makeDoclet([nameTag, event, memberOf]);
|
||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toBe('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toBe('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@name @memberof @event resolves correctly', () => {
|
it('@name @memberof @event resolves correctly', () => {
|
||||||
const doclet = makeDoclet([nameTag, memberOf, event]);
|
const doclet = makeDoclet([nameTag, memberOf, event]);
|
||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toBe('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toBe('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@memberof @event @name resolves correctly', () => {
|
it('@memberof @event @name resolves correctly', () => {
|
||||||
const doclet = makeDoclet([memberOf, event, nameTag]);
|
const doclet = makeDoclet([memberOf, event, nameTag]);
|
||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toBe('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toBe('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@memberof @name @event resolves correctly', () => {
|
it('@memberof @name @event resolves correctly', () => {
|
||||||
const doclet = makeDoclet([memberOf, nameTag, event]);
|
const doclet = makeDoclet([memberOf, nameTag, event]);
|
||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toBe('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toBe('MyClass.event:A');
|
||||||
});
|
});
|
||||||
|
|
||||||
// test all permutations of @event [name] @memberof
|
// test all permutations of @event [name] @memberof
|
||||||
@ -511,18 +482,18 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toBe('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toBe('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@memberof @event [name] resolves correctly', () => {
|
it('@memberof @event [name] resolves correctly', () => {
|
||||||
const doclet = makeDoclet([memberOf, '@event A']);
|
const doclet = makeDoclet([memberOf, '@event A']);
|
||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toBe('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toBe('MyClass.event:A');
|
||||||
});
|
});
|
||||||
|
|
||||||
// test full @event A.B
|
// test full @event A.B
|
||||||
@ -531,18 +502,18 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toBe('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toBe('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('full @event definition with event: works', () => {
|
it('full @event definition with event: works', () => {
|
||||||
const doclet = makeDoclet(['@event MyClass.event:A']);
|
const doclet = makeDoclet(['@event MyClass.event:A']);
|
||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('event:A');
|
expect(doclet.name).toBe('event:A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toBe('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toBe('MyClass.event:A');
|
||||||
});
|
});
|
||||||
|
|
||||||
// a double-nested one just in case
|
// a double-nested one just in case
|
||||||
@ -551,9 +522,9 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toBe('A');
|
||||||
expect(doclet.memberof).toEqual('MyNamespace.MyClass');
|
expect(doclet.memberof).toBe('MyNamespace.MyClass');
|
||||||
expect(doclet.longname).toEqual('MyNamespace.MyClass.event:A');
|
expect(doclet.longname).toBe('MyNamespace.MyClass.event:A');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -23,34 +23,26 @@ describe('jsdoc/opts/argparser', () => {
|
|||||||
ourOptions = argParser.parse(['-s', 'true', '-n', 'true']);
|
ourOptions = argParser.parse(['-s', 'true', '-n', 'true']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should exist', () => {
|
|
||||||
expect(ArgParser).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be a constructor', () => {
|
it('should be a constructor', () => {
|
||||||
expect(typeof ArgParser).toBe('function');
|
expect(ArgParser).toBeFunction();
|
||||||
expect(new ArgParser() instanceof ArgParser).toBe(true);
|
expect(new ArgParser() instanceof ArgParser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ArgParser', () => {
|
describe('ArgParser', () => {
|
||||||
it('should provide an "addIgnoredOption" method', () => {
|
it('should provide an "addIgnoredOption" method', () => {
|
||||||
expect(argParser.addIgnoredOption).toBeDefined();
|
expect(argParser.addIgnoredOption).toBeFunction();
|
||||||
expect(typeof argParser.addIgnoredOption).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide an "addOption" method', () => {
|
it('should provide an "addOption" method', () => {
|
||||||
expect(argParser.addOption).toBeDefined();
|
expect(argParser.addOption).toBeFunction();
|
||||||
expect(typeof argParser.addOption).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a "help" method', () => {
|
it('should provide a "help" method', () => {
|
||||||
expect(argParser.help).toBeDefined();
|
expect(argParser.help).toBeFunction();
|
||||||
expect(typeof argParser.help).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a "parse" method', () => {
|
it('should provide a "parse" method', () => {
|
||||||
expect(argParser.parse).toBeDefined();
|
expect(argParser.parse).toBeFunction();
|
||||||
expect(typeof argParser.parse).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('addIgnoredOption', () => {
|
describe('addIgnoredOption', () => {
|
||||||
@ -99,8 +91,8 @@ describe('jsdoc/opts/argparser', () => {
|
|||||||
|
|
||||||
describe('parse', () => {
|
describe('parse', () => {
|
||||||
it('should return an object with information about the options', () => {
|
it('should return an object with information about the options', () => {
|
||||||
expect(typeof ourOptions).toBe('object');
|
expect(ourOptions).toBeObject();
|
||||||
expect(ourOptions.strict).toBe(true);
|
expect(ourOptions.strict).toBeTrue();
|
||||||
expect(ourOptions.name).toBe('true');
|
expect(ourOptions.name).toBe('true');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -112,7 +104,7 @@ describe('jsdoc/opts/argparser', () => {
|
|||||||
|
|
||||||
ourOptions = argParser.parse(['-s', true], defaults);
|
ourOptions = argParser.parse(['-s', true], defaults);
|
||||||
|
|
||||||
expect(ourOptions.strict).toBe(true);
|
expect(ourOptions.strict).toBeTrue();
|
||||||
expect(ourOptions.name).toBe(defaults.name);
|
expect(ourOptions.name).toBe(defaults.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -121,11 +113,11 @@ describe('jsdoc/opts/argparser', () => {
|
|||||||
|
|
||||||
ourOptions = argParser.parse(['--multi', 'value1', '--multi', 'value2',
|
ourOptions = argParser.parse(['--multi', 'value1', '--multi', 'value2',
|
||||||
'--multi', 'value3']);
|
'--multi', 'value3']);
|
||||||
expect(Array.isArray(ourOptions.multi)).toBe(true);
|
expect(ourOptions.multi).toEqual([
|
||||||
expect(ourOptions.multi.length).toBe(3);
|
'value1',
|
||||||
expect(ourOptions.multi[0]).toBe('value1');
|
'value2',
|
||||||
expect(ourOptions.multi[1]).toBe('value2');
|
'value3'
|
||||||
expect(ourOptions.multi[2]).toBe('value3');
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if an unrecognized short option is used', () => {
|
it('should throw an error if an unrecognized short option is used', () => {
|
||||||
@ -155,12 +147,10 @@ describe('jsdoc/opts/argparser', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should coerce a true value if a coercer is provided', () => {
|
it('should coerce a true value if a coercer is provided', () => {
|
||||||
expect(ourOptions.strict).toBeDefined();
|
expect(ourOptions.strict).toBeTrue();
|
||||||
expect(ourOptions.strict).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should coerce a string value if no coercer is provided', () => {
|
it('should coerce a string value if no coercer is provided', () => {
|
||||||
expect(ourOptions.name).toBeDefined();
|
|
||||||
expect(ourOptions.name).toBe('true');
|
expect(ourOptions.name).toBe('true');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,141 +3,123 @@ describe('jsdoc/opts/args', () => {
|
|||||||
const querystring = require('querystring');
|
const querystring = require('querystring');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(args).toBeDefined();
|
expect(args).toBeObject();
|
||||||
expect(typeof args).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "parse" function', () => {
|
it('should export a "parse" function', () => {
|
||||||
expect(args.parse).toBeDefined();
|
expect(args.parse).toBeFunction();
|
||||||
expect(typeof args.parse).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "help" function', () => {
|
it('should export a "help" function', () => {
|
||||||
expect(args.help).toBeDefined();
|
expect(args.help).toBeFunction();
|
||||||
expect(typeof args.help).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "get" function', () => {
|
it('should export a "get" function', () => {
|
||||||
expect(args.get).toBeDefined();
|
expect(args.get).toBeFunction();
|
||||||
expect(typeof args.get).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parse', () => {
|
describe('parse', () => {
|
||||||
it('should accept a "-t" option and return an object with a "template" property', () => {
|
it('should accept a "-t" option and return an object with a "template" property', () => {
|
||||||
args.parse(['-t', 'mytemplate']);
|
args.parse(['-t', 'mytemplate']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.template).toBe('mytemplate');
|
expect(args.get().template).toBe('mytemplate');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--template" option and return an object with a "template" property', () => {
|
it('should accept a "--template" option and return an object with a "template" property', () => {
|
||||||
args.parse(['--template', 'mytemplate']);
|
args.parse(['--template', 'mytemplate']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.template).toBe('mytemplate');
|
expect(args.get().template).toBe('mytemplate');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-c" option with a JSON file and return an object with a "configure" property', () => {
|
it('should accept a "-c" option with a JSON file and return an object with a "configure" property', () => {
|
||||||
args.parse(['-c', 'myconf.json']);
|
args.parse(['-c', 'myconf.json']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.configure).toBe('myconf.json');
|
expect(args.get().configure).toBe('myconf.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-c" option with a JS file and return an object with a "configure" property', () => {
|
it('should accept a "-c" option with a JS file and return an object with a "configure" property', () => {
|
||||||
args.parse(['-c', 'myconf.js']);
|
args.parse(['-c', 'myconf.js']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.configure).toBe('myconf.js');
|
expect(args.get().configure).toBe('myconf.js');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--configure" option with a JSON file and return an object with a "configure" property', () => {
|
it('should accept a "--configure" option with a JSON file and return an object with a "configure" property', () => {
|
||||||
args.parse(['--configure', 'myconf.json']);
|
args.parse(['--configure', 'myconf.json']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.configure).toBe('myconf.json');
|
expect(args.get().configure).toBe('myconf.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--configure" option with a JS file and return an object with a "configure" property', () => {
|
it('should accept a "--configure" option with a JS file and return an object with a "configure" property', () => {
|
||||||
args.parse(['--configure', 'myconf.js']);
|
args.parse(['--configure', 'myconf.js']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.configure).toBe('myconf.js');
|
expect(args.get().configure).toBe('myconf.js');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept an "-e" option and return an object with a "encoding" property', () => {
|
it('should accept an "-e" option and return an object with a "encoding" property', () => {
|
||||||
args.parse(['-e', 'ascii']);
|
args.parse(['-e', 'ascii']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.encoding).toBe('ascii');
|
expect(args.get().encoding).toBe('ascii');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept an "--encoding" option and return an object with an "encoding" property', () => {
|
it('should accept an "--encoding" option and return an object with an "encoding" property', () => {
|
||||||
args.parse(['--encoding', 'ascii']);
|
args.parse(['--encoding', 'ascii']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.encoding).toBe('ascii');
|
expect(args.get().encoding).toBe('ascii');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-T" option and return an object with a "test" property', () => {
|
it('should accept a "-T" option and return an object with a "test" property', () => {
|
||||||
args.parse(['-T']);
|
args.parse(['-T']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.test).toBe(true);
|
expect(args.get().test).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--test" option and return an object with a "test" property', () => {
|
it('should accept a "--test" option and return an object with a "test" property', () => {
|
||||||
args.parse(['--test']);
|
args.parse(['--test']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.test).toBe(true);
|
expect(args.get().test).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-d" option and return an object with a "destination" property', () => {
|
it('should accept a "-d" option and return an object with a "destination" property', () => {
|
||||||
args.parse(['-d', 'mydestination']);
|
args.parse(['-d', 'mydestination']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.destination).toBe('mydestination');
|
expect(args.get().destination).toBe('mydestination');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--destination" option and return an object with a "destination" property', () => {
|
it('should accept a "--destination" option and return an object with a "destination" property', () => {
|
||||||
args.parse(['--destination', 'mydestination']);
|
args.parse(['--destination', 'mydestination']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.destination).toBe('mydestination');
|
expect(args.get().destination).toBe('mydestination');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-p" option and return an object with a "private" property', () => {
|
it('should accept a "-p" option and return an object with a "private" property', () => {
|
||||||
args.parse(['-p']);
|
args.parse(['-p']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.private).toBe(true);
|
expect(args.get().private).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--private" option and return an object with a "private" property', () => {
|
it('should accept a "--private" option and return an object with a "private" property', () => {
|
||||||
args.parse(['--private']);
|
args.parse(['--private']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.private).toBe(true);
|
expect(args.get().private).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-a" option and return an object with an "access" property', () => {
|
it('should accept a "-a" option and return an object with an "access" property', () => {
|
||||||
args.parse(['-a', 'public']);
|
args.parse(['-a', 'public']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.access).toBe('public');
|
expect(args.get().access).toBe('public');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--access" option and return an object with an "access" property', () => {
|
it('should accept a "--access" option and return an object with an "access" property', () => {
|
||||||
args.parse(['--access', 'public']);
|
args.parse(['--access', 'public']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.access).toBe('public');
|
expect(args.get().access).toBe('public');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept multiple "--access" options and return an object with an "access" property', () => {
|
it('should accept multiple "--access" options and return an object with an "access" property', () => {
|
||||||
|
let r;
|
||||||
|
|
||||||
args.parse(['--access', 'public', '--access', 'protected']);
|
args.parse(['--access', 'public', '--access', 'protected']);
|
||||||
const r = args.get();
|
r = args.get();
|
||||||
|
|
||||||
expect(r.access).toContain('public');
|
expect(r.access).toContain('public');
|
||||||
expect(r.access).toContain('protected');
|
expect(r.access).toContain('protected');
|
||||||
@ -145,65 +127,56 @@ describe('jsdoc/opts/args', () => {
|
|||||||
|
|
||||||
it('should accept a "-r" option and return an object with a "recurse" property', () => {
|
it('should accept a "-r" option and return an object with a "recurse" property', () => {
|
||||||
args.parse(['-r']);
|
args.parse(['-r']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.recurse).toBe(true);
|
expect(args.get().recurse).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--recurse" option and return an object with a "recurse" property', () => {
|
it('should accept a "--recurse" option and return an object with a "recurse" property', () => {
|
||||||
args.parse(['--recurse']);
|
args.parse(['--recurse']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.recurse).toBe(true);
|
expect(args.get().recurse).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-l" option and ignore it', () => {
|
it('should accept a "-l" option and ignore it', () => {
|
||||||
args.parse(['-l']);
|
args.parse(['-l']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.lenient).not.toBeDefined();
|
expect(args.get().lenient).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--lenient" option and ignore it', () => {
|
it('should accept a "--lenient" option and ignore it', () => {
|
||||||
args.parse(['--lenient']);
|
args.parse(['--lenient']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.lenient).not.toBeDefined();
|
expect(args.get().lenient).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-h" option and return an object with a "help" property', () => {
|
it('should accept a "-h" option and return an object with a "help" property', () => {
|
||||||
args.parse(['-h']);
|
args.parse(['-h']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.help).toBe(true);
|
expect(args.get().help).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--help" option and return an object with a "help" property', () => {
|
it('should accept a "--help" option and return an object with a "help" property', () => {
|
||||||
args.parse(['--help']);
|
args.parse(['--help']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.help).toBe(true);
|
expect(args.get().help).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept an "-X" option and return an object with an "explain" property', () => {
|
it('should accept an "-X" option and return an object with an "explain" property', () => {
|
||||||
args.parse(['-X']);
|
args.parse(['-X']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.explain).toBe(true);
|
expect(args.get().explain).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept an "--explain" option and return an object with an "explain" property', () => {
|
it('should accept an "--explain" option and return an object with an "explain" property', () => {
|
||||||
args.parse(['--explain']);
|
args.parse(['--explain']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.explain).toBe(true);
|
expect(args.get().explain).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-q" option and return an object with a "query" property', () => {
|
it('should accept a "-q" option and return an object with a "query" property', () => {
|
||||||
args.parse(['-q', 'foo=bar&fab=baz']);
|
args.parse(['-q', 'foo=bar&fab=baz']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.query).toEqual({
|
expect(args.get().query).toEqual({
|
||||||
foo: 'bar',
|
foo: 'bar',
|
||||||
fab: 'baz'
|
fab: 'baz'
|
||||||
});
|
});
|
||||||
@ -211,9 +184,8 @@ describe('jsdoc/opts/args', () => {
|
|||||||
|
|
||||||
it('should accept a "--query" option and return an object with a "query" property', () => {
|
it('should accept a "--query" option and return an object with a "query" property', () => {
|
||||||
args.parse(['--query', 'foo=bar&fab=baz']);
|
args.parse(['--query', 'foo=bar&fab=baz']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.query).toEqual({
|
expect(args.get().query).toEqual({
|
||||||
foo: 'bar',
|
foo: 'bar',
|
||||||
fab: 'baz'
|
fab: 'baz'
|
||||||
});
|
});
|
||||||
@ -226,33 +198,28 @@ describe('jsdoc/opts/args', () => {
|
|||||||
baz: false,
|
baz: false,
|
||||||
qux: [1, -97]
|
qux: [1, -97]
|
||||||
};
|
};
|
||||||
let r;
|
|
||||||
|
|
||||||
args.parse(['-q', querystring.stringify(obj)]);
|
args.parse(['-q', querystring.stringify(obj)]);
|
||||||
r = args.get();
|
|
||||||
|
|
||||||
expect(r.query).toEqual(obj);
|
expect(args.get().query).toEqual(obj);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-u" option and return an object with a "tutorials" property', () => {
|
it('should accept a "-u" option and return an object with a "tutorials" property', () => {
|
||||||
args.parse(['-u', 'mytutorials']);
|
args.parse(['-u', 'mytutorials']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.tutorials).toBe('mytutorials');
|
expect(args.get().tutorials).toBe('mytutorials');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--tutorials" option and return an object with a "tutorials" property', () => {
|
it('should accept a "--tutorials" option and return an object with a "tutorials" property', () => {
|
||||||
args.parse(['--tutorials', 'mytutorials']);
|
args.parse(['--tutorials', 'mytutorials']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.tutorials).toBe('mytutorials');
|
expect(args.get().tutorials).toBe('mytutorials');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--debug" option and return an object with a "debug" property', () => {
|
it('should accept a "--debug" option and return an object with a "debug" property', () => {
|
||||||
args.parse(['--debug']);
|
args.parse(['--debug']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.debug).toBe(true);
|
expect(args.get().debug).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--verbose" option and return an object with a "verbose" property', () => {
|
it('should accept a "--verbose" option and return an object with a "verbose" property', () => {
|
||||||
@ -264,79 +231,68 @@ describe('jsdoc/opts/args', () => {
|
|||||||
|
|
||||||
it('should accept a "--pedantic" option and return an object with a "pedantic" property', () => {
|
it('should accept a "--pedantic" option and return an object with a "pedantic" property', () => {
|
||||||
args.parse(['--pedantic']);
|
args.parse(['--pedantic']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.pedantic).toBe(true);
|
expect(args.get().pedantic).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--match" option and return an object with a "match" property', () => {
|
it('should accept a "--match" option and return an object with a "match" property', () => {
|
||||||
args.parse(['--match', '.*tag']);
|
args.parse(['--match', '.*tag']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.match).toBe('.*tag');
|
expect(args.get().match).toBe('.*tag');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept multiple "--match" options and return an object with a "match" property', () => {
|
it('should accept multiple "--match" options and return an object with a "match" property', () => {
|
||||||
args.parse(['--match', '.*tag', '--match', 'parser']);
|
args.parse(['--match', '.*tag', '--match', 'parser']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.match).toEqual(['.*tag', 'parser']);
|
expect(args.get().match).toEqual(['.*tag', 'parser']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--nocolor" option and return an object with a "nocolor" property', () => {
|
it('should accept a "--nocolor" option and return an object with a "nocolor" property', () => {
|
||||||
args.parse(['--nocolor']);
|
args.parse(['--nocolor']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.nocolor).toBe(true);
|
expect(args.get().nocolor).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-P" option and return an object with a "package" property', () => {
|
it('should accept a "-P" option and return an object with a "package" property', () => {
|
||||||
args.parse(['-P', 'path/to/package/file.json']);
|
args.parse(['-P', 'path/to/package/file.json']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.package).toBe('path/to/package/file.json');
|
expect(args.get().package).toBe('path/to/package/file.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--package" option and return an object with a "package" property', () => {
|
it('should accept a "--package" option and return an object with a "package" property', () => {
|
||||||
args.parse(['--package', 'path/to/package/file.json']);
|
args.parse(['--package', 'path/to/package/file.json']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.package).toBe('path/to/package/file.json');
|
expect(args.get().package).toBe('path/to/package/file.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-R" option and return an object with a "readme" property', () => {
|
it('should accept a "-R" option and return an object with a "readme" property', () => {
|
||||||
args.parse(['-R', 'path/to/readme/file.md']);
|
args.parse(['-R', 'path/to/readme/file.md']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.readme).toBe('path/to/readme/file.md');
|
expect(args.get().readme).toBe('path/to/readme/file.md');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--readme" option and return an object with a "readme" property', () => {
|
it('should accept a "--readme" option and return an object with a "readme" property', () => {
|
||||||
args.parse(['--readme', 'path/to/readme/file.md']);
|
args.parse(['--readme', 'path/to/readme/file.md']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.readme).toBe('path/to/readme/file.md');
|
expect(args.get().readme).toBe('path/to/readme/file.md');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "-v" option and return an object with a "version" property', () => {
|
it('should accept a "-v" option and return an object with a "version" property', () => {
|
||||||
args.parse(['-v']);
|
args.parse(['-v']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.version).toBe(true);
|
expect(args.get().version).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a "--version" option and return an object with a "version" property', () => {
|
it('should accept a "--version" option and return an object with a "version" property', () => {
|
||||||
args.parse(['--version']);
|
args.parse(['--version']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r.version).toBe(true);
|
expect(args.get().version).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept a naked option (with no "-") and return an object with a "_" property', () => {
|
it('should accept a naked option (with no "-") and return an object with a "_" property', () => {
|
||||||
args.parse(['myfile1', 'myfile2']);
|
args.parse(['myfile1', 'myfile2']);
|
||||||
const r = args.get();
|
|
||||||
|
|
||||||
expect(r._).toEqual(['myfile1', 'myfile2']);
|
expect(args.get()._).toEqual(['myfile1', 'myfile2']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: tests for args that must have values
|
// TODO: tests for args that must have values
|
||||||
|
|||||||
@ -16,18 +16,15 @@ describe('jsdoc/package', () => {
|
|||||||
// doclet schema
|
// doclet schema
|
||||||
jsdoc.addParseResults(`package-property-${name}.js`, [myPackage]);
|
jsdoc.addParseResults(`package-property-${name}.js`, [myPackage]);
|
||||||
|
|
||||||
// use toEqual so we can test array/object values
|
|
||||||
expect(myPackage[name]).toEqual(value);
|
expect(myPackage[name]).toEqual(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(jsdocPackage).toBeDefined();
|
expect(jsdocPackage).toBeObject();
|
||||||
expect(typeof jsdocPackage).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "Package" constructor', () => {
|
it('should export a "Package" constructor', () => {
|
||||||
expect(Package).toBeDefined();
|
expect(Package).toBeFunction();
|
||||||
expect(typeof Package).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Package', () => {
|
describe('Package', () => {
|
||||||
@ -72,7 +69,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('author', () => {
|
describe('author', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'author') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'author') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -85,7 +82,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('bugs', () => {
|
describe('bugs', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'bugs') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'bugs') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -95,7 +92,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('contributors', () => {
|
describe('contributors', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'contributors') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'contributors') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -108,7 +105,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('dependencies', () => {
|
describe('dependencies', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'dependencies') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'dependencies') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -118,7 +115,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('description', () => {
|
describe('description', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'description') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'description') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -128,7 +125,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('devDependencies', () => {
|
describe('devDependencies', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'devDependencies') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'devDependencies') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -138,7 +135,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('engines', () => {
|
describe('engines', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'engines') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'engines') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -148,20 +145,19 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('files', () => {
|
describe('files', () => {
|
||||||
it('should contain an empty array by default', () => {
|
it('should contain an empty array by default', () => {
|
||||||
expect(emptyPackage.files).toBeDefined();
|
expect(emptyPackage.files).toBeEmptyArray();
|
||||||
expect(emptyPackage.files).toEqual([]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ignore the value from the package file', () => {
|
it('should ignore the value from the package file', () => {
|
||||||
const myPackage = new Package('{"files": ["foo", "bar"]}');
|
const myPackage = new Package('{"files": ["foo", "bar"]}');
|
||||||
|
|
||||||
expect(myPackage.files.length).toBe(0);
|
expect(myPackage.files).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('homepage', () => {
|
describe('homepage', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'homepage') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'homepage') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -171,7 +167,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('keywords', () => {
|
describe('keywords', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'keywords') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'keywords') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -181,7 +177,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('licenses', () => {
|
describe('licenses', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'licenses') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'licenses') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -194,9 +190,8 @@ describe('jsdoc/package', () => {
|
|||||||
it('should contain the value of "license" from the package file', () => {
|
it('should contain the value of "license" from the package file', () => {
|
||||||
const myPackage = new Package('{"license": "My-OSS-License"}');
|
const myPackage = new Package('{"license": "My-OSS-License"}');
|
||||||
|
|
||||||
expect(myPackage.license).not.toBeDefined();
|
expect(myPackage.license).toBeUndefined();
|
||||||
expect(myPackage.licenses).toBeDefined();
|
expect(myPackage.licenses).toBeArrayOfSize(1);
|
||||||
expect(myPackage.licenses.length).toBe(1);
|
|
||||||
expect(myPackage.licenses[0].type).toBe('My-OSS-License');
|
expect(myPackage.licenses[0].type).toBe('My-OSS-License');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -210,7 +205,7 @@ describe('jsdoc/package', () => {
|
|||||||
};
|
};
|
||||||
const myPackage = new Package( JSON.stringify(packageInfo) );
|
const myPackage = new Package( JSON.stringify(packageInfo) );
|
||||||
|
|
||||||
expect(myPackage.licenses.length).toBe(2);
|
expect(myPackage.licenses).toBeArrayOfSize(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -228,7 +223,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('main', () => {
|
describe('main', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'main') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'main') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -238,7 +233,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('name', () => {
|
describe('name', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'name') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'name') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -248,7 +243,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('repository', () => {
|
describe('repository', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'repository') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'repository') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
@ -261,7 +256,7 @@ describe('jsdoc/package', () => {
|
|||||||
|
|
||||||
describe('version', () => {
|
describe('version', () => {
|
||||||
it('should not exist by default', () => {
|
it('should not exist by default', () => {
|
||||||
expect( hasOwnProp.call(emptyPackage, 'version') ).toBe(false);
|
expect( hasOwnProp.call(emptyPackage, 'version') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the value from the package file', () => {
|
it('should contain the value from the package file', () => {
|
||||||
|
|||||||
@ -7,27 +7,23 @@ describe('jsdoc/path', () => {
|
|||||||
const isWindows = /^win/.test( os.platform() );
|
const isWindows = /^win/.test( os.platform() );
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(path).toBeDefined();
|
expect(path).toBeObject();
|
||||||
expect(typeof path).toEqual('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export all functions in the "path" module', () => {
|
it('should export all functions in the "path" module', () => {
|
||||||
Object.keys(standardPath).forEach(item => {
|
Object.keys(standardPath).forEach(item => {
|
||||||
if (typeof standardPath[item] === 'function') {
|
if (typeof standardPath[item] === 'function') {
|
||||||
expect(path[item]).toBeDefined();
|
expect(path[item]).toBeFunction();
|
||||||
expect(typeof path[item]).toEqual('function');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "commonPrefix" function', () => {
|
it('should export a "commonPrefix" function', () => {
|
||||||
expect(path.commonPrefix).toBeDefined();
|
expect(path.commonPrefix).toBeFunction();
|
||||||
expect(typeof path.commonPrefix).toEqual('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "getResourcePath" function', () => {
|
it('should export a "getResourcePath" function', () => {
|
||||||
expect(path.getResourcePath).toBeDefined();
|
expect(path.getResourcePath).toBeFunction();
|
||||||
expect(typeof path.getResourcePath).toEqual('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('commonPrefix', () => {
|
describe('commonPrefix', () => {
|
||||||
@ -61,7 +57,7 @@ describe('jsdoc/path', () => {
|
|||||||
// we expect a trailing slash
|
// we expect a trailing slash
|
||||||
const expected = cwd.concat('foo', 'bar', '').join(path.sep);
|
const expected = cwd.concat('foo', 'bar', '').join(path.sep);
|
||||||
|
|
||||||
expect( path.commonPrefix(paths) ).toEqual(expected);
|
expect( path.commonPrefix(paths) ).toBe(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('finds the correct prefix for a single absolute path', () => {
|
it('finds the correct prefix for a single absolute path', () => {
|
||||||
@ -81,7 +77,7 @@ describe('jsdoc/path', () => {
|
|||||||
// we expect a trailing slash
|
// we expect a trailing slash
|
||||||
const expected = cwd.concat('foo', 'bar', '').join(path.sep);
|
const expected = cwd.concat('foo', 'bar', '').join(path.sep);
|
||||||
|
|
||||||
expect( path.commonPrefix(paths) ).toEqual(expected);
|
expect( path.commonPrefix(paths) ).toBe(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('finds the correct prefix for a group of absolute paths and dotted relative paths',
|
it('finds the correct prefix for a group of absolute paths and dotted relative paths',
|
||||||
@ -94,7 +90,7 @@ describe('jsdoc/path', () => {
|
|||||||
// we expect a trailing slash
|
// we expect a trailing slash
|
||||||
const expected = cwd.concat('foo', 'bar', '').join(path.sep);
|
const expected = cwd.concat('foo', 'bar', '').join(path.sep);
|
||||||
|
|
||||||
expect( path.commonPrefix(paths) ).toEqual(expected);
|
expect( path.commonPrefix(paths) ).toBe(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns an empty string when the paths array is empty', () => {
|
it('returns an empty string when the paths array is empty', () => {
|
||||||
@ -111,7 +107,7 @@ describe('jsdoc/path', () => {
|
|||||||
path.join('..', '..', 'Library', 'foo', 'bar', 'baz.js')
|
path.join('..', '..', 'Library', 'foo', 'bar', 'baz.js')
|
||||||
];
|
];
|
||||||
|
|
||||||
expect( path.commonPrefix(paths) ).toEqual('');
|
expect( path.commonPrefix(paths) ).toBe('');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,13 +2,11 @@ describe('jsdoc/plugins', () => {
|
|||||||
const plugins = require('jsdoc/plugins');
|
const plugins = require('jsdoc/plugins');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(plugins).toBeDefined();
|
expect(plugins).toBeObject();
|
||||||
expect(typeof plugins).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an "installPlugins" function', () => {
|
it('should export an "installPlugins" function', () => {
|
||||||
expect(plugins.installPlugins).toBeDefined();
|
expect(plugins.installPlugins).toBeFunction();
|
||||||
expect(typeof plugins.installPlugins).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
xdescribe('installPlugins', () => {
|
xdescribe('installPlugins', () => {
|
||||||
|
|||||||
@ -3,8 +3,7 @@ describe('jsdoc/readme', () => {
|
|||||||
const html = (new Readme('test/fixtures/markdowntest.md')).html;
|
const html = (new Readme('test/fixtures/markdowntest.md')).html;
|
||||||
|
|
||||||
it('should convert Markdown files to HTML', () => {
|
it('should convert Markdown files to HTML', () => {
|
||||||
expect(html).toBeDefined();
|
expect(html).toBeString();
|
||||||
expect(typeof html).toBe('string');
|
|
||||||
expect(html).toContain('<code>');
|
expect(html).toContain('<code>');
|
||||||
expect(html).toContain('<h2>');
|
expect(html).toContain('<h2>');
|
||||||
expect(html).toContain('<p>');
|
expect(html).toContain('<p>');
|
||||||
|
|||||||
@ -2,53 +2,43 @@ describe('jsdoc/schema', () => {
|
|||||||
const schema = require('jsdoc/schema');
|
const schema = require('jsdoc/schema');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(schema).toBeDefined();
|
expect(schema).toBeObject();
|
||||||
expect(typeof schema).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "BUGS_SCHEMA" object', () => {
|
it('should export a "BUGS_SCHEMA" object', () => {
|
||||||
expect(schema.BUGS_SCHEMA).toBeDefined();
|
expect(schema.BUGS_SCHEMA).toBeObject();
|
||||||
expect(typeof schema.BUGS_SCHEMA).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "CONTACT_INFO_SCHEMA" object', () => {
|
it('should export a "CONTACT_INFO_SCHEMA" object', () => {
|
||||||
expect(schema.CONTACT_INFO_SCHEMA).toBeDefined();
|
expect(schema.CONTACT_INFO_SCHEMA).toBeObject();
|
||||||
expect(typeof schema.CONTACT_INFO_SCHEMA).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "DOCLET_SCHEMA" object', () => {
|
it('should export a "DOCLET_SCHEMA" object', () => {
|
||||||
expect(schema.DOCLET_SCHEMA).toBeDefined();
|
expect(schema.DOCLET_SCHEMA).toBeObject();
|
||||||
expect(typeof schema.DOCLET_SCHEMA).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "DOCLETS_SCHEMA" object', () => {
|
it('should export a "DOCLETS_SCHEMA" object', () => {
|
||||||
expect(schema.DOCLETS_SCHEMA).toBeDefined();
|
expect(schema.DOCLETS_SCHEMA).toBeObject();
|
||||||
expect(typeof schema.DOCLETS_SCHEMA).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an "ENUM_PROPERTY_SCHEMA" object', () => {
|
it('should export an "ENUM_PROPERTY_SCHEMA" object', () => {
|
||||||
expect(schema.ENUM_PROPERTY_SCHEMA).toBeDefined();
|
expect(schema.ENUM_PROPERTY_SCHEMA).toBeObject();
|
||||||
expect(typeof schema.ENUM_PROPERTY_SCHEMA).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "META_SCHEMA" object', () => {
|
it('should export a "META_SCHEMA" object', () => {
|
||||||
expect(schema.META_SCHEMA).toBeDefined();
|
expect(schema.META_SCHEMA).toBeObject();
|
||||||
expect(typeof schema.META_SCHEMA).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "PACKAGE_SCHEMA" object', () => {
|
it('should export a "PACKAGE_SCHEMA" object', () => {
|
||||||
expect(schema.PACKAGE_SCHEMA).toBeDefined();
|
expect(schema.PACKAGE_SCHEMA).toBeObject();
|
||||||
expect(typeof schema.PACKAGE_SCHEMA).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "PARAM_SCHEMA" object', () => {
|
it('should export a "PARAM_SCHEMA" object', () => {
|
||||||
expect(schema.PARAM_SCHEMA).toBeDefined();
|
expect(schema.PARAM_SCHEMA).toBeObject();
|
||||||
expect(typeof schema.PARAM_SCHEMA).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "TYPE_PROPERTY_SCHEMA" object', () => {
|
it('should export a "TYPE_PROPERTY_SCHEMA" object', () => {
|
||||||
expect(schema.TYPE_PROPERTY_SCHEMA).toBeDefined();
|
expect(schema.TYPE_PROPERTY_SCHEMA).toBeObject();
|
||||||
expect(typeof schema.TYPE_PROPERTY_SCHEMA).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('validation', () => {
|
describe('validation', () => {
|
||||||
@ -68,7 +58,7 @@ describe('jsdoc/schema', () => {
|
|||||||
];
|
];
|
||||||
const isValid = validate(doclets);
|
const isValid = validate(doclets);
|
||||||
|
|
||||||
expect(isValid).toBe(false);
|
expect(isValid).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not find any validation errors in the JSDoc parse results', () => {
|
it('should not find any validation errors in the JSDoc parse results', () => {
|
||||||
@ -78,10 +68,10 @@ describe('jsdoc/schema', () => {
|
|||||||
// hack to get the filename/errors in the test results
|
// hack to get the filename/errors in the test results
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
expect(doclets.filename).toBe('');
|
expect(doclets.filename).toBe('');
|
||||||
expect(validate.errors).toEqual([]);
|
expect(validate.errors).toBeEmptyArray();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
expect(validate.errors).toBe(null);
|
expect(validate.errors).toBeNull();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,13 +2,11 @@ describe('jsdoc/src/astbuilder', () => {
|
|||||||
const astbuilder = require('jsdoc/src/astbuilder');
|
const astbuilder = require('jsdoc/src/astbuilder');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(astbuilder).toBeDefined();
|
expect(astbuilder).toBeObject();
|
||||||
expect(typeof astbuilder).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an AstBuilder class', () => {
|
it('should export an AstBuilder class', () => {
|
||||||
expect(astbuilder.AstBuilder).toBeDefined();
|
expect(astbuilder.AstBuilder).toBeFunction();
|
||||||
expect(typeof astbuilder.AstBuilder).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('AstBuilder', () => {
|
describe('AstBuilder', () => {
|
||||||
@ -20,8 +18,7 @@ describe('jsdoc/src/astbuilder', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a "build" method', () => {
|
it('should provide a "build" method', () => {
|
||||||
expect(builder.build).toBeDefined();
|
expect(builder.build).toBeFunction();
|
||||||
expect(typeof builder.build).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('build', () => {
|
describe('build', () => {
|
||||||
|
|||||||
@ -39,43 +39,43 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
const variableDeclarator2 = parse('var foo;').declarations[0];
|
const variableDeclarator2 = parse('var foo;').declarations[0];
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(typeof astNode).toBe('object');
|
expect(astNode).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an addNodeProperties method', () => {
|
it('should export an addNodeProperties method', () => {
|
||||||
expect(typeof astNode.addNodeProperties).toBe('function');
|
expect(astNode.addNodeProperties).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a getInfo method', () => {
|
it('should export a getInfo method', () => {
|
||||||
expect(typeof astNode.getInfo).toBe('function');
|
expect(astNode.getInfo).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a getParamNames method', () => {
|
it('should export a getParamNames method', () => {
|
||||||
expect(typeof astNode.getParamNames).toBe('function');
|
expect(astNode.getParamNames).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an isAccessor method', () => {
|
it('should export an isAccessor method', () => {
|
||||||
expect(typeof astNode.isAccessor).toBe('function');
|
expect(astNode.isAccessor).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an isAssignment method', () => {
|
it('should export an isAssignment method', () => {
|
||||||
expect(typeof astNode.isAssignment).toBe('function');
|
expect(astNode.isAssignment).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an isFunction method', () => {
|
it('should export an isFunction method', () => {
|
||||||
expect(typeof astNode.isFunction).toBe('function');
|
expect(astNode.isFunction).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an isScope method', () => {
|
it('should export an isScope method', () => {
|
||||||
expect(typeof astNode.isScope).toBe('function');
|
expect(astNode.isScope).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a nodeToString method', () => {
|
it('should export a nodeToString method', () => {
|
||||||
expect(typeof astNode.nodeToString).toBe('function');
|
expect(astNode.nodeToString).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a nodeToValue method', () => {
|
it('should export a nodeToValue method', () => {
|
||||||
expect(typeof astNode.nodeToValue).toBe('function');
|
expect(astNode.nodeToValue).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('addNodeProperties', () => {
|
describe('addNodeProperties', () => {
|
||||||
@ -100,7 +100,7 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
it('should preserve existing properties that are not "node properties"', () => {
|
it('should preserve existing properties that are not "node properties"', () => {
|
||||||
const node = astNode.addNodeProperties({foo: 1});
|
const node = astNode.addNodeProperties({foo: 1});
|
||||||
|
|
||||||
expect(typeof node).toBe('object');
|
expect(node).toBeObject();
|
||||||
expect(node.foo).toBe(1);
|
expect(node.foo).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -108,9 +108,9 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
const node = astNode.addNodeProperties({});
|
const node = astNode.addNodeProperties({});
|
||||||
const descriptor = Object.getOwnPropertyDescriptor(node, 'nodeId');
|
const descriptor = Object.getOwnPropertyDescriptor(node, 'nodeId');
|
||||||
|
|
||||||
expect(descriptor).toBeDefined();
|
expect(descriptor).toBeObject();
|
||||||
expect(typeof descriptor.value).toBe('string');
|
expect(descriptor.value).toBeString();
|
||||||
expect(descriptor.enumerable).toBe(false);
|
expect(descriptor.enumerable).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not overwrite an existing nodeId', () => {
|
it('should not overwrite an existing nodeId', () => {
|
||||||
@ -128,7 +128,7 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
node = astNode.addNodeProperties({});
|
node = astNode.addNodeProperties({});
|
||||||
descriptor = Object.getOwnPropertyDescriptor(node, 'nodeId');
|
descriptor = Object.getOwnPropertyDescriptor(node, 'nodeId');
|
||||||
|
|
||||||
expect(descriptor.enumerable).toBe(true);
|
expect(descriptor.enumerable).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add a non-enumerable, writable parent if necessary', () => {
|
it('should add a non-enumerable, writable parent if necessary', () => {
|
||||||
@ -136,9 +136,9 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
const descriptor = Object.getOwnPropertyDescriptor(node, 'parent');
|
const descriptor = Object.getOwnPropertyDescriptor(node, 'parent');
|
||||||
|
|
||||||
expect(descriptor).toBeDefined();
|
expect(descriptor).toBeDefined();
|
||||||
expect(descriptor.value).toBe(undefined);
|
expect(descriptor.value).toBeUndefined();
|
||||||
expect(descriptor.enumerable).toBe(false);
|
expect(descriptor.enumerable).toBeFalse();
|
||||||
expect(descriptor.writable).toBe(true);
|
expect(descriptor.writable).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not overwrite an existing parent', () => {
|
it('should not overwrite an existing parent', () => {
|
||||||
@ -151,7 +151,7 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
it('should not overwrite a null parent', () => {
|
it('should not overwrite a null parent', () => {
|
||||||
const node = astNode.addNodeProperties({parent: null});
|
const node = astNode.addNodeProperties({parent: null});
|
||||||
|
|
||||||
expect(node.parent).toBe(null);
|
expect(node.parent).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add an enumerable parentId in debug mode', () => {
|
it('should add an enumerable parentId in debug mode', () => {
|
||||||
@ -162,8 +162,8 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
node = astNode.addNodeProperties({});
|
node = astNode.addNodeProperties({});
|
||||||
descriptor = Object.getOwnPropertyDescriptor(node, 'parentId');
|
descriptor = Object.getOwnPropertyDescriptor(node, 'parentId');
|
||||||
|
|
||||||
expect(descriptor).toBeDefined();
|
expect(descriptor).toBeObject();
|
||||||
expect(descriptor.enumerable).toBe(true);
|
expect(descriptor.enumerable).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a null parentId in debug mode for nodes with no parent', () => {
|
it('should provide a null parentId in debug mode for nodes with no parent', () => {
|
||||||
@ -172,7 +172,7 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
env.opts.debug = true;
|
env.opts.debug = true;
|
||||||
node = astNode.addNodeProperties({});
|
node = astNode.addNodeProperties({});
|
||||||
|
|
||||||
expect(node.parentId).toBe(null);
|
expect(node.parentId).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a non-null parentId in debug mode for nodes with a parent', () => {
|
it('should provide a non-null parentId in debug mode for nodes with a parent', () => {
|
||||||
@ -191,10 +191,10 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
const node = astNode.addNodeProperties({});
|
const node = astNode.addNodeProperties({});
|
||||||
const descriptor = Object.getOwnPropertyDescriptor(node, 'enclosingScope');
|
const descriptor = Object.getOwnPropertyDescriptor(node, 'enclosingScope');
|
||||||
|
|
||||||
expect(descriptor).toBeDefined();
|
expect(descriptor).toBeObject();
|
||||||
expect(descriptor.value).toBe(undefined);
|
expect(descriptor.value).toBeUndefined();
|
||||||
expect(descriptor.enumerable).toBe(false);
|
expect(descriptor.enumerable).toBeFalse();
|
||||||
expect(descriptor.writable).toBe(true);
|
expect(descriptor.writable).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not overwrite an existing enclosingScope', () => {
|
it('should not overwrite an existing enclosingScope', () => {
|
||||||
@ -207,7 +207,7 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
it('should not overwrite a null enclosingScope', () => {
|
it('should not overwrite a null enclosingScope', () => {
|
||||||
const node = astNode.addNodeProperties({enclosingScope: null});
|
const node = astNode.addNodeProperties({enclosingScope: null});
|
||||||
|
|
||||||
expect(node.enclosingScope).toBe(null);
|
expect(node.enclosingScope).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add an enumerable enclosingScopeId in debug mode', () => {
|
it('should add an enumerable enclosingScopeId in debug mode', () => {
|
||||||
@ -218,8 +218,8 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
node = astNode.addNodeProperties({});
|
node = astNode.addNodeProperties({});
|
||||||
descriptor = Object.getOwnPropertyDescriptor(node, 'enclosingScopeId');
|
descriptor = Object.getOwnPropertyDescriptor(node, 'enclosingScopeId');
|
||||||
|
|
||||||
expect(descriptor).toBeDefined();
|
expect(descriptor).toBeObject();
|
||||||
expect(descriptor.enumerable).toBe(true);
|
expect(descriptor.enumerable).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a null enclosingScopeId in debug mode for nodes with no enclosing scope',
|
it('should provide a null enclosingScopeId in debug mode for nodes with no enclosing scope',
|
||||||
@ -229,7 +229,7 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
env.opts.debug = true;
|
env.opts.debug = true;
|
||||||
node = astNode.addNodeProperties({});
|
node = astNode.addNodeProperties({});
|
||||||
|
|
||||||
expect(node.enclosingScopeId).toBe(null);
|
expect(node.enclosingScopeId).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a non-null enclosingScopeId in debug mode for nodes with an enclosing ' +
|
it('should provide a non-null enclosingScopeId in debug mode for nodes with an enclosing ' +
|
||||||
@ -258,9 +258,9 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
it('should return the correct info for an AssignmentExpression', () => {
|
it('should return the correct info for an AssignmentExpression', () => {
|
||||||
const info = astNode.getInfo(assignmentExpression);
|
const info = astNode.getInfo(assignmentExpression);
|
||||||
|
|
||||||
expect(info).toBeDefined();
|
expect(info).toBeObject();
|
||||||
|
|
||||||
expect(info.node).toBeDefined();
|
expect(info.node).toBeObject();
|
||||||
expect(info.node.type).toBe(Syntax.Literal);
|
expect(info.node.type).toBe(Syntax.Literal);
|
||||||
expect(info.node.value).toBe(1);
|
expect(info.node.value).toBe(1);
|
||||||
|
|
||||||
@ -272,41 +272,41 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
it('should return the correct info for a FunctionDeclaration', () => {
|
it('should return the correct info for a FunctionDeclaration', () => {
|
||||||
const info = astNode.getInfo(functionDeclaration2);
|
const info = astNode.getInfo(functionDeclaration2);
|
||||||
|
|
||||||
expect(info).toBeDefined();
|
expect(info).toBeObject();
|
||||||
|
|
||||||
expect(info.node).toBeDefined();
|
expect(info.node).toBeObject();
|
||||||
expect(info.node.type).toBe(Syntax.FunctionDeclaration);
|
expect(info.node.type).toBe(Syntax.FunctionDeclaration);
|
||||||
|
|
||||||
expect(info.name).toBe('foo');
|
expect(info.name).toBe('foo');
|
||||||
expect(info.type).toBe(Syntax.FunctionDeclaration);
|
expect(info.type).toBe(Syntax.FunctionDeclaration);
|
||||||
expect(info.value).not.toBeDefined();
|
expect(info.value).toBeUndefined();
|
||||||
expect( Array.isArray(info.paramnames) ).toBe(true);
|
|
||||||
expect(info.paramnames.length).toBe(1);
|
expect(info.paramnames).toBeArrayOfSize(1);
|
||||||
expect(info.paramnames[0]).toBe('bar');
|
expect(info.paramnames[0]).toBe('bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the correct info for a FunctionExpression', () => {
|
it('should return the correct info for a FunctionExpression', () => {
|
||||||
const info = astNode.getInfo(functionExpression2);
|
const info = astNode.getInfo(functionExpression2);
|
||||||
|
|
||||||
expect(info).toBeDefined();
|
expect(info).toBeObject();
|
||||||
|
|
||||||
expect(info.node).toBeDefined();
|
expect(info.node).toBeObject();
|
||||||
expect(info.node.type).toBe(Syntax.FunctionExpression);
|
expect(info.node.type).toBe(Syntax.FunctionExpression);
|
||||||
|
|
||||||
expect(info.name).toBe('');
|
expect(info.name).toBe('');
|
||||||
expect(info.type).toBe(Syntax.FunctionExpression);
|
expect(info.type).toBe(Syntax.FunctionExpression);
|
||||||
expect(info.value).not.toBeDefined();
|
expect(info.value).toBeUndefined();
|
||||||
expect( Array.isArray(info.paramnames) ).toBe(true);
|
|
||||||
expect(info.paramnames.length).toBe(1);
|
expect(info.paramnames).toBeArrayOfSize(1);
|
||||||
expect(info.paramnames[0]).toBe('bar');
|
expect(info.paramnames[0]).toBe('bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the correct info for a MemberExpression', () => {
|
it('should return the correct info for a MemberExpression', () => {
|
||||||
const info = astNode.getInfo(memberExpression);
|
const info = astNode.getInfo(memberExpression);
|
||||||
|
|
||||||
expect(info).toBeDefined();
|
expect(info).toBeObject();
|
||||||
|
|
||||||
expect(info.node).toBeDefined();
|
expect(info.node).toBeObject();
|
||||||
expect(info.node.type).toBe(Syntax.MemberExpression);
|
expect(info.node.type).toBe(Syntax.MemberExpression);
|
||||||
|
|
||||||
expect(info.name).toBe('foo.bar');
|
expect(info.name).toBe('foo.bar');
|
||||||
@ -316,9 +316,9 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
it('should return the correct info for a computed MemberExpression', () => {
|
it('should return the correct info for a computed MemberExpression', () => {
|
||||||
const info = astNode.getInfo(memberExpressionComputed1);
|
const info = astNode.getInfo(memberExpressionComputed1);
|
||||||
|
|
||||||
expect(info).toBeDefined();
|
expect(info).toBeObject();
|
||||||
|
|
||||||
expect(info.node).toBeDefined();
|
expect(info.node).toBeObject();
|
||||||
expect(info.node.type).toBe(Syntax.MemberExpression);
|
expect(info.node.type).toBe(Syntax.MemberExpression);
|
||||||
|
|
||||||
expect(info.name).toBe('foo["bar"]');
|
expect(info.name).toBe('foo["bar"]');
|
||||||
@ -328,9 +328,9 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
it('should return the correct info for a Property initializer', () => {
|
it('should return the correct info for a Property initializer', () => {
|
||||||
const info = astNode.getInfo(propertyInit);
|
const info = astNode.getInfo(propertyInit);
|
||||||
|
|
||||||
expect(info).toBeDefined();
|
expect(info).toBeObject();
|
||||||
|
|
||||||
expect(info.node).toBeDefined();
|
expect(info.node).toBeObject();
|
||||||
expect(info.node.type).toBe(Syntax.ObjectExpression);
|
expect(info.node.type).toBe(Syntax.ObjectExpression);
|
||||||
|
|
||||||
expect(info.name).toBe('bar');
|
expect(info.name).toBe('bar');
|
||||||
@ -340,25 +340,25 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
it('should return the correct info for a Property setter', () => {
|
it('should return the correct info for a Property setter', () => {
|
||||||
const info = astNode.getInfo(propertySet);
|
const info = astNode.getInfo(propertySet);
|
||||||
|
|
||||||
expect(info).toBeDefined();
|
expect(info).toBeObject();
|
||||||
|
|
||||||
expect(info.node).toBeDefined();
|
expect(info.node).toBeObject();
|
||||||
expect(info.node.type).toBe(Syntax.FunctionExpression);
|
expect(info.node.type).toBe(Syntax.FunctionExpression);
|
||||||
|
|
||||||
expect(info.name).toBe('bar');
|
expect(info.name).toBe('bar');
|
||||||
expect(info.type).toBeUndefined();
|
expect(info.type).toBeUndefined();
|
||||||
expect(info.value).toBeUndefined();
|
expect(info.value).toBeUndefined();
|
||||||
expect( Array.isArray(info.paramnames) ).toBe(true);
|
|
||||||
expect(info.paramnames.length).toBe(1);
|
expect(info.paramnames).toBeArrayOfSize(1);
|
||||||
expect(info.paramnames[0]).toBe('a');
|
expect(info.paramnames[0]).toBe('a');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the correct info for a VariableDeclarator with a value', () => {
|
it('should return the correct info for a VariableDeclarator with a value', () => {
|
||||||
const info = astNode.getInfo(variableDeclarator1);
|
const info = astNode.getInfo(variableDeclarator1);
|
||||||
|
|
||||||
expect(info).toBeDefined();
|
expect(info).toBeObject();
|
||||||
|
|
||||||
expect(info.node).toBeDefined();
|
expect(info.node).toBeObject();
|
||||||
expect(info.node.type).toBe(Syntax.Literal);
|
expect(info.node.type).toBe(Syntax.Literal);
|
||||||
|
|
||||||
expect(info.name).toBe('foo');
|
expect(info.name).toBe('foo');
|
||||||
@ -369,20 +369,20 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
it('should return the correct info for a VariableDeclarator with no value', () => {
|
it('should return the correct info for a VariableDeclarator with no value', () => {
|
||||||
const info = astNode.getInfo(variableDeclarator2);
|
const info = astNode.getInfo(variableDeclarator2);
|
||||||
|
|
||||||
expect(info).toBeDefined();
|
expect(info).toBeObject();
|
||||||
|
|
||||||
expect(info.node).toBeDefined();
|
expect(info.node).toBeObject();
|
||||||
expect(info.node.type).toBe(Syntax.Identifier);
|
expect(info.node.type).toBe(Syntax.Identifier);
|
||||||
|
|
||||||
expect(info.name).toBe('foo');
|
expect(info.name).toBe('foo');
|
||||||
expect(info.type).not.toBeDefined();
|
expect(info.type).toBeUndefined();
|
||||||
expect(info.value).not.toBeDefined();
|
expect(info.value).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the correct info for other node types', () => {
|
it('should return the correct info for other node types', () => {
|
||||||
const info = astNode.getInfo(binaryExpression);
|
const info = astNode.getInfo(binaryExpression);
|
||||||
|
|
||||||
expect(info).toBeDefined();
|
expect(info).toBeObject();
|
||||||
|
|
||||||
expect(info.node).toBe(binaryExpression);
|
expect(info.node).toBe(binaryExpression);
|
||||||
expect(info.type).toBe(Syntax.BinaryExpression);
|
expect(info.type).toBe(Syntax.BinaryExpression);
|
||||||
@ -393,144 +393,137 @@ describe('jsdoc/src/astNode', () => {
|
|||||||
it('should return an empty array for undefined input', () => {
|
it('should return an empty array for undefined input', () => {
|
||||||
const params = astNode.getParamNames();
|
const params = astNode.getParamNames();
|
||||||
|
|
||||||
expect( Array.isArray(params) ).toBe(true);
|
expect(params).toBeEmptyArray();
|
||||||
expect(params.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an empty array if the input has no params property', () => {
|
it('should return an empty array if the input has no params property', () => {
|
||||||
const params = astNode.getParamNames({});
|
const params = astNode.getParamNames({});
|
||||||
|
|
||||||
expect( Array.isArray(params) ).toBe(true);
|
expect(params).toBeEmptyArray();
|
||||||
expect(params.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an empty array if the input has no params', () => {
|
it('should return an empty array if the input has no params', () => {
|
||||||
const params = astNode.getParamNames(functionDeclaration1);
|
const params = astNode.getParamNames(functionDeclaration1);
|
||||||
|
|
||||||
expect( Array.isArray(params) ).toBe(true);
|
expect(params).toBeEmptyArray();
|
||||||
expect(params.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a single-item array if the input has a single param', () => {
|
it('should return a single-item array if the input has a single param', () => {
|
||||||
const params = astNode.getParamNames(functionDeclaration2);
|
const params = astNode.getParamNames(functionDeclaration2);
|
||||||
|
|
||||||
expect( Array.isArray(params) ).toBe(true);
|
expect(params).toEqual(['bar']);
|
||||||
expect(params.length).toBe(1);
|
|
||||||
expect(params[0]).toBe('bar');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a multi-item array if the input has multiple params', () => {
|
it('should return a multi-item array if the input has multiple params', () => {
|
||||||
const params = astNode.getParamNames(functionDeclaration3);
|
const params = astNode.getParamNames(functionDeclaration3);
|
||||||
|
|
||||||
expect( Array.isArray(params) ).toBe(true);
|
expect(params).toEqual([
|
||||||
expect(params.length).toBe(3);
|
'bar',
|
||||||
expect(params[0]).toBe('bar');
|
'baz',
|
||||||
expect(params[1]).toBe('baz');
|
'qux'
|
||||||
expect(params[2]).toBe('qux');
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should include rest parameters', () => {
|
it('should include rest parameters', () => {
|
||||||
const params = astNode.getParamNames(functionDeclaration4);
|
const params = astNode.getParamNames(functionDeclaration4);
|
||||||
|
|
||||||
expect( Array.isArray(params) ).toBe(true);
|
expect(params).toEqual(['bar']);
|
||||||
expect(params.length).toBe(1);
|
|
||||||
expect(params[0]).toBe('bar');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isAccessor', () => {
|
describe('isAccessor', () => {
|
||||||
it('should return false for undefined values', () => {
|
it('should return false for undefined values', () => {
|
||||||
expect( astNode.isAccessor() ).toBe(false);
|
expect( astNode.isAccessor() ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false if the parameter is not an object', () => {
|
it('should return false if the parameter is not an object', () => {
|
||||||
expect( astNode.isAccessor('foo') ).toBe(false);
|
expect( astNode.isAccessor('foo') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for non-Property nodes', () => {
|
it('should return false for non-Property nodes', () => {
|
||||||
expect( astNode.isAccessor(binaryExpression) ).toBe(false);
|
expect( astNode.isAccessor(binaryExpression) ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for Property nodes whose kind is "init"', () => {
|
it('should return false for Property nodes whose kind is "init"', () => {
|
||||||
expect( astNode.isAccessor(propertyInit) ).toBe(false);
|
expect( astNode.isAccessor(propertyInit) ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true for Property nodes whose kind is "get"', () => {
|
it('should return true for Property nodes whose kind is "get"', () => {
|
||||||
expect( astNode.isAccessor(propertyGet) ).toBe(true);
|
expect( astNode.isAccessor(propertyGet) ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true for Property nodes whose kind is "set"', () => {
|
it('should return true for Property nodes whose kind is "set"', () => {
|
||||||
expect( astNode.isAccessor(propertySet) ).toBe(true);
|
expect( astNode.isAccessor(propertySet) ).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isAssignment', () => {
|
describe('isAssignment', () => {
|
||||||
it('should return false for undefined values', () => {
|
it('should return false for undefined values', () => {
|
||||||
expect( astNode.isAssignment() ).toBe(false);
|
expect( astNode.isAssignment() ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false if the parameter is not an object', () => {
|
it('should return false if the parameter is not an object', () => {
|
||||||
expect( astNode.isAssignment('foo') ).toBe(false);
|
expect( astNode.isAssignment('foo') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for nodes that are not assignments', () => {
|
it('should return false for nodes that are not assignments', () => {
|
||||||
expect( astNode.isAssignment(binaryExpression) ).toBe(false);
|
expect( astNode.isAssignment(binaryExpression) ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true for AssignmentExpression nodes', () => {
|
it('should return true for AssignmentExpression nodes', () => {
|
||||||
expect( astNode.isAssignment(assignmentExpression) ).toBe(true);
|
expect( astNode.isAssignment(assignmentExpression) ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true for VariableDeclarator nodes', () => {
|
it('should return true for VariableDeclarator nodes', () => {
|
||||||
expect( astNode.isAssignment(variableDeclarator1) ).toBe(true);
|
expect( astNode.isAssignment(variableDeclarator1) ).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isFunction', () => {
|
describe('isFunction', () => {
|
||||||
it('should recognize function declarations as functions', () => {
|
it('should recognize function declarations as functions', () => {
|
||||||
expect( astNode.isFunction(functionDeclaration1) ).toBe(true);
|
expect( astNode.isFunction(functionDeclaration1) ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should recognize function expressions as functions', () => {
|
it('should recognize function expressions as functions', () => {
|
||||||
expect( astNode.isFunction(functionExpression1) ).toBe(true);
|
expect( astNode.isFunction(functionExpression1) ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should recognize method definitions as functions', () => {
|
it('should recognize method definitions as functions', () => {
|
||||||
expect( astNode.isFunction(methodDefinition1) ).toBe(true);
|
expect( astNode.isFunction(methodDefinition1) ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should recognize arrow function expressions as functions', () => {
|
it('should recognize arrow function expressions as functions', () => {
|
||||||
expect( astNode.isFunction(arrowFunctionExpression) ).toBe(true);
|
expect( astNode.isFunction(arrowFunctionExpression) ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should recognize non-functions', () => {
|
it('should recognize non-functions', () => {
|
||||||
expect( astNode.isFunction(arrayExpression) ).toBe(false);
|
expect( astNode.isFunction(arrayExpression) ).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isScope', () => {
|
describe('isScope', () => {
|
||||||
it('should return false for undefined values', () => {
|
it('should return false for undefined values', () => {
|
||||||
expect( astNode.isScope() ).toBe(false);
|
expect( astNode.isScope() ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false if the parameter is not an object', () => {
|
it('should return false if the parameter is not an object', () => {
|
||||||
expect( astNode.isScope('foo') ).toBe(false);
|
expect( astNode.isScope('foo') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true for CatchClause nodes', () => {
|
it('should return true for CatchClause nodes', () => {
|
||||||
expect( astNode.isScope({type: Syntax.CatchClause}) ).toBe(true);
|
expect( astNode.isScope({type: Syntax.CatchClause}) ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true for FunctionDeclaration nodes', () => {
|
it('should return true for FunctionDeclaration nodes', () => {
|
||||||
expect( astNode.isScope({type: Syntax.FunctionDeclaration}) ).toBe(true);
|
expect( astNode.isScope({type: Syntax.FunctionDeclaration}) ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true for FunctionExpression nodes', () => {
|
it('should return true for FunctionExpression nodes', () => {
|
||||||
expect( astNode.isScope({type: Syntax.FunctionExpression}) ).toBe(true);
|
expect( astNode.isScope({type: Syntax.FunctionExpression}) ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for other nodes', () => {
|
it('should return false for other nodes', () => {
|
||||||
expect( astNode.isScope({type: Syntax.NameExpression}) ).toBe(false);
|
expect( astNode.isScope({type: Syntax.NameExpression}) ).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -4,13 +4,11 @@ describe('jsdoc/src/filter', () => {
|
|||||||
const path = require('jsdoc/path');
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(filter).toBeDefined();
|
expect(filter).toBeObject();
|
||||||
expect(typeof filter).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "Filter" class', () => {
|
it('should export a "Filter" class', () => {
|
||||||
expect(filter.Filter).toBeDefined();
|
expect(filter.Filter).toBeFunction();
|
||||||
expect(typeof filter.Filter).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Filter', () => {
|
describe('Filter', () => {
|
||||||
@ -36,13 +34,12 @@ describe('jsdoc/src/filter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "isIncluded" method', () => {
|
it('should have an "isIncluded" method', () => {
|
||||||
expect(myFilter.isIncluded).toBeDefined();
|
expect(myFilter.isIncluded).toBeFunction();
|
||||||
expect(typeof myFilter.isIncluded).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('exclude', () => {
|
describe('exclude', () => {
|
||||||
it('should default to null', () => {
|
it('should default to null', () => {
|
||||||
expect(myFilter.exclude).toBe(null);
|
expect(myFilter.exclude).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be null if the value passed to the constructor was not an array',
|
it('should be null if the value passed to the constructor was not an array',
|
||||||
@ -51,7 +48,7 @@ describe('jsdoc/src/filter', () => {
|
|||||||
exclude: 'foo'
|
exclude: 'foo'
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(myFilter.exclude).toBe(null);
|
expect(myFilter.exclude).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should resolve paths relative to the user\'s working directory', () => {
|
it('should resolve paths relative to the user\'s working directory', () => {
|
||||||
@ -67,7 +64,7 @@ describe('jsdoc/src/filter', () => {
|
|||||||
|
|
||||||
function testRegExpProperty(name) {
|
function testRegExpProperty(name) {
|
||||||
it('should default to null', () => {
|
it('should default to null', () => {
|
||||||
expect(myFilter[name]).toBe(null);
|
expect(myFilter[name]).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the regexp passed to the constructor', () => {
|
it('should contain the regexp passed to the constructor', () => {
|
||||||
@ -87,7 +84,7 @@ describe('jsdoc/src/filter', () => {
|
|||||||
options[name] = regExpString;
|
options[name] = regExpString;
|
||||||
myFilter = new filter.Filter(options);
|
myFilter = new filter.Filter(options);
|
||||||
|
|
||||||
expect(myFilter[name] instanceof RegExp).toBe(true);
|
expect(myFilter[name]).toBeRegExp();
|
||||||
expect(myFilter[name].source).toBe(regExpString);
|
expect(myFilter[name].source).toBe(regExpString);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -114,9 +111,9 @@ describe('jsdoc/src/filter', () => {
|
|||||||
|
|
||||||
files = files.filter($ => myFilter.isIncluded($));
|
files = files.filter($ => myFilter.isIncluded($));
|
||||||
|
|
||||||
expect(files.length).toEqual(2);
|
expect(files).toBeArrayOfSize(2);
|
||||||
expect( files.indexOf('yes.js') ).toBeGreaterThan(-1);
|
expect( files.includes('yes.js') ).toBeTrue();
|
||||||
expect( files.indexOf('/yes.jsdoc') ).toBeGreaterThan(-1);
|
expect( files.includes('/yes.jsdoc') ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to exclude specific subdirectories', () => {
|
it('should be able to exclude specific subdirectories', () => {
|
||||||
@ -135,9 +132,9 @@ describe('jsdoc/src/filter', () => {
|
|||||||
|
|
||||||
files = files.filter($ => myFilter.isIncluded($));
|
files = files.filter($ => myFilter.isIncluded($));
|
||||||
|
|
||||||
expect(files.length).toBe(2);
|
expect(files).toBeArrayOfSize(2);
|
||||||
expect( files.indexOf('yes.js') ).toBeGreaterThan(-1);
|
expect( files.includes('yes.js') ).toBeTrue();
|
||||||
expect( files.indexOf('module/yes.js') ).toBeGreaterThan(-1);
|
expect( files.includes('module/yes.js') ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to exclude descendants of excluded subdirectories', () => {
|
it('should be able to exclude descendants of excluded subdirectories', () => {
|
||||||
@ -156,11 +153,11 @@ describe('jsdoc/src/filter', () => {
|
|||||||
|
|
||||||
files = files.filter($ => myFilter.isIncluded($));
|
files = files.filter($ => myFilter.isIncluded($));
|
||||||
|
|
||||||
expect(files.length).toBe(2);
|
expect(files).toBeArrayOfSize(2);
|
||||||
expect( files.indexOf('yes.js') ).toBeGreaterThan(-1);
|
expect( files.includes('yes.js') ).toBeTrue();
|
||||||
expect( files.indexOf('module/yes.js') ).toBeGreaterThan(-1);
|
expect( files.includes('module/yes.js') ).toBeTrue();
|
||||||
expect( files.indexOf('topsecret/nested/nope.js') ).toBe(-1);
|
expect( files.includes('topsecret/nested/nope.js') ).toBeFalse();
|
||||||
expect( files.indexOf('module/topsecret/nested/nope.js') ).toBe(-1);
|
expect( files.includes('module/topsecret/nested/nope.js') ).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,38 +6,33 @@ describe('jsdoc/src/handlers', () => {
|
|||||||
handlers.attachTo(testParser);
|
handlers.attachTo(testParser);
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(handlers).toBeDefined();
|
expect(handlers).toBeObject();
|
||||||
expect(typeof handlers).toEqual('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an "attachTo" function', () => {
|
it('should export an "attachTo" function', () => {
|
||||||
expect(handlers.attachTo).toBeDefined();
|
expect(handlers.attachTo).toBeFunction();
|
||||||
expect(typeof handlers.attachTo).toEqual('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('attachTo', () => {
|
describe('attachTo', () => {
|
||||||
it('should attach a "jsdocCommentFound" handler to the parser', () => {
|
it('should attach a "jsdocCommentFound" handler to the parser', () => {
|
||||||
const callbacks = testParser.listeners('jsdocCommentFound');
|
const callbacks = testParser.listeners('jsdocCommentFound');
|
||||||
|
|
||||||
expect(callbacks).toBeDefined();
|
expect(callbacks).toBeArrayOfSize(1);
|
||||||
expect(callbacks.length).toEqual(1);
|
expect(callbacks[0]).toBeFunction();
|
||||||
expect(typeof callbacks[0]).toEqual('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should attach a "symbolFound" handler to the parser', () => {
|
it('should attach a "symbolFound" handler to the parser', () => {
|
||||||
const callbacks = testParser.listeners('symbolFound');
|
const callbacks = testParser.listeners('symbolFound');
|
||||||
|
|
||||||
expect(callbacks).toBeDefined();
|
expect(callbacks).toBeArrayOfSize(1);
|
||||||
expect(callbacks.length).toEqual(1);
|
expect(callbacks[0]).toBeFunction();
|
||||||
expect(typeof callbacks[0]).toEqual('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should attach a "fileComplete" handler to the parser', () => {
|
it('should attach a "fileComplete" handler to the parser', () => {
|
||||||
const callbacks = testParser.listeners('fileComplete');
|
const callbacks = testParser.listeners('fileComplete');
|
||||||
|
|
||||||
expect(callbacks).toBeDefined();
|
expect(callbacks).toBeArrayOfSize(1);
|
||||||
expect(callbacks.length).toEqual(1);
|
expect(callbacks[0]).toBeFunction();
|
||||||
expect(typeof callbacks[0]).toEqual('function');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -48,8 +43,8 @@ describe('jsdoc/src/handlers', () => {
|
|||||||
const result = testParser.parse(sourceCode);
|
const result = testParser.parse(sourceCode);
|
||||||
|
|
||||||
it('should create a doclet for comments with "@name" tags', () => {
|
it('should create a doclet for comments with "@name" tags', () => {
|
||||||
expect(result.length).toEqual(1);
|
expect(result).toBeArrayOfSize(1);
|
||||||
expect(result[0].name).toEqual('bar');
|
expect(result[0].name).toBe('bar');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -8,27 +8,26 @@ describe('jsdoc/src/parser', () => {
|
|||||||
const path = require('jsdoc/path');
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(jsdocParser).toBeDefined();
|
expect(jsdocParser).toBeObject();
|
||||||
expect(typeof jsdocParser).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "createParser" method', () => {
|
it('should export a "createParser" method', () => {
|
||||||
expect(typeof jsdocParser.createParser).toBe('function');
|
expect(jsdocParser.createParser).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "Parser" constructor', () => {
|
it('should export a "Parser" constructor', () => {
|
||||||
expect(typeof jsdocParser.Parser).toBe('function');
|
expect(jsdocParser.Parser).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('createParser', () => {
|
describe('createParser', () => {
|
||||||
it('should return a Parser when called without arguments', () => {
|
it('should return a Parser when called without arguments', () => {
|
||||||
expect(typeof jsdocParser.createParser()).toBe('object');
|
expect(jsdocParser.createParser()).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a jsdoc/src/parser.Parser instance with the argument "js"', () => {
|
it('should create a jsdoc/src/parser.Parser instance with the argument "js"', () => {
|
||||||
const parser = jsdocParser.createParser('js');
|
const parser = jsdocParser.createParser('js');
|
||||||
|
|
||||||
expect(parser instanceof jsdocParser.Parser).toBe(true);
|
expect(parser instanceof jsdocParser.Parser).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log a fatal error on bad input', () => {
|
it('should log a fatal error on bad input', () => {
|
||||||
@ -49,15 +48,15 @@ describe('jsdoc/src/parser', () => {
|
|||||||
newParser();
|
newParser();
|
||||||
|
|
||||||
it('should have an "astBuilder" property', () => {
|
it('should have an "astBuilder" property', () => {
|
||||||
expect(parser.astBuilder).toBeDefined();
|
expect(parser.astBuilder).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "visitor" property', () => {
|
it('should have a "visitor" property', () => {
|
||||||
expect(parser.visitor).toBeDefined();
|
expect(parser.visitor).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "walker" property', () => {
|
it('should have a "walker" property', () => {
|
||||||
expect(parser.walker).toBeDefined();
|
expect(parser.walker).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept an astBuilder, visitor, and walker as arguments', () => {
|
it('should accept an astBuilder, visitor, and walker as arguments', () => {
|
||||||
@ -77,40 +76,42 @@ describe('jsdoc/src/parser', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "parse" method', () => {
|
it('should have a "parse" method', () => {
|
||||||
expect(parser.parse).toBeDefined();
|
expect(parser.parse).toBeFunction();
|
||||||
expect(typeof parser.parse).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "results" method', () => {
|
it('should have a "results" method', () => {
|
||||||
expect(parser.results).toBeDefined();
|
expect(parser.results).toBeFunction();
|
||||||
expect(typeof parser.results).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "addAstNodeVisitor" method', () => {
|
it('should have an "addAstNodeVisitor" method', () => {
|
||||||
expect(parser.addAstNodeVisitor).toBeDefined();
|
expect(parser.addAstNodeVisitor).toBeFunction();
|
||||||
expect(typeof parser.addAstNodeVisitor).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "getAstNodeVisitors" method', () => {
|
it('should have a "getAstNodeVisitors" method', () => {
|
||||||
expect(parser.getAstNodeVisitors).toBeDefined();
|
expect(parser.getAstNodeVisitors).toBeFunction();
|
||||||
expect(typeof parser.getAstNodeVisitors).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('astBuilder', () => {
|
describe('astBuilder', () => {
|
||||||
it('should contain an appropriate astBuilder by default', () => {
|
it('should contain an appropriate astBuilder by default', () => {
|
||||||
expect(parser.astBuilder instanceof (require('jsdoc/src/astbuilder')).AstBuilder).toBe(true);
|
const { AstBuilder } = require('jsdoc/src/astbuilder');
|
||||||
|
|
||||||
|
expect(parser.astBuilder instanceof AstBuilder).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('visitor', () => {
|
describe('visitor', () => {
|
||||||
it('should contain an appropriate visitor by default', () => {
|
it('should contain an appropriate visitor by default', () => {
|
||||||
expect(parser.visitor instanceof (require('jsdoc/src/visitor')).Visitor).toBe(true);
|
const { Visitor } = require('jsdoc/src/visitor');
|
||||||
|
|
||||||
|
expect(parser.visitor instanceof Visitor).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('walker', () => {
|
describe('walker', () => {
|
||||||
it('should contain an appropriate walker by default', () => {
|
it('should contain an appropriate walker by default', () => {
|
||||||
expect(parser.walker instanceof (require('jsdoc/src/walker')).Walker).toBe(true);
|
const { Walker } = require('jsdoc/src/walker');
|
||||||
|
|
||||||
|
expect(parser.walker instanceof Walker).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -203,23 +204,19 @@ describe('jsdoc/src/parser', () => {
|
|||||||
parser.addAstNodeVisitor(visitor);
|
parser.addAstNodeVisitor(visitor);
|
||||||
parser.parse(sourceCode);
|
parser.parse(sourceCode);
|
||||||
|
|
||||||
expect(args).toBeDefined();
|
expect(args).toBeArrayOfSize(4);
|
||||||
expect( Array.isArray(args) ).toBe(true);
|
|
||||||
expect(args.length).toBe(4);
|
|
||||||
|
|
||||||
// args[0]: AST node
|
// args[0]: AST node
|
||||||
expect(args[0].type).toBeDefined();
|
|
||||||
expect(args[0].type).toBe(Syntax.VariableDeclarator);
|
expect(args[0].type).toBe(Syntax.VariableDeclarator);
|
||||||
|
|
||||||
// args[1]: JSDoc event
|
// args[1]: JSDoc event
|
||||||
expect(typeof args[1]).toBe('object');
|
expect(args[1]).toBeObject();
|
||||||
expect(args[1].code).toBeDefined();
|
expect(args[1].code).toBeObject();
|
||||||
expect(args[1].code.name).toBeDefined();
|
|
||||||
expect(args[1].code.name).toBe('foo');
|
expect(args[1].code.name).toBe('foo');
|
||||||
|
|
||||||
// args[2]: parser
|
// args[2]: parser
|
||||||
expect(typeof args[2]).toBe('object');
|
expect(args[2]).toBeObject();
|
||||||
expect(args[2] instanceof jsdocParser.Parser).toBe(true);
|
expect(args[2] instanceof jsdocParser.Parser).toBeTrue();
|
||||||
|
|
||||||
// args[3]: current source name
|
// args[3]: current source name
|
||||||
expect( String(args[3]) ).toBe('[[string0]]');
|
expect( String(args[3]) ).toBe('[[string0]]');
|
||||||
@ -242,9 +239,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
|
|
||||||
doclet = parser.results()[0];
|
doclet = parser.results()[0];
|
||||||
|
|
||||||
expect(doclet).toBeDefined();
|
expect(doclet).toBeObject();
|
||||||
expect(typeof doclet).toBe('object');
|
|
||||||
expect(doclet.name).toBeDefined();
|
|
||||||
expect(doclet.name).toBe('bar');
|
expect(doclet.name).toBe('bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -259,12 +254,11 @@ describe('jsdoc/src/parser', () => {
|
|||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
|
|
||||||
eventObject = spy.calls.mostRecent().args[0];
|
eventObject = spy.calls.mostRecent().args[0];
|
||||||
|
|
||||||
expect(eventObject).toBeDefined();
|
expect(eventObject).toBeDefined();
|
||||||
expect( Array.isArray(eventObject.sourcefiles) ).toBe(true);
|
expect(eventObject.sourcefiles).toEqual(['[[string0]]']);
|
||||||
expect(eventObject.sourcefiles.length).toBe(1);
|
|
||||||
expect(eventObject.sourcefiles[0]).toBe('[[string0]]');
|
expect(eventObject.doclets).toBeArrayOfSize(1);
|
||||||
expect( Array.isArray(eventObject.doclets) ).toBe(true);
|
|
||||||
expect(eventObject.doclets.length).toBe(1);
|
|
||||||
expect(eventObject.doclets[0].kind).toBe('class');
|
expect(eventObject.doclets[0].kind).toBe('class');
|
||||||
expect(eventObject.doclets[0].longname).toBe('Foo');
|
expect(eventObject.doclets[0].longname).toBe('Foo');
|
||||||
});
|
});
|
||||||
@ -272,13 +266,15 @@ describe('jsdoc/src/parser', () => {
|
|||||||
it('should fire a "processingComplete" event when fireProcessingComplete is called', () => {
|
it('should fire a "processingComplete" event when fireProcessingComplete is called', () => {
|
||||||
const spy = jasmine.createSpy();
|
const spy = jasmine.createSpy();
|
||||||
const doclets = ['a', 'b'];
|
const doclets = ['a', 'b'];
|
||||||
|
let mostRecentArg0;
|
||||||
|
|
||||||
parser.on('processingComplete', spy).fireProcessingComplete(doclets);
|
parser.on('processingComplete', spy).fireProcessingComplete(doclets);
|
||||||
|
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
expect(typeof spy.calls.mostRecent().args[0]).toBe('object');
|
|
||||||
expect(spy.calls.mostRecent().args[0].doclets).toBeDefined();
|
mostRecentArg0 = spy.calls.mostRecent().args[0];
|
||||||
expect(spy.calls.mostRecent().args[0].doclets).toBe(doclets);
|
expect(mostRecentArg0).toBeObject();
|
||||||
|
expect(mostRecentArg0.doclets).toBe(doclets);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not throw errors when parsing files with ES6 syntax', () => {
|
it('should not throw errors when parsing files with ES6 syntax', () => {
|
||||||
@ -320,9 +316,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
it('returns an empty array before files are parsed', () => {
|
it('returns an empty array before files are parsed', () => {
|
||||||
const results = parser.results();
|
const results = parser.results();
|
||||||
|
|
||||||
expect(results).toBeDefined();
|
expect(results).toBeEmptyArray();
|
||||||
expect( Array.isArray(results) ).toBe(true);
|
|
||||||
expect(results.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns an array of doclets after files are parsed', () => {
|
it('returns an array of doclets after files are parsed', () => {
|
||||||
@ -334,10 +328,8 @@ describe('jsdoc/src/parser', () => {
|
|||||||
parser.parse(source);
|
parser.parse(source);
|
||||||
results = parser.results();
|
results = parser.results();
|
||||||
|
|
||||||
expect(results).toBeDefined();
|
expect(results).toBeArrayOfSize(1);
|
||||||
expect(results[0]).toBeDefined();
|
expect(results[0]).toBeObject();
|
||||||
expect(typeof results[0]).toBe('object');
|
|
||||||
expect(results[0].name).toBeDefined();
|
|
||||||
expect(results[0].name).toBe('foo');
|
expect(results[0].name).toBe('foo');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -413,8 +405,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
|
|
||||||
visitors = parser.getAstNodeVisitors();
|
visitors = parser.getAstNodeVisitors();
|
||||||
|
|
||||||
expect(visitors.length).toBe(1);
|
expect(visitors).toEqual([visitorA]);
|
||||||
expect(visitors[0]).toBe(visitorA);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work with multiple node visitors', () => {
|
it('should work with multiple node visitors', () => {
|
||||||
@ -423,9 +414,10 @@ describe('jsdoc/src/parser', () => {
|
|||||||
|
|
||||||
visitors = parser.getAstNodeVisitors();
|
visitors = parser.getAstNodeVisitors();
|
||||||
|
|
||||||
expect(visitors.length).toBe(2);
|
expect(visitors).toEqual([
|
||||||
expect(visitors[0]).toBe(visitorA);
|
visitorA,
|
||||||
expect(visitors[1]).toBe(visitorB);
|
visitorB
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -435,8 +427,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
it('should return an empty array by default', () => {
|
it('should return an empty array by default', () => {
|
||||||
const visitors = parser.getAstNodeVisitors();
|
const visitors = parser.getAstNodeVisitors();
|
||||||
|
|
||||||
expect( Array.isArray(visitors) ).toBe(true);
|
expect(visitors).toBeEmptyArray();
|
||||||
expect(visitors.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// other functionality is covered by the addNodeVisitors tests
|
// other functionality is covered by the addNodeVisitors tests
|
||||||
|
|||||||
@ -10,28 +10,25 @@ describe('jsdoc/src/scanner', () => {
|
|||||||
const sourcePath = path.normalize(`${env.pwd}/test/fixtures/src`);
|
const sourcePath = path.normalize(`${env.pwd}/test/fixtures/src`);
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(scanner).toBeDefined();
|
expect(scanner).toBeObject();
|
||||||
expect(typeof scanner).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "Scanner" class', () => {
|
it('should export a "Scanner" class', () => {
|
||||||
expect(scanner.Scanner).toBeDefined();
|
expect(scanner.Scanner).toBeFunction();
|
||||||
expect(typeof scanner.Scanner).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Scanner', () => {
|
describe('Scanner', () => {
|
||||||
it('should inherit from EventEmitter', () => {
|
it('should inherit from EventEmitter', () => {
|
||||||
const EventEmitter = require('events').EventEmitter;
|
const { EventEmitter } = require('events');
|
||||||
const testScanner = new scanner.Scanner();
|
const testScanner = new scanner.Scanner();
|
||||||
|
|
||||||
expect(testScanner instanceof EventEmitter).toBe(true);
|
expect(testScanner instanceof EventEmitter).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "scan" method', () => {
|
it('should have a "scan" method', () => {
|
||||||
const testScanner = new scanner.Scanner();
|
const testScanner = new scanner.Scanner();
|
||||||
|
|
||||||
expect(testScanner.scan).toBeDefined();
|
expect(testScanner.scan).toBeFunction();
|
||||||
expect(typeof testScanner.scan).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('scan', () => {
|
describe('scan', () => {
|
||||||
@ -41,13 +38,13 @@ describe('jsdoc/src/scanner', () => {
|
|||||||
|
|
||||||
sourceFiles = sourceFiles.map($ => path.relative(env.pwd, $));
|
sourceFiles = sourceFiles.map($ => path.relative(env.pwd, $));
|
||||||
|
|
||||||
expect(sourceFiles.length).toEqual(3);
|
expect(sourceFiles).toBeArrayOfSize(3);
|
||||||
expect( sourceFiles.indexOf(path.join('test', 'fixtures', 'src', 'one.js')) )
|
expect( sourceFiles.includes(path.join('test', 'fixtures', 'src', 'one.js')) )
|
||||||
.toBeGreaterThan(-1);
|
.toBeTrue();
|
||||||
expect( sourceFiles.indexOf(path.join('test', 'fixtures', 'src', 'two.js')) )
|
expect( sourceFiles.includes(path.join('test', 'fixtures', 'src', 'two.js')) )
|
||||||
.toBeGreaterThan(-1);
|
.toBeTrue();
|
||||||
expect( sourceFiles.indexOf(path.join('test', 'fixtures', 'src', 'dir1', 'three.js')) )
|
expect( sourceFiles.includes(path.join('test', 'fixtures', 'src', 'dir1', 'three.js')) )
|
||||||
.toBeGreaterThan(-1);
|
.toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,7 +2,6 @@ describe('jsdoc/src/syntax', () => {
|
|||||||
const Syntax = require('jsdoc/src/syntax').Syntax;
|
const Syntax = require('jsdoc/src/syntax').Syntax;
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(Syntax).toBeDefined();
|
expect(Syntax).toBeObject();
|
||||||
expect(typeof Syntax).toBe('object');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -42,7 +42,7 @@ describe('jsdoc/src/visitor', () => {
|
|||||||
|
|
||||||
visitor.visitNodeComments(node, parser, 'fake');
|
visitor.visitNodeComments(node, parser, 'fake');
|
||||||
|
|
||||||
expect(events).toEqual([]);
|
expect(events).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ignore normal, non-JSDoc block comments', () => {
|
it('should ignore normal, non-JSDoc block comments', () => {
|
||||||
@ -63,7 +63,7 @@ describe('jsdoc/src/visitor', () => {
|
|||||||
|
|
||||||
visitor.visitNodeComments(node, parser, 'fake');
|
visitor.visitNodeComments(node, parser, 'fake');
|
||||||
|
|
||||||
expect(events).toEqual([]);
|
expect(events).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ignore comments that begin with three or more asterisks', () => {
|
it('should ignore comments that begin with three or more asterisks', () => {
|
||||||
@ -84,7 +84,7 @@ describe('jsdoc/src/visitor', () => {
|
|||||||
|
|
||||||
visitor.visitNodeComments(node, parser, 'fake');
|
visitor.visitNodeComments(node, parser, 'fake');
|
||||||
|
|
||||||
expect(events).toEqual([]);
|
expect(events).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ignore empty block comments', () => {
|
it('should ignore empty block comments', () => {
|
||||||
@ -105,7 +105,7 @@ describe('jsdoc/src/visitor', () => {
|
|||||||
|
|
||||||
visitor.visitNodeComments(node, parser, 'fake');
|
visitor.visitNodeComments(node, parser, 'fake');
|
||||||
|
|
||||||
expect(events).toEqual([]);
|
expect(events).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fire an event for JSDoc comments', () => {
|
it('should fire an event for JSDoc comments', () => {
|
||||||
@ -126,14 +126,13 @@ describe('jsdoc/src/visitor', () => {
|
|||||||
|
|
||||||
visitor.visitNodeComments(node, parser, 'fake');
|
visitor.visitNodeComments(node, parser, 'fake');
|
||||||
|
|
||||||
expect(events.length).toBe(1);
|
expect(events).toBeArrayOfSize(1);
|
||||||
expect(events[0].comment).toBe('/** block comment */');
|
expect(events[0].comment).toBe('/** block comment */');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: these tests aren't working; for some strange reason, Node.js 6.10.2 stops running code
|
// TODO: these tests aren't working; the code for visitor.visitNode() stops running in the
|
||||||
// for visitor.visitNode() while it's in the middle of the SymbolFound constructor. maybe a
|
// middle of the SymbolFound constructor. maybe an async issue?
|
||||||
// version-specific bug?
|
|
||||||
xdescribe('visitNode', () => {
|
xdescribe('visitNode', () => {
|
||||||
// TODO: more tests
|
// TODO: more tests
|
||||||
|
|
||||||
|
|||||||
@ -2,29 +2,25 @@ describe('jsdoc/src/walker', () => {
|
|||||||
const walker = require('jsdoc/src/walker');
|
const walker = require('jsdoc/src/walker');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(walker).toBeDefined();
|
expect(walker).toBeObject();
|
||||||
expect(typeof walker).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "walkers" object', () => {
|
it('should export a "walkers" object', () => {
|
||||||
expect(walker.walkers).toBeDefined();
|
expect(walker.walkers).toBeObject();
|
||||||
expect(typeof walker.walkers).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "Walker" class', () => {
|
it('should export a "Walker" class', () => {
|
||||||
expect(walker.Walker).toBeDefined();
|
expect(walker.Walker).toBeFunction();
|
||||||
expect(typeof walker.Walker).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('walkers', () => {
|
describe('walkers', () => {
|
||||||
const Syntax = require('jsdoc/src/syntax').Syntax;
|
const { Syntax } = require('jsdoc/src/syntax');
|
||||||
|
|
||||||
// TODO: tests for default functions
|
// TODO: tests for default functions
|
||||||
|
|
||||||
it('should contain a function for each known node type', () => {
|
it('should contain a function for each known node type', () => {
|
||||||
Object.keys(Syntax).forEach(nodeType => {
|
Object.keys(Syntax).forEach(nodeType => {
|
||||||
expect(walker.walkers[nodeType]).toBeDefined();
|
expect(walker.walkers[nodeType]).toBeFunction();
|
||||||
expect(typeof walker.walkers[nodeType]).toBe('function');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,13 +8,11 @@ describe('jsdoc/tag', () => {
|
|||||||
const parseType = require('jsdoc/tag/type').parse;
|
const parseType = require('jsdoc/tag/type').parse;
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(jsdocTag).toBeDefined();
|
expect(jsdocTag).toBeObject();
|
||||||
expect(typeof jsdocTag).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a Tag function', () => {
|
it('should export a Tag function', () => {
|
||||||
expect(jsdocTag.Tag).toBeDefined();
|
expect(jsdocTag.Tag).toBeFunction();
|
||||||
expect(typeof jsdocTag.Tag).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Tag', () => {
|
describe('Tag', () => {
|
||||||
@ -66,8 +64,7 @@ describe('jsdoc/tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'originalTitle' property, a string", () => {
|
it("should have a 'originalTitle' property, a string", () => {
|
||||||
expect(tagArg.originalTitle).toBeDefined();
|
expect(tagArg.originalTitle).toBeString();
|
||||||
expect(typeof tagArg.originalTitle).toBe('string');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'originalTitle' property should be the initial tag title, trimmed of whitespace", () => {
|
it("'originalTitle' property should be the initial tag title, trimmed of whitespace", () => {
|
||||||
@ -76,8 +73,7 @@ describe('jsdoc/tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'title' property, a string", () => {
|
it("should have a 'title' property, a string", () => {
|
||||||
expect(tagArg.title).toBeDefined();
|
expect(tagArg.title).toBeString();
|
||||||
expect(typeof tagArg.title).toBe('string');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'title' property should be the normalized tag title", () => {
|
it("'title' property should be the normalized tag title", () => {
|
||||||
@ -86,8 +82,7 @@ describe('jsdoc/tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'text' property, a string", () => {
|
it("should have a 'text' property, a string", () => {
|
||||||
expect(tagArg.text).toBeDefined();
|
expect(tagArg.text).toBeString();
|
||||||
expect(typeof tagArg.text).toBe('string');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'value' property", () => {
|
it("should have a 'value' property", () => {
|
||||||
@ -108,11 +103,9 @@ describe('jsdoc/tag', () => {
|
|||||||
it("'text' property should have onTagText run on it if it has it.", () => {
|
it("'text' property should have onTagText run on it if it has it.", () => {
|
||||||
const def = jsdocDictionary.lookUp('type');
|
const def = jsdocDictionary.lookUp('type');
|
||||||
|
|
||||||
expect(def.onTagText).toBeDefined();
|
expect(def.onTagText).toBeFunction();
|
||||||
expect(typeof def.onTagText).toBe('function');
|
|
||||||
|
|
||||||
// @type adds {} around the type if necessary.
|
// @type adds {} around the type if necessary.
|
||||||
expect(tagType.text).toBeDefined();
|
|
||||||
expect(tagType.text).toBe(def.onTagText('MyType'));
|
expect(tagType.text).toBe(def.onTagText('MyType'));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -138,6 +131,12 @@ describe('jsdoc/tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("'value' property", () => {
|
describe("'value' property", () => {
|
||||||
|
const debug = Boolean(env.opts.debug);
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
env.opts.debug = debug;
|
||||||
|
});
|
||||||
|
|
||||||
it("'value' property should equal tag text if tagDef.canHaveType and canHaveName are both false", () => {
|
it("'value' property should equal tag text if tagDef.canHaveType and canHaveName are both false", () => {
|
||||||
// @example can't have type or name
|
// @example can't have type or name
|
||||||
expect(typeof tagExample.value).toBe('string');
|
expect(typeof tagExample.value).toBe('string');
|
||||||
@ -155,7 +154,8 @@ describe('jsdoc/tag', () => {
|
|||||||
let info;
|
let info;
|
||||||
|
|
||||||
def = jsdocDictionary.lookUp(tag.title);
|
def = jsdocDictionary.lookUp(tag.title);
|
||||||
expect(def).not.toBe(false);
|
|
||||||
|
expect(def).toBeObject();
|
||||||
|
|
||||||
info = parseType(tag.text, def.canHaveName, def.canHaveType);
|
info = parseType(tag.text, def.canHaveName, def.canHaveType);
|
||||||
|
|
||||||
@ -166,13 +166,10 @@ describe('jsdoc/tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (info.type && info.type.length) {
|
if (info.type && info.type.length) {
|
||||||
expect(tag.value.type).toBeDefined();
|
expect(tag.value.type).toBeObject();
|
||||||
expect(typeof tag.value.type).toBe('object');
|
|
||||||
expect(tag.value.type.names).toBeDefined();
|
|
||||||
expect(tag.value.type.names).toEqual(info.type);
|
expect(tag.value.type.names).toEqual(info.type);
|
||||||
|
|
||||||
expect(tag.value.type.parsedType).toBeDefined();
|
expect(tag.value.type.parsedType).toBeObject();
|
||||||
expect(typeof tag.value.type.parsedType).toBe('object');
|
|
||||||
|
|
||||||
descriptor = Object.getOwnPropertyDescriptor(tag.value.type, 'parsedType');
|
descriptor = Object.getOwnPropertyDescriptor(tag.value.type, 'parsedType');
|
||||||
expect(descriptor.enumerable).toBe( Boolean(env.opts.debug) );
|
expect(descriptor.enumerable).toBe( Boolean(env.opts.debug) );
|
||||||
@ -180,9 +177,7 @@ describe('jsdoc/tag', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('if the tag has a type, tag.value should contain the type information', () => {
|
it('if the tag has a type, tag.value should contain the type information', () => {
|
||||||
// we assume jsdoc/tag/type.parse works (it has its own tests to verify this);
|
// we assume jsdoc/tag/type.parse works (it has its own tests to verify this)
|
||||||
const debug = Boolean(env.opts.debug);
|
|
||||||
|
|
||||||
[true, false].forEach(bool => {
|
[true, false].forEach(bool => {
|
||||||
env.opts.debug = bool;
|
env.opts.debug = bool;
|
||||||
createTags();
|
createTags();
|
||||||
@ -191,27 +186,21 @@ describe('jsdoc/tag', () => {
|
|||||||
verifyTagType(tagArg);
|
verifyTagType(tagArg);
|
||||||
verifyTagType(tagParam);
|
verifyTagType(tagParam);
|
||||||
});
|
});
|
||||||
|
|
||||||
env.opts.debug = debug;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('if the tag has a description beyond the name/type, this should be in tag.value.description', () => {
|
it('if the tag has a description beyond the name/type, this should be in tag.value.description', () => {
|
||||||
expect(tagType.value.description).not.toBeDefined();
|
expect(tagType.value.description).toBeUndefined();
|
||||||
|
|
||||||
expect(tagArg.value.description).toBeDefined();
|
|
||||||
expect(tagArg.value.description).toBe(desc);
|
expect(tagArg.value.description).toBe(desc);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('if the tag can have a name, it should be stored in tag.value.name', () => {
|
it('if the tag can have a name, it should be stored in tag.value.name', () => {
|
||||||
expect(tagArg.value.name).toBeDefined();
|
|
||||||
expect(tagArg.value.name).toBe('foo');
|
expect(tagArg.value.name).toBe('foo');
|
||||||
|
expect(tagType.value.name).toBeUndefined();
|
||||||
expect(tagType.value.name).not.toBeDefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('if the tag has a type without modifiers, tag.value should not include properties for the modifiers', () => {
|
it('if the tag has a type without modifiers, tag.value should not include properties for the modifiers', () => {
|
||||||
['optional', 'nullable', 'variable', 'defaultvalue'].forEach(modifier => {
|
['optional', 'nullable', 'variable', 'defaultvalue'].forEach(modifier => {
|
||||||
expect( hasOwnProp.call(tagParamWithType.value, modifier) ).toBe(false);
|
expect( hasOwnProp.call(tagParamWithType.value, modifier) ).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,13 +6,12 @@ describe('jsdoc/tag/dictionary', () => {
|
|||||||
canHaveValue: true,
|
canHaveValue: true,
|
||||||
isNamespace: true
|
isNamespace: true
|
||||||
};
|
};
|
||||||
const tagTitle = '!!!testTag!!!';
|
const TAG_TITLE = '!!!testTag!!!';
|
||||||
const tagSynonym = '!!!testTagSynonym!!!';
|
const TAG_SYNONYM = '!!!testTagSynonym!!!';
|
||||||
const tagDef = testDictionary.defineTag(tagTitle, tagOptions).synonym(tagSynonym);
|
const TAG_DEF = testDictionary.defineTag(TAG_TITLE, tagOptions).synonym(TAG_SYNONYM);
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(dictionary).toBeDefined();
|
expect(dictionary).toBeObject();
|
||||||
expect(typeof dictionary).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be an instance of dictionary.Dictionary', () => {
|
it('should be an instance of dictionary.Dictionary', () => {
|
||||||
@ -20,37 +19,31 @@ describe('jsdoc/tag/dictionary', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should export a defineSynonym method', () => {
|
it('should export a defineSynonym method', () => {
|
||||||
expect(dictionary.defineSynonym).toBeDefined();
|
expect(dictionary.defineSynonym).toBeFunction();
|
||||||
expect(typeof dictionary.defineSynonym).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a defineTag method', () => {
|
it('should export a defineTag method', () => {
|
||||||
expect(dictionary.defineTag).toBeDefined();
|
expect(dictionary.defineTag).toBeFunction();
|
||||||
expect(typeof dictionary.defineTag).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a lookUp method', () => {
|
it('should export a lookUp method', () => {
|
||||||
expect(dictionary.lookUp).toBeDefined();
|
expect(dictionary.lookUp).toBeFunction();
|
||||||
expect(typeof dictionary.lookUp).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an isNamespace method', () => {
|
it('should export an isNamespace method', () => {
|
||||||
expect(dictionary.isNamespace).toBeDefined();
|
expect(dictionary.isNamespace).toBeFunction();
|
||||||
expect(typeof dictionary.isNamespace).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a normalise method', () => {
|
it('should export a normalise method', () => {
|
||||||
expect(dictionary.normalise).toBeDefined();
|
expect(dictionary.normalise).toBeFunction();
|
||||||
expect(typeof dictionary.normalise).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a normalize method', () => {
|
it('should export a normalize method', () => {
|
||||||
expect(typeof dictionary.normalize).toBe('function');
|
expect(dictionary.normalize).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a Dictionary constructor', () => {
|
it('should export a Dictionary constructor', () => {
|
||||||
expect(dictionary.Dictionary).toBeDefined();
|
expect(dictionary.Dictionary).toBeFunction();
|
||||||
expect(typeof dictionary.Dictionary).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('defineSynonym', () => {
|
describe('defineSynonym', () => {
|
||||||
@ -58,76 +51,74 @@ describe('jsdoc/tag/dictionary', () => {
|
|||||||
dictionary.defineTag('foo', {});
|
dictionary.defineTag('foo', {});
|
||||||
dictionary.defineSynonym('foo', 'bar');
|
dictionary.defineSynonym('foo', 'bar');
|
||||||
|
|
||||||
expect(dictionary.normalise('bar')).toBe('foo');
|
expect(dictionary.normalize('bar')).toBe('foo');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('defineTag', () => {
|
describe('defineTag', () => {
|
||||||
it('returns an object with the correct "title" property', () => {
|
it('returns an object with the correct "title" property', () => {
|
||||||
expect(typeof tagDef).toBe('object');
|
expect(TAG_DEF).toBeObject();
|
||||||
expect(tagDef.title).toBeDefined();
|
expect(TAG_DEF.title).toBe(testDictionary.normalize(TAG_TITLE));
|
||||||
expect(typeof tagDef.title).toBe('string');
|
|
||||||
expect(tagDef.title).toBe(testDictionary.normalise(tagTitle));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns an object that contains all of the tag properties', () => {
|
it('returns an object that contains all of the tag properties', () => {
|
||||||
Object.keys(tagOptions).forEach(opt => {
|
Object.keys(tagOptions).forEach(opt => {
|
||||||
expect(tagDef[opt]).toBe(tagOptions[opt]);
|
expect(TAG_DEF[opt]).toBe(tagOptions[opt]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works correctly without an options object', () => {
|
it('works correctly without an options object', () => {
|
||||||
const title = '!!!testTagNoOptions!!!';
|
const NEW_TITLE = '!!!testTagNoOptions!!!';
|
||||||
|
|
||||||
function makeTag() {
|
function makeTag() {
|
||||||
return testDictionary.defineTag(title);
|
return testDictionary.defineTag(NEW_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(makeTag).not.toThrow();
|
expect(makeTag).not.toThrow();
|
||||||
expect(makeTag().title).toBe(testDictionary.normalise(title));
|
expect(makeTag().title).toBe(testDictionary.normalize(NEW_TITLE));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('lookUp', () => {
|
describe('lookUp', () => {
|
||||||
it("retrieves the definition using the tag's canonical name", () => {
|
it("retrieves the definition using the tag's canonical name", () => {
|
||||||
expect(testDictionary.lookUp(tagTitle)).toBe(tagDef);
|
expect(testDictionary.lookUp(TAG_TITLE)).toBe(TAG_DEF);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('retrieves the definition using a synonym for the tag', () => {
|
it('retrieves the definition using a synonym for the tag', () => {
|
||||||
expect(testDictionary.lookUp(tagSynonym)).toBe(tagDef);
|
expect(testDictionary.lookUp(TAG_SYNONYM)).toBe(TAG_DEF);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns `false` when a tag is not found', () => {
|
it('returns `false` when a tag is not found', () => {
|
||||||
expect(testDictionary.lookUp('lkjas1l24jk')).toBe(false);
|
expect(testDictionary.lookUp('lkjas1l24jk')).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isNamespace', () => {
|
describe('isNamespace', () => {
|
||||||
it("returns whether a tag is a namespace using the tag's canonical name", () => {
|
it("returns whether a tag is a namespace using the tag's canonical name", () => {
|
||||||
expect(testDictionary.isNamespace(tagTitle)).toBe(true);
|
expect(testDictionary.isNamespace(TAG_TITLE)).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns whether a tag is a namespace when using a synonym for the tag', () => {
|
it('returns whether a tag is a namespace when using a synonym for the tag', () => {
|
||||||
expect(testDictionary.isNamespace(tagSynonym)).toBe(true);
|
expect(testDictionary.isNamespace(TAG_SYNONYM)).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns `false` for nonexistent tags', () => {
|
it('returns `false` for nonexistent tags', () => {
|
||||||
expect(testDictionary.isNamespace('lkjasd90034')).toBe(false);
|
expect(testDictionary.isNamespace('lkjasd90034')).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns `false` for non-namespace tags', () => {
|
it('returns `false` for non-namespace tags', () => {
|
||||||
expect(testDictionary.isNamespace('see')).toBe(false);
|
expect(testDictionary.isNamespace('see')).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('normalise', () => {
|
describe('normalise', () => {
|
||||||
it("should return the tag's title if it is not a synonym", () => {
|
it("should return the tag's title if it is not a synonym", () => {
|
||||||
expect(testDictionary.normalise('FooBar')).toBe('foobar');
|
expect(testDictionary.normalise('FooBar')).toBe('foobar');
|
||||||
expect(testDictionary.normalise(tagTitle)).toBe(tagDef.title);
|
expect(testDictionary.normalise(TAG_TITLE)).toBe(TAG_DEF.title);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the canonical name of a tag if the synonym is normalised', () => {
|
it('should return the canonical name of a tag if the synonym is normalized', () => {
|
||||||
expect(testDictionary.normalise(tagSynonym)).toBe(tagDef.title);
|
expect(testDictionary.normalise(TAG_SYNONYM)).toBe(TAG_DEF.title);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -5,28 +5,23 @@ describe('jsdoc/tag/dictionary/definitions', () => {
|
|||||||
const logger = require('jsdoc/util/logger');
|
const logger = require('jsdoc/util/logger');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(definitions).toBeDefined();
|
expect(definitions).toBeObject();
|
||||||
expect(typeof definitions).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a baseTags object', () => {
|
it('should export a baseTags object', () => {
|
||||||
expect(definitions.baseTags).toBeDefined();
|
expect(definitions.baseTags).toBeObject();
|
||||||
expect(typeof definitions.baseTags).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a closureTags object', () => {
|
it('should export a closureTags object', () => {
|
||||||
expect(definitions.closureTags).toBeDefined();
|
expect(definitions.closureTags).toBeObject();
|
||||||
expect(typeof definitions.closureTags).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a defineTags method', () => {
|
it('should export a defineTags method', () => {
|
||||||
expect(definitions.defineTags).toBeDefined();
|
expect(definitions.defineTags).toBeFunction();
|
||||||
expect(typeof definitions.defineTags).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a jsdocTags object', () => {
|
it('should export a jsdocTags object', () => {
|
||||||
expect(definitions.jsdocTags).toBeDefined();
|
expect(definitions.jsdocTags).toBeObject();
|
||||||
expect(typeof definitions.jsdocTags).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('baseTags', () => {
|
describe('baseTags', () => {
|
||||||
@ -38,7 +33,9 @@ describe('jsdoc/tag/dictionary/definitions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('defineTags', () => {
|
describe('defineTags', () => {
|
||||||
|
const CLOSURE_TAGNAME = 'final';
|
||||||
const dictionaryConfig = env.conf.tags.dictionaries.slice(0);
|
const dictionaryConfig = env.conf.tags.dictionaries.slice(0);
|
||||||
|
const JSDOC_TAGNAME = 'abstract';
|
||||||
let tagDict;
|
let tagDict;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -70,30 +67,24 @@ describe('jsdoc/tag/dictionary/definitions', () => {
|
|||||||
env.conf.tags.dictionaries = dictionaryConfig.slice(0);
|
env.conf.tags.dictionaries = dictionaryConfig.slice(0);
|
||||||
definitions.defineTags(tagDict);
|
definitions.defineTags(tagDict);
|
||||||
|
|
||||||
// Check for one tag from the JSDoc tagdefs and another tag from the Closure tagdefs.
|
expect(tagDict.lookUp(JSDOC_TAGNAME)).toBeObject();
|
||||||
// Not thorough, but probably good enough.
|
expect(tagDict.lookUp(CLOSURE_TAGNAME)).toBeObject();
|
||||||
expect(tagDict.lookUp('abstract')).not.toBe(false);
|
|
||||||
expect(tagDict.lookUp('final')).not.toBe(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add only the JSDoc tags if requested', () => {
|
it('should add only the JSDoc tags if requested', () => {
|
||||||
env.conf.tags.dictionaries = ['jsdoc'];
|
env.conf.tags.dictionaries = ['jsdoc'];
|
||||||
definitions.defineTags(tagDict);
|
definitions.defineTags(tagDict);
|
||||||
|
|
||||||
// Check for one tag from the JSDoc tagdefs and another tag from another set of tagdefs.
|
expect(tagDict.lookUp(JSDOC_TAGNAME)).toBeObject();
|
||||||
// Not thorough, but probably good enough.
|
expect(tagDict.lookUp(CLOSURE_TAGNAME)).toBeFalse();
|
||||||
expect(tagDict.lookUp('abstract')).not.toBe(false);
|
|
||||||
expect(tagDict.lookUp('final')).toBe(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add only the Closure tags if requested', () => {
|
it('should add only the Closure tags if requested', () => {
|
||||||
env.conf.tags.dictionaries = ['closure'];
|
env.conf.tags.dictionaries = ['closure'];
|
||||||
definitions.defineTags(tagDict);
|
definitions.defineTags(tagDict);
|
||||||
|
|
||||||
// Check for one tag from the Closure tagdefs and another tag from another set of
|
expect(tagDict.lookUp(JSDOC_TAGNAME)).toBeFalse();
|
||||||
// tagdefs. Not thorough, but probably good enough.
|
expect(tagDict.lookUp(CLOSURE_TAGNAME)).toBeObject();
|
||||||
expect(tagDict.lookUp('final')).not.toBe(false);
|
|
||||||
expect(tagDict.lookUp('abstract')).toBe(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should prefer tagdefs from the first dictionary on the list', () => {
|
it('should prefer tagdefs from the first dictionary on the list', () => {
|
||||||
@ -107,8 +98,8 @@ describe('jsdoc/tag/dictionary/definitions', () => {
|
|||||||
env.conf.tags.dictionaries = ['jsdoc'];
|
env.conf.tags.dictionaries = ['jsdoc'];
|
||||||
definitions.defineTags(tagDict);
|
definitions.defineTags(tagDict);
|
||||||
|
|
||||||
expect(tagDict.lookUp('extends')).not.toBe(false);
|
expect(tagDict.lookUp('extends')).toBeObject();
|
||||||
expect(tagDict.normalise('extends')).toBe('augments');
|
expect(tagDict.normalize('extends')).toBe('augments');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ignore the config settings if tagdefs are passed in', () => {
|
it('should ignore the config settings if tagdefs are passed in', () => {
|
||||||
@ -121,8 +112,8 @@ describe('jsdoc/tag/dictionary/definitions', () => {
|
|||||||
env.conf.tags.dictionaries = ['jsdoc'];
|
env.conf.tags.dictionaries = ['jsdoc'];
|
||||||
definitions.defineTags(tagDict, tagDefs);
|
definitions.defineTags(tagDict, tagDefs);
|
||||||
|
|
||||||
expect(tagDict.lookUp('foo')).not.toBe(false);
|
expect(tagDict.lookUp('foo')).toBeObject();
|
||||||
expect(tagDict.lookUp('abstract')).toBe(false);
|
expect(tagDict.lookUp('abstract')).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -2,50 +2,46 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
const inline = require('jsdoc/tag/inline');
|
const inline = require('jsdoc/tag/inline');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(inline).toBeDefined();
|
expect(inline).toBeObject();
|
||||||
expect(typeof inline).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an isInlineTag function', () => {
|
it('should export an isInlineTag function', () => {
|
||||||
expect(inline.isInlineTag).toBeDefined();
|
expect(inline.isInlineTag).toBeFunction();
|
||||||
expect(typeof inline.isInlineTag).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a replaceInlineTag function', () => {
|
it('should export a replaceInlineTag function', () => {
|
||||||
expect(inline.replaceInlineTag).toBeDefined();
|
expect(inline.replaceInlineTag).toBeFunction();
|
||||||
expect(typeof inline.replaceInlineTag).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an extractInlineTag function', () => {
|
it('should export an extractInlineTag function', () => {
|
||||||
expect(inline.extractInlineTag).toBeDefined();
|
expect(inline.extractInlineTag).toBeFunction();
|
||||||
expect(typeof inline.replaceInlineTag).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isInlineTag', () => {
|
describe('isInlineTag', () => {
|
||||||
const isInlineTag = inline.isInlineTag;
|
const isInlineTag = inline.isInlineTag;
|
||||||
|
|
||||||
it('should correctly identify an inline tag', () => {
|
it('should correctly identify an inline tag', () => {
|
||||||
expect( isInlineTag('{@mytag hooray}', 'mytag') ).toBe(true);
|
expect( isInlineTag('{@mytag hooray}', 'mytag') ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should correctly identify a non-inline tag', () => {
|
it('should correctly identify a non-inline tag', () => {
|
||||||
expect( isInlineTag('mytag hooray', 'mytag') ).toBe(false);
|
expect( isInlineTag('mytag hooray', 'mytag') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should report that a string containing an inline tag is not an inline tag', () => {
|
it('should report that a string containing an inline tag is not an inline tag', () => {
|
||||||
expect( isInlineTag('this is {@mytag hooray}', 'mytag') ).toBe(false);
|
expect( isInlineTag('this is {@mytag hooray}', 'mytag') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should default to allowing any inline tag', () => {
|
it('should default to allowing any inline tag', () => {
|
||||||
expect( isInlineTag('{@anyoldtag will do}') ).toBe(true);
|
expect( isInlineTag('{@anyoldtag will do}') ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should still identify non-inline tags when a tag name is not provided', () => {
|
it('should still identify non-inline tags when a tag name is not provided', () => {
|
||||||
expect( isInlineTag('mytag hooray') ).toBe(false);
|
expect( isInlineTag('mytag hooray') ).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow regexp characters in the tag name', () => {
|
it('should allow regexp characters in the tag name', () => {
|
||||||
expect( isInlineTag('{@mytags hooray}', 'mytag\\S') ).toBe(true);
|
expect( isInlineTag('{@mytags hooray}', 'mytag\\S') ).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false (rather than throwing) with invalid input', () => {
|
it('should return false (rather than throwing) with invalid input', () => {
|
||||||
@ -54,7 +50,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expect(badInput).not.toThrow();
|
expect(badInput).not.toThrow();
|
||||||
expect( badInput() ).toBe(false);
|
expect( badInput() ).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -100,8 +96,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
const result = inline.replaceInlineTag('{@foo text in braces}', 'foo',
|
const result = inline.replaceInlineTag('{@foo text in braces}', 'foo',
|
||||||
replacer);
|
replacer);
|
||||||
|
|
||||||
expect(result.tags[0]).toBeDefined();
|
expect(result.tags[0]).toBeObject();
|
||||||
expect(typeof result.tags[0]).toBe('object');
|
|
||||||
expect(result.tags[0].tag).toBe('foo');
|
expect(result.tags[0].tag).toBe('foo');
|
||||||
expect(result.tags[0].text).toBe('text in braces');
|
expect(result.tags[0].text).toBe('text in braces');
|
||||||
expect(result.newString).toBe('{@foo text in braces}');
|
expect(result.newString).toBe('{@foo text in braces}');
|
||||||
@ -119,8 +114,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
const result = inline.replaceInlineTag('{@foo test string} ahoy', 'foo',
|
const result = inline.replaceInlineTag('{@foo test string} ahoy', 'foo',
|
||||||
replacer);
|
replacer);
|
||||||
|
|
||||||
expect(result.tags[0]).toBeDefined();
|
expect(result.tags[0]).toBeObject();
|
||||||
expect(typeof result.tags[0]).toBe('object');
|
|
||||||
expect(result.tags[0].tag).toBe('foo');
|
expect(result.tags[0].tag).toBe('foo');
|
||||||
expect(result.tags[0].text).toBe('test string');
|
expect(result.tags[0].text).toBe('test string');
|
||||||
expect(result.newString).toBe('{@foo test string} ahoy');
|
expect(result.newString).toBe('{@foo test string} ahoy');
|
||||||
@ -138,8 +132,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
const result = inline.replaceInlineTag('a {@foo test string} yay', 'foo',
|
const result = inline.replaceInlineTag('a {@foo test string} yay', 'foo',
|
||||||
replacer);
|
replacer);
|
||||||
|
|
||||||
expect(result.tags[0]).toBeDefined();
|
expect(result.tags[0]).toBeObject();
|
||||||
expect(typeof result.tags[0]).toBe('object');
|
|
||||||
expect(result.tags[0].tag).toBe('foo');
|
expect(result.tags[0].tag).toBe('foo');
|
||||||
expect(result.tags[0].text).toBe('test string');
|
expect(result.tags[0].text).toBe('test string');
|
||||||
expect(result.newString).toBe('a {@foo test string} yay');
|
expect(result.newString).toBe('a {@foo test string} yay');
|
||||||
@ -156,8 +149,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
|
|
||||||
const result = inline.replaceInlineTag('a {@foo test string}', 'foo', replacer);
|
const result = inline.replaceInlineTag('a {@foo test string}', 'foo', replacer);
|
||||||
|
|
||||||
expect(result.tags[0]).toBeDefined();
|
expect(result.tags[0]).toBeObject();
|
||||||
expect(typeof result.tags[0]).toBe('object');
|
|
||||||
expect(result.tags[0].tag).toBe('foo');
|
expect(result.tags[0].tag).toBe('foo');
|
||||||
expect(result.tags[0].text).toBe('test string');
|
expect(result.tags[0].text).toBe('test string');
|
||||||
expect(result.newString).toBe('a {@foo test string}');
|
expect(result.newString).toBe('a {@foo test string}');
|
||||||
@ -183,23 +175,19 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
|
|
||||||
expect(result.tags.length).toBe(4);
|
expect(result.tags.length).toBe(4);
|
||||||
|
|
||||||
expect(result.tags[0]).toBeDefined();
|
expect(result.tags[0]).toBeObject();
|
||||||
expect(typeof result.tags[0]).toBe('object');
|
|
||||||
expect(result.tags[0].tag).toBe('foo');
|
expect(result.tags[0].tag).toBe('foo');
|
||||||
expect(result.tags[0].text).toBe('text');
|
expect(result.tags[0].text).toBe('text');
|
||||||
|
|
||||||
expect(result.tags[1]).toBeDefined();
|
expect(result.tags[1]).toBeObject();
|
||||||
expect(typeof result.tags[1]).toBe('object');
|
|
||||||
expect(result.tags[1].tag).toBe('foo');
|
expect(result.tags[1].tag).toBe('foo');
|
||||||
expect(result.tags[1].text).toBe('tags');
|
expect(result.tags[1].text).toBe('tags');
|
||||||
|
|
||||||
expect(result.tags[2]).toBeDefined();
|
expect(result.tags[2]).toBeObject();
|
||||||
expect(typeof result.tags[2]).toBe('object');
|
|
||||||
expect(result.tags[2].tag).toBe('foo');
|
expect(result.tags[2].tag).toBe('foo');
|
||||||
expect(result.tags[2].text).toBe('like');
|
expect(result.tags[2].text).toBe('like');
|
||||||
|
|
||||||
expect(result.tags[3]).toBeDefined();
|
expect(result.tags[3]).toBeObject();
|
||||||
expect(typeof result.tags[3]).toBe('object');
|
|
||||||
expect(result.tags[3].tag).toBe('foo');
|
expect(result.tags[3].tag).toBe('foo');
|
||||||
expect(result.tags[3].text).toBe('this');
|
expect(result.tags[3].text).toBe('this');
|
||||||
|
|
||||||
@ -259,8 +247,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
it('should work when a tag is specified', () => {
|
it('should work when a tag is specified', () => {
|
||||||
const result = inline.extractInlineTag('some {@tagged text}', 'tagged');
|
const result = inline.extractInlineTag('some {@tagged text}', 'tagged');
|
||||||
|
|
||||||
expect(result.tags[0]).toBeDefined();
|
expect(result.tags[0]).toBeObject();
|
||||||
expect(typeof result.tags[0]).toBe('object');
|
|
||||||
expect(result.tags[0].tag).toBe('tagged');
|
expect(result.tags[0].tag).toBe('tagged');
|
||||||
expect(result.tags[0].text).toBe('text');
|
expect(result.tags[0].text).toBe('text');
|
||||||
expect(result.newString).toBe('some');
|
expect(result.newString).toBe('some');
|
||||||
|
|||||||
@ -26,29 +26,27 @@ describe('jsdoc/tag/type', () => {
|
|||||||
const type = require('jsdoc/tag/type');
|
const type = require('jsdoc/tag/type');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(type).toBeDefined();
|
expect(type).toBeObject();
|
||||||
expect(typeof type).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a parse function', () => {
|
it('should export a parse function', () => {
|
||||||
expect(type.parse).toBeDefined();
|
expect(type.parse).toBeFunction();
|
||||||
expect(typeof type.parse).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parse', () => {
|
describe('parse', () => {
|
||||||
it('should return an object with name, type, and text properties', () => {
|
it('should return an object with name, type, and text properties', () => {
|
||||||
const info = type.parse('');
|
const info = type.parse('');
|
||||||
|
|
||||||
expect(info.name).toBeDefined();
|
expect(info.name).toBeString();
|
||||||
expect(info.type).toBeDefined();
|
expect(info.type).toBeArray();
|
||||||
expect(info.text).toBeDefined();
|
expect(info.text).toBeString();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not extract a name or type if canHaveName and canHaveType are not set', () => {
|
it('should not extract a name or type if canHaveName and canHaveType are not set', () => {
|
||||||
const desc = '{number} foo The foo parameter.';
|
const desc = '{number} foo The foo parameter.';
|
||||||
const info = type.parse(desc);
|
const info = type.parse(desc);
|
||||||
|
|
||||||
expect(info.type).toEqual([]);
|
expect(info.type).toBeEmptyArray();
|
||||||
expect(info.name).toBe('');
|
expect(info.name).toBe('');
|
||||||
expect(info.text).toBe(desc);
|
expect(info.text).toBe(desc);
|
||||||
});
|
});
|
||||||
@ -58,7 +56,7 @@ describe('jsdoc/tag/type', () => {
|
|||||||
const desc = 'The bar parameter.';
|
const desc = 'The bar parameter.';
|
||||||
const info = type.parse( buildText(null, name, desc), true, false );
|
const info = type.parse( buildText(null, name, desc), true, false );
|
||||||
|
|
||||||
expect(info.type).toEqual([]);
|
expect(info.type).toBeEmptyArray();
|
||||||
expect(info.name).toBe(name);
|
expect(info.name).toBe(name);
|
||||||
expect(info.text).toBe(desc);
|
expect(info.text).toBe(desc);
|
||||||
});
|
});
|
||||||
@ -88,15 +86,15 @@ describe('jsdoc/tag/type', () => {
|
|||||||
let desc = '{string} [foo]';
|
let desc = '{string} [foo]';
|
||||||
let info = type.parse(desc, true, true);
|
let info = type.parse(desc, true, true);
|
||||||
|
|
||||||
expect(info.optional).toBe(true);
|
expect(info.optional).toBeTrue();
|
||||||
|
|
||||||
desc = '{string=} [foo]';
|
desc = '{string=} [foo]';
|
||||||
info = type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.optional).toBe(true);
|
expect(info.optional).toBeTrue();
|
||||||
|
|
||||||
desc = '[foo]';
|
desc = '[foo]';
|
||||||
info = type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.optional).toBe(true);
|
expect(info.optional).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the types as an array', () => {
|
it('should return the types as an array', () => {
|
||||||
@ -129,14 +127,14 @@ describe('jsdoc/tag/type', () => {
|
|||||||
const desc = 'braceless text';
|
const desc = 'braceless text';
|
||||||
const info = type.parse(desc, false, true);
|
const info = type.parse(desc, false, true);
|
||||||
|
|
||||||
expect(info.type).toEqual([]);
|
expect(info.type).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should cope with bad escapement at the end of the string', () => {
|
it('should cope with bad escapement at the end of the string', () => {
|
||||||
const desc = 'bad {escapement \\';
|
const desc = 'bad {escapement \\';
|
||||||
const info = type.parse(desc, false, true);
|
const info = type.parse(desc, false, true);
|
||||||
|
|
||||||
expect(info.type).toEqual([]);
|
expect(info.type).toBeEmptyArray();
|
||||||
expect(info.text).toBe(desc);
|
expect(info.text).toBe(desc);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -223,26 +221,26 @@ describe('jsdoc/tag/type', () => {
|
|||||||
|
|
||||||
expect(info.name).toBe('qux');
|
expect(info.name).toBe('qux');
|
||||||
expect(info.text).toBe(desc);
|
expect(info.text).toBe(desc);
|
||||||
expect(info.optional).toBe(true);
|
expect(info.optional).toBeTrue();
|
||||||
|
|
||||||
name = '[ qux ]';
|
name = '[ qux ]';
|
||||||
info = type.parse( buildText(null, name, desc), true, false );
|
info = type.parse( buildText(null, name, desc), true, false );
|
||||||
expect(info.name).toBe('qux');
|
expect(info.name).toBe('qux');
|
||||||
expect(info.text).toBe(desc);
|
expect(info.text).toBe(desc);
|
||||||
expect(info.optional).toBe(true);
|
expect(info.optional).toBeTrue();
|
||||||
|
|
||||||
name = '[qux=hooray]';
|
name = '[qux=hooray]';
|
||||||
info = type.parse( buildText(null, name, desc), true, false );
|
info = type.parse( buildText(null, name, desc), true, false );
|
||||||
expect(info.name).toBe('qux');
|
expect(info.name).toBe('qux');
|
||||||
expect(info.text).toBe(desc);
|
expect(info.text).toBe(desc);
|
||||||
expect(info.optional).toBe(true);
|
expect(info.optional).toBeTrue();
|
||||||
expect(info.defaultvalue).toBe('hooray');
|
expect(info.defaultvalue).toBe('hooray');
|
||||||
|
|
||||||
name = '[ qux = hooray ]';
|
name = '[ qux = hooray ]';
|
||||||
info = type.parse( buildText(null, name, desc), true, false );
|
info = type.parse( buildText(null, name, desc), true, false );
|
||||||
expect(info.name).toBe('qux');
|
expect(info.name).toBe('qux');
|
||||||
expect(info.text).toBe(desc);
|
expect(info.text).toBe(desc);
|
||||||
expect(info.optional).toBe(true);
|
expect(info.optional).toBeTrue();
|
||||||
expect(info.defaultvalue).toBe('hooray');
|
expect(info.defaultvalue).toBe('hooray');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -254,7 +252,7 @@ describe('jsdoc/tag/type', () => {
|
|||||||
const info = type.parse(desc, true, true);
|
const info = type.parse(desc, true, true);
|
||||||
|
|
||||||
expect(info.type).toEqual( ['string'] );
|
expect(info.type).toEqual( ['string'] );
|
||||||
expect(info.variable).toBe(true);
|
expect(info.variable).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the type correctly for type applications that contain type unions',
|
it('should set the type correctly for type applications that contain type unions',
|
||||||
|
|||||||
@ -6,13 +6,11 @@ describe('jsdoc/tag/validator', () => {
|
|||||||
const validator = require('jsdoc/tag/validator');
|
const validator = require('jsdoc/tag/validator');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(validator).toBeDefined();
|
expect(validator).toBeObject();
|
||||||
expect(typeof validator).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a validate function', () => {
|
it('should export a validate function', () => {
|
||||||
expect(validator.validate).toBeDefined();
|
expect(validator.validate).toBeFunction();
|
||||||
expect(typeof validator.validate).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('validate', () => {
|
describe('validate', () => {
|
||||||
|
|||||||
@ -15,101 +15,82 @@ describe('jsdoc/tutorial', () => {
|
|||||||
tutorial.TYPES.MARKDOWN);
|
tutorial.TYPES.MARKDOWN);
|
||||||
|
|
||||||
it('module should exist', () => {
|
it('module should exist', () => {
|
||||||
expect(tutorial).toBeDefined();
|
expect(tutorial).toBeObject();
|
||||||
expect(typeof tutorial).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a Tutorial function', () => {
|
it('should export a Tutorial function', () => {
|
||||||
expect(tutorial.Tutorial).toBeDefined();
|
expect(tutorial.Tutorial).toBeFunction();
|
||||||
expect(typeof tutorial.Tutorial).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a RootTutorial function', () => {
|
it('should export a RootTutorial function', () => {
|
||||||
expect(tutorial.RootTutorial).toBeDefined();
|
expect(tutorial.RootTutorial).toBeFunction();
|
||||||
expect(typeof tutorial.RootTutorial).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a TYPES object', () => {
|
it('should export a TYPES object', () => {
|
||||||
expect(tutorial.TYPES).toBeDefined();
|
expect(tutorial.TYPES).toBeObject();
|
||||||
expect(typeof tutorial.TYPES).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('tutorial.TYPES', () => {
|
describe('tutorial.TYPES', () => {
|
||||||
it('should have a HTML property', () => {
|
it('should have a HTML property', () => {
|
||||||
expect(tutorial.TYPES.HTML).toBeDefined();
|
expect(tutorial.TYPES.HTML).toBeNumber();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a MARKDOWN property', () => {
|
it('should have a MARKDOWN property', () => {
|
||||||
expect(tutorial.TYPES.MARKDOWN).toBeDefined();
|
expect(tutorial.TYPES.MARKDOWN).toBeNumber();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Tutorial', () => {
|
describe('Tutorial', () => {
|
||||||
it('should have a "setParent" method', () => {
|
it('should have a "setParent" method', () => {
|
||||||
expect(tutorial.Tutorial.prototype.setParent).toBeDefined();
|
expect(tutorial.Tutorial.prototype.setParent).toBeFunction();
|
||||||
expect(typeof tutorial.Tutorial.prototype.setParent).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "removeChild" method', () => {
|
it('should have a "removeChild" method', () => {
|
||||||
expect(tutorial.Tutorial.prototype.removeChild).toBeDefined();
|
expect(tutorial.Tutorial.prototype.removeChild).toBeFunction();
|
||||||
expect(typeof tutorial.Tutorial.prototype.removeChild).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an "addChild" method', () => {
|
it('should have an "addChild" method', () => {
|
||||||
expect(tutorial.Tutorial.prototype.addChild).toBeDefined();
|
expect(tutorial.Tutorial.prototype.addChild).toBeFunction();
|
||||||
expect(typeof tutorial.Tutorial.prototype.addChild).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "parse" method', () => {
|
it('should have a "parse" method', () => {
|
||||||
expect(tutorial.Tutorial.prototype.parse).toBeDefined();
|
expect(tutorial.Tutorial.prototype.parse).toBeFunction();
|
||||||
expect(typeof tutorial.Tutorial.prototype.parse).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "name" property', () => {
|
it('should have a "name" property', () => {
|
||||||
expect(tute.name).toBeDefined();
|
|
||||||
expect(typeof tute.name).toBe('string');
|
|
||||||
expect(tute.name).toBe(name);
|
expect(tute.name).toBe(name);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "longname" property', () => {
|
it('should have a "longname" property', () => {
|
||||||
expect(typeof tute.longname).toBe('string');
|
|
||||||
expect(tute.longname).toBe(name);
|
expect(tute.longname).toBe(name);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'title' property, by default set to to the tutorial's name", () => {
|
it("should have a 'title' property, by default set to to the tutorial's name", () => {
|
||||||
expect(tute.title).toBeDefined();
|
|
||||||
expect(typeof tute.title).toBe('string');
|
|
||||||
expect(tute.title).toBe(name);
|
expect(tute.title).toBe(name);
|
||||||
// Testing of overriding a tutorial's title in its JSON file is
|
// Testing of overriding a tutorial's title in its JSON file is
|
||||||
// covered in tutorial/resolver.js tests.
|
// covered in tutorial/resolver.js tests.
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'content' property set to the tutorial's content", () => {
|
it("should have a 'content' property set to the tutorial's content", () => {
|
||||||
expect(tute.content).toBeDefined();
|
|
||||||
expect(typeof tute.content).toBe('string');
|
|
||||||
expect(tute.content).toBe(content);
|
expect(tute.content).toBe(content);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'type' property set to the tutorial's type", () => {
|
it("should have a 'type' property set to the tutorial's type", () => {
|
||||||
expect(par.type).toBeDefined();
|
|
||||||
expect(typeof par.type).toBe(typeof tutorial.TYPES.MARKDOWN);
|
|
||||||
expect(par.type).toBe(tutorial.TYPES.MARKDOWN);
|
expect(par.type).toBe(tutorial.TYPES.MARKDOWN);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'parent' property, initially null", () => {
|
it("should have a 'parent' property, initially null", () => {
|
||||||
expect(tute.parent).toBeDefined();
|
expect(tute.parent).toBeNull();
|
||||||
expect(tute.parent).toBe(null);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'children' property, an empty array", () => {
|
it("should have a 'children' property, an empty array", () => {
|
||||||
expect(tute.children).toBeDefined();
|
expect(tute.children).toBeEmptyArray();
|
||||||
expect(Array.isArray(tute.children)).toBe(true);
|
|
||||||
expect(tute.children.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('setParent', () => {
|
describe('setParent', () => {
|
||||||
it("adding a parent sets the child's 'parent' property", () => {
|
it("adding a parent sets the child's 'parent' property", () => {
|
||||||
tute.setParent(par);
|
tute.setParent(par);
|
||||||
|
|
||||||
expect(tute.parent).toBe(par);
|
expect(tute.parent).toBe(par);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -127,9 +108,10 @@ describe('jsdoc/tutorial', () => {
|
|||||||
|
|
||||||
it("calling setParent with a null parent unsets the child's parent and removes the child from its previous parent", () => {
|
it("calling setParent with a null parent unsets the child's parent and removes the child from its previous parent", () => {
|
||||||
expect(par2.children).toContain(tute);
|
expect(par2.children).toContain(tute);
|
||||||
|
|
||||||
tute.setParent(null);
|
tute.setParent(null);
|
||||||
|
|
||||||
expect(tute.parent).toBe(null);
|
expect(tute.parent).toBeNull();
|
||||||
expect(par2.children).not.toContain(tute);
|
expect(par2.children).not.toContain(tute);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -137,11 +119,12 @@ describe('jsdoc/tutorial', () => {
|
|||||||
describe('addChild', () => {
|
describe('addChild', () => {
|
||||||
it("adding a child tutorial adds the child to the parent's 'children' property", () => {
|
it("adding a child tutorial adds the child to the parent's 'children' property", () => {
|
||||||
tute.setParent(null);
|
tute.setParent(null);
|
||||||
|
|
||||||
const n = par.children.length;
|
const n = par.children.length;
|
||||||
|
|
||||||
par.addChild(tute);
|
par.addChild(tute);
|
||||||
|
|
||||||
expect(par.children.length).toBe(n + 1);
|
expect(par.children).toBeArrayOfSize(n + 1);
|
||||||
expect(par.children).toContain(tute);
|
expect(par.children).toContain(tute);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -152,6 +135,7 @@ describe('jsdoc/tutorial', () => {
|
|||||||
it('adding a child tutorial removes the child from its old parent', () => {
|
it('adding a child tutorial removes the child from its old parent', () => {
|
||||||
// tue is currently owned by par; we reparent it to par2
|
// tue is currently owned by par; we reparent it to par2
|
||||||
expect(tute.parent).toBe(par);
|
expect(tute.parent).toBe(par);
|
||||||
|
|
||||||
par2.addChild(tute);
|
par2.addChild(tute);
|
||||||
|
|
||||||
expect(tute.parent).toBe(par2);
|
expect(tute.parent).toBe(par2);
|
||||||
@ -169,7 +153,7 @@ describe('jsdoc/tutorial', () => {
|
|||||||
const n = par2.children.length;
|
const n = par2.children.length;
|
||||||
|
|
||||||
expect(removeChild).not.toThrow();
|
expect(removeChild).not.toThrow();
|
||||||
expect(par2.children.length).toBe(n);
|
expect(par2.children).toBeArrayOfSize(n);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removing a child removes the child from the parent's 'children' property", () => {
|
it("removing a child removes the child from the parent's 'children' property", () => {
|
||||||
@ -179,11 +163,11 @@ describe('jsdoc/tutorial', () => {
|
|||||||
par2.removeChild(tute);
|
par2.removeChild(tute);
|
||||||
|
|
||||||
expect(par2.children).not.toContain(tute);
|
expect(par2.children).not.toContain(tute);
|
||||||
expect(par2.children.length).toBe(0);
|
expect(par2.children).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removing a child unsets the child's 'parent' property", () => {
|
it("removing a child unsets the child's 'parent' property", () => {
|
||||||
expect(tute.parent).toBe(null);
|
expect(tute.parent).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -196,24 +180,27 @@ describe('jsdoc/tutorial', () => {
|
|||||||
|
|
||||||
// let tute belong to par
|
// let tute belong to par
|
||||||
tute.setParent(par);
|
tute.setParent(par);
|
||||||
|
|
||||||
expect(tute.parent).toBe(par);
|
expect(tute.parent).toBe(par);
|
||||||
expect(par2.children.length).toBe(0);
|
expect(par2.children).toBeEmptyArray();
|
||||||
expect(par.children.length).toBe(1);
|
expect(par.children).toBeArrayOfSize(1);
|
||||||
expect(par.children[0]).toBe(tute);
|
expect(par.children[0]).toBe(tute);
|
||||||
|
|
||||||
// addChild tute to par2. its parent should now be par2, and
|
// addChild tute to par2. its parent should now be par2, and
|
||||||
// it can't be the child of two parents
|
// it can't be the child of two parents
|
||||||
par2.addChild(tute);
|
par2.addChild(tute);
|
||||||
|
|
||||||
expect(tute.parent).toBe(par2);
|
expect(tute.parent).toBe(par2);
|
||||||
expect(par.children.length).toBe(0);
|
expect(par.children).toBeEmptyArray();
|
||||||
expect(par2.children.length).toBe(1);
|
expect(par2.children).toBeArrayOfSize(1);
|
||||||
expect(par2.children[0]).toBe(tute);
|
expect(par2.children[0]).toBe(tute);
|
||||||
|
|
||||||
// removeChild tute from par2. tute should now be unparented.
|
// removeChild tute from par2. tute should now be unparented.
|
||||||
par2.removeChild(tute);
|
par2.removeChild(tute);
|
||||||
|
|
||||||
expect(tute.parent).toBe(null);
|
expect(tute.parent).toBe(null);
|
||||||
expect(par.children.length).toBe(0);
|
expect(par.children).toBeEmptyArray();
|
||||||
expect(par2.children.length).toBe(0);
|
expect(par2.children).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -259,8 +246,7 @@ describe('jsdoc/tutorial', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have a "getByName" method', () => {
|
it('should have a "getByName" method', () => {
|
||||||
expect(tutorial.RootTutorial.prototype.getByName).toBeDefined();
|
expect(tutorial.RootTutorial.prototype.getByName).toBeFunction();
|
||||||
expect(typeof tutorial.RootTutorial.prototype.getByName).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getByName', () => {
|
describe('getByName', () => {
|
||||||
@ -279,11 +265,11 @@ describe('jsdoc/tutorial', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns nothing for non-existent tutorials', () => {
|
it('returns nothing for non-existent tutorials', () => {
|
||||||
expect(root.getByName('asdf')).toBeFalsy();
|
expect(root.getByName('asdf')).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses hasOwnProperty when it checks for the tutorial', () => {
|
it('uses hasOwnProperty when it checks for the tutorial', () => {
|
||||||
expect(root.getByName('prototype')).toBeFalsy();
|
expect(root.getByName('prototype')).toBeFalse();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -31,33 +31,28 @@ describe('jsdoc/tutorial/resolver', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(resolver).toBeDefined();
|
expect(resolver).toBeObject();
|
||||||
expect(typeof resolver).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an "addTutorial" function', () => {
|
it('should export an "addTutorial" function', () => {
|
||||||
expect(resolver.addTutorial).toBeDefined();
|
expect(resolver.addTutorial).toBeFunction();
|
||||||
expect(typeof resolver.addTutorial).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "load" function', () => {
|
it('should export a "load" function', () => {
|
||||||
expect(resolver.load).toBeDefined();
|
expect(resolver.load).toBeFunction();
|
||||||
expect(typeof resolver.load).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "resolve" function', () => {
|
it('should export a "resolve" function', () => {
|
||||||
expect(resolver.resolve).toBeDefined();
|
expect(resolver.resolve).toBeFunction();
|
||||||
expect(typeof resolver.resolve).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "root" tutorial', () => {
|
it('should export a "root" tutorial', () => {
|
||||||
expect(resolver.root).toBeDefined();
|
expect(resolver.root).toBeObject();
|
||||||
expect(resolver.root instanceof tutorial.RootTutorial).toBe(true);
|
expect(resolver.root instanceof tutorial.RootTutorial).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('exported "root" tutorial should export a "getByName" function', () => {
|
it('exported "root" tutorial should export a "getByName" function', () => {
|
||||||
expect(resolver.root.getByName).toBeDefined();
|
expect(resolver.root.getByName).toBeFunction();
|
||||||
expect(typeof resolver.root.getByName).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// note: every time we addTutorial or run the resolver, we are *adding*
|
// note: every time we addTutorial or run the resolver, we are *adding*
|
||||||
@ -84,36 +79,39 @@ describe('jsdoc/tutorial/resolver', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('load', () => {
|
describe('load', () => {
|
||||||
|
const recurse = env.opts.recurse;
|
||||||
|
|
||||||
beforeEach(loadTutorials);
|
beforeEach(loadTutorials);
|
||||||
|
|
||||||
afterEach(resetRootTutorial);
|
afterEach(() => {
|
||||||
|
resetRootTutorial();
|
||||||
|
|
||||||
|
env.opts.recurse = recurse;
|
||||||
|
});
|
||||||
|
|
||||||
it('does not, by default, recurse into subdirectories', () => {
|
it('does not, by default, recurse into subdirectories', () => {
|
||||||
expect(resolver.root.getByName('test_recursive')).toBeFalsy();
|
expect(resolver.root.getByName('test_recursive')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('recurses into subdirectories when the --recurse flag is used', () => {
|
it('recurses into subdirectories when the --recurse flag is used', () => {
|
||||||
const recurse = env.opts.recurse;
|
|
||||||
let recursiveTute;
|
let recursiveTute;
|
||||||
|
|
||||||
env.opts.recurse = true;
|
env.opts.recurse = true;
|
||||||
loadTutorials();
|
loadTutorials();
|
||||||
recursiveTute = resolver.root.getByName('test_recursive');
|
recursiveTute = resolver.root.getByName('test_recursive');
|
||||||
|
|
||||||
expect(recursiveTute).toBeDefined();
|
expect(recursiveTute).toBeObject();
|
||||||
expect(recursiveTute instanceof tutorial.Tutorial).toBe(true);
|
expect(recursiveTute instanceof tutorial.Tutorial).toBe(true);
|
||||||
|
|
||||||
env.opts.recurse = recurse;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('all tutorials are added, initially as top-level tutorials', () => {
|
it('all tutorials are added, initially as top-level tutorials', () => {
|
||||||
// check they were added
|
// check they were added
|
||||||
expect(test).toBeDefined();
|
expect(test).toBeObject();
|
||||||
expect(test2).toBeDefined();
|
expect(test2).toBeObject();
|
||||||
expect(test3).toBeDefined();
|
expect(test3).toBeObject();
|
||||||
expect(test4).toBeDefined();
|
expect(test4).toBeObject();
|
||||||
expect(test6).toBeDefined();
|
expect(test6).toBeObject();
|
||||||
expect(constr).toBeDefined();
|
expect(constr).toBeObject();
|
||||||
// check they are top-level in resolver.root
|
// check they are top-level in resolver.root
|
||||||
expect(childNames).toContain('test');
|
expect(childNames).toContain('test');
|
||||||
expect(childNames).toContain('test2');
|
expect(childNames).toContain('test2');
|
||||||
@ -127,8 +125,8 @@ describe('jsdoc/tutorial/resolver', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('non-tutorials are skipped', () => {
|
it('non-tutorials are skipped', () => {
|
||||||
expect(resolver.root.getByName('multiple')).toBeFalsy();
|
expect(resolver.root.getByName('multiple')).toBeFalse();
|
||||||
expect(resolver.root.getByName('test5')).toBeFalsy();
|
expect(resolver.root.getByName('test5')).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('tutorial types are determined correctly', () => {
|
it('tutorial types are determined correctly', () => {
|
||||||
@ -172,26 +170,26 @@ describe('jsdoc/tutorial/resolver', () => {
|
|||||||
|
|
||||||
it('hierarchy is resolved properly no matter how the children property is defined', () => {
|
it('hierarchy is resolved properly no matter how the children property is defined', () => {
|
||||||
// root has child 'test'
|
// root has child 'test'
|
||||||
expect(resolver.root.children.length).toBe(2);
|
expect(resolver.root.children).toBeArrayOfSize(2);
|
||||||
expect(resolver.root.children).toContain(test);
|
expect(resolver.root.children).toContain(test);
|
||||||
expect(resolver.root.children).toContain(constr);
|
expect(resolver.root.children).toContain(constr);
|
||||||
expect(test.parent).toBe(resolver.root);
|
expect(test.parent).toBe(resolver.root);
|
||||||
expect(constr.parent).toBe(resolver.root);
|
expect(constr.parent).toBe(resolver.root);
|
||||||
|
|
||||||
// test has child 'test2'
|
// test has child 'test2'
|
||||||
expect(test.children.length).toBe(1);
|
expect(test.children).toBeArrayOfSize(1);
|
||||||
expect(test.children).toContain(test2);
|
expect(test.children).toContain(test2);
|
||||||
expect(test2.parent).toBe(test);
|
expect(test2.parent).toBe(test);
|
||||||
|
|
||||||
// test2 has children test3, test6
|
// test2 has children test3, test6
|
||||||
expect(test2.children.length).toBe(2);
|
expect(test2.children).toBeArrayOfSize(2);
|
||||||
expect(test2.children).toContain(test3);
|
expect(test2.children).toContain(test3);
|
||||||
expect(test2.children).toContain(test6);
|
expect(test2.children).toContain(test6);
|
||||||
expect(test3.parent).toBe(test2);
|
expect(test3.parent).toBe(test2);
|
||||||
expect(test6.parent).toBe(test2);
|
expect(test6.parent).toBe(test2);
|
||||||
|
|
||||||
// test3 has child test4
|
// test3 has child test4
|
||||||
expect(test3.children.length).toBe(1);
|
expect(test3.children).toBeArrayOfSize(1);
|
||||||
expect(test3.children).toContain(test4);
|
expect(test3.children).toContain(test4);
|
||||||
expect(test4.parent).toBe(test3);
|
expect(test4.parent).toBe(test3);
|
||||||
});
|
});
|
||||||
@ -236,7 +234,7 @@ describe('jsdoc/tutorial/resolver', () => {
|
|||||||
expect(logger.warn).toHaveBeenCalled();
|
expect(logger.warn).toHaveBeenCalled();
|
||||||
// we don't check to see which one wins; it depends on the order in which the JS engine
|
// we don't check to see which one wins; it depends on the order in which the JS engine
|
||||||
// iterates over object keys
|
// iterates over object keys
|
||||||
expect(resolver.root.getByName('asdf')).toBeDefined();
|
expect(resolver.root.getByName('asdf')).toBeObject();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,11 +2,11 @@ describe('jsdoc/util/cast', () => {
|
|||||||
const cast = require('jsdoc/util/cast');
|
const cast = require('jsdoc/util/cast');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(typeof cast).toBe('object');
|
expect(cast).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "cast" method', () => {
|
it('should export a "cast" method', () => {
|
||||||
expect(typeof cast.cast).toBe('function');
|
expect(cast.cast).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('cast', () => {
|
describe('cast', () => {
|
||||||
@ -26,14 +26,14 @@ describe('jsdoc/util/cast', () => {
|
|||||||
const truthish = cast.cast('true');
|
const truthish = cast.cast('true');
|
||||||
const falsish = cast.cast('false');
|
const falsish = cast.cast('false');
|
||||||
|
|
||||||
expect(truthish).toBe(true);
|
expect(truthish).toBeTrue();
|
||||||
expect(falsish).toBe(false);
|
expect(falsish).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should cast null-ish values to null', () => {
|
it('should cast null-ish values to null', () => {
|
||||||
const nullish = cast.cast('null');
|
const nullish = cast.cast('null');
|
||||||
|
|
||||||
expect(nullish).toBe(null);
|
expect(nullish).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should cast undefined-ish values to undefined', () => {
|
it('should cast undefined-ish values to undefined', () => {
|
||||||
@ -57,8 +57,7 @@ describe('jsdoc/util/cast', () => {
|
|||||||
it('should cast NaN-ish values to NaN', () => {
|
it('should cast NaN-ish values to NaN', () => {
|
||||||
const nan = cast.cast('NaN');
|
const nan = cast.cast('NaN');
|
||||||
|
|
||||||
expect(typeof nan).toBe('number');
|
expect(nan).toBeNaN();
|
||||||
expect(isNaN(nan)).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should convert values in an object', () => {
|
it('should convert values in an object', () => {
|
||||||
|
|||||||
@ -2,13 +2,11 @@ describe('jsdoc/util/doop', () => {
|
|||||||
const doop = require('jsdoc/util/doop');
|
const doop = require('jsdoc/util/doop');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(doop).toBeDefined();
|
expect(doop).toBeFunction();
|
||||||
expect(typeof doop).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a doop function for backwards compatibility', () => {
|
it('should export a doop function for backwards compatibility', () => {
|
||||||
expect(doop.doop).toBeDefined();
|
expect(doop.doop).toBeFunction();
|
||||||
expect(typeof doop.doop).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// deep-clones a simple object.
|
// deep-clones a simple object.
|
||||||
@ -19,18 +17,18 @@ describe('jsdoc/util/doop', () => {
|
|||||||
/* eslint-enable no-empty-function */
|
/* eslint-enable no-empty-function */
|
||||||
|
|
||||||
// test a number...
|
// test a number...
|
||||||
expect(doop.doop(3)).toBe(3);
|
expect(doop(3)).toBe(3);
|
||||||
// test a string...
|
// test a string...
|
||||||
expect(doop.doop('asdf')).toBe('asdf');
|
expect(doop('asdf')).toBe('asdf');
|
||||||
// test a boolean...
|
// test a boolean...
|
||||||
expect(doop.doop(true)).toBe(true);
|
expect(doop(true)).toBeTrue();
|
||||||
// test a function...
|
// test a function...
|
||||||
expect(doop.doop(f)).toBe(f);
|
expect(doop(f)).toBe(f);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a clone of an array', () => {
|
it('should return a clone of an array', () => {
|
||||||
const inp = [1, 2, 3];
|
const inp = [1, 2, 3];
|
||||||
const out = doop.doop(inp);
|
const out = doop(inp);
|
||||||
|
|
||||||
expect(inp).toEqual(out);
|
expect(inp).toEqual(out);
|
||||||
expect(inp).not.toBe(out);
|
expect(inp).not.toBe(out);
|
||||||
@ -42,7 +40,7 @@ describe('jsdoc/util/doop', () => {
|
|||||||
b: 2,
|
b: 2,
|
||||||
'asdf-fdsa': 3
|
'asdf-fdsa': 3
|
||||||
};
|
};
|
||||||
const out = doop.doop(inp);
|
const out = doop(inp);
|
||||||
|
|
||||||
expect(inp).toEqual(out);
|
expect(inp).toEqual(out);
|
||||||
expect(inp).not.toBe(out);
|
expect(inp).not.toBe(out);
|
||||||
@ -87,7 +85,7 @@ describe('jsdoc/util/doop', () => {
|
|||||||
b: [1, 2, 3]
|
b: [1, 2, 3]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const out = doop.doop(inp);
|
const out = doop(inp);
|
||||||
|
|
||||||
expect(inp).toEqual(out);
|
expect(inp).toEqual(out);
|
||||||
expect(inp).not.toBe(out);
|
expect(inp).not.toBe(out);
|
||||||
@ -107,7 +105,7 @@ describe('jsdoc/util/doop', () => {
|
|||||||
|
|
||||||
clone = doop(obj);
|
clone = doop(obj);
|
||||||
|
|
||||||
expect(clone.foo).not.toBeDefined();
|
expect(clone.foo).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not create a circular reference if an object is seen more than once', () => {
|
it('should not create a circular reference if an object is seen more than once', () => {
|
||||||
|
|||||||
@ -2,13 +2,11 @@ describe('jsdoc/util/dumper', () => {
|
|||||||
const dumper = require('jsdoc/util/dumper');
|
const dumper = require('jsdoc/util/dumper');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(dumper).toBeDefined();
|
expect(dumper).toBeObject();
|
||||||
expect(typeof dumper).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "dump" function', () => {
|
it('should export a "dump" function', () => {
|
||||||
expect(dumper.dump).toBeDefined();
|
expect(dumper.dump).toBeFunction();
|
||||||
expect(typeof dumper.dump).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can dump string values', () => {
|
it('can dump string values', () => {
|
||||||
@ -58,22 +56,19 @@ describe('jsdoc/util/dumper', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can dump array values', () => {
|
it('can dump array values', () => {
|
||||||
const actual = dumper.dump(['hello', 'world']);
|
const dumped = dumper.dump(['hello', 'world']);
|
||||||
const expected = '[\n "hello",\n "world"\n]';
|
|
||||||
|
|
||||||
expect(actual).toBe(expected);
|
expect(dumped).toBe('[\n "hello",\n "world"\n]');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can dump simple object values', () => {
|
it('can dump simple object values', () => {
|
||||||
const actual = dumper.dump({ hello: 'world' });
|
const dumped = dumper.dump({ hello: 'world' });
|
||||||
const expected = '{\n "hello": "world"\n}';
|
|
||||||
|
|
||||||
expect(actual).toBe(expected);
|
expect(dumped).toBe('{\n "hello": "world"\n}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can dump constructed instance values, not displaying prototype members', () => {
|
it('can dump constructed instance values, not displaying prototype members', () => {
|
||||||
let actual;
|
let dumped;
|
||||||
let expected;
|
|
||||||
|
|
||||||
function Foo(name) {
|
function Foo(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -82,10 +77,9 @@ describe('jsdoc/util/dumper', () => {
|
|||||||
Foo.prototype.sayHello = () => {};
|
Foo.prototype.sayHello = () => {};
|
||||||
/* eslint-enable no-empty-function */
|
/* eslint-enable no-empty-function */
|
||||||
|
|
||||||
actual = dumper.dump(new Foo('hello'));
|
dumped = dumper.dump(new Foo('hello'));
|
||||||
expected = '{\n "name": "hello"\n}';
|
|
||||||
|
|
||||||
expect(actual).toBe(expected);
|
expect(dumped).toBe('{\n "name": "hello"\n}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can dump complex mixed values', () => {
|
it('can dump complex mixed values', () => {
|
||||||
@ -93,7 +87,7 @@ describe('jsdoc/util/dumper', () => {
|
|||||||
function Foo() {}
|
function Foo() {}
|
||||||
/* eslint-enable no-empty-function */
|
/* eslint-enable no-empty-function */
|
||||||
|
|
||||||
const actual = dumper.dump([
|
const dumped = dumper.dump([
|
||||||
undefined,
|
undefined,
|
||||||
null,
|
null,
|
||||||
new Foo(),
|
new Foo(),
|
||||||
@ -133,20 +127,18 @@ describe('jsdoc/util/dumper', () => {
|
|||||||
' }\n' +
|
' }\n' +
|
||||||
']';
|
']';
|
||||||
|
|
||||||
expect(actual).toBe(expected);
|
expect(dumped).toBe(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('circular references', () => {
|
describe('circular references', () => {
|
||||||
it('should not crash on circular references', () => {
|
it('should not crash on circular references', () => {
|
||||||
const a = {};
|
const a = {};
|
||||||
let actual;
|
let dumped;
|
||||||
let expected;
|
|
||||||
|
|
||||||
a.b = a;
|
a.b = a;
|
||||||
actual = dumper.dump(a);
|
dumped = dumper.dump(a);
|
||||||
expected = '{\n "b": "<CircularRef>"\n}';
|
|
||||||
|
|
||||||
expect(actual).toBe(expected);
|
expect(dumped).toBe('{\n "b": "<CircularRef>"\n}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not treat references between different objects as circular refs', () => {
|
it('should not treat references between different objects as circular refs', () => {
|
||||||
@ -157,11 +149,11 @@ describe('jsdoc/util/dumper', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
let actual;
|
let dumped;
|
||||||
let expected;
|
let expected;
|
||||||
|
|
||||||
a[1] = { d: a[0].b };
|
a[1] = { d: a[0].b };
|
||||||
actual = dumper.dump(a);
|
dumped = dumper.dump(a);
|
||||||
expected = '' +
|
expected = '' +
|
||||||
'[\n' +
|
'[\n' +
|
||||||
' {\n' +
|
' {\n' +
|
||||||
@ -176,7 +168,7 @@ describe('jsdoc/util/dumper', () => {
|
|||||||
' }\n' +
|
' }\n' +
|
||||||
']';
|
']';
|
||||||
|
|
||||||
expect(actual).toBe(expected);
|
expect(dumped).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -184,14 +176,14 @@ describe('jsdoc/util/dumper', () => {
|
|||||||
it('should dump all of its arguments, separated by newlines', () => {
|
it('should dump all of its arguments, separated by newlines', () => {
|
||||||
const a = { b: 1 };
|
const a = { b: 1 };
|
||||||
const b = 'hello';
|
const b = 'hello';
|
||||||
const actual = dumper.dump(a, b);
|
const dumped = dumper.dump(a, b);
|
||||||
const expected = '' +
|
const expected = '' +
|
||||||
'{\n' +
|
'{\n' +
|
||||||
' "b": 1\n' +
|
' "b": 1\n' +
|
||||||
'}\n' +
|
'}\n' +
|
||||||
'"hello"';
|
'"hello"';
|
||||||
|
|
||||||
expect(actual).toBe(expected);
|
expect(dumped).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,59 +4,49 @@ describe('jsdoc/util/logger', () => {
|
|||||||
const loggerArgs = ['foo bar %s', 'hello'];
|
const loggerArgs = ['foo bar %s', 'hello'];
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(logger).toBeDefined();
|
expect(logger).toBeObject();
|
||||||
expect(typeof logger).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should inherit from EventEmitter', () => {
|
it('should inherit from EventEmitter', () => {
|
||||||
const EventEmitter = require('events').EventEmitter;
|
const { EventEmitter } = require('events');
|
||||||
|
|
||||||
expect(logger instanceof EventEmitter).toBe(true);
|
expect(logger instanceof EventEmitter).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "debug" method', () => {
|
it('should export a "debug" method', () => {
|
||||||
expect(logger.debug).toBeDefined();
|
expect(logger.debug).toBeFunction();
|
||||||
expect(typeof logger.debug).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an "error" method', () => {
|
it('should export an "error" method', () => {
|
||||||
expect(logger.error).toBeDefined();
|
expect(logger.error).toBeFunction();
|
||||||
expect(typeof logger.error).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "fatal" method', () => {
|
it('should export a "fatal" method', () => {
|
||||||
expect(logger.fatal).toBeDefined();
|
expect(logger.fatal).toBeFunction();
|
||||||
expect(typeof logger.fatal).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "getLevel" method', () => {
|
it('should export a "getLevel" method', () => {
|
||||||
expect(logger.getLevel).toBeDefined();
|
expect(logger.getLevel).toBeFunction();
|
||||||
expect(typeof logger.getLevel).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an "info" method', () => {
|
it('should export an "info" method', () => {
|
||||||
expect(logger.info).toBeDefined();
|
expect(logger.info).toBeFunction();
|
||||||
expect(typeof logger.info).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "LEVELS" object', () => {
|
it('should export a "LEVELS" object', () => {
|
||||||
expect(logger.LEVELS).toBeDefined();
|
expect(logger.LEVELS).toBeObject();
|
||||||
expect(typeof logger.LEVELS).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "setLevel" method', () => {
|
it('should export a "setLevel" method', () => {
|
||||||
expect(logger.setLevel).toBeDefined();
|
expect(logger.setLevel).toBeFunction();
|
||||||
expect(typeof logger.setLevel).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "verbose" method', () => {
|
it('should export a "verbose" method', () => {
|
||||||
expect(logger.verbose).toBeDefined();
|
expect(logger.verbose).toBeFunction();
|
||||||
expect(typeof logger.verbose).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "warn" method', () => {
|
it('should export a "warn" method', () => {
|
||||||
expect(logger.warn).toBeDefined();
|
expect(logger.warn).toBeFunction();
|
||||||
expect(typeof logger.warn).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// helpers for testing logger methods
|
// helpers for testing logger methods
|
||||||
@ -79,8 +69,7 @@ describe('jsdoc/util/logger', () => {
|
|||||||
});
|
});
|
||||||
logger[name](loggerArgs[0], loggerArgs[1]);
|
logger[name](loggerArgs[0], loggerArgs[1]);
|
||||||
|
|
||||||
expect(capturedArgs).toBeDefined();
|
expect(capturedArgs).toBeArrayOfSize(2);
|
||||||
expect( Array.isArray(capturedArgs) ).toBe(true);
|
|
||||||
expect(capturedArgs[0]).toBe(loggerArgs[0]);
|
expect(capturedArgs[0]).toBe(loggerArgs[0]);
|
||||||
expect(capturedArgs[1]).toBe(loggerArgs[1]);
|
expect(capturedArgs[1]).toBe(loggerArgs[1]);
|
||||||
}
|
}
|
||||||
@ -143,12 +132,12 @@ describe('jsdoc/util/logger', () => {
|
|||||||
const LEVELS = logger.LEVELS;
|
const LEVELS = logger.LEVELS;
|
||||||
|
|
||||||
it('should include the correct properties', () => {
|
it('should include the correct properties', () => {
|
||||||
expect(LEVELS.VERBOSE).toBeDefined();
|
expect(LEVELS.VERBOSE).toBeNumber();
|
||||||
expect(LEVELS.DEBUG).toBeDefined();
|
expect(LEVELS.DEBUG).toBeNumber();
|
||||||
expect(LEVELS.INFO).toBeDefined();
|
expect(LEVELS.INFO).toBeNumber();
|
||||||
expect(LEVELS.WARN).toBeDefined();
|
expect(LEVELS.WARN).toBeNumber();
|
||||||
expect(LEVELS.ERROR).toBeDefined();
|
expect(LEVELS.ERROR).toBeNumber();
|
||||||
expect(LEVELS.SILENT).toBeDefined();
|
expect(LEVELS.SILENT).toBeNumber();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should weight the logging levels correctly relative to one another', () => {
|
it('should weight the logging levels correctly relative to one another', () => {
|
||||||
|
|||||||
@ -4,13 +4,11 @@ describe('jsdoc/util/markdown', () => {
|
|||||||
const markdown = require('jsdoc/util/markdown');
|
const markdown = require('jsdoc/util/markdown');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(markdown).toBeDefined();
|
expect(markdown).toBeObject();
|
||||||
expect(typeof markdown).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "getParser" function', () => {
|
it('should export a "getParser" function', () => {
|
||||||
expect(markdown.getParser).toBeDefined();
|
expect(markdown.getParser).toBeFunction();
|
||||||
expect(typeof markdown.getParser).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getParser', () => {
|
describe('getParser', () => {
|
||||||
@ -29,7 +27,8 @@ describe('jsdoc/util/markdown', () => {
|
|||||||
|
|
||||||
setMarkdownConf({});
|
setMarkdownConf({});
|
||||||
parser = markdown.getParser();
|
parser = markdown.getParser();
|
||||||
expect(typeof parser).toBe('function');
|
|
||||||
|
expect(parser).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use the markdown-it parser by default', () => {
|
it('should use the markdown-it parser by default', () => {
|
||||||
@ -37,6 +36,7 @@ describe('jsdoc/util/markdown', () => {
|
|||||||
|
|
||||||
setMarkdownConf({});
|
setMarkdownConf({});
|
||||||
parser = markdown.getParser();
|
parser = markdown.getParser();
|
||||||
|
|
||||||
expect(parser._parser).toBe('markdownit');
|
expect(parser._parser).toBe('markdownit');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -45,6 +45,7 @@ describe('jsdoc/util/markdown', () => {
|
|||||||
|
|
||||||
setMarkdownConf({parser: 'evilstreak'});
|
setMarkdownConf({parser: 'evilstreak'});
|
||||||
parser = markdown.getParser();
|
parser = markdown.getParser();
|
||||||
|
|
||||||
expect(parser._parser).toBe('markdownit');
|
expect(parser._parser).toBe('markdownit');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -53,6 +54,7 @@ describe('jsdoc/util/markdown', () => {
|
|||||||
|
|
||||||
setMarkdownConf({parser: 'marked'});
|
setMarkdownConf({parser: 'marked'});
|
||||||
parser = markdown.getParser();
|
parser = markdown.getParser();
|
||||||
|
|
||||||
expect(parser._parser).toBe('marked');
|
expect(parser._parser).toBe('marked');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -61,6 +63,7 @@ describe('jsdoc/util/markdown', () => {
|
|||||||
|
|
||||||
setMarkdownConf({parser: 'gfm'});
|
setMarkdownConf({parser: 'gfm'});
|
||||||
parser = markdown.getParser();
|
parser = markdown.getParser();
|
||||||
|
|
||||||
expect(parser._parser).toBe('markdownit');
|
expect(parser._parser).toBe('markdownit');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,11 @@ describe('jsdoc/util/stripbom', () => {
|
|||||||
const stripBom = require('jsdoc/util/stripbom');
|
const stripBom = require('jsdoc/util/stripbom');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(typeof stripBom).toBe('object');
|
expect(stripBom).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "strip" method', () => {
|
it('should export a "strip" method', () => {
|
||||||
expect(typeof stripBom.strip).toBe('function');
|
expect(stripBom.strip).toBeFunction();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('strip', () => {
|
describe('strip', () => {
|
||||||
|
|||||||
@ -10,143 +10,116 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
const helper = require('jsdoc/util/templateHelper');
|
const helper = require('jsdoc/util/templateHelper');
|
||||||
const logger = require('jsdoc/util/logger');
|
const logger = require('jsdoc/util/logger');
|
||||||
const resolver = require('jsdoc/tutorial/resolver');
|
const resolver = require('jsdoc/tutorial/resolver');
|
||||||
const taffy = require('taffydb').taffy;
|
const { taffy } = require('taffydb');
|
||||||
|
|
||||||
helper.registerLink('test', 'path/to/test.html');
|
helper.registerLink('test', 'path/to/test.html');
|
||||||
|
|
||||||
it("should exist", () => {
|
it("should exist", () => {
|
||||||
expect(helper).toBeDefined();
|
expect(helper).toBeObject();
|
||||||
expect(typeof helper).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'setTutorials' function", () => {
|
it("should export a 'setTutorials' function", () => {
|
||||||
expect(helper.setTutorials).toBeDefined();
|
expect(helper.setTutorials).toBeFunction();
|
||||||
expect(typeof helper.setTutorials).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'globalName' property", () => {
|
it("should export a 'globalName' property", () => {
|
||||||
expect(helper.globalName).toBeDefined();
|
expect(helper.globalName).toBeString();
|
||||||
expect(typeof helper.globalName).toBe("string");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'fileExtension' property", () => {
|
it("should export a 'fileExtension' property", () => {
|
||||||
expect(helper.fileExtension).toBeDefined();
|
expect(helper.fileExtension).toBeString();
|
||||||
expect(typeof helper.fileExtension).toBe("string");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'scopeToPunc' property", () => {
|
it("should export a 'scopeToPunc' property", () => {
|
||||||
expect(helper.scopeToPunc).toBeDefined();
|
expect(helper.scopeToPunc).toBeObject();
|
||||||
expect(typeof helper.scopeToPunc).toBe("object");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'getUniqueFilename' function", () => {
|
it("should export a 'getUniqueFilename' function", () => {
|
||||||
expect(helper.getUniqueFilename).toBeDefined();
|
expect(helper.getUniqueFilename).toBeFunction();
|
||||||
expect(typeof helper.getUniqueFilename).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'getUniqueId' function", () => {
|
it("should export a 'getUniqueId' function", () => {
|
||||||
expect(helper.getUniqueId).toBeDefined();
|
expect(helper.getUniqueId).toBeFunction();
|
||||||
expect(typeof helper.getUniqueId).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'longnameToUrl' property", () => {
|
it("should export a 'longnameToUrl' property", () => {
|
||||||
expect(helper.longnameToUrl).toBeDefined();
|
expect(helper.longnameToUrl).toBeObject();
|
||||||
expect(typeof helper.longnameToUrl).toBe("object");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'linkto' function", () => {
|
it("should export a 'linkto' function", () => {
|
||||||
expect(helper.linkto).toBeDefined();
|
expect(helper.linkto).toBeFunction();
|
||||||
expect(typeof helper.linkto).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export an 'htmlsafe' function", () => {
|
it("should export an 'htmlsafe' function", () => {
|
||||||
expect(helper.htmlsafe).toBeDefined();
|
expect(helper.htmlsafe).toBeFunction();
|
||||||
expect(typeof helper.htmlsafe).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'find' function", () => {
|
it("should export a 'find' function", () => {
|
||||||
expect(helper.find).toBeDefined();
|
expect(helper.find).toBeFunction();
|
||||||
expect(typeof helper.find).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'getMembers' function", () => {
|
it("should export a 'getMembers' function", () => {
|
||||||
expect(helper.getMembers).toBeDefined();
|
expect(helper.getMembers).toBeFunction();
|
||||||
expect(typeof helper.getMembers).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'getAttribs' function", () => {
|
it("should export a 'getAttribs' function", () => {
|
||||||
expect(helper.getAttribs).toBeDefined();
|
expect(helper.getAttribs).toBeFunction();
|
||||||
expect(typeof helper.getAttribs).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'getSignatureTypes' function", () => {
|
it("should export a 'getSignatureTypes' function", () => {
|
||||||
expect(helper.getSignatureTypes).toBeDefined();
|
expect(helper.getSignatureTypes).toBeFunction();
|
||||||
expect(typeof helper.getSignatureTypes).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'getSignatureParams' function", () => {
|
it("should export a 'getSignatureParams' function", () => {
|
||||||
expect(helper.getSignatureParams).toBeDefined();
|
expect(helper.getSignatureParams).toBeFunction();
|
||||||
expect(typeof helper.getSignatureParams).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'getSignatureReturns' function", () => {
|
it("should export a 'getSignatureReturns' function", () => {
|
||||||
expect(helper.getSignatureReturns).toBeDefined();
|
expect(helper.getSignatureReturns).toBeFunction();
|
||||||
expect(typeof helper.getSignatureReturns).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'getAncestors' function", () => {
|
it("should export a 'getAncestors' function", () => {
|
||||||
expect(helper.getAncestors).toBeDefined();
|
expect(helper.getAncestors).toBeFunction();
|
||||||
expect(typeof helper.getAncestors).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'getAncestorLinks' function", () => {
|
it("should export a 'getAncestorLinks' function", () => {
|
||||||
expect(helper.getAncestorLinks).toBeDefined();
|
expect(helper.getAncestorLinks).toBeFunction();
|
||||||
expect(typeof helper.getAncestorLinks).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'addEventListeners' function", () => {
|
it("should export a 'addEventListeners' function", () => {
|
||||||
expect(helper.addEventListeners).toBeDefined();
|
expect(helper.addEventListeners).toBeFunction();
|
||||||
expect(typeof helper.addEventListeners).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'prune' function", () => {
|
it("should export a 'prune' function", () => {
|
||||||
expect(helper.prune).toBeDefined();
|
expect(helper.prune).toBeFunction();
|
||||||
expect(typeof helper.prune).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'registerLink' function", () => {
|
it("should export a 'registerLink' function", () => {
|
||||||
expect(helper.registerLink).toBeDefined();
|
expect(helper.registerLink).toBeFunction();
|
||||||
expect(typeof helper.registerLink).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'tutorialToUrl' function", () => {
|
it("should export a 'tutorialToUrl' function", () => {
|
||||||
expect(helper.tutorialToUrl).toBeDefined();
|
expect(helper.tutorialToUrl).toBeFunction();
|
||||||
expect(typeof helper.tutorialToUrl).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'toTutorial' function", () => {
|
it("should export a 'toTutorial' function", () => {
|
||||||
expect(helper.toTutorial).toBeDefined();
|
expect(helper.toTutorial).toBeFunction();
|
||||||
expect(typeof helper.toTutorial).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'resolveLinks' function", () => {
|
it("should export a 'resolveLinks' function", () => {
|
||||||
expect(helper.resolveLinks).toBeDefined();
|
expect(helper.resolveLinks).toBeFunction();
|
||||||
expect(typeof helper.resolveLinks).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'resolveAuthorLinks' function", () => {
|
it("should export a 'resolveAuthorLinks' function", () => {
|
||||||
expect(helper.resolveAuthorLinks).toBeDefined();
|
expect(helper.resolveAuthorLinks).toBeFunction();
|
||||||
expect(typeof helper.resolveAuthorLinks).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'createLink' function", () => {
|
it("should export a 'createLink' function", () => {
|
||||||
expect(helper.createLink).toBeDefined();
|
expect(helper.createLink).toBeFunction();
|
||||||
expect(typeof helper.createLink).toBe("function");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "longnamesToTree" function', () => {
|
it('should export a "longnamesToTree" function', () => {
|
||||||
expect(helper.longnamesToTree).toBeDefined();
|
expect(helper.longnamesToTree).toBeFunction();
|
||||||
expect(typeof helper.longnamesToTree).toBe('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("setTutorials", () => {
|
describe("setTutorials", () => {
|
||||||
@ -154,6 +127,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
it("setting tutorials to null causes all tutorial lookups to fail", () => {
|
it("setting tutorials to null causes all tutorial lookups to fail", () => {
|
||||||
// bit of a dodgy test but the best I can manage. setTutorials doesn't do much.
|
// bit of a dodgy test but the best I can manage. setTutorials doesn't do much.
|
||||||
helper.setTutorials(null);
|
helper.setTutorials(null);
|
||||||
|
|
||||||
// should throw error: no 'getByName' in tutorials.
|
// should throw error: no 'getByName' in tutorials.
|
||||||
expect(() => helper.tutorialToUrl('asdf')).toThrow();
|
expect(() => helper.tutorialToUrl('asdf')).toThrow();
|
||||||
});
|
});
|
||||||
@ -317,22 +291,26 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("longnameToUrl", () => {
|
describe("longnameToUrl", () => {
|
||||||
|
afterEach(() => {
|
||||||
|
delete helper.longnameToUrl.foo2;
|
||||||
|
delete helper.longnameToUrl.MySymbol;
|
||||||
|
});
|
||||||
|
|
||||||
it("is an object", () => {
|
it("is an object", () => {
|
||||||
expect(typeof helper.longnameToUrl).toBe('object');
|
expect(typeof helper.longnameToUrl).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has an entry added into it by calling registerLink", () => {
|
it("has an entry added into it by calling registerLink", () => {
|
||||||
helper.registerLink('MySymbol', 'asdf.html');
|
helper.registerLink('MySymbol', 'asdf.html');
|
||||||
|
|
||||||
expect(helper.longnameToUrl.MySymbol).toBeDefined();
|
expect(helper.longnameToUrl.MySymbol).toBeDefined();
|
||||||
expect(helper.longnameToUrl.MySymbol).toBe('asdf.html');
|
expect(helper.longnameToUrl.MySymbol).toBe('asdf.html');
|
||||||
|
|
||||||
delete helper.longnameToUrl.MySymbol;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("adding an entry to it allows me to link with linkto", () => {
|
it("adding an entry to it allows me to link with linkto", () => {
|
||||||
helper.longnameToUrl.foo2 = 'bar.html';
|
helper.longnameToUrl.foo2 = 'bar.html';
|
||||||
|
|
||||||
expect(helper.linkto('foo2')).toBe('<a href="bar.html">foo2</a>');
|
expect(helper.linkto('foo2')).toBe('<a href="bar.html">foo2</a>');
|
||||||
delete helper.longnameToUrl.foo2;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -390,7 +368,6 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
// we don't have a registered link for 'constructor' so it should return the text 'link text'.
|
// we don't have a registered link for 'constructor' so it should return the text 'link text'.
|
||||||
const link = helper.linkto('constructor', 'link text');
|
const link = helper.linkto('constructor', 'link text');
|
||||||
|
|
||||||
expect(typeof link).toBe('string');
|
|
||||||
expect(link).toBe('link text');
|
expect(link).toBe('link text');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -432,6 +409,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
spyOn(logger, 'error');
|
spyOn(logger, 'error');
|
||||||
|
|
||||||
helper.linkto('<anonymous>~foo');
|
helper.linkto('<anonymous>~foo');
|
||||||
|
|
||||||
expect(logger.error).not.toHaveBeenCalled();
|
expect(logger.error).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -644,37 +622,45 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
const misc = miscGlobal.concat(miscNonGlobal);
|
const misc = miscGlobal.concat(miscNonGlobal);
|
||||||
const array = classes.concat(externals.concat(events.concat(mixins.concat(modules.concat(namespaces.concat(misc))))));
|
const array = [
|
||||||
|
...classes,
|
||||||
|
...externals,
|
||||||
|
...events,
|
||||||
|
...mixins,
|
||||||
|
...modules,
|
||||||
|
...namespaces,
|
||||||
|
...misc
|
||||||
|
];
|
||||||
const data = taffy(array);
|
const data = taffy(array);
|
||||||
const members = helper.getMembers(data);
|
const members = helper.getMembers(data);
|
||||||
|
|
||||||
// check the output object has properties as expected.
|
// check the output object has properties as expected.
|
||||||
it("should have a 'classes' property", () => {
|
it("should have a 'classes' property", () => {
|
||||||
expect(members.classes).toBeDefined();
|
expect(members.classes).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'externals' property", () => {
|
it("should have a 'externals' property", () => {
|
||||||
expect(members.externals).toBeDefined();
|
expect(members.externals).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'events' property", () => {
|
it("should have a 'events' property", () => {
|
||||||
expect(members.events).toBeDefined();
|
expect(members.events).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'globals' property", () => {
|
it("should have a 'globals' property", () => {
|
||||||
expect(members.globals).toBeDefined();
|
expect(members.globals).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'mixins' property", () => {
|
it("should have a 'mixins' property", () => {
|
||||||
expect(members.mixins).toBeDefined();
|
expect(members.mixins).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'modules' property", () => {
|
it("should have a 'modules' property", () => {
|
||||||
expect(members.modules).toBeDefined();
|
expect(members.modules).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'namespaces' property", () => {
|
it("should have a 'namespaces' property", () => {
|
||||||
expect(members.namespaces).toBeDefined();
|
expect(members.namespaces).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
// check that things were found properly.
|
// check that things were found properly.
|
||||||
@ -711,10 +697,11 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
let doc;
|
let doc;
|
||||||
let attribs;
|
let attribs;
|
||||||
|
|
||||||
it('should return an array of strings', () => {
|
it('should return an array', () => {
|
||||||
doc = new doclet.Doclet('/** ljklajsdf */', {});
|
doc = new doclet.Doclet('/** ljklajsdf */', {});
|
||||||
attribs = helper.getAttribs(doc);
|
attribs = helper.getAttribs(doc);
|
||||||
expect(Array.isArray(attribs)).toBe(true);
|
|
||||||
|
expect(attribs).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
// tests is an object of test[doclet src] = <result expected in attribs|false>
|
// tests is an object of test[doclet src] = <result expected in attribs|false>
|
||||||
@ -843,28 +830,31 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
expect(getAttribs).not.toThrow();
|
expect(getAttribs).not.toThrow();
|
||||||
|
|
||||||
emptyAttribs = getAttribs();
|
emptyAttribs = getAttribs();
|
||||||
expect( Array.isArray(emptyAttribs) ).toBe(true);
|
|
||||||
expect(emptyAttribs.length).toBe(0);
|
expect(emptyAttribs).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getSignatureTypes", () => {
|
describe("getSignatureTypes", () => {
|
||||||
|
afterEach(() => {
|
||||||
|
delete helper.longnameToUrl.MyClass;
|
||||||
|
});
|
||||||
|
|
||||||
// returns links to allowed types for a doclet.
|
// returns links to allowed types for a doclet.
|
||||||
it("returns an empty array if the doclet has no specified type", () => {
|
it("returns an empty array if the doclet has no specified type", () => {
|
||||||
const doc = new doclet.Doclet('/** @const ASDF */', {});
|
const doc = new doclet.Doclet('/** @const ASDF */', {});
|
||||||
const types = helper.getSignatureTypes(doc);
|
const types = helper.getSignatureTypes(doc);
|
||||||
|
|
||||||
expect(Array.isArray(types)).toBe(true);
|
expect(types).toBeEmptyArray();
|
||||||
expect(types.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns a string array of the doclet's types", () => {
|
it("returns a string array of the doclet's types", () => {
|
||||||
const doc = new doclet.Doclet('/** @const {number|Array.<boolean>} ASDF */', {});
|
const doc = new doclet.Doclet('/** @const {number|Array.<boolean>} ASDF */', {});
|
||||||
const types = helper.getSignatureTypes(doc);
|
const types = helper.getSignatureTypes(doc);
|
||||||
|
|
||||||
expect(types.length).toBe(2);
|
expect(types).toBeArrayOfSize(2);
|
||||||
expect(types).toContain('number');
|
expect(types).toContain('number');
|
||||||
expect(types).toContain(helper.htmlsafe('Array.<boolean>')); // should be HTML safe
|
expect(types).toContain(helper.htmlsafe('Array.<boolean>'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("creates links for types if relevant", () => {
|
it("creates links for types if relevant", () => {
|
||||||
@ -877,10 +867,8 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
doc = new doclet.Doclet('/** @const {MyClass} ASDF */', {});
|
doc = new doclet.Doclet('/** @const {MyClass} ASDF */', {});
|
||||||
types = helper.getSignatureTypes(doc);
|
types = helper.getSignatureTypes(doc);
|
||||||
|
|
||||||
expect(types.length).toBe(1);
|
expect(types).toBeArrayOfSize(1);
|
||||||
expect(types).toContain('<a href="MyClass.html">MyClass</a>');
|
expect(types).toContain('<a href="MyClass.html">MyClass</a>');
|
||||||
|
|
||||||
delete helper.longnameToUrl.MyClass;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses the cssClass parameter for links if it is provided", () => {
|
it("uses the cssClass parameter for links if it is provided", () => {
|
||||||
@ -893,10 +881,8 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
doc = new doclet.Doclet('/** @const {MyClass} ASDF */', {});
|
doc = new doclet.Doclet('/** @const {MyClass} ASDF */', {});
|
||||||
types = helper.getSignatureTypes(doc, 'myCSSClass');
|
types = helper.getSignatureTypes(doc, 'myCSSClass');
|
||||||
|
|
||||||
expect(types.length).toBe(1);
|
expect(types).toBeArrayOfSize(1);
|
||||||
expect(types).toContain('<a href="MyClass.html" class="myCSSClass">MyClass</a>');
|
expect(types).toContain('<a href="MyClass.html" class="myCSSClass">MyClass</a>');
|
||||||
|
|
||||||
delete helper.longnameToUrl.MyClass;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -907,15 +893,14 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
const doc = new doclet.Doclet('/** @function myFunction */', {});
|
const doc = new doclet.Doclet('/** @function myFunction */', {});
|
||||||
const params = helper.getSignatureParams(doc);
|
const params = helper.getSignatureParams(doc);
|
||||||
|
|
||||||
expect(Array.isArray(params)).toBe(true);
|
expect(params).toBeEmptyArray();
|
||||||
expect(params.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns a string array of the doclet's parameter names", () => {
|
it("returns a string array of the doclet's parameter names", () => {
|
||||||
const doc = new doclet.Doclet('/** @function myFunction\n @param {string} foo - asdf. */', {});
|
const doc = new doclet.Doclet('/** @function myFunction\n @param {string} foo - asdf. */', {});
|
||||||
const params = helper.getSignatureParams(doc);
|
const params = helper.getSignatureParams(doc);
|
||||||
|
|
||||||
expect(params.length).toBe(1);
|
expect(params).toBeArrayOfSize(1);
|
||||||
expect(params).toContain('foo');
|
expect(params).toContain('foo');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -928,7 +913,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
' */', {});
|
' */', {});
|
||||||
const params = helper.getSignatureParams(doc, 'cssClass');
|
const params = helper.getSignatureParams(doc, 'cssClass');
|
||||||
|
|
||||||
expect(params.length).toBe(3);
|
expect(params).toBeArrayOfSize(3);
|
||||||
expect(params).toContain('foo');
|
expect(params).toContain('foo');
|
||||||
expect(params).toContain('<span class="cssClass">bar</span>');
|
expect(params).toContain('<span class="cssClass">bar</span>');
|
||||||
expect(params).toContain('<span class="cssClass">baz</span>');
|
expect(params).toContain('<span class="cssClass">baz</span>');
|
||||||
@ -943,7 +928,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
' */', {});
|
' */', {});
|
||||||
const params = helper.getSignatureParams(doc);
|
const params = helper.getSignatureParams(doc);
|
||||||
|
|
||||||
expect(params.length).toBe(3);
|
expect(params).toBeArrayOfSize(3);
|
||||||
expect(params).toContain('foo');
|
expect(params).toContain('foo');
|
||||||
expect(params).toContain('bar');
|
expect(params).toContain('bar');
|
||||||
expect(params).toContain('baz');
|
expect(params).toContain('baz');
|
||||||
@ -951,6 +936,10 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("getSignatureReturns", () => {
|
describe("getSignatureReturns", () => {
|
||||||
|
afterEach(() => {
|
||||||
|
delete helper.longnameToUrl.MyClass;
|
||||||
|
});
|
||||||
|
|
||||||
it("returns a value with correctly escaped HTML", () => {
|
it("returns a value with correctly escaped HTML", () => {
|
||||||
const mockDoclet = {
|
const mockDoclet = {
|
||||||
returns: [
|
returns: [
|
||||||
@ -973,16 +962,14 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
const doc = new doclet.Doclet('/** @function myFunction */', {});
|
const doc = new doclet.Doclet('/** @function myFunction */', {});
|
||||||
const returns = helper.getSignatureReturns(doc);
|
const returns = helper.getSignatureReturns(doc);
|
||||||
|
|
||||||
expect(Array.isArray(returns)).toBe(true);
|
expect(returns).toBeEmptyArray();
|
||||||
expect(returns.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns an empty array if the doclet has @returns but with no type", () => {
|
it("returns an empty array if the doclet has @returns but with no type", () => {
|
||||||
const doc = new doclet.Doclet('/** @function myFunction\n@returns an interesting result.*/', {});
|
const doc = new doclet.Doclet('/** @function myFunction\n@returns an interesting result.*/', {});
|
||||||
const returns = helper.getSignatureReturns(doc);
|
const returns = helper.getSignatureReturns(doc);
|
||||||
|
|
||||||
expect(Array.isArray(returns)).toBe(true);
|
expect(returns).toBeEmptyArray();
|
||||||
expect(returns.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses the value of the `yields` property', () => {
|
it('uses the value of the `yields` property', () => {
|
||||||
@ -1010,11 +997,9 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
doc = new doclet.Doclet('/** @function myFunction\n@returns {number|MyClass} an interesting result.*/', {});
|
doc = new doclet.Doclet('/** @function myFunction\n@returns {number|MyClass} an interesting result.*/', {});
|
||||||
returns = helper.getSignatureReturns(doc);
|
returns = helper.getSignatureReturns(doc);
|
||||||
|
|
||||||
expect(returns.length).toBe(2);
|
expect(returns).toBeArrayOfSize(2);
|
||||||
expect(returns).toContain('<a href="MyClass.html">MyClass</a>');
|
expect(returns).toContain('<a href="MyClass.html">MyClass</a>');
|
||||||
expect(returns).toContain('number');
|
expect(returns).toContain('number');
|
||||||
|
|
||||||
delete helper.longnameToUrl.MyClass;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses the cssClass parameter for links if it is provided", () => {
|
it("uses the cssClass parameter for links if it is provided", () => {
|
||||||
@ -1027,11 +1012,9 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
doc = new doclet.Doclet('/** @function myFunction\n@returns {number|MyClass} an interesting result.*/', {});
|
doc = new doclet.Doclet('/** @function myFunction\n@returns {number|MyClass} an interesting result.*/', {});
|
||||||
returns = helper.getSignatureReturns(doc, 'myCssClass');
|
returns = helper.getSignatureReturns(doc, 'myCssClass');
|
||||||
|
|
||||||
expect(returns.length).toBe(2);
|
expect(returns).toBeArrayOfSize(2);
|
||||||
expect(returns).toContain('<a href="MyClass.html" class="myCssClass">MyClass</a>');
|
expect(returns).toContain('<a href="MyClass.html" class="myCssClass">MyClass</a>');
|
||||||
expect(returns).toContain('number');
|
expect(returns).toContain('number');
|
||||||
|
|
||||||
delete helper.longnameToUrl.MyClass;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1047,29 +1030,35 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
const mafia = new doclet.Doclet('/** @module mafia/gangs */', {});
|
const mafia = new doclet.Doclet('/** @module mafia/gangs */', {});
|
||||||
const data = taffy([lackeys, henchman, gang, mafia]);
|
const data = taffy([lackeys, henchman, gang, mafia]);
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
delete helper.longnameToUrl['module:mafia/gangs'];
|
||||||
|
delete helper.longnameToUrl['module:mafia/gangs.Sharks~Henchman'];
|
||||||
|
});
|
||||||
|
|
||||||
// register some links
|
// register some links
|
||||||
it("returns an empty array if there are no ancestors", () => {
|
it("returns an empty array if there are no ancestors", () => {
|
||||||
const links = helper.getAncestorLinks(data, mafia);
|
const links = helper.getAncestorLinks(data, mafia);
|
||||||
|
|
||||||
expect(Array.isArray(links)).toBe(true);
|
expect(links).toBeEmptyArray();
|
||||||
expect(links.length).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns an array of ancestor names (with preceding punctuation) if there are ancestors, the direct ancestor with following punctuation too", () => {
|
it("returns an array of ancestor names (with preceding punctuation) if there are ancestors, the direct ancestor with following punctuation too", () => {
|
||||||
let links = helper.getAncestorLinks(data, lackeys);
|
let links = helper.getAncestorLinks(data, lackeys);
|
||||||
|
|
||||||
expect(links.length).toBe(3);
|
expect(links).toBeArrayOfSize(3);
|
||||||
expect(links).toContain('~Henchman#');
|
expect(links).toContain('~Henchman#');
|
||||||
expect(links).toContain('.Sharks');
|
expect(links).toContain('.Sharks');
|
||||||
expect(links).toContain('mafia/gangs');
|
expect(links).toContain('mafia/gangs');
|
||||||
|
|
||||||
links = helper.getAncestorLinks(data, henchman);
|
links = helper.getAncestorLinks(data, henchman);
|
||||||
expect(links.length).toBe(2);
|
|
||||||
|
expect(links).toBeArrayOfSize(2);
|
||||||
expect(links).toContain('.Sharks~');
|
expect(links).toContain('.Sharks~');
|
||||||
expect(links).toContain('mafia/gangs');
|
expect(links).toContain('mafia/gangs');
|
||||||
|
|
||||||
links = helper.getAncestorLinks(data, gang);
|
links = helper.getAncestorLinks(data, gang);
|
||||||
expect(links.length).toBe(1);
|
|
||||||
|
expect(links).toBeArrayOfSize(1);
|
||||||
expect(links).toContain('mafia/gangs.');
|
expect(links).toContain('mafia/gangs.');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1082,13 +1071,10 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
links = helper.getAncestorLinks(data, lackeys);
|
links = helper.getAncestorLinks(data, lackeys);
|
||||||
|
|
||||||
expect(links.length).toBe(3);
|
expect(links).toBeArrayOfSize(3);
|
||||||
expect(links).toContain('<a href="henchman.html">~Henchman</a>#');
|
expect(links).toContain('<a href="henchman.html">~Henchman</a>#');
|
||||||
expect(links).toContain('.Sharks');
|
expect(links).toContain('.Sharks');
|
||||||
expect(links).toContain('<a href="mafia_gangs.html">mafia/gangs</a>');
|
expect(links).toContain('<a href="mafia_gangs.html">mafia/gangs</a>');
|
||||||
|
|
||||||
delete helper.longnameToUrl['module:mafia/gangs'];
|
|
||||||
delete helper.longnameToUrl['module:mafia/gangs.Sharks~Henchman'];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("adds cssClass to any link", () => {
|
it("adds cssClass to any link", () => {
|
||||||
@ -1100,13 +1086,10 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
links = helper.getAncestorLinks(data, lackeys, 'myClass');
|
links = helper.getAncestorLinks(data, lackeys, 'myClass');
|
||||||
|
|
||||||
expect(links.length).toBe(3);
|
expect(links).toBeArrayOfSize(3);
|
||||||
expect(links).toContain('<a href="henchman.html" class="myClass">~Henchman</a>#');
|
expect(links).toContain('<a href="henchman.html" class="myClass">~Henchman</a>#');
|
||||||
expect(links).toContain('.Sharks');
|
expect(links).toContain('.Sharks');
|
||||||
expect(links).toContain('<a href="mafia_gangs.html" class="myClass">mafia/gangs</a>');
|
expect(links).toContain('<a href="mafia_gangs.html" class="myClass">mafia/gangs</a>');
|
||||||
|
|
||||||
delete helper.longnameToUrl['module:mafia/gangs'];
|
|
||||||
delete helper.longnameToUrl['module:mafia/gangs.Sharks~Henchman'];
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1119,23 +1102,20 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
helper.addEventListeners(doclets);
|
helper.addEventListeners(doclets);
|
||||||
|
|
||||||
it("adds a 'listeners' array to events with the longnames of the listeners", () => {
|
it("adds a 'listeners' array to events with the longnames of the listeners", () => {
|
||||||
expect(Array.isArray(ev.listeners)).toBe(true);
|
expect(ev.listeners).toBeArrayOfSize(2);
|
||||||
expect(Array.isArray(ev2.listeners)).toBe(true);
|
|
||||||
|
|
||||||
expect(ev.listeners.length).toBe(2);
|
|
||||||
expect(ev.listeners).toContain('module:myModule~MyHandler');
|
expect(ev.listeners).toContain('module:myModule~MyHandler');
|
||||||
expect(ev.listeners).toContain('module:myModule~AnotherHandler');
|
expect(ev.listeners).toContain('module:myModule~AnotherHandler');
|
||||||
|
|
||||||
expect(ev2.listeners.length).toBe(1);
|
expect(ev2.listeners).toBeArrayOfSize(1);
|
||||||
expect(ev2.listeners).toContain('module:myModule~MyHandler');
|
expect(ev2.listeners).toContain('module:myModule~MyHandler');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not add listeners for events with no listeners", () => {
|
it("does not add listeners for events with no listeners", () => {
|
||||||
expect(ev3.listeners).not.toBeDefined();
|
expect(ev3.listeners).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not make spurious doclets if something @listens to a non-existent symbol", () => {
|
it("does not make spurious doclets if something @listens to a non-existent symbol", () => {
|
||||||
expect(helper.find(doclets, {longname: 'event:fakeEvent'}).length).toBe(0);
|
expect(helper.find(doclets, {longname: 'event:fakeEvent'})).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1193,6 +1173,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
env.opts.private = false;
|
env.opts.private = false;
|
||||||
pruned = helper.prune( taffy(arrayPrivate) )().get();
|
pruned = helper.prune( taffy(arrayPrivate) )().get();
|
||||||
|
|
||||||
compareObjectArrays([], pruned);
|
compareObjectArrays([], pruned);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1202,6 +1183,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
env.opts.access = 'package';
|
env.opts.access = 'package';
|
||||||
pruned = helper.prune( taffy(arrayMixed) )().get();
|
pruned = helper.prune( taffy(arrayMixed) )().get();
|
||||||
|
|
||||||
compareObjectArrays(keepPackage, pruned);
|
compareObjectArrays(keepPackage, pruned);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1211,6 +1193,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
env.opts.access = 'public';
|
env.opts.access = 'public';
|
||||||
pruned = helper.prune( taffy(arrayMixed) )().get();
|
pruned = helper.prune( taffy(arrayMixed) )().get();
|
||||||
|
|
||||||
compareObjectArrays(keepPublic, pruned);
|
compareObjectArrays(keepPublic, pruned);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1220,6 +1203,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
env.opts.access = 'undefined';
|
env.opts.access = 'undefined';
|
||||||
pruned = helper.prune( taffy(arrayMixed) )().get();
|
pruned = helper.prune( taffy(arrayMixed) )().get();
|
||||||
|
|
||||||
compareObjectArrays(keepUndefined, pruned);
|
compareObjectArrays(keepUndefined, pruned);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1229,6 +1213,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
env.opts.access = 'protected';
|
env.opts.access = 'protected';
|
||||||
pruned = helper.prune( taffy(arrayMixed) )().get();
|
pruned = helper.prune( taffy(arrayMixed) )().get();
|
||||||
|
|
||||||
compareObjectArrays(keepProtected, pruned);
|
compareObjectArrays(keepProtected, pruned);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1238,6 +1223,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
env.opts.access = 'private';
|
env.opts.access = 'private';
|
||||||
pruned = helper.prune( taffy(arrayMixed) )().get();
|
pruned = helper.prune( taffy(arrayMixed) )().get();
|
||||||
|
|
||||||
compareObjectArrays(keepPrivate, pruned);
|
compareObjectArrays(keepPrivate, pruned);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1251,6 +1237,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
env.opts.access = ['public', 'protected'];
|
env.opts.access = ['public', 'protected'];
|
||||||
pruned = helper.prune( taffy(arrayMixed) )().get();
|
pruned = helper.prune( taffy(arrayMixed) )().get();
|
||||||
|
|
||||||
compareObjectArrays(keepPublicProtected, pruned);
|
compareObjectArrays(keepPublicProtected, pruned);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1268,26 +1255,26 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
env.opts.private = true;
|
env.opts.private = true;
|
||||||
pruned = helper.prune( taffy(arrayPrivate) )().get();
|
pruned = helper.prune( taffy(arrayPrivate) )().get();
|
||||||
|
|
||||||
compareObjectArrays(arrayPrivate, pruned);
|
compareObjectArrays(arrayPrivate, pruned);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("registerLink", () => {
|
describe("registerLink", () => {
|
||||||
|
afterEach(() => {
|
||||||
|
delete helper.longnameToUrl.MySymbol;
|
||||||
|
});
|
||||||
|
|
||||||
it("adds an entry to exports.longnameToUrl", () => {
|
it("adds an entry to exports.longnameToUrl", () => {
|
||||||
helper.longnameToUrl.MySymbol = 'asdf.html';
|
helper.longnameToUrl.MySymbol = 'asdf.html';
|
||||||
|
|
||||||
expect(helper.longnameToUrl.MySymbol).toBeDefined();
|
|
||||||
expect(helper.longnameToUrl.MySymbol).toBe('asdf.html');
|
expect(helper.longnameToUrl.MySymbol).toBe('asdf.html');
|
||||||
|
|
||||||
delete helper.longnameToUrl.MySymbol;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows linkto to work", () => {
|
it("allows linkto to work", () => {
|
||||||
helper.registerLink('MySymbol', 'asdf.html');
|
helper.registerLink('MySymbol', 'asdf.html');
|
||||||
|
|
||||||
expect(helper.linkto('MySymbol')).toBe('<a href="asdf.html">MySymbol</a>');
|
expect(helper.linkto('MySymbol')).toBe('<a href="asdf.html">MySymbol</a>');
|
||||||
|
|
||||||
delete helper.longnameToUrl.MySymbol;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1322,14 +1309,12 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
url = helper.tutorialToUrl('test');
|
url = helper.tutorialToUrl('test');
|
||||||
|
|
||||||
expect(typeof url).toBe('string');
|
|
||||||
expect(url).toBe('tutorial-test.html');
|
expect(url).toBe('tutorial-test.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("creates links for tutorials where the name is a reserved JS keyword", () => {
|
it("creates links for tutorials where the name is a reserved JS keyword", () => {
|
||||||
const url = helper.tutorialToUrl('constructor');
|
const url = helper.tutorialToUrl('constructor');
|
||||||
|
|
||||||
expect(typeof url).toBe('string');
|
|
||||||
expect(url).toBe('tutorial-constructor.html');
|
expect(url).toBe('tutorial-constructor.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1392,12 +1377,14 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
expect(link).toBe('<span class="missing">TODO-qwerty</span>');
|
expect(link).toBe('<span class="missing">TODO-qwerty</span>');
|
||||||
|
|
||||||
link = helper.toTutorial('qwerty', 'lkjklqwerty', {prefix: 'TODO-'});
|
link = helper.toTutorial('qwerty', 'lkjklqwerty', {prefix: 'TODO-'});
|
||||||
|
|
||||||
expect(link).toBe('TODO-qwerty');
|
expect(link).toBe('TODO-qwerty');
|
||||||
|
|
||||||
link = helper.toTutorial('qwerty', 'lkjklqwerty', {
|
link = helper.toTutorial('qwerty', 'lkjklqwerty', {
|
||||||
prefix: 'TODO-',
|
prefix: 'TODO-',
|
||||||
classname: 'missing'
|
classname: 'missing'
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(link).toBe('TODO-qwerty');
|
expect(link).toBe('TODO-qwerty');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1410,6 +1397,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
resolver.resolve();
|
resolver.resolve();
|
||||||
|
|
||||||
link = helper.toTutorial('constructor', 'The Constructor tutorial');
|
link = helper.toTutorial('constructor', 'The Constructor tutorial');
|
||||||
|
|
||||||
expect(link).toBe(`<a href="${helper.tutorialToUrl('constructor')}">The Constructor tutorial</a>`);
|
expect(link).toBe(`<a href="${helper.tutorialToUrl('constructor')}">The Constructor tutorial</a>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1439,6 +1427,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
env.conf.templates = conf;
|
env.conf.templates = conf;
|
||||||
|
delete helper.longnameToUrl['my.long.namespace'];
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should translate {@link test} into a HTML link.', () => {
|
it('should translate {@link test} into a HTML link.', () => {
|
||||||
@ -1674,7 +1663,10 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
env.conf.templates.monospaceLinks = true;
|
env.conf.templates.monospaceLinks = true;
|
||||||
output = helper.resolveLinks(input);
|
output = helper.resolveLinks(input);
|
||||||
|
|
||||||
expect(output).toBe('Link to <a href="path/to/test.html"><code>test</code></a> and <a href="http://github.com">http://github.com</a>');
|
expect(output).toBe(
|
||||||
|
'Link to <a href="path/to/test.html"><code>test</code></a> and ' +
|
||||||
|
'<a href="http://github.com">http://github.com</a>'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('if conf.useShortNamesInLinks is true, it uses the short name in links', () => {
|
it('if conf.useShortNamesInLinks is true, it uses the short name in links', () => {
|
||||||
@ -1686,8 +1678,6 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
output = helper.resolveLinks(input);
|
output = helper.resolveLinks(input);
|
||||||
|
|
||||||
expect(output).toBe('Link to <a href="asdf.html">namespace</a>');
|
expect(output).toBe('Link to <a href="asdf.html">namespace</a>');
|
||||||
|
|
||||||
delete helper.longnameToUrl['my.long.namespace'];
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -20,37 +20,25 @@ describe('plugins', () => {
|
|||||||
docSet = jsdoc.getDocSetFromFile('test/fixtures/plugins.js', app.jsdoc.parser, false);
|
docSet = jsdoc.getDocSetFromFile('test/fixtures/plugins.js', app.jsdoc.parser, false);
|
||||||
|
|
||||||
it("should fire the plugin's event handlers", () => {
|
it("should fire the plugin's event handlers", () => {
|
||||||
expect(global.jsdocPluginsTest.plugin1.fileBegin).toBeDefined();
|
expect(global.jsdocPluginsTest.plugin1.fileBegin).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin1.fileBegin).toBe(true);
|
expect(global.jsdocPluginsTest.plugin1.beforeParse).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin1.beforeParse).toBeDefined();
|
expect(global.jsdocPluginsTest.plugin1.jsdocCommentFound).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin1.beforeParse).toBe(true);
|
expect(global.jsdocPluginsTest.plugin1.symbolFound).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin1.jsdocCommentFound).toBeDefined();
|
expect(global.jsdocPluginsTest.plugin1.newDoclet).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin1.jsdocCommentFound).toBe(true);
|
expect(global.jsdocPluginsTest.plugin1.fileComplete).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin1.symbolFound).toBeDefined();
|
|
||||||
expect(global.jsdocPluginsTest.plugin1.symbolFound).toBe(true);
|
|
||||||
expect(global.jsdocPluginsTest.plugin1.newDoclet).toBeDefined();
|
|
||||||
expect(global.jsdocPluginsTest.plugin1.newDoclet).toBe(true);
|
|
||||||
expect(global.jsdocPluginsTest.plugin1.fileComplete).toBeDefined();
|
|
||||||
expect(global.jsdocPluginsTest.plugin1.fileComplete).toBe(true);
|
|
||||||
|
|
||||||
expect(global.jsdocPluginsTest.plugin2.fileBegin).toBeDefined();
|
expect(global.jsdocPluginsTest.plugin2.fileBegin).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin2.fileBegin).toBe(true);
|
expect(global.jsdocPluginsTest.plugin2.beforeParse).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin2.beforeParse).toBeDefined();
|
expect(global.jsdocPluginsTest.plugin2.jsdocCommentFound).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin2.beforeParse).toBe(true);
|
expect(global.jsdocPluginsTest.plugin2.symbolFound).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin2.jsdocCommentFound).toBeDefined();
|
expect(global.jsdocPluginsTest.plugin2.newDoclet).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin2.jsdocCommentFound).toBe(true);
|
expect(global.jsdocPluginsTest.plugin2.fileComplete).toBeTrue();
|
||||||
expect(global.jsdocPluginsTest.plugin2.symbolFound).toBeDefined();
|
|
||||||
expect(global.jsdocPluginsTest.plugin2.symbolFound).toBe(true);
|
|
||||||
expect(global.jsdocPluginsTest.plugin2.newDoclet).toBeDefined();
|
|
||||||
expect(global.jsdocPluginsTest.plugin2.newDoclet).toBe(true);
|
|
||||||
expect(global.jsdocPluginsTest.plugin2.fileComplete).toBeDefined();
|
|
||||||
expect(global.jsdocPluginsTest.plugin2.fileComplete).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should add the plugin's tag definitions to the dictionary", () => {
|
it("should add the plugin's tag definitions to the dictionary", () => {
|
||||||
const test = docSet.getByLongname('test');
|
const test = docSet.getByLongname('test');
|
||||||
|
|
||||||
expect(test[0].longname).toBe('test');
|
expect(test[0].longname).toBe('test');
|
||||||
expect(test[0].foo).toBe(true);
|
expect(test[0].foo).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,7 +9,7 @@ describe('@abstract tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should set the doclet\'s "virtual" property to true when "@abstract" tag is present', () => {
|
it('should set the doclet\'s "virtual" property to true when "@abstract" tag is present', () => {
|
||||||
expect(thingyPez.virtual).toBe(true);
|
expect(thingyPez.virtual).toBeTrue();
|
||||||
expect(otherThingyPez.virtual).toBe(true);
|
expect(otherThingyPez.virtual).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,6 @@ describe('@alias tag', () => {
|
|||||||
const myObject = docSet.getByLongname('myObject')[1];
|
const myObject = docSet.getByLongname('myObject')[1];
|
||||||
|
|
||||||
it('adds an "alias" property to the doclet with the tag\'s value', () => {
|
it('adds an "alias" property to the doclet with the tag\'s value', () => {
|
||||||
expect(myObject.alias).toBeDefined();
|
|
||||||
expect(myObject.alias).toBe('myObject');
|
expect(myObject.alias).toBe('myObject');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,6 @@ describe('@async tag', () => {
|
|||||||
const foo = docSet.getByLongname('foo')[0];
|
const foo = docSet.getByLongname('foo')[0];
|
||||||
|
|
||||||
it('should add an `async` property to the doclet', () => {
|
it('should add an `async` property to the doclet', () => {
|
||||||
expect(foo.async).toBe(true);
|
expect(foo.async).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,7 +9,7 @@ describe('@augments tag', () => {
|
|||||||
it('When a symbol has an @augments tag, the doclet has a augments property that includes that value.', () => {
|
it('When a symbol has an @augments tag, the doclet has a augments property that includes that value.', () => {
|
||||||
const bar = docSet.getByLongname('Bar')[0];
|
const bar = docSet.getByLongname('Bar')[0];
|
||||||
|
|
||||||
expect(typeof bar.augments).toBe('object');
|
expect(bar.augments).toBeArray();
|
||||||
expect(bar.augments[0]).toBe('Foo');
|
expect(bar.augments[0]).toBe('Foo');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -59,13 +59,12 @@ describe('@augments tag', () => {
|
|||||||
it('When an object is extended, and it overrides an ancestor method, the child does not include docs for the ancestor method.', () => {
|
it('When an object is extended, and it overrides an ancestor method, the child does not include docs for the ancestor method.', () => {
|
||||||
const barMethod2All = docSet.getByLongname('Bar#method2');
|
const barMethod2All = docSet.getByLongname('Bar#method2');
|
||||||
|
|
||||||
expect(barMethod2All.length).toBe(1);
|
expect(barMethod2All).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When an object is extended, and it overrides an ancestor, the child has an "overrides" property', () => {
|
it('When an object is extended, and it overrides an ancestor, the child has an "overrides" property', () => {
|
||||||
const barMethod2 = docSet.getByLongname('Bar#method2')[0];
|
const barMethod2 = docSet.getByLongname('Bar#method2')[0];
|
||||||
|
|
||||||
expect(barMethod2.overrides).toBeDefined();
|
|
||||||
expect(barMethod2.overrides).toBe('Foo#method2');
|
expect(barMethod2.overrides).toBe('Foo#method2');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -91,8 +90,8 @@ describe('@augments tag', () => {
|
|||||||
const bazMethod1 = docSet.getByLongname('Baz#method1')[0];
|
const bazMethod1 = docSet.getByLongname('Baz#method1')[0];
|
||||||
const bazMethod2 = docSet.getByLongname('Baz#method2')[0];
|
const bazMethod2 = docSet.getByLongname('Baz#method2')[0];
|
||||||
|
|
||||||
expect(fooProp1.inherits).not.toBeDefined();
|
expect(fooProp1.inherits).toBeUndefined();
|
||||||
expect(barProp3.inherits).not.toBeDefined();
|
expect(barProp3.inherits).toBeUndefined();
|
||||||
expect(barProp1.inherits).toBe('Foo#prop1');
|
expect(barProp1.inherits).toBe('Foo#prop1');
|
||||||
expect(bazProp2.inherits).toBe('Foo#prop2');
|
expect(bazProp2.inherits).toBe('Foo#prop2');
|
||||||
expect(bazProp3.inherits).toBe('Bar#prop3');
|
expect(bazProp3.inherits).toBe('Bar#prop3');
|
||||||
@ -103,7 +102,7 @@ describe('@augments tag', () => {
|
|||||||
it('When the grandparent has a method, the parent overrides it, and the child inherits it, the child should not say it overrides anything', () => {
|
it('When the grandparent has a method, the parent overrides it, and the child inherits it, the child should not say it overrides anything', () => {
|
||||||
const bazMethod2 = docSet.getByLongname('Baz#method2')[0];
|
const bazMethod2 = docSet.getByLongname('Baz#method2')[0];
|
||||||
|
|
||||||
expect(bazMethod2.overrides).not.toBeDefined();
|
expect(bazMethod2.overrides).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When the grandparent has a method, the parent inherits it, and the child overrides it, the child should say it overrides the parent', () => {
|
it('When the grandparent has a method, the parent inherits it, and the child overrides it, the child should say it overrides the parent', () => {
|
||||||
@ -115,13 +114,13 @@ describe('@augments tag', () => {
|
|||||||
it('When an object is extended, and it overrides an ancestor property, the child does not include docs for the ancestor property.', () => {
|
it('When an object is extended, and it overrides an ancestor property, the child does not include docs for the ancestor property.', () => {
|
||||||
const bazProp1All = docSet.getByLongname('Baz#prop1');
|
const bazProp1All = docSet.getByLongname('Baz#prop1');
|
||||||
|
|
||||||
expect(bazProp1All.length).toBe(1);
|
expect(bazProp1All).toBeArrayOfSize(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has an @augments tag, and the parent is not documented, the doclet still has an augments property', () => {
|
it('When a symbol has an @augments tag, and the parent is not documented, the doclet still has an augments property', () => {
|
||||||
const qux = docSet2.getByLongname('Qux')[0];
|
const qux = docSet2.getByLongname('Qux')[0];
|
||||||
|
|
||||||
expect(typeof qux.augments).toBe('object');
|
expect(qux.augments).toBeArray();
|
||||||
expect(qux.augments[0]).toBe('UndocumentedThing');
|
expect(qux.augments[0]).toBe('UndocumentedThing');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -142,8 +141,8 @@ describe('@augments tag', () => {
|
|||||||
const derivedMethod1All = docSet4.getByLongname('Derived#test1');
|
const derivedMethod1All = docSet4.getByLongname('Derived#test1');
|
||||||
const derivedMethod1 = derivedMethod1All[1];
|
const derivedMethod1 = derivedMethod1All[1];
|
||||||
|
|
||||||
expect(derivedMethod1All.length).toBe(2);
|
expect(derivedMethod1All).toBeArrayOfSize(2);
|
||||||
expect(derivedMethod1.undocumented).not.toBe(true);
|
expect(derivedMethod1.undocumented).toBeUndefined();
|
||||||
expect(derivedMethod1.description).toBe(baseMethod1.description);
|
expect(derivedMethod1.description).toBe(baseMethod1.description);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -151,7 +150,7 @@ describe('@augments tag', () => {
|
|||||||
const baseMethod3 = docSet4.getByLongname('Base#test3')[0];
|
const baseMethod3 = docSet4.getByLongname('Base#test3')[0];
|
||||||
const derivedMethod3 = docSet4.getByLongname('Derived#test3')[0];
|
const derivedMethod3 = docSet4.getByLongname('Derived#test3')[0];
|
||||||
|
|
||||||
expect(derivedMethod3).toBeDefined();
|
expect(derivedMethod3).toBeObject();
|
||||||
expect(derivedMethod3.comment).toBe(baseMethod3.comment);
|
expect(derivedMethod3.comment).toBe(baseMethod3.comment);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -160,7 +159,7 @@ describe('@augments tag', () => {
|
|||||||
const base1CommonMethod = docSet5.getByLongname('Base1#methodOfBaseCommon')[0];
|
const base1CommonMethod = docSet5.getByLongname('Base1#methodOfBaseCommon')[0];
|
||||||
const classCommonMethod = docSet5.getByLongname('Class#methodOfBaseCommon');
|
const classCommonMethod = docSet5.getByLongname('Class#methodOfBaseCommon');
|
||||||
|
|
||||||
expect(classCommonMethod.length).toBe(1);
|
expect(classCommonMethod).toBeArrayOfSize(1);
|
||||||
expect(classCommonMethod[0].description).toBe(base1CommonMethod.description);
|
expect(classCommonMethod[0].description).toBe(base1CommonMethod.description);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -168,7 +167,7 @@ describe('@augments tag', () => {
|
|||||||
const connectionOpen = docSet6.getByLongname('IConnection#open')[0];
|
const connectionOpen = docSet6.getByLongname('IConnection#open')[0];
|
||||||
const closableConnectionOpen = docSet6.getByLongname('IClosableConnection#open')[0];
|
const closableConnectionOpen = docSet6.getByLongname('IClosableConnection#open')[0];
|
||||||
|
|
||||||
expect(closableConnectionOpen).toBeDefined();
|
expect(closableConnectionOpen).toBeObject();
|
||||||
expect(closableConnectionOpen.description).toBe(connectionOpen.description);
|
expect(closableConnectionOpen.description).toBe(connectionOpen.description);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,14 +4,12 @@ describe('@author tag', () => {
|
|||||||
const Thingy2 = docSet.getByLongname('Thingy2')[0];
|
const Thingy2 = docSet.getByLongname('Thingy2')[0];
|
||||||
|
|
||||||
it('When a symbol has a @author tag, the doclet has a author property with that value.', () => {
|
it('When a symbol has a @author tag, the doclet has a author property with that value.', () => {
|
||||||
expect(Thingy.author).toBeDefined();
|
expect(Thingy.author).toBeArray();
|
||||||
expect(Array.isArray(Thingy.author)).toBe(true);
|
|
||||||
expect(Thingy.author[0]).toBe('Michael Mathews <micmath@gmail.com>');
|
expect(Thingy.author[0]).toBe('Michael Mathews <micmath@gmail.com>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has multiple @author tags, the doclet has a author property, an array with those values.', () => {
|
it('When a symbol has multiple @author tags, the doclet has a author property, an array with those values.', () => {
|
||||||
expect(Thingy2.author).toBeDefined();
|
expect(Thingy2.author).toBeArray();
|
||||||
expect(Array.isArray(Thingy2.author)).toBe(true);
|
|
||||||
expect(Thingy2.author).toContain('Jane Doe <jane.doe@gmail.com>');
|
expect(Thingy2.author).toContain('Jane Doe <jane.doe@gmail.com>');
|
||||||
expect(Thingy2.author).toContain('John Doe <john.doe@gmail.com>');
|
expect(Thingy2.author).toContain('John Doe <john.doe@gmail.com>');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,7 +7,7 @@ describe('@borrows tag', () => {
|
|||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/borrowstag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/borrowstag.js');
|
||||||
const util = docSet.getByLongname('util').filter(filterUndocumented)[0];
|
const util = docSet.getByLongname('util').filter(filterUndocumented)[0];
|
||||||
|
|
||||||
expect(util.borrowed.length).toBe(1);
|
expect(util.borrowed).toBeArrayOfSize(1);
|
||||||
expect(util.borrowed[0].from).toBe('trstr');
|
expect(util.borrowed[0].from).toBe('trstr');
|
||||||
expect(util.borrowed[0].as).toBe('trim');
|
expect(util.borrowed[0].as).toBe('trim');
|
||||||
});
|
});
|
||||||
@ -20,14 +20,14 @@ describe('@borrows tag', () => {
|
|||||||
|
|
||||||
const strRtrim = docSet.getByLongname('str.rtrim').filter(({undocumented}) => !(undocumented))[0];
|
const strRtrim = docSet.getByLongname('str.rtrim').filter(({undocumented}) => !(undocumented))[0];
|
||||||
|
|
||||||
expect(typeof strRtrim).toBe('object');
|
expect(strRtrim).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has a `@borrows X as Y` tag, X and Y may contain whitespace.', () => {
|
it('When a symbol has a `@borrows X as Y` tag, X and Y may contain whitespace.', () => {
|
||||||
const docSet = jsdoc.getDocSetFromFile('test/fixtures/borrowstag3.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/borrowstag3.js');
|
||||||
const util = docSet.getByLongname('util').filter(filterUndocumented)[0];
|
const util = docSet.getByLongname('util').filter(filterUndocumented)[0];
|
||||||
|
|
||||||
expect(util.borrowed.length).toBe(2);
|
expect(util.borrowed).toBeArrayOfSize(2);
|
||||||
expect(util.borrowed[0].from).toBe('trstr');
|
expect(util.borrowed[0].from).toBe('trstr');
|
||||||
expect(util.borrowed[0].as).toBe('trim string');
|
expect(util.borrowed[0].as).toBe('trim string');
|
||||||
expect(util.borrowed[1].from).toBe('util.hidden util');
|
expect(util.borrowed[1].from).toBe('util.hidden util');
|
||||||
|
|||||||
@ -34,9 +34,9 @@ describe('@class tag', () => {
|
|||||||
|
|
||||||
it('When a symbol is a class declaration, the constructor info is merged into the doclet for the symbol', () => {
|
it('When a symbol is a class declaration, the constructor info is merged into the doclet for the symbol', () => {
|
||||||
expect(subscription.description).toBe('Describe the constructor here.');
|
expect(subscription.description).toBe('Describe the constructor here.');
|
||||||
expect(subscription.params.length).toBe(1);
|
expect(subscription.params).toBeArrayOfSize(1);
|
||||||
expect(subscription.params[0].name).toBe('name');
|
expect(subscription.params[0].name).toBe('name');
|
||||||
expect(subscription.examples.length).toBe(1);
|
expect(subscription.examples).toBeArrayOfSize(1);
|
||||||
expect(subscription.examples[0]).toBe('var subscription = new Subscription();');
|
expect(subscription.examples[0]).toBe('var subscription = new Subscription();');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ describe('@class tag', () => {
|
|||||||
|
|
||||||
it('When a symbol is a class expression, the constructor info is merged into the doclet for the symbol', () => {
|
it('When a symbol is a class expression, the constructor info is merged into the doclet for the symbol', () => {
|
||||||
expect(subscriber.description).toBe('Describe the constructor here.');
|
expect(subscriber.description).toBe('Describe the constructor here.');
|
||||||
expect(subscriber.params.length).toBe(1);
|
expect(subscriber.params).toBeArrayOfSize(1);
|
||||||
expect(subscriber.params[0].name).toBe('name');
|
expect(subscriber.params[0].name).toBe('name');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -8,22 +8,22 @@ describe('@constant tag', () => {
|
|||||||
const ROCKET = docSet.getByLongname('ROCKET')[0];
|
const ROCKET = docSet.getByLongname('ROCKET')[0];
|
||||||
|
|
||||||
it("sets the doclet's 'kind' property to 'constant'", () => {
|
it("sets the doclet's 'kind' property to 'constant'", () => {
|
||||||
expect(FOO).toBeDefined();
|
expect(FOO).toBeObject();
|
||||||
expect(FOO.kind).toBe('constant');
|
expect(FOO.kind).toBe('constant');
|
||||||
|
|
||||||
expect(BAR).toBeDefined();
|
expect(BAR).toBeObject();
|
||||||
expect(BAR.kind).toBe('constant');
|
expect(BAR.kind).toBe('constant');
|
||||||
|
|
||||||
expect(BAZ).toBeDefined();
|
expect(BAZ).toBeObject();
|
||||||
expect(BAZ.kind).toBe('constant');
|
expect(BAZ.kind).toBe('constant');
|
||||||
|
|
||||||
expect(QUX).toBeDefined();
|
expect(QUX).toBeObject();
|
||||||
expect(QUX.kind).toBe('constant');
|
expect(QUX.kind).toBe('constant');
|
||||||
|
|
||||||
expect(SOCKET).toBeDefined();
|
expect(SOCKET).toBeObject();
|
||||||
expect(SOCKET.kind).toBe('constant');
|
expect(SOCKET.kind).toBe('constant');
|
||||||
|
|
||||||
expect(ROCKET).toBeDefined();
|
expect(ROCKET).toBeObject();
|
||||||
expect(ROCKET.kind).toBe('constant');
|
expect(ROCKET.kind).toBe('constant');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,25 +37,22 @@ describe('@constant tag', () => {
|
|||||||
|
|
||||||
it('If used with a name and a type, sets the doclet\'s name and type appropriately', () => {
|
it('If used with a name and a type, sets the doclet\'s name and type appropriately', () => {
|
||||||
expect(BAZ.name).toBe('BAZ');
|
expect(BAZ.name).toBe('BAZ');
|
||||||
expect(typeof BAZ.type).toBe('object');
|
expect(BAZ.type).toBeObject();
|
||||||
expect(BAZ.type.names).toBeDefined();
|
expect(BAZ.type.names).toBeArrayOfSize(1);
|
||||||
expect(BAZ.type.names.length).toBe(1);
|
|
||||||
expect(BAZ.type.names[0]).toBe('string');
|
expect(BAZ.type.names[0]).toBe('string');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('If used with just a type, adds the type and takes the name from the code', () => {
|
it('If used with just a type, adds the type and takes the name from the code', () => {
|
||||||
expect(QUX.name).toBe('QUX');
|
expect(QUX.name).toBe('QUX');
|
||||||
expect(typeof QUX.type).toBe('object');
|
expect(QUX.type).toBeObject();
|
||||||
expect(QUX.type.names).toBeDefined();
|
expect(QUX.type.names).toBeArrayOfSize(1);
|
||||||
expect(QUX.type.names.length).toBe(1);
|
|
||||||
expect(QUX.type.names[0]).toBe('number');
|
expect(QUX.type.names[0]).toBe('number');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('If used with a name and type, ignores the name in the code', () => {
|
it('If used with a name and type, ignores the name in the code', () => {
|
||||||
expect(SOCKET.name).toBe('SOCKET');
|
expect(SOCKET.name).toBe('SOCKET');
|
||||||
expect(typeof SOCKET.type).toBe('object');
|
expect(SOCKET.type).toBeObject();
|
||||||
expect(SOCKET.type.names).toBeDefined();
|
expect(SOCKET.type.names).toBeArrayOfSize(1);
|
||||||
expect(SOCKET.type.names.length).toBe(1);
|
|
||||||
expect(SOCKET.type.names[0]).toBe('Object');
|
expect(SOCKET.type.names[0]).toBe('Object');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ describe('@default tag', () => {
|
|||||||
it('When symbol set to null has a @default tag with no text, the doclet\'s defaultValue property should be: null', () => {
|
it('When symbol set to null has a @default tag with no text, the doclet\'s defaultValue property should be: null', () => {
|
||||||
const request = docSet.getByLongname('request')[0];
|
const request = docSet.getByLongname('request')[0];
|
||||||
|
|
||||||
expect(request.defaultvalue).toBe(null);
|
expect(request.defaultvalue).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When symbol set to a string has a @default tag with no text, the doclet\'s defaultValue property should be that string', () => {
|
it('When symbol set to a string has a @default tag with no text, the doclet\'s defaultValue property should be that string', () => {
|
||||||
@ -28,13 +28,13 @@ describe('@default tag', () => {
|
|||||||
it('When symbol has a @default tag with true.', () => {
|
it('When symbol has a @default tag with true.', () => {
|
||||||
const rvalid = docSet.getByLongname('rvalid')[0];
|
const rvalid = docSet.getByLongname('rvalid')[0];
|
||||||
|
|
||||||
expect(rvalid.defaultvalue).toBe(true);
|
expect(rvalid.defaultvalue).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When symbol has a @default tag with false.', () => {
|
it('When symbol has a @default tag with false.', () => {
|
||||||
const rerrored = docSet.getByLongname('rerrored')[0];
|
const rerrored = docSet.getByLongname('rerrored')[0];
|
||||||
|
|
||||||
expect(rerrored.defaultvalue, false);
|
expect(rerrored.defaultvalue).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When symbol has a @default tag with a function call.', () => {
|
it('When symbol has a @default tag with a function call.', () => {
|
||||||
|
|||||||
@ -36,7 +36,7 @@ describe('@define tag', () => {
|
|||||||
const enableDebug = docSet.getByLongname('ENABLE_DEBUG')[0];
|
const enableDebug = docSet.getByLongname('ENABLE_DEBUG')[0];
|
||||||
|
|
||||||
expect(enableDebug.kind).toBe('constant');
|
expect(enableDebug.kind).toBe('constant');
|
||||||
expect(enableDebug.type).toBeDefined();
|
expect(enableDebug.type).toBeObject();
|
||||||
expect(enableDebug.type.names[0]).toBe('boolean');
|
expect(enableDebug.type.names[0]).toBe('boolean');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,7 @@ describe('@deprecated tag', () => {
|
|||||||
const bar = docSet.getByLongname('bar')[0];
|
const 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.', () => {
|
it('When a symbol has a @deprecated tag with no value, the doclet has a deprecated property set to true.', () => {
|
||||||
expect(foo.deprecated).toBe(true);
|
expect(foo.deprecated).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has a @deprecated tag with a value, the doclet has a deprecated property set to that value.', () => {
|
it('When a symbol has a @deprecated tag with a value, the doclet has a deprecated property set to that value.', () => {
|
||||||
|
|||||||
@ -4,12 +4,10 @@ describe('@description tag', () => {
|
|||||||
const doc2 = docSet.getByLongname('y')[0];
|
const doc2 = docSet.getByLongname('y')[0];
|
||||||
|
|
||||||
it('sets the doclet\'s "description" property to the description', () => {
|
it('sets the doclet\'s "description" property to the description', () => {
|
||||||
expect(doc2.description).toBeDefined();
|
|
||||||
expect(doc2.description).toBe('lkjasdf');
|
expect(doc2.description).toBe('lkjasdf');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('overrides the default description', () => {
|
it('overrides the default description', () => {
|
||||||
expect(doc.description).toBeDefined();
|
|
||||||
expect(doc.description).toBe('halb halb halb');
|
expect(doc.description).toBe('halb halb halb');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@ describe('@enum tag', () => {
|
|||||||
const tristate = docSet.getByLongname('TriState')[0];
|
const tristate = docSet.getByLongname('TriState')[0];
|
||||||
|
|
||||||
it('When a symbol has an @enum tag, it has a properties array.', () => {
|
it('When a symbol has an @enum tag, it has a properties array.', () => {
|
||||||
expect(typeof tristate.properties).toBe('object');
|
expect(tristate.properties).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('If no @type is given for the property, it is inherited from the enum.', () => {
|
it('If no @type is given for the property, it is inherited from the enum.', () => {
|
||||||
@ -33,7 +33,7 @@ describe('@enum tag', () => {
|
|||||||
it('When an enum is defined with numeric object properties, the enum is parsed correctly.', () => {
|
it('When an enum is defined with numeric object properties, the enum is parsed correctly.', () => {
|
||||||
const zero = docSet.getByLongname('TrueFalseNumeric.0')[0];
|
const zero = docSet.getByLongname('TrueFalseNumeric.0')[0];
|
||||||
|
|
||||||
expect(zero).toBeDefined();
|
expect(zero).toBeObject();
|
||||||
expect(zero.description).toBe('false');
|
expect(zero.description).toBe('false');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -45,16 +45,12 @@ describe('@enum tag', () => {
|
|||||||
const quadState = docSet2.getByLongname('module:my/enums.QuadState')[0];
|
const quadState = docSet2.getByLongname('module:my/enums.QuadState')[0];
|
||||||
|
|
||||||
it('When a symbol at the start of an assignment chain has an @enum tag, that symbol has a properties array.', () => {
|
it('When a symbol at the start of an assignment chain has an @enum tag, that symbol has a properties array.', () => {
|
||||||
expect( Array.isArray(quadState.properties) ).toBe(true);
|
expect(quadState.properties).toBeArrayOfSize(4);
|
||||||
expect(quadState.properties.length).toBe(4);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When multiple symbols in an assignment chain have @enum tags, each symbol has a properties array.', () => {
|
it('When multiple symbols in an assignment chain have @enum tags, each symbol has a properties array.', () => {
|
||||||
expect( Array.isArray(pentaState.properties) ).toBe(true);
|
expect(pentaState.properties).toBeArrayOfSize(5);
|
||||||
expect(pentaState.properties.length).toBe(5);
|
expect(PENTASTATE.properties).toBeArrayOfSize(5);
|
||||||
|
|
||||||
expect( Array.isArray(PENTASTATE.properties) ).toBe(true);
|
|
||||||
expect(pentaState.properties.length).toBe(5);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -11,11 +11,11 @@ describe('@event and @fires/@emits tags', () => {
|
|||||||
|
|
||||||
// @fires/@emits tag
|
// @fires/@emits tag
|
||||||
it('When a symbol has a @fires tag, the doclet has an array named "fires".', () => {
|
it('When a symbol has a @fires tag, the doclet has an array named "fires".', () => {
|
||||||
expect(typeof snowballMethod.fires).toBe('object');
|
expect(snowballMethod.fires).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has an @emits tag, the doclet has an array named "fires".', () => {
|
it('When a symbol has an @emits tag, the doclet has an array named "fires".', () => {
|
||||||
expect(typeof footballMatchMethod.fires).toBe('object');
|
expect(footballMatchMethod.fires).toBeArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has a "fires" array, the members have the "event:" namespace.', () => {
|
it('When a symbol has a "fires" array, the members have the "event:" namespace.', () => {
|
||||||
|
|||||||
@ -6,16 +6,12 @@ describe('@example tag', () => {
|
|||||||
const txt2RegExp = new RegExp('<caption>Example 2</caption>[\\r\\n]{1,2}1 \\+ 2;');
|
const txt2RegExp = new RegExp('<caption>Example 2</caption>[\\r\\n]{1,2}1 \\+ 2;');
|
||||||
|
|
||||||
it("creates an 'examples' property on the doclet with the example", () => {
|
it("creates an 'examples' property on the doclet with the example", () => {
|
||||||
expect(doc.examples).toBeDefined();
|
expect(doc.examples).toBeArrayOfSize(1);
|
||||||
expect(Array.isArray(doc.examples)).toBe(true);
|
|
||||||
expect(doc.examples.length).toBe(1);
|
|
||||||
expect(doc.examples).toMatch(txtRegExp);
|
expect(doc.examples).toMatch(txtRegExp);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be specified multiple times on one doclet', () => {
|
it('can be specified multiple times on one doclet', () => {
|
||||||
expect(doc2.examples).toBeDefined();
|
expect(doc2.examples).toBeArrayOfSize(2);
|
||||||
expect(Array.isArray(doc2.examples)).toBe(true);
|
|
||||||
expect(doc2.examples.length).toBe(2);
|
|
||||||
expect(doc2.examples).toMatch(txtRegExp);
|
expect(doc2.examples).toMatch(txtRegExp);
|
||||||
expect(doc2.examples).toMatch(txt2RegExp);
|
expect(doc2.examples).toMatch(txt2RegExp);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,24 +6,19 @@ describe('@exception tag', () => {
|
|||||||
const cos = docSet.getByLongname('cos')[0];
|
const cos = docSet.getByLongname('cos')[0];
|
||||||
|
|
||||||
it('When a symbol has an @exception tag, the doclet has a exception property set to that value.', () => {
|
it('When a symbol has an @exception tag, the doclet has a exception property set to that value.', () => {
|
||||||
expect(typeof foo.exceptions).toBe('object');
|
expect(foo.exceptions).toBeArrayOfSize(1);
|
||||||
expect(foo.exceptions.length).toBe(1);
|
expect(bar.exceptions).toBeArrayOfSize(1);
|
||||||
|
expect(pez.exceptions).toBeArrayOfSize(1);
|
||||||
expect(typeof bar.exceptions).toBe('object');
|
|
||||||
expect(bar.exceptions.length).toBe(1);
|
|
||||||
|
|
||||||
expect(typeof pez.exceptions).toBe('object');
|
|
||||||
expect(pez.exceptions.length).toBe(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('The description and type for the @exception tag are not added to the parent doclet.', () => {
|
it('The description and type for the @exception tag are not added to the parent doclet.', () => {
|
||||||
expect(pez.description).not.toBeDefined();
|
expect(pez.description).not.toBeDefined();
|
||||||
expect(pez.type).not.toBeDefined();
|
expect(pez.type).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has a description, plus an @exception tag with a description, neither description overwrites the other.', () => {
|
it('When a symbol has a description, plus an @exception tag with a description, neither description overwrites the other.', () => {
|
||||||
expect(cos.description).toBe('A description of the function.');
|
expect(cos.description).toBe('A description of the function.');
|
||||||
expect(cos.exceptions.length).toBe(1);
|
expect(cos.exceptions).toBeArrayOfSize(1);
|
||||||
expect(cos.exceptions[0].description).toBe('A description of the exception.');
|
expect(cos.exceptions[0].description).toBe('A description of the exception.');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,32 +7,32 @@ describe('@exports tag', () => {
|
|||||||
const size = docSet.getByLongname('module:my/shirt.Turtleneck#size')[0];
|
const size = docSet.getByLongname('module:my/shirt.Turtleneck#size')[0];
|
||||||
|
|
||||||
it('When an objlit symbol has an @exports tag, the doclet is aliased to "module:" + the tag value.', () => {
|
it('When an objlit symbol has an @exports tag, the doclet is aliased to "module:" + the tag value.', () => {
|
||||||
expect(typeof shirt).toEqual('object');
|
expect(shirt).toBeObject();
|
||||||
expect(shirt.alias).toEqual('my/shirt');
|
expect(shirt.alias).toBe('my/shirt');
|
||||||
expect(shirt.undocumented).not.toBeDefined();
|
expect(shirt.undocumented).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When an objlit symbol has an @exports tag, the doclet\'s longname includes the "module:" namespace.', () => {
|
it('When an objlit symbol has an @exports tag, the doclet\'s longname includes the "module:" namespace.', () => {
|
||||||
expect(shirt.longname).toEqual('module:my/shirt');
|
expect(shirt.longname).toBe('module:my/shirt');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When an objlit symbol has an @exports tag, the doclet kind is set to module.', () => {
|
it('When an objlit symbol has an @exports tag, the doclet kind is set to module.', () => {
|
||||||
expect(shirt.kind).toEqual('module');
|
expect(shirt.kind).toBe('module');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When an objlit symbol has an @exports tag, the module doclet does not have a scope.', () => {
|
it('When an objlit symbol has an @exports tag, the module doclet does not have a scope.', () => {
|
||||||
expect(shirt.scope).not.toBeDefined();
|
expect(shirt.scope).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When an objlit symbol has an @exports tag, the objlit members are documented as members of the module.', () => {
|
it('When an objlit symbol has an @exports tag, the objlit members are documented as members of the module.', () => {
|
||||||
expect(typeof color).toEqual('object');
|
expect(color).toBeObject();
|
||||||
expect(color.memberof).toEqual('module:my/shirt');
|
expect(color.memberof).toBe('module:my/shirt');
|
||||||
|
|
||||||
expect(typeof tneck).toEqual('object');
|
expect(tneck).toBeObject();
|
||||||
expect(tneck.memberof).toEqual('module:my/shirt');
|
expect(tneck.memberof).toBe('module:my/shirt');
|
||||||
|
|
||||||
expect(typeof size).toEqual('object');
|
expect(size).toBeObject();
|
||||||
expect(size.memberof).toEqual('module:my/shirt.Turtleneck');
|
expect(size.memberof).toBe('module:my/shirt.Turtleneck');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,25 +42,25 @@ describe('@exports tag', () => {
|
|||||||
const wool = docSet.getByLongname('module:my/coat#wool')[0];
|
const wool = docSet.getByLongname('module:my/coat#wool')[0];
|
||||||
|
|
||||||
it('When a function symbol has an @exports tag, the doclet is aliased to "module:" + the tag value.', () => {
|
it('When a function symbol has an @exports tag, the doclet is aliased to "module:" + the tag value.', () => {
|
||||||
expect(typeof coat).toEqual('object');
|
expect(coat).toBeObject();
|
||||||
expect(coat.alias).toEqual('my/coat');
|
expect(coat.alias).toBe('my/coat');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a function symbol has an @exports tag, the doclet\'s longname includes the "module:" namespace.', () => {
|
it('When a function symbol has an @exports tag, the doclet\'s longname includes the "module:" namespace.', () => {
|
||||||
expect(coat.longname).toEqual('module:my/coat');
|
expect(coat.longname).toBe('module:my/coat');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a function symbol has an @exports tag, the doclet kind is set to module.', () => {
|
it('When a function symbol has an @exports tag, the doclet kind is set to module.', () => {
|
||||||
expect(coat.kind).toEqual('module');
|
expect(coat.kind).toBe('module');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a function symbol has an @exports tag, the module doclet does not have a scope.', () => {
|
it('When a function symbol has an @exports tag, the module doclet does not have a scope.', () => {
|
||||||
expect(coat.scope).not.toBeDefined();
|
expect(coat.scope).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a function symbol has an @exports tag, the this members are documented as instance members of the module.', () => {
|
it('When a function symbol has an @exports tag, the this members are documented as instance members of the module.', () => {
|
||||||
expect(typeof wool).toEqual('object');
|
expect(wool).toBeObject();
|
||||||
expect(wool.memberof).toEqual('module:my/coat');
|
expect(wool.memberof).toBe('module:my/coat');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -71,17 +71,17 @@ describe('@exports tag', () => {
|
|||||||
const inhead = docSet.getByLongname('module:html/utils.isInHead')[0];
|
const inhead = docSet.getByLongname('module:html/utils.isInHead')[0];
|
||||||
|
|
||||||
it('When a function symbol has an @exports tag, the module doclet does not have a scope.', () => {
|
it('When a function symbol has an @exports tag, the module doclet does not have a scope.', () => {
|
||||||
expect(html.scope).not.toBeDefined();
|
expect(html.scope).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a function symbol has an @exports tag and there is an objlit named "exports" the members are documented as members of the module.', () => {
|
it('When a function symbol has an @exports tag and there is an objlit named "exports" the members are documented as members of the module.', () => {
|
||||||
expect(typeof getstyle).toEqual('object');
|
expect(getstyle).toBeObject();
|
||||||
expect(getstyle.memberof).toEqual('module:html/utils');
|
expect(getstyle.memberof).toBe('module:html/utils');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a function symbol has an @exports tag and there are members assigned to an "exports" name, the members are documented as members of the module.', () => {
|
it('When a function symbol has an @exports tag and there are members assigned to an "exports" name, the members are documented as members of the module.', () => {
|
||||||
expect(typeof inhead).toEqual('object');
|
expect(inhead).toBeObject();
|
||||||
expect(inhead.memberof).toEqual('module:html/utils');
|
expect(inhead.memberof).toBe('module:html/utils');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -92,15 +92,15 @@ describe('@exports tag', () => {
|
|||||||
const method = docSet.getByLongname('module:some/module~myClass#myMethod')[0];
|
const method = docSet.getByLongname('module:some/module~myClass#myMethod')[0];
|
||||||
|
|
||||||
it('When a function symbol has an @exports tag, the module doclet does not have a scope.', () => {
|
it('When a function symbol has an @exports tag, the module doclet does not have a scope.', () => {
|
||||||
expect(module.scope).not.toBeDefined();
|
expect(module.scope).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('An inner class declared as a function in a module should be documented.', () => {
|
it('An inner class declared as a function in a module should be documented.', () => {
|
||||||
expect(typeof innerClass).toEqual('object');
|
expect(innerClass).toBeObject();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('A method of an inner class declared as a function in a module should be documented.', () => {
|
it('A method of an inner class declared as a function in a module should be documented.', () => {
|
||||||
expect(typeof method).toEqual('object');
|
expect(method).toBeObject();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ describe('@exports tag', () => {
|
|||||||
const method = docSet.getByLongname('module:Foo#bar')[0];
|
const method = docSet.getByLongname('module:Foo#bar')[0];
|
||||||
|
|
||||||
it('When a var has an @exports tag, the module doclet does not have a scope.', () => {
|
it('When a var has an @exports tag, the module doclet does not have a scope.', () => {
|
||||||
expect(foo.scope).not.toBeDefined();
|
expect(foo.scope).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('A variable defined in an inner scope should correctly shadow a variable in an outer scope.', () => {
|
it('A variable defined in an inner scope should correctly shadow a variable in an outer scope.', () => {
|
||||||
@ -126,9 +126,9 @@ describe('@exports tag', () => {
|
|||||||
const size = docSet.getByLongname('module:my/shirt.Turtleneck#size')[0];
|
const size = docSet.getByLongname('module:my/shirt.Turtleneck#size')[0];
|
||||||
|
|
||||||
it('When a param has an @exports tag, the doclet is aliased to "module:" + the tag value.', () => {
|
it('When a param has an @exports tag, the doclet is aliased to "module:" + the tag value.', () => {
|
||||||
expect(typeof shirt).toBe('object');
|
expect(shirt).toBeObject();
|
||||||
expect(shirt.alias).toBe('my/shirt');
|
expect(shirt.alias).toBe('my/shirt');
|
||||||
expect(shirt.undocumented).not.toBeDefined();
|
expect(shirt.undocumented).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a param has an @exports tag, the doclet\'s longname includes the "module:" namespace.', () => {
|
it('When a param has an @exports tag, the doclet\'s longname includes the "module:" namespace.', () => {
|
||||||
@ -136,21 +136,21 @@ describe('@exports tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('When a param has an @exports tag, the doclet kind is set to module.', () => {
|
it('When a param has an @exports tag, the doclet kind is set to module.', () => {
|
||||||
expect(shirt.kind).toEqual('module');
|
expect(shirt.kind).toBe('module');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a param has an @exports tag, the module doclet does not have a scope.', () => {
|
it('When a param has an @exports tag, the module doclet does not have a scope.', () => {
|
||||||
expect(shirt.scope).not.toBeDefined();
|
expect(shirt.scope).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a param has an @exports tag, the properties added to the param are documented as members of the module.', () => {
|
it('When a param has an @exports tag, the properties added to the param are documented as members of the module.', () => {
|
||||||
expect(typeof color).toBe('object');
|
expect(color).toBeObject();
|
||||||
expect(color.memberof).toBe('module:my/shirt');
|
expect(color.memberof).toBe('module:my/shirt');
|
||||||
|
|
||||||
expect(typeof tneck).toBe('object');
|
expect(tneck).toBeObject();
|
||||||
expect(tneck.memberof).toBe('module:my/shirt');
|
expect(tneck.memberof).toBe('module:my/shirt');
|
||||||
|
|
||||||
expect(typeof size).toBe('object');
|
expect(size).toBeObject();
|
||||||
expect(size.memberof).toBe('module:my/shirt.Turtleneck');
|
expect(size.memberof).toBe('module:my/shirt.Turtleneck');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -164,34 +164,34 @@ describe('@exports tag', () => {
|
|||||||
const iron = docSet.getByLongname('module:my/shirt.Turtleneck#iron')[0];
|
const iron = docSet.getByLongname('module:my/shirt.Turtleneck#iron')[0];
|
||||||
|
|
||||||
it('When a symbol has an @exports tag, the doclet is aliased to "module:" + the tag value.', () => {
|
it('When a symbol has an @exports tag, the doclet is aliased to "module:" + the tag value.', () => {
|
||||||
expect(typeof shirt).toBe('object');
|
expect(shirt).toBeObject();
|
||||||
expect(shirt.alias).toBe('my/shirt');
|
expect(shirt.alias).toBe('my/shirt');
|
||||||
expect(shirt.undocumented).not.toBeDefined();
|
expect(shirt.undocumented).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has an @exports tag, the doclet kind is set to module.', () => {
|
it('When a symbol has an @exports tag, the doclet kind is set to module.', () => {
|
||||||
expect(shirt.kind).toEqual('module');
|
expect(shirt.kind).toBe('module');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has an @exports tag, the module doclet does not have a scope.', () => {
|
it('When a symbol has an @exports tag, the module doclet does not have a scope.', () => {
|
||||||
expect(shirt.scope).not.toBeDefined();
|
expect(shirt.scope).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol tagged with @exports is an alias to "exports", the symbol properties are documented as members of the module.', () => {
|
it('When a symbol tagged with @exports is an alias to "exports", the symbol properties are documented as members of the module.', () => {
|
||||||
expect(typeof color).toBe('object');
|
expect(color).toBeObject();
|
||||||
expect(color.memberof).toBe('module:my/shirt');
|
expect(color.memberof).toBe('module:my/shirt');
|
||||||
|
|
||||||
expect(typeof tneck).toBe('object');
|
expect(tneck).toBeObject();
|
||||||
expect(tneck.memberof).toBe('module:my/shirt');
|
expect(tneck.memberof).toBe('module:my/shirt');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol tagged with @exports is an alias to "exports", and a symbol property contains a class, the instance members of the class are documented correctly.', () => {
|
it('When a symbol tagged with @exports is an alias to "exports", and a symbol property contains a class, the instance members of the class are documented correctly.', () => {
|
||||||
expect(typeof size).toBe('object');
|
expect(size).toBeObject();
|
||||||
expect(size.name).toBe('size');
|
expect(size.name).toBe('size');
|
||||||
expect(size.memberof).toBe('module:my/shirt.Turtleneck');
|
expect(size.memberof).toBe('module:my/shirt.Turtleneck');
|
||||||
expect(size.scope).toBe('instance');
|
expect(size.scope).toBe('instance');
|
||||||
|
|
||||||
expect(typeof iron).toBe('object');
|
expect(iron).toBeObject();
|
||||||
expect(iron.name).toBe('iron');
|
expect(iron.name).toBe('iron');
|
||||||
expect(iron.memberof).toBe('module:my/shirt.Turtleneck');
|
expect(iron.memberof).toBe('module:my/shirt.Turtleneck');
|
||||||
expect(iron.scope).toBe('instance');
|
expect(iron.scope).toBe('instance');
|
||||||
@ -203,7 +203,7 @@ describe('@exports tag', () => {
|
|||||||
const shirt = docSet.getByLongname('module:my/shirt')[0];
|
const shirt = docSet.getByLongname('module:my/shirt')[0];
|
||||||
|
|
||||||
it('When the name for an @exports tag begins with the "module:" namespace, we remove the namespace', () => {
|
it('When the name for an @exports tag begins with the "module:" namespace, we remove the namespace', () => {
|
||||||
expect(typeof shirt).toBe('object');
|
expect(shirt).toBeObject();
|
||||||
expect(shirt.name).toBe('my/shirt');
|
expect(shirt.name).toBe('my/shirt');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,8 +10,7 @@ describe('@external tag', () => {
|
|||||||
|
|
||||||
|
|
||||||
it('An @external should have its own doclet', () => {
|
it('An @external should have its own doclet', () => {
|
||||||
expect(stringExternal).toBeDefined();
|
expect(stringExternal).toBeObject();
|
||||||
expect(typeof stringExternal).toBe('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("An @external's name should be the same as its longname, minus 'external:'", () => {
|
it("An @external's name should be the same as its longname, minus 'external:'", () => {
|
||||||
@ -23,13 +22,13 @@ describe('@external tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('An @external with a quoted name should get the correct name', () => {
|
it('An @external with a quoted name should get the correct name', () => {
|
||||||
expect(jQueryExternal).toBeDefined();
|
expect(jQueryExternal).toBeObject();
|
||||||
expect(jQueryExternal.name).toBe('"jQuery.fn"');
|
expect(jQueryExternal.name).toBe('"jQuery.fn"');
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: enable after jsdoc3/jsdoc#652 is fixed
|
// TODO: enable after jsdoc3/jsdoc#652 is fixed
|
||||||
xit('An @external should work correctly when the type is in curly braces', () => {
|
xit('An @external should work correctly when the type is in curly braces', () => {
|
||||||
expect(fooBarBazExternal).toBeDefined();
|
expect(fooBarBazExternal).toBeObject();
|
||||||
expect(fooBarBazExternal.name).toBe('"foo.bar.baz"');
|
expect(fooBarBazExternal.name).toBe('"foo.bar.baz"');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,6 +3,6 @@ describe('@generator tag', () => {
|
|||||||
const idMaker = docSet.getByLongname('idMaker')[0];
|
const idMaker = docSet.getByLongname('idMaker')[0];
|
||||||
|
|
||||||
it('should mark the symbol as a generator function', () => {
|
it('should mark the symbol as a generator function', () => {
|
||||||
expect(idMaker.generator).toBe(true);
|
expect(idMaker.generator).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,11 +4,11 @@ describe('@hideconstructor tag', () => {
|
|||||||
const waffleIron = docSet.getByLongname('WaffleIron').filter(({undocumented}) => !undocumented)[0];
|
const waffleIron = docSet.getByLongname('WaffleIron').filter(({undocumented}) => !undocumented)[0];
|
||||||
|
|
||||||
it('should add a `hideconstructor` attribute to pre-ES2015 classes', () => {
|
it('should add a `hideconstructor` attribute to pre-ES2015 classes', () => {
|
||||||
expect(toaster.hideconstructor).toBe(true);
|
expect(toaster.hideconstructor).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add a `hideconstructor` attribute to ES2015 classes when the constructor is tagged',
|
it('should add a `hideconstructor` attribute to ES2015 classes when the constructor is tagged',
|
||||||
() => {
|
() => {
|
||||||
expect(waffleIron.hideconstructor).toBe(true);
|
expect(waffleIron.hideconstructor).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,17 +1,20 @@
|
|||||||
|
const logger = require('jsdoc/util/logger');
|
||||||
|
|
||||||
describe('@ignore tag', () => {
|
describe('@ignore tag', () => {
|
||||||
let docSet = jsdoc.getDocSetFromFile('test/fixtures/ignoretag.js');
|
let docSet = jsdoc.getDocSetFromFile('test/fixtures/ignoretag.js');
|
||||||
let foo = docSet.getByLongname('foo')[0];
|
let foo = docSet.getByLongname('foo')[0];
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(logger, 'warn');
|
||||||
|
});
|
||||||
|
|
||||||
it('When a symbol has an @ignore tag, the doclet has a ignore property set to true.', () => {
|
it('When a symbol has an @ignore tag, the doclet has a ignore property set to true.', () => {
|
||||||
expect(foo.ignore).toBe(true);
|
expect(foo.ignore).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol has an @ignore tag with a value an error is thrown', () => {
|
it('When a symbol has an @ignore tag with a value a warning is logged', () => {
|
||||||
try {
|
docSet = jsdoc.getDocSetFromFile('test/fixtures/ignoretag2.js');
|
||||||
docSet = jsdoc.getDocSetFromFile('test/fixtures/ignoretag2.js');
|
|
||||||
foo = docSet.getByLongname('foo')[0];
|
expect(logger.warn).toHaveBeenCalled();
|
||||||
} catch (e) {
|
|
||||||
expect(e instanceof Error).toBe(true);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,14 +7,12 @@ describe('@implements tag', () => {
|
|||||||
const processMethod = docSet.getByLongname('MyWorker#process')[0];
|
const processMethod = docSet.getByLongname('MyWorker#process')[0];
|
||||||
|
|
||||||
it('MyTester has an "implements" array', () => {
|
it('MyTester has an "implements" array', () => {
|
||||||
expect(Array.isArray(myTester.implements)).toBe(true);
|
expect(myTester.implements).toBeArrayOfSize(1);
|
||||||
expect(myTester.implements.length).toBe(1);
|
|
||||||
expect(myTester.implements[0]).toBe('ITester');
|
expect(myTester.implements[0]).toBe('ITester');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('beforeEach has an "implements" array', () => {
|
it('beforeEach has an "implements" array', () => {
|
||||||
expect(Array.isArray(beforeEachMethod.implements)).toBe(true);
|
expect(beforeEachMethod.implements).toBeArrayOfSize(1);
|
||||||
expect(beforeEachMethod.implements.length).toBe(1);
|
|
||||||
expect(beforeEachMethod.implements[0]).toBe('ITester#beforeEach');
|
expect(beforeEachMethod.implements[0]).toBe('ITester#beforeEach');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -27,6 +25,6 @@ describe('@implements tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('MyIncompleteWorker does not have any methods', () => {
|
it('MyIncompleteWorker does not have any methods', () => {
|
||||||
expect(docSet.getByLongname('MyIncompleteWorker#work').length).toBe(0);
|
expect(docSet.getByLongname('MyIncompleteWorker#work')).toBeEmptyArray();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,9 +8,9 @@ describe('@inheritdoc tag', () => {
|
|||||||
it('should cause the symbol to be documented', () => {
|
it('should cause the symbol to be documented', () => {
|
||||||
const open = docSet.getByLongname('Socket#open');
|
const open = docSet.getByLongname('Socket#open');
|
||||||
|
|
||||||
expect(open.length).toBe(2);
|
expect(open).toBeArrayOfSize(2);
|
||||||
expect(open[0].ignore).toBe(true);
|
expect(open[0].ignore).toBeTrue();
|
||||||
expect(open[1].ignore).not.toBeDefined();
|
expect(open[1].ignore).toBeUndefined();
|
||||||
expect(open[1].description).toBe('Open the connection.');
|
expect(open[1].description).toBe('Open the connection.');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -18,22 +18,22 @@ describe('@inheritdoc tag', () => {
|
|||||||
const close = docSet.getByLongname('Socket#close').filter(ignored)[0];
|
const close = docSet.getByLongname('Socket#close').filter(ignored)[0];
|
||||||
|
|
||||||
expect(close.description).toBe('Close the connection.');
|
expect(close.description).toBe('Close the connection.');
|
||||||
expect(close.params).not.toBeDefined();
|
expect(close.params).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not say that the child symbol is abstract', () => {
|
it('should not say that the child symbol is abstract', () => {
|
||||||
const open = docSet.getByLongname('Socket#open').filter(ignored)[0];
|
const open = docSet.getByLongname('Socket#open').filter(ignored)[0];
|
||||||
const parentOpen = docSet.getByLongname('Connection#open')[0];
|
const parentOpen = docSet.getByLongname('Connection#open')[0];
|
||||||
|
|
||||||
expect(parentOpen.virtual).toBe(true);
|
expect(parentOpen.virtual).toBeTrue();
|
||||||
expect(open.virtual).not.toBeDefined();
|
expect(open.virtual).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work with interface members whose names are specified in the comment', () => {
|
it('should work with interface members whose names are specified in the comment', () => {
|
||||||
const connectionRead = docSet.getByLongname('Connection#read').filter(ignored)[0];
|
const connectionRead = docSet.getByLongname('Connection#read').filter(ignored)[0];
|
||||||
const socketRead = docSet.getByLongname('Socket#read').filter(ignored)[0];
|
const socketRead = docSet.getByLongname('Socket#read').filter(ignored)[0];
|
||||||
|
|
||||||
expect(socketRead).toBeDefined();
|
expect(socketRead).toBeObject();
|
||||||
expect(socketRead.description).toBe(connectionRead.description);
|
expect(socketRead.description).toBe(connectionRead.description);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -32,7 +32,7 @@ describe('@interface tag', () => {
|
|||||||
virtualInterface = docSet2.getByLongname('VirtualInterface')[0];
|
virtualInterface = docSet2.getByLongname('VirtualInterface')[0];
|
||||||
|
|
||||||
expect(logger.warn).not.toHaveBeenCalled();
|
expect(logger.warn).not.toHaveBeenCalled();
|
||||||
expect(virtualInterface).toBeDefined();
|
expect(virtualInterface).toBeObject();
|
||||||
expect(virtualInterface.longname).toBe('VirtualInterface');
|
expect(virtualInterface.longname).toBe('VirtualInterface');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ describe('@interface tag', () => {
|
|||||||
virtualInterface = docSet2.getByLongname('VirtualInterface')[0];
|
virtualInterface = docSet2.getByLongname('VirtualInterface')[0];
|
||||||
|
|
||||||
expect(logger.warn).toHaveBeenCalled();
|
expect(logger.warn).toHaveBeenCalled();
|
||||||
expect(virtualInterface).not.toBeDefined();
|
expect(virtualInterface).toBeUndefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user