mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Replace old, vendored Jasmine with current npm package.
JSDoc-specific test functions are now properties of a `jsdoc` global, not a `jasmine` global. Also updates license files to reflect the fact that we no longer vendor anything.
This commit is contained in:
parent
9d0d86fba4
commit
617b3236bf
72
LICENSE.md
72
LICENSE.md
@ -1,72 +0,0 @@
|
|||||||
# License
|
|
||||||
|
|
||||||
JSDoc is free software, licensed under the Apache License, Version 2.0 (the
|
|
||||||
"License"). Commercial and non-commercial use are permitted in compliance with
|
|
||||||
the License.
|
|
||||||
|
|
||||||
Copyright (c) 2011-present Michael Mathews <micmath@gmail.com> and the
|
|
||||||
[contributors to JSDoc](https://github.com/jsdoc/jsdoc/graphs/contributors). All
|
|
||||||
rights reserved.
|
|
||||||
|
|
||||||
You can obtain a copy of the License at:
|
|
||||||
https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
In addition, a copy of the License is included with this distribution.
|
|
||||||
|
|
||||||
As stated in Section 7, "Disclaimer of Warranty," of the License:
|
|
||||||
|
|
||||||
> Licensor provides the Work (and each Contributor provides its Contributions)
|
|
||||||
> on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
||||||
> express or implied, including, without limitation, any warranties or
|
|
||||||
> conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
> PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
> appropriateness of using or redistributing the Work and assume any risks
|
|
||||||
> associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
The source code for JSDoc is available at: https://github.com/jsdoc/jsdoc
|
|
||||||
|
|
||||||
# Third-party software
|
|
||||||
|
|
||||||
JSDoc includes the following third-party software, either in whole or in part.
|
|
||||||
Each third-party software package is provided under its own license.
|
|
||||||
|
|
||||||
## MIT License
|
|
||||||
|
|
||||||
Several of the following software packages are distributed under the MIT
|
|
||||||
license, which is reproduced below:
|
|
||||||
|
|
||||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
> of this software and associated documentation files (the "Software"), to deal
|
|
||||||
> in the Software without restriction, including without limitation the rights
|
|
||||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
> copies of the Software, and to permit persons to whom the Software is
|
|
||||||
> furnished to do so, subject to the following conditions:
|
|
||||||
>
|
|
||||||
> The above copyright notice and this permission notice shall be included in all
|
|
||||||
> copies or substantial portions of the Software.
|
|
||||||
>
|
|
||||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
> SOFTWARE.
|
|
||||||
|
|
||||||
## Jasmine
|
|
||||||
|
|
||||||
Jasmine is distributed under the MIT license, which is reproduced above.
|
|
||||||
|
|
||||||
Copyright (c) 2008-2011 Pivotal Labs.
|
|
||||||
|
|
||||||
The source code for Jasmine is available at:
|
|
||||||
https://github.com/pivotal/jasmine
|
|
||||||
|
|
||||||
## jasmine-node
|
|
||||||
|
|
||||||
jasmine-node is distributed under the MIT license, which is reproduced above.
|
|
||||||
|
|
||||||
Copyright (c) 2010 Adam Abrons and Misko Hevery (http://getangular.com).
|
|
||||||
|
|
||||||
The source code for jasmine-node is available at:
|
|
||||||
https://github.com/mhevery/jasmine-node
|
|
||||||
42
cli.js
42
cli.js
@ -117,22 +117,26 @@ module.exports = (() => {
|
|||||||
cli.exit(1);
|
cli.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env.opts.debug) {
|
if (env.opts.test) {
|
||||||
logger.setLevel(logger.LEVELS.DEBUG);
|
logger.setLevel(logger.LEVELS.SILENT);
|
||||||
}
|
} else {
|
||||||
else if (env.opts.verbose) {
|
if (env.opts.debug) {
|
||||||
logger.setLevel(logger.LEVELS.INFO);
|
logger.setLevel(logger.LEVELS.DEBUG);
|
||||||
}
|
}
|
||||||
|
else if (env.opts.verbose) {
|
||||||
|
logger.setLevel(logger.LEVELS.INFO);
|
||||||
|
}
|
||||||
|
|
||||||
if (env.opts.pedantic) {
|
if (env.opts.pedantic) {
|
||||||
logger.once('logger:warn', recoverableError);
|
logger.once('logger:warn', recoverableError);
|
||||||
logger.once('logger:error', fatalError);
|
logger.once('logger:error', fatalError);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.once('logger:error', recoverableError);
|
logger.once('logger:error', recoverableError);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.once('logger:fatal', fatalError);
|
logger.once('logger:fatal', fatalError);
|
||||||
|
}
|
||||||
|
|
||||||
return cli;
|
return cli;
|
||||||
};
|
};
|
||||||
@ -201,15 +205,7 @@ module.exports = (() => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO: docs
|
// TODO: docs
|
||||||
cli.runTests = () => {
|
cli.runTests = () => require('./test')();
|
||||||
const path = require('jsdoc/path');
|
|
||||||
|
|
||||||
const runner = Promise.promisify(require( path.join(env.dirname, 'test/runner') ));
|
|
||||||
|
|
||||||
console.log('Running tests...');
|
|
||||||
|
|
||||||
return runner();
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: docs
|
// TODO: docs
|
||||||
cli.getVersion = () => `JSDoc ${env.version.number} (${env.version.revision})`;
|
cli.getVersion = () => `JSDoc ${env.version.number} (${env.version.revision})`;
|
||||||
|
|||||||
10
jsdoc.js
10
jsdoc.js
@ -64,13 +64,9 @@ global.app = (() => require('./lib/jsdoc/app'))();
|
|||||||
}
|
}
|
||||||
|
|
||||||
cli.setVersionInfo()
|
cli.setVersionInfo()
|
||||||
.loadConfig();
|
.loadConfig()
|
||||||
|
.configureLogger()
|
||||||
if (!env.opts.test) {
|
.logStart();
|
||||||
cli.configureLogger();
|
|
||||||
}
|
|
||||||
|
|
||||||
cli.logStart();
|
|
||||||
|
|
||||||
if (env.opts.debug) {
|
if (env.opts.debug) {
|
||||||
/**
|
/**
|
||||||
|
|||||||
156
package-lock.json
generated
156
package-lock.json
generated
@ -639,6 +639,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ci-info": {
|
||||||
|
"version": "1.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.6.0.tgz",
|
||||||
|
"integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"circular-json": {
|
"circular-json": {
|
||||||
"version": "0.3.3",
|
"version": "0.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz",
|
||||||
@ -677,6 +683,12 @@
|
|||||||
"restore-cursor": "^2.0.0"
|
"restore-cursor": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"cli-spinners": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-8B00fJOEh1HPrx4fo5eW16XmE1PcL1tGpGrxy63CXGP9nHdPBN63X75hA1zhvQuhVztJWLqV58Roj2qlNM7cAA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"cli-width": {
|
"cli-width": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz",
|
||||||
@ -1004,6 +1016,23 @@
|
|||||||
"integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=",
|
"integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"defaults": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz",
|
||||||
|
"integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"clone": "^1.0.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"clone": {
|
||||||
|
"version": "1.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz",
|
||||||
|
"integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"define-properties": {
|
"define-properties": {
|
||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
|
||||||
@ -2436,7 +2465,8 @@
|
|||||||
"graceful-fs": {
|
"graceful-fs": {
|
||||||
"version": "4.1.11",
|
"version": "4.1.11",
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
||||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
|
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"gulp": {
|
"gulp": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
@ -3036,6 +3066,36 @@
|
|||||||
"handlebars": "^4.1.2"
|
"handlebars": "^4.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"jasmine": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-sR9b4n+fnBFDEd7VS2el2DeHgKcPiMVn44rtKFumq9q7P/t8WrxsVIZPob4UDdgcDNCwyDqwxCt4k9TDRmjPoQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3",
|
||||||
|
"jasmine-core": "~3.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jasmine-console-reporter": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jasmine-console-reporter/-/jasmine-console-reporter-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-fNP6XlgkIyNvfr6JVMJudZL9qWNY2K7l934Ojj4k8J09/QXf4xYf2Mc7MUgcsDhqIb2zTkLd2LsBJWFvJz41/w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"ansi-styles": "^3.2.1",
|
||||||
|
"chalk": "^2.4.1",
|
||||||
|
"ci-info": "^1.4.0",
|
||||||
|
"node-emoji": "^1.8.1",
|
||||||
|
"ora": "^3.0.0",
|
||||||
|
"perfy": "^1.1.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jasmine-core": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-HU/YxV4i6GcmiH4duATwAbJQMlE0MsDIR5XmSVxURxKHn3aGAdbY1/ZJFmVRbKtnLwIxxMJD7gYaPsypcbYimg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"js-beautify": {
|
"js-beautify": {
|
||||||
"version": "1.10.0",
|
"version": "1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.10.0.tgz",
|
||||||
@ -3065,14 +3125,6 @@
|
|||||||
"esprima": "^4.0.0"
|
"esprima": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"js2xmlparser": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-WuNgdZOXVmBk5kUPMcTcVUpbGRzLfNkv7+7APq7WiDihpXVKrgxo6wwRpRl9OQeEBgKCVk9mR7RbzrnNWC8oBw==",
|
|
||||||
"requires": {
|
|
||||||
"xmlcreate": "^2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"jsesc": {
|
"jsesc": {
|
||||||
"version": "2.5.2",
|
"version": "2.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
|
||||||
@ -3109,12 +3161,13 @@
|
|||||||
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
|
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"klaw": {
|
"klaw-sync": {
|
||||||
"version": "3.0.0",
|
"version": "6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz",
|
||||||
"integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==",
|
"integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"graceful-fs": "^4.1.9"
|
"graceful-fs": "^4.1.11"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"last-run": {
|
"last-run": {
|
||||||
@ -3230,6 +3283,21 @@
|
|||||||
"integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=",
|
"integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"lodash.toarray": {
|
||||||
|
"version": "4.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.toarray/-/lodash.toarray-4.4.0.tgz",
|
||||||
|
"integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"log-symbols": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"chalk": "^2.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"lru-cache": {
|
"lru-cache": {
|
||||||
"version": "4.1.5",
|
"version": "4.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
|
||||||
@ -3533,6 +3601,15 @@
|
|||||||
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node-emoji": {
|
||||||
|
"version": "1.10.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz",
|
||||||
|
"integrity": "sha512-Yt3384If5H6BYGVHiHwTL+99OzJKHhgp82S8/dktEK73T26BazdgZ4JZh92xSVtGNJvz9UbXdNAc5hcrXV42vw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"lodash.toarray": "^4.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nopt": {
|
"nopt": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz",
|
||||||
@ -3953,6 +4030,37 @@
|
|||||||
"wordwrap": "~1.0.0"
|
"wordwrap": "~1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ora": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ora/-/ora-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-eNwHudNbO1folBP3JsZ19v9azXWtQZjICdr3Q0TDPIaeBQ3mXLrh54wM+er0+hSp+dWKf+Z8KM58CYzEyIYxYg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"chalk": "^2.4.2",
|
||||||
|
"cli-cursor": "^2.1.0",
|
||||||
|
"cli-spinners": "^2.0.0",
|
||||||
|
"log-symbols": "^2.2.0",
|
||||||
|
"strip-ansi": "^5.2.0",
|
||||||
|
"wcwidth": "^1.0.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-regex": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"strip-ansi": {
|
||||||
|
"version": "5.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
|
||||||
|
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"ansi-regex": "^4.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"ordered-read-streams": {
|
"ordered-read-streams": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz",
|
||||||
@ -4167,6 +4275,12 @@
|
|||||||
"pinkie-promise": "^2.0.0"
|
"pinkie-promise": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"perfy": {
|
||||||
|
"version": "1.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/perfy/-/perfy-1.1.5.tgz",
|
||||||
|
"integrity": "sha512-/ieVBpMaPTJf83YTUl2TImsSwMEJ23qGP2w27pE6aX+NrB/ZRGqOnQZpl7J719yFwd+ebDiHguPNFeMSamyK7w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"pify": {
|
"pify": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||||
@ -5475,6 +5589,15 @@
|
|||||||
"vinyl": "^2.0.0"
|
"vinyl": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"wcwidth": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz",
|
||||||
|
"integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"defaults": "^1.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"which": {
|
"which": {
|
||||||
"version": "1.3.1",
|
"version": "1.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
||||||
@ -5554,11 +5677,6 @@
|
|||||||
"signal-exit": "^3.0.2"
|
"signal-exit": "^3.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"xmlcreate": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-MjGsXhKG8YjTKrDCXseFo3ClbMGvUD4en29H2Cev1dv4P/chlpw6KdYmlCWDkhosBVKRDjM836+3e3pm1cBNJA=="
|
|
||||||
},
|
|
||||||
"xtend": {
|
"xtend": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
|
||||||
|
|||||||
@ -19,8 +19,6 @@
|
|||||||
"code-prettify": "^0.1.0",
|
"code-prettify": "^0.1.0",
|
||||||
"color-themes-for-google-code-prettify": "^2.0.4",
|
"color-themes-for-google-code-prettify": "^2.0.4",
|
||||||
"escape-string-regexp": "^2.0.0",
|
"escape-string-regexp": "^2.0.0",
|
||||||
"js2xmlparser": "^4.0.0",
|
|
||||||
"klaw": "^3.0.0",
|
|
||||||
"lodash": "^4.17.11",
|
"lodash": "^4.17.11",
|
||||||
"markdown-it": "^8.4.2",
|
"markdown-it": "^8.4.2",
|
||||||
"markdown-it-anchor": "^5.0.2",
|
"markdown-it-anchor": "^5.0.2",
|
||||||
@ -36,6 +34,9 @@
|
|||||||
"gulp": "^4.0.1",
|
"gulp": "^4.0.1",
|
||||||
"gulp-eslint": "^5.0.0",
|
"gulp-eslint": "^5.0.0",
|
||||||
"gulp-json-editor": "^2.5.2",
|
"gulp-json-editor": "^2.5.2",
|
||||||
|
"jasmine": "^3.3.1",
|
||||||
|
"jasmine-console-reporter": "^3.1.0",
|
||||||
|
"klaw-sync": "^6.0.0",
|
||||||
"nyc": "^14.1.0"
|
"nyc": "^14.1.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
'use strict';
|
/* global jsdoc */
|
||||||
|
|
||||||
describe('commentConvert plugin', function() {
|
describe('commentConvert plugin', () => {
|
||||||
var env = require('jsdoc/env');
|
const env = require('jsdoc/env');
|
||||||
var path = require('jsdoc/path');
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
var docSet;
|
let docSet;
|
||||||
var parser = jasmine.createParser();
|
const parser = jsdoc.createParser();
|
||||||
var pluginPath = 'plugins/commentConvert';
|
const pluginPath = 'plugins/commentConvert';
|
||||||
var pluginPathResolved = path.join(env.dirname, pluginPath);
|
const pluginPathResolved = path.join(env.dirname, pluginPath);
|
||||||
var plugin = require(pluginPathResolved);
|
|
||||||
|
|
||||||
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
||||||
docSet = jasmine.getDocSetFromFile(pluginPath + '.js', parser);
|
docSet = jsdoc.getDocSetFromFile(`${pluginPath}.js`, parser);
|
||||||
|
|
||||||
|
it('should convert ///-style comments into jsdoc comments', () => {
|
||||||
|
const doclet = docSet.getByLongname('module:plugins/commentConvert.handlers.beforeParse');
|
||||||
|
|
||||||
it('should convert ///-style comments into jsdoc comments', function() {
|
|
||||||
var doclet = docSet.getByLongname('module:plugins/commentConvert.handlers.beforeParse');
|
|
||||||
expect(doclet.length).toEqual(1);
|
expect(doclet.length).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
'use strict';
|
/* global jsdoc */
|
||||||
|
describe('escapeHtml plugin', () => {
|
||||||
|
const env = require('jsdoc/env');
|
||||||
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
describe('escapeHtml plugin', function() {
|
let docSet;
|
||||||
var env = require('jsdoc/env');
|
const parser = jsdoc.createParser();
|
||||||
var path = require('jsdoc/path');
|
const pluginPath = 'plugins/escapeHtml';
|
||||||
|
const pluginPathResolved = path.join(env.dirname, pluginPath);
|
||||||
var docSet;
|
|
||||||
var parser = jasmine.createParser();
|
|
||||||
var pluginPath = 'plugins/escapeHtml';
|
|
||||||
var pluginPathResolved = path.join(env.dirname, pluginPath);
|
|
||||||
|
|
||||||
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
||||||
docSet = jasmine.getDocSetFromFile(pluginPath + '.js', parser);
|
docSet = jsdoc.getDocSetFromFile(`${pluginPath}.js`, parser);
|
||||||
|
|
||||||
it("should escape '&', '<' and newlines in doclet descriptions", function() {
|
it("should escape '&', '<' and newlines in doclet descriptions", () => {
|
||||||
var doclet = docSet.getByLongname('module:plugins/escapeHtml.handlers.newDoclet');
|
const doclet = docSet.getByLongname('module:plugins/escapeHtml.handlers.newDoclet');
|
||||||
|
|
||||||
expect(doclet[0].description).toEqual('Translate HTML tags in descriptions into safe entities. Replaces <, & and newlines');
|
expect(doclet[0].description).toBe('Translate HTML tags in descriptions into safe ' +
|
||||||
|
'entities. Replaces <, & and newlines');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,19 +1,18 @@
|
|||||||
'use strict';
|
/* global jsdoc */
|
||||||
|
const env = require('jsdoc/env');
|
||||||
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
var env = require('jsdoc/env');
|
describe('markdown plugin', () => {
|
||||||
var path = require('jsdoc/path');
|
const pluginPath = 'plugins/markdown';
|
||||||
|
const pluginPathResolved = path.join(env.dirname, pluginPath);
|
||||||
|
const plugin = require(pluginPathResolved);
|
||||||
|
|
||||||
describe('markdown plugin', function() {
|
const docSet = jsdoc.getDocSetFromFile('plugins/test/fixtures/markdown.js');
|
||||||
var pluginPath = 'plugins/markdown';
|
|
||||||
var pluginPathResolved = path.join(env.dirname, pluginPath);
|
|
||||||
var plugin = require(pluginPathResolved);
|
|
||||||
|
|
||||||
var docSet = jasmine.getDocSetFromFile('plugins/test/fixtures/markdown.js');
|
|
||||||
|
|
||||||
// TODO: more tests; refactor the plugin so multiple settings can be tested
|
// TODO: more tests; refactor the plugin so multiple settings can be tested
|
||||||
|
|
||||||
it('should process the correct tags by default', function() {
|
it('should process the correct tags by default', () => {
|
||||||
var myClass = docSet.getByLongname('MyClass')[0];
|
const myClass = docSet.getByLongname('MyClass')[0];
|
||||||
|
|
||||||
plugin.handlers.newDoclet({ doclet: myClass });
|
plugin.handlers.newDoclet({ doclet: myClass });
|
||||||
[
|
[
|
||||||
@ -26,14 +25,14 @@ describe('markdown plugin', function() {
|
|||||||
myClass.returns[0].description,
|
myClass.returns[0].description,
|
||||||
myClass.see,
|
myClass.see,
|
||||||
myClass.summary
|
myClass.summary
|
||||||
].forEach(function(value) {
|
].forEach(value => {
|
||||||
// if we processed the value, it should be wrapped in a <p> tag
|
// if we processed the value, it should be wrapped in a <p> tag
|
||||||
expect( /^<p>(?:.+)<\/p>$/.test(value) ).toBe(true);
|
expect( /^<p>(?:.+)<\/p>$/.test(value) ).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should unescape " entities in inline tags, but not elsewhere', function() {
|
it('should unescape " entities in inline tags, but not elsewhere', () => {
|
||||||
var myOtherClass = docSet.getByLongname('MyOtherClass')[0];
|
const myOtherClass = docSet.getByLongname('MyOtherClass')[0];
|
||||||
|
|
||||||
plugin.handlers.newDoclet({ doclet: myOtherClass });
|
plugin.handlers.newDoclet({ doclet: myOtherClass });
|
||||||
|
|
||||||
@ -41,17 +40,17 @@ describe('markdown plugin', function() {
|
|||||||
expect(myOtherClass.description).toContain('"See"');
|
expect(myOtherClass.description).toContain('"See"');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('@see tag support', function() {
|
describe('@see tag support', () => {
|
||||||
var foo = docSet.getByLongname('foo')[0];
|
const foo = docSet.getByLongname('foo')[0];
|
||||||
var bar = docSet.getByLongname('bar')[0];
|
const bar = docSet.getByLongname('bar')[0];
|
||||||
|
|
||||||
it('should parse @see tags containing links', function() {
|
it('should parse @see tags containing links', () => {
|
||||||
plugin.handlers.newDoclet({ doclet: foo });
|
plugin.handlers.newDoclet({ doclet: foo });
|
||||||
expect(typeof foo).toEqual('object');
|
expect(typeof foo).toEqual('object');
|
||||||
expect(foo.see[0]).toEqual('<p><a href="http://nowhere.com">Nowhere</a></p>');
|
expect(foo.see[0]).toEqual('<p><a href="http://nowhere.com">Nowhere</a></p>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not parse @see tags that do not contain links', function() {
|
it('should not parse @see tags that do not contain links', () => {
|
||||||
plugin.handlers.newDoclet({ doclet: bar });
|
plugin.handlers.newDoclet({ doclet: bar });
|
||||||
expect(typeof bar).toEqual('object');
|
expect(typeof bar).toEqual('object');
|
||||||
expect(bar.see[0]).toEqual('AnObject#myProperty');
|
expect(bar.see[0]).toEqual('AnObject#myProperty');
|
||||||
|
|||||||
@ -1,100 +1,99 @@
|
|||||||
'use strict';
|
/* global jsdoc */
|
||||||
|
describe('plugins/overloadHelper', () => {
|
||||||
|
const env = require('jsdoc/env');
|
||||||
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
describe('plugins/overloadHelper', function() {
|
let docSet;
|
||||||
var env = require('jsdoc/env');
|
const parser = jsdoc.createParser();
|
||||||
var path = require('jsdoc/path');
|
const pluginPath = 'plugins/overloadHelper';
|
||||||
|
const pluginPathResolved = path.resolve(env.dirname, pluginPath);
|
||||||
var docSet;
|
const plugin = require(pluginPathResolved);
|
||||||
var parser = jasmine.createParser();
|
|
||||||
var pluginPath = 'plugins/overloadHelper';
|
|
||||||
var pluginPathResolved = path.resolve(env.dirname, pluginPath);
|
|
||||||
var plugin = require(pluginPathResolved);
|
|
||||||
|
|
||||||
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
||||||
docSet = jasmine.getDocSetFromFile('plugins/test/fixtures/overloadHelper.js', parser);
|
docSet = jsdoc.getDocSetFromFile('plugins/test/fixtures/overloadHelper.js', parser);
|
||||||
|
|
||||||
it('should exist', function() {
|
it('should exist', () => {
|
||||||
expect(plugin).toBeDefined();
|
expect(plugin).toBeDefined();
|
||||||
expect(typeof plugin).toBe('object');
|
expect(typeof plugin).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export handlers', function() {
|
it('should export handlers', () => {
|
||||||
expect(plugin.handlers).toBeDefined();
|
expect(plugin.handlers).toBeDefined();
|
||||||
expect(typeof plugin.handlers).toBe('object');
|
expect(typeof plugin.handlers).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "newDoclet" handler', function() {
|
it('should export a "newDoclet" handler', () => {
|
||||||
expect(plugin.handlers.newDoclet).toBeDefined();
|
expect(plugin.handlers.newDoclet).toBeDefined();
|
||||||
expect(typeof plugin.handlers.newDoclet).toBe('function');
|
expect(typeof plugin.handlers.newDoclet).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "parseComplete" handler', function() {
|
it('should export a "parseComplete" handler', () => {
|
||||||
expect(plugin.handlers.parseComplete).toBeDefined();
|
expect(plugin.handlers.parseComplete).toBeDefined();
|
||||||
expect(typeof plugin.handlers.parseComplete).toBe('function');
|
expect(typeof plugin.handlers.parseComplete).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('newDoclet handler', function() {
|
describe('newDoclet handler', () => {
|
||||||
it('should not add unique longnames to constructors', function() {
|
it('should not add unique longnames to constructors', () => {
|
||||||
var soup = docSet.getByLongname('Soup');
|
const soup = docSet.getByLongname('Soup');
|
||||||
var soup1 = docSet.getByLongname('Soup()');
|
const soup1 = docSet.getByLongname('Soup()');
|
||||||
var soup2 = docSet.getByLongname('Soup(spiciness)');
|
const soup2 = docSet.getByLongname('Soup(spiciness)');
|
||||||
|
|
||||||
expect(soup.length).toBe(2);
|
expect(soup.length).toBe(2);
|
||||||
expect(soup1.length).toBe(0);
|
expect(soup1.length).toBe(0);
|
||||||
expect(soup2.length).toBe(0);
|
expect(soup2.length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add unique longnames to methods', function() {
|
it('should add unique longnames to methods', () => {
|
||||||
var slurp = docSet.getByLongname('Soup#slurp');
|
const slurp = docSet.getByLongname('Soup#slurp');
|
||||||
var slurp1 = docSet.getByLongname('Soup#slurp()');
|
const slurp1 = docSet.getByLongname('Soup#slurp()');
|
||||||
var slurp2 = docSet.getByLongname('Soup#slurp(dBA)');
|
const slurp2 = docSet.getByLongname('Soup#slurp(dBA)');
|
||||||
|
|
||||||
expect(slurp.length).toBe(0);
|
expect(slurp.length).toBe(0);
|
||||||
expect(slurp1.length).toBe(1);
|
expect(slurp1.length).toBe(1);
|
||||||
expect(slurp2.length).toBe(1);
|
expect(slurp2.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the "variation" property of the method', function() {
|
it('should update the "variation" property of the method', () => {
|
||||||
var slurp1 = docSet.getByLongname('Soup#slurp()')[0];
|
const slurp1 = docSet.getByLongname('Soup#slurp()')[0];
|
||||||
var slurp2 = docSet.getByLongname('Soup#slurp(dBA)')[0];
|
const slurp2 = docSet.getByLongname('Soup#slurp(dBA)')[0];
|
||||||
|
|
||||||
expect(slurp1.variation).toBe('');
|
expect(slurp1.variation).toBe('');
|
||||||
expect(slurp2.variation).toBe('dBA');
|
expect(slurp2.variation).toBe('dBA');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not add to or change existing variations that are unique', function() {
|
it('should not add to or change existing variations that are unique', () => {
|
||||||
var salt1 = docSet.getByLongname('Soup#salt');
|
const salt1 = docSet.getByLongname('Soup#salt');
|
||||||
var salt2 = docSet.getByLongname('Soup#salt(mg)');
|
const salt2 = docSet.getByLongname('Soup#salt(mg)');
|
||||||
|
|
||||||
expect(salt1.length).toBe(1);
|
expect(salt1.length).toBe(1);
|
||||||
expect(salt2.length).toBe(1);
|
expect(salt2.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not duplicate the names of existing numeric variations', function() {
|
it('should not duplicate the names of existing numeric variations', () => {
|
||||||
var heat1 = docSet.getByLongname('Soup#heat(1)');
|
const heat1 = docSet.getByLongname('Soup#heat(1)');
|
||||||
var heat2 = docSet.getByLongname('Soup#heat(2)');
|
const heat2 = docSet.getByLongname('Soup#heat(2)');
|
||||||
var heat3 = docSet.getByLongname('Soup#heat(3)');
|
const heat3 = docSet.getByLongname('Soup#heat(3)');
|
||||||
|
|
||||||
expect(heat1.length).toBe(1);
|
expect(heat1.length).toBe(1);
|
||||||
expect(heat2.length).toBe(1);
|
expect(heat2.length).toBe(1);
|
||||||
expect(heat3.length).toBe(1);
|
expect(heat3.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should replace identical variations with new, unique variations', function() {
|
it('should replace identical variations with new, unique variations', () => {
|
||||||
var discard1 = docSet.getByLongname('Soup#discard()');
|
const discard1 = docSet.getByLongname('Soup#discard()');
|
||||||
var discard2 = docSet.getByLongname('Soup#discard(container)');
|
const discard2 = docSet.getByLongname('Soup#discard(container)');
|
||||||
|
|
||||||
expect(discard1.length).toBe(1);
|
expect(discard1.length).toBe(1);
|
||||||
expect(discard2.length).toBe(1);
|
expect(discard2.length).toBe(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parseComplete handler', function() {
|
describe('parseComplete handler', () => {
|
||||||
// disabled because on the second run, each comment is being parsed twice; who knows why...
|
// disabled because on the second run, each comment is being parsed twice; who knows why...
|
||||||
xit('should not retain parse results between parser runs', function() {
|
xit('should not retain parse results between parser runs', () => {
|
||||||
parser.clear();
|
parser.clear();
|
||||||
docSet = jasmine.getDocSetFromFile('plugins/test/fixtures/overloadHelper.js', parser);
|
docSet = jsdoc.getDocSetFromFile('plugins/test/fixtures/overloadHelper.js', parser);
|
||||||
var heat = docSet.getByLongname('Soup#heat(4)');
|
const heat = docSet.getByLongname('Soup#heat(4)');
|
||||||
|
|
||||||
expect(heat.length).toBe(0);
|
expect(heat.length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
'use strict';
|
/* global jsdoc */
|
||||||
|
describe('railsTemplate plugin', () => {
|
||||||
|
const env = require('jsdoc/env');
|
||||||
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
describe('railsTemplate plugin', function() {
|
const parser = jsdoc.createParser();
|
||||||
var env = require('jsdoc/env');
|
const pluginPath = path.join(env.dirname, 'plugins/railsTemplate');
|
||||||
var path = require('jsdoc/path');
|
|
||||||
|
|
||||||
var parser = jasmine.createParser();
|
|
||||||
var pluginPath = path.join(env.dirname, 'plugins/railsTemplate');
|
|
||||||
var plugin = require(pluginPath);
|
|
||||||
|
|
||||||
require('jsdoc/plugins').installPlugins([pluginPath], parser);
|
require('jsdoc/plugins').installPlugins([pluginPath], parser);
|
||||||
require('jsdoc/src/handlers').attachTo(parser);
|
require('jsdoc/src/handlers').attachTo(parser);
|
||||||
|
|
||||||
it('should remove <% %> rails template tags from the source of *.erb files', function() {
|
it('should remove <% %> rails template tags from the source of *.erb files', () => {
|
||||||
var docSet = parser.parse([path.join(env.dirname, 'plugins/test/fixtures/railsTemplate.js.erb')]);
|
const docSet = parser.parse([path.join(env.dirname, 'plugins/test/fixtures/railsTemplate.js.erb')]);
|
||||||
|
|
||||||
expect(docSet[2].description).toEqual('Remove rails tags from the source input (e.g. )');
|
expect(docSet[2].description).toEqual('Remove rails tags from the source input (e.g. )');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,20 +1,19 @@
|
|||||||
'use strict';
|
/* global jsdoc */
|
||||||
|
describe('shout plugin', () => {
|
||||||
|
const env = require('jsdoc/env');
|
||||||
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
describe('shout plugin', function() {
|
let docSet;
|
||||||
var env = require('jsdoc/env');
|
const parser = jsdoc.createParser();
|
||||||
var path = require('jsdoc/path');
|
const pluginPath = 'plugins/shout';
|
||||||
|
const pluginPathResolved = path.join(env.dirname, pluginPath);
|
||||||
var docSet;
|
|
||||||
var parser = jasmine.createParser();
|
|
||||||
var pluginPath = 'plugins/shout';
|
|
||||||
var pluginPathResolved = path.join(env.dirname, pluginPath);
|
|
||||||
var plugin = require(pluginPathResolved);
|
|
||||||
|
|
||||||
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
||||||
docSet = jasmine.getDocSetFromFile(pluginPath + '.js', parser);
|
docSet = jsdoc.getDocSetFromFile(`${pluginPath}.js`, parser);
|
||||||
|
|
||||||
|
it('should make the description uppercase', () => {
|
||||||
|
const doclet = docSet.getByLongname('module:plugins/shout.handlers.newDoclet');
|
||||||
|
|
||||||
it('should make the description uppercase', function() {
|
|
||||||
var doclet = docSet.getByLongname('module:plugins/shout.handlers.newDoclet');
|
|
||||||
expect(doclet[0].description).toEqual('MAKE YOUR DESCRIPTIONS MORE SHOUTIER.');
|
expect(doclet[0].description).toEqual('MAKE YOUR DESCRIPTIONS MORE SHOUTIER.');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,19 +1,18 @@
|
|||||||
'use strict';
|
/* global jsdoc */
|
||||||
|
describe('sourcetag plugin', () => {
|
||||||
|
const env = require('jsdoc/env');
|
||||||
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
describe('sourcetag plugin', function() {
|
let docSet;
|
||||||
var env = require('jsdoc/env');
|
const parser = jsdoc.createParser();
|
||||||
var path = require('jsdoc/path');
|
const pluginPath = 'plugins/sourcetag';
|
||||||
|
const pluginPathResolved = path.join(env.dirname, pluginPath);
|
||||||
var docSet;
|
|
||||||
var parser = jasmine.createParser();
|
|
||||||
var pluginPath = 'plugins/sourcetag';
|
|
||||||
var pluginPathResolved = path.join(env.dirname, pluginPath);
|
|
||||||
|
|
||||||
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
||||||
docSet = jasmine.getDocSetFromFile(pluginPath + '.js', parser);
|
docSet = jsdoc.getDocSetFromFile(`${pluginPath}.js`, parser);
|
||||||
|
|
||||||
it("should set the lineno and filename of the doclet's meta property", function() {
|
it("should set the lineno and filename of the doclet's meta property", () => {
|
||||||
var doclet = docSet.getByLongname('module:plugins/sourcetag.handlers.newDoclet');
|
const doclet = docSet.getByLongname('module:plugins/sourcetag.handlers.newDoclet');
|
||||||
|
|
||||||
expect(doclet[0].meta).toBeDefined();
|
expect(doclet[0].meta).toBeDefined();
|
||||||
expect(doclet[0].meta.filename).toEqual('sourcetag.js');
|
expect(doclet[0].meta.filename).toEqual('sourcetag.js');
|
||||||
|
|||||||
@ -1,23 +1,20 @@
|
|||||||
/*global describe, expect, it */
|
const summarize = require('../../summarize');
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var summarize = require('../../summarize');
|
describe('summarize', () => {
|
||||||
|
it('should export handlers', () => {
|
||||||
describe('summarize', function() {
|
|
||||||
it('should export handlers', function() {
|
|
||||||
expect(summarize.handlers).toBeDefined();
|
expect(summarize.handlers).toBeDefined();
|
||||||
expect(typeof summarize.handlers).toBe('object');
|
expect(typeof summarize.handlers).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a newDoclet handler', function() {
|
it('should export a newDoclet handler', () => {
|
||||||
expect(summarize.handlers.newDoclet).toBeDefined();
|
expect(summarize.handlers.newDoclet).toBeDefined();
|
||||||
expect(typeof summarize.handlers.newDoclet).toBe('function');
|
expect(typeof summarize.handlers.newDoclet).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('newDoclet handler', function() {
|
describe('newDoclet handler', () => {
|
||||||
var handler = summarize.handlers.newDoclet;
|
const handler = summarize.handlers.newDoclet;
|
||||||
|
|
||||||
it('should not blow up if the doclet is missing', function() {
|
it('should not blow up if the doclet is missing', () => {
|
||||||
function noDoclet() {
|
function noDoclet() {
|
||||||
return handler({});
|
return handler({});
|
||||||
}
|
}
|
||||||
@ -25,85 +22,92 @@ describe('summarize', function() {
|
|||||||
expect(noDoclet).not.toThrow();
|
expect(noDoclet).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not change the summary if it is already defined', function() {
|
it('should not change the summary if it is already defined', () => {
|
||||||
var doclet = {
|
const doclet = {
|
||||||
summary: 'This is a summary.',
|
summary: 'This is a summary.',
|
||||||
description: 'Descriptions are good.'
|
description: 'Descriptions are good.'
|
||||||
};
|
};
|
||||||
|
|
||||||
handler({ doclet: doclet });
|
handler({ doclet: doclet });
|
||||||
|
|
||||||
expect(doclet.summary).not.toBe(doclet.description);
|
expect(doclet.summary).not.toBe(doclet.description);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not do anything if the description is missing', function() {
|
it('should not do anything if the description is missing', () => {
|
||||||
var doclet = {};
|
const doclet = {};
|
||||||
|
|
||||||
handler({ doclet: doclet });
|
handler({ doclet: doclet });
|
||||||
|
|
||||||
expect(doclet.summary).not.toBeDefined();
|
expect(doclet.summary).not.toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use the first sentence as the summary', function() {
|
it('should use the first sentence as the summary', () => {
|
||||||
var doclet = {
|
const doclet = {
|
||||||
description: 'This sentence is the summary. This sentence is not.'
|
description: 'This sentence is the summary. This sentence is not.'
|
||||||
};
|
};
|
||||||
|
|
||||||
handler({ doclet: doclet });
|
handler({ doclet: doclet });
|
||||||
|
|
||||||
expect(doclet.summary).toBe('This sentence is the summary.');
|
expect(doclet.summary).toBe('This sentence is the summary.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not add an extra period if there is only one sentence in the description',
|
it('should not add an extra period if there is only one sentence in the description', () => {
|
||||||
function() {
|
const doclet = {
|
||||||
var doclet = {
|
|
||||||
description: 'This description has only one sentence.'
|
description: 'This description has only one sentence.'
|
||||||
};
|
};
|
||||||
|
|
||||||
handler({ doclet: doclet });
|
handler({ doclet: doclet });
|
||||||
|
|
||||||
expect(doclet.summary).toBe('This description has only one sentence.');
|
expect(doclet.summary).toBe('This description has only one sentence.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use the entire description, plus a period, as the summary if the description ' +
|
it('should use the entire description, plus a period, as the summary if the description ' +
|
||||||
'does not contain a period', function() {
|
'does not contain a period', () => {
|
||||||
var doclet = {
|
const doclet = {
|
||||||
description: 'This is a description'
|
description: 'This is a description'
|
||||||
};
|
};
|
||||||
|
|
||||||
handler({ doclet: doclet });
|
handler({ doclet: doclet });
|
||||||
|
|
||||||
expect(doclet.summary).toBe('This is a description.');
|
expect(doclet.summary).toBe('This is a description.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use the entire description as the summary if the description contains only ' +
|
it('should use the entire description as the summary if the description contains only ' +
|
||||||
'one sentence', function() {
|
'one sentence', () => {
|
||||||
var doclet = {
|
const doclet = {
|
||||||
description: 'This is a description.'
|
description: 'This is a description.'
|
||||||
};
|
};
|
||||||
|
|
||||||
handler({ doclet: doclet });
|
handler({ doclet: doclet });
|
||||||
|
|
||||||
expect(doclet.description).toBe('This is a description.');
|
expect(doclet.description).toBe('This is a description.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work when an HTML tag immediately follows the first sentence', function() {
|
it('should work when an HTML tag immediately follows the first sentence', () => {
|
||||||
var doclet = {
|
const doclet = {
|
||||||
description: 'This sentence is the summary.<small>This sentence is small.</small>'
|
description: 'This sentence is the summary.<small>This sentence is small.</small>'
|
||||||
};
|
};
|
||||||
|
|
||||||
handler({ doclet: doclet });
|
handler({ doclet: doclet });
|
||||||
|
|
||||||
expect(doclet.summary).toBe('This sentence is the summary.');
|
expect(doclet.summary).toBe('This sentence is the summary.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate valid HTML if a tag is opened, but not closed, in the summary',
|
it('should generate valid HTML if a tag is opened, but not closed, in the summary', () => {
|
||||||
function() {
|
const doclet = {
|
||||||
var doclet = {
|
|
||||||
description: 'This description has <em>a tag. The tag straddles</em> sentences.'
|
description: 'This description has <em>a tag. The tag straddles</em> sentences.'
|
||||||
};
|
};
|
||||||
|
|
||||||
handler({ doclet: doclet });
|
handler({ doclet: doclet });
|
||||||
|
|
||||||
expect(doclet.summary).toBe('This description has <em>a tag.</em>');
|
expect(doclet.summary).toBe('This description has <em>a tag.</em>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not include a <p> tag in the summary', function() {
|
it('should not include a <p> tag in the summary', () => {
|
||||||
var doclet = {
|
const doclet = {
|
||||||
description: '<p>This description contains HTML.</p><p>And plenty of it!</p>'
|
description: '<p>This description contains HTML.</p><p>And plenty of it!</p>'
|
||||||
};
|
};
|
||||||
|
|
||||||
handler({ doclet: doclet });
|
handler({ doclet: doclet });
|
||||||
|
|
||||||
expect(doclet.summary).toBe('This description contains HTML.');
|
expect(doclet.summary).toBe('This description contains HTML.');
|
||||||
|
|||||||
@ -1,35 +1,37 @@
|
|||||||
'use strict';
|
/* global jsdoc */
|
||||||
|
describe('underscore plugin', () => {
|
||||||
|
const env = require('jsdoc/env');
|
||||||
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
describe('underscore plugin', function () {
|
let docSet;
|
||||||
var env = require('jsdoc/env');
|
const parser = jsdoc.createParser();
|
||||||
var path = require('jsdoc/path');
|
const pluginPath = 'plugins/underscore';
|
||||||
|
const fixturePath = 'plugins/test/fixtures/underscore';
|
||||||
var docSet;
|
const pluginPathResolved = path.join(env.dirname, pluginPath);
|
||||||
var parser = jasmine.createParser();
|
|
||||||
var pluginPath = 'plugins/underscore';
|
|
||||||
var fixturePath = 'plugins/test/fixtures/underscore';
|
|
||||||
var pluginPathResolved = path.join(env.dirname, pluginPath);
|
|
||||||
var plugin = require(pluginPathResolved);
|
|
||||||
|
|
||||||
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
require('jsdoc/plugins').installPlugins([pluginPathResolved], parser);
|
||||||
docSet = jasmine.getDocSetFromFile(fixturePath + '.js', parser);
|
docSet = jsdoc.getDocSetFromFile(`${fixturePath}.js`, parser);
|
||||||
|
|
||||||
it('should not mark normal, public properties as private', function() {
|
it('should not mark normal, public properties as private', () => {
|
||||||
// Base line tests
|
// Base line tests
|
||||||
var normal = docSet.getByLongname('normal');
|
const normal = docSet.getByLongname('normal');
|
||||||
|
|
||||||
expect(normal[0].access).toBeUndefined();
|
expect(normal[0].access).toBeUndefined();
|
||||||
|
|
||||||
var realPrivate = docSet.getByLongname('Klass#privateProp');
|
const realPrivate = docSet.getByLongname('Klass#privateProp');
|
||||||
|
|
||||||
expect(realPrivate[0].access).toEqual('private');
|
expect(realPrivate[0].access).toEqual('private');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should hide doclet for symbols beginning with an underscore under normal circumstances', function () {
|
it('should hide doclet for symbols beginning with an underscore under normal circumstances', () => {
|
||||||
var hidden = docSet.getByLongname('_hidden');
|
const hidden = docSet.getByLongname('_hidden');
|
||||||
|
|
||||||
expect(hidden[0].access).toEqual('private');
|
expect(hidden[0].access).toEqual('private');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('picks up "this"', function() {
|
it('picks up "this"', () => {
|
||||||
var privateUnderscore = docSet.getByLongname('Klass#_privateProp');
|
const privateUnderscore = docSet.getByLongname('Klass#_privateProp');
|
||||||
|
|
||||||
expect(privateUnderscore[0].access).toEqual('private');
|
expect(privateUnderscore[0].access).toEqual('private');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
5
test/.eslintrc.js
Normal file
5
test/.eslintrc.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
globals: {
|
||||||
|
jsdoc: 'readonly'
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -1,39 +1,20 @@
|
|||||||
Testing JSDoc 3
|
# Testing JSDoc
|
||||||
===============
|
|
||||||
|
|
||||||
Running Tests
|
JSDoc uses [Jasmine](https://github.com/jasmine/jasmine) as its testing framework. See the
|
||||||
-------------
|
[Jasmine documentation](https://jasmine.github.io/pages/docs_home.html) for details.
|
||||||
|
|
||||||
Running tests is easy. Just change your working directory to the jsdoc folder
|
## Running tests
|
||||||
and run the following command on Windows:
|
|
||||||
|
|
||||||
jsdoc -T
|
Clone the GitHub repository; change to its directory; and run the following commands:
|
||||||
|
|
||||||
Or on OS X, Linux, and other POSIX-compliant platforms:
|
npm install
|
||||||
|
node jsdoc.js -T
|
||||||
|
|
||||||
./jsdoc -T
|
## Writing tests
|
||||||
|
|
||||||
Writing Tests
|
You can write tests for all of the following:
|
||||||
-------------
|
|
||||||
|
|
||||||
Adding tests is pretty easy, too. You can write tests for JSDoc itself (to
|
+ **JSDoc itself**. See the `test` directory. Test specs are in `test/specs`, and fixtures used by
|
||||||
make sure tags and the parser, etc. are working properly), tests for plugins, and/or
|
the tests are in `test/fixtures`.
|
||||||
tests for templates.
|
+ **Plugins**. See the `plugins/test` directory.
|
||||||
|
+ **Packages**. See the `packages/**/test` directories.
|
||||||
JSDoc 3 uses Jasmine (https://github.com/pivotal/jasmine) as its testing framework.
|
|
||||||
Take a look at that project's wiki for documentation on writing tests in general.
|
|
||||||
|
|
||||||
### Tests for JSDoc
|
|
||||||
|
|
||||||
Take a look at the files in the ```test``` directory for many examples of
|
|
||||||
writing tests for JSDoc itself. The ```test\fixtures``` directory hold fixtures
|
|
||||||
for use in the tests, and the ```test\specs``` directory holds the tests themselves.
|
|
||||||
|
|
||||||
### Tests for plugins
|
|
||||||
|
|
||||||
Tests for plugins are found in the ```plugins\test``` directory. Plugins containing
|
|
||||||
tests that were installed with the Jakefile install task will be run automatically.
|
|
||||||
|
|
||||||
### Tests for templates
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|||||||
@ -1,57 +0,0 @@
|
|||||||
/*global jasmine: true */
|
|
||||||
(function() {
|
|
||||||
var withoutAsync = {};
|
|
||||||
|
|
||||||
["it", "beforeEach", "afterEach"].forEach(function(jasmineFunction) {
|
|
||||||
withoutAsync[jasmineFunction] = jasmine.Env.prototype[jasmineFunction];
|
|
||||||
return jasmine.Env.prototype[jasmineFunction] = function() {
|
|
||||||
var args = Array.prototype.slice.call(arguments, 0);
|
|
||||||
var timeout = null;
|
|
||||||
if (isLastArgumentATimeout(args)) {
|
|
||||||
timeout = args.pop();
|
|
||||||
}
|
|
||||||
if (isLastArgumentAnAsyncSpecFunction(args))
|
|
||||||
{
|
|
||||||
var specFunction = args.pop();
|
|
||||||
args.push(function() {
|
|
||||||
return asyncSpec(specFunction, this, timeout);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return withoutAsync[jasmineFunction].apply(this, args);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
function isLastArgumentATimeout(args)
|
|
||||||
{
|
|
||||||
return args.length > 0 && (typeof args[args.length-1]) === "number";
|
|
||||||
}
|
|
||||||
|
|
||||||
function isLastArgumentAnAsyncSpecFunction(args)
|
|
||||||
{
|
|
||||||
return args.length > 0 && (typeof args[args.length-1]) === "function" && args[args.length-1].length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function asyncSpec(specFunction, spec, timeout) {
|
|
||||||
if (timeout == null){timeout = jasmine.DEFAULT_TIMEOUT_INTERVAL || 1000;}
|
|
||||||
var done = false;
|
|
||||||
spec.runs(function() {
|
|
||||||
try {
|
|
||||||
return specFunction(function(error) {
|
|
||||||
done = true;
|
|
||||||
if (error != null) {
|
|
||||||
return spec.fail(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
done = true;
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return spec.waitsFor(function() {
|
|
||||||
if (done === true) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}, "spec to complete", timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
}).call(this);
|
|
||||||
77
test/helpers/jsdoc.js
Normal file
77
test/helpers/jsdoc.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
const fs = require('jsdoc/fs');
|
||||||
|
const jsdoc = {
|
||||||
|
augment: require('jsdoc/augment'),
|
||||||
|
doclet: require('jsdoc/doclet'),
|
||||||
|
env: require('jsdoc/env'),
|
||||||
|
schema: require('jsdoc/schema'),
|
||||||
|
src: {
|
||||||
|
handlers: require('jsdoc/src/handlers'),
|
||||||
|
parser: require('jsdoc/src/parser')
|
||||||
|
},
|
||||||
|
tag: {
|
||||||
|
dictionary: require('jsdoc/tag/dictionary'),
|
||||||
|
definitions: require('jsdoc/tag/dictionary/definitions')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
|
const originalDictionary = jsdoc.tag.dictionary;
|
||||||
|
const parseResults = [];
|
||||||
|
|
||||||
|
const helpers = global.jsdoc = {
|
||||||
|
addParseResults: (filename, doclets) => {
|
||||||
|
parseResults.push({
|
||||||
|
filename: filename,
|
||||||
|
doclets: doclets
|
||||||
|
});
|
||||||
|
},
|
||||||
|
createParser: () => jsdoc.src.parser.createParser(),
|
||||||
|
getDocSetFromFile: (filename, parser, shouldValidate, augment) => {
|
||||||
|
let doclets;
|
||||||
|
|
||||||
|
const sourceCode = fs.readFileSync(path.join(jsdoc.env.dirname, filename), 'utf8');
|
||||||
|
const testParser = parser || helpers.createParser();
|
||||||
|
|
||||||
|
jsdoc.src.handlers.attachTo(testParser);
|
||||||
|
|
||||||
|
/* eslint-disable no-script-url */
|
||||||
|
doclets = testParser.parse(`javascript:${sourceCode}`);
|
||||||
|
/* eslint-enable no-script-url */
|
||||||
|
|
||||||
|
if (augment !== false) {
|
||||||
|
jsdoc.augment.augmentAll(doclets);
|
||||||
|
}
|
||||||
|
|
||||||
|
// tests assume that borrows have not yet been resolved
|
||||||
|
|
||||||
|
if (shouldValidate !== false) {
|
||||||
|
helpers.addParseResults(filename, doclets);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
doclets: doclets,
|
||||||
|
getByLongname(longname) {
|
||||||
|
return doclets.filter(doclet => (doclet.longname || doclet.name) === longname);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
getParseResults: () => parseResults,
|
||||||
|
replaceTagDictionary: dictionaryNames => {
|
||||||
|
const dict = new jsdoc.tag.dictionary.Dictionary();
|
||||||
|
const originalDictionaries = jsdoc.env.conf.tags.dictionaries.slice(0);
|
||||||
|
|
||||||
|
if (!Array.isArray(dictionaryNames)) {
|
||||||
|
dictionaryNames = [dictionaryNames];
|
||||||
|
}
|
||||||
|
|
||||||
|
jsdoc.env.conf.tags.dictionaries = dictionaryNames;
|
||||||
|
|
||||||
|
jsdoc.tag.definitions.defineTags(dict);
|
||||||
|
jsdoc.doclet._replaceDictionary(dict);
|
||||||
|
|
||||||
|
jsdoc.env.conf.tags.dictionaries = originalDictionaries;
|
||||||
|
},
|
||||||
|
restoreTagDictionary: () => {
|
||||||
|
jsdoc.doclet._replaceDictionary(originalDictionary);
|
||||||
|
}
|
||||||
|
};
|
||||||
54
test/index.js
Normal file
54
test/index.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
const ConsoleReporter = require('jasmine-console-reporter');
|
||||||
|
const env = require('jsdoc/env');
|
||||||
|
const Jasmine = require('jasmine');
|
||||||
|
const klawSync = require('klaw-sync');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const SCHEMA_SPEC = path.resolve('test/specs/jsdoc/schema.js');
|
||||||
|
const SPEC_FILES = (() => {
|
||||||
|
// Normal specs are specs that don't need filtering.
|
||||||
|
const normalSpecs = [
|
||||||
|
'packages/**/test/specs/**/*.js',
|
||||||
|
'plugins/test/specs/**/*.js'
|
||||||
|
];
|
||||||
|
// Klawed specs are specs we've filtered to avoid the schema spec, which must run last.
|
||||||
|
const klawedSpecs = klawSync('test/specs', {
|
||||||
|
filter: (item) => (item.path !== SCHEMA_SPEC),
|
||||||
|
nodir: true
|
||||||
|
}).map((item) => item.path);
|
||||||
|
|
||||||
|
// We want an array of spec files with the schema spec at the end.
|
||||||
|
return normalSpecs.concat(klawedSpecs).concat([SCHEMA_SPEC]);
|
||||||
|
})();
|
||||||
|
|
||||||
|
module.exports = () => {
|
||||||
|
const jasmine = new Jasmine();
|
||||||
|
const matcher = env.opts.matcher;
|
||||||
|
/* eslint-disable no-empty-function */
|
||||||
|
const promise = new Promise(() => {});
|
||||||
|
/* eslint-enable no-empty-function */
|
||||||
|
const reporter = new ConsoleReporter({
|
||||||
|
beep: false,
|
||||||
|
verbosity: {
|
||||||
|
disabled: false,
|
||||||
|
pending: false,
|
||||||
|
specs: false,
|
||||||
|
summary: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.loadConfig({
|
||||||
|
helpers: [
|
||||||
|
'test/helpers/**/*.js'
|
||||||
|
],
|
||||||
|
random: false
|
||||||
|
});
|
||||||
|
jasmine.env.clearReporters();
|
||||||
|
jasmine.addReporter(reporter);
|
||||||
|
|
||||||
|
jasmine.onComplete(() => promise.resolve());
|
||||||
|
jasmine.execute(SPEC_FILES, matcher);
|
||||||
|
|
||||||
|
return promise;
|
||||||
|
};
|
||||||
|
|
||||||
@ -1,209 +0,0 @@
|
|||||||
/* global jasmine: true */
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var fs = require('jsdoc/fs');
|
|
||||||
var path = require('jsdoc/path');
|
|
||||||
|
|
||||||
var jsdoc = {
|
|
||||||
augment: require('jsdoc/augment'),
|
|
||||||
doclet: require('jsdoc/doclet'),
|
|
||||||
env: require('jsdoc/env'),
|
|
||||||
schema: require('jsdoc/schema'),
|
|
||||||
src: {
|
|
||||||
handlers: require('jsdoc/src/handlers'),
|
|
||||||
parser: require('jsdoc/src/parser')
|
|
||||||
},
|
|
||||||
tag: {
|
|
||||||
dictionary: require('jsdoc/tag/dictionary'),
|
|
||||||
definitions: require('jsdoc/tag/dictionary/definitions')
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var originalDictionary = jsdoc.tag.dictionary;
|
|
||||||
|
|
||||||
var jasmineAll = require('./lib/jasmine');
|
|
||||||
var jasmine = jasmineAll.jasmine;
|
|
||||||
var jasmineNode = ( require('./reporter') )(jasmine);
|
|
||||||
|
|
||||||
var reporter = null;
|
|
||||||
|
|
||||||
var parseResults = [];
|
|
||||||
|
|
||||||
jasmine.addParseResults = function(filename, doclets) {
|
|
||||||
parseResults.push({
|
|
||||||
filename: filename,
|
|
||||||
doclets: doclets
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.getParseResults = function() {
|
|
||||||
return parseResults;
|
|
||||||
};
|
|
||||||
|
|
||||||
// use the requested parser, or default to the pure JS parser (on Node.js)
|
|
||||||
jasmine.jsParser = (function() {
|
|
||||||
var parser = 'js';
|
|
||||||
|
|
||||||
if (jsdoc.env.opts.query && jsdoc.env.opts.query.parser) {
|
|
||||||
parser = jsdoc.env.opts.query.parser;
|
|
||||||
// remove this so the config tests don't complain
|
|
||||||
delete jsdoc.env.opts.query;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parser;
|
|
||||||
})();
|
|
||||||
|
|
||||||
jasmine.initialize = function(done) {
|
|
||||||
var jasmineEnv = jasmine.getEnv();
|
|
||||||
|
|
||||||
if (reporter !== null) {
|
|
||||||
// If we've run before, we need to reset the runner
|
|
||||||
jasmineEnv.currentRunner_ = new jasmine.Runner(jasmineEnv);
|
|
||||||
// And clear the reporter
|
|
||||||
jasmineEnv.reporter.subReporters_.splice(jasmineEnv.reporter.subReporters_.indexOf(reporter));
|
|
||||||
}
|
|
||||||
|
|
||||||
var reporterOpts = {
|
|
||||||
color: !jsdoc.env.opts.nocolor,
|
|
||||||
onComplete: done
|
|
||||||
};
|
|
||||||
|
|
||||||
reporter = jsdoc.env.opts.verbose ? new jasmineNode.TerminalVerboseReporter(reporterOpts) :
|
|
||||||
new jasmineNode.TerminalReporter(reporterOpts);
|
|
||||||
jasmineEnv.addReporter(reporter);
|
|
||||||
|
|
||||||
// updateInterval is set to 0 because there were not-fully-understood
|
|
||||||
// issues with asynchronous behavior in jasmine otherwise.
|
|
||||||
jasmineEnv.updateInterval = 0;
|
|
||||||
|
|
||||||
return jasmineEnv;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.createParser = function(type) {
|
|
||||||
return jsdoc.src.parser.createParser(type || jasmine.jsParser);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the specs in the specified folder.
|
|
||||||
*
|
|
||||||
* @param {string} folder The folder in which the specs are to be found.
|
|
||||||
* @param {function?} done Callback function to execute when finished.
|
|
||||||
* @param {object} opts Options for executing the specs.
|
|
||||||
* @param {boolean} opts.verbose Whether or not to output verbose results.
|
|
||||||
* @param {RegExp} opts.matcher A regular expression to filter specs by. Only matching specs run.
|
|
||||||
*/
|
|
||||||
jasmine.executeSpecsInFolder = function(folder, done, opts) {
|
|
||||||
var specs = require('./spec-collection');
|
|
||||||
|
|
||||||
var fileMatcher = opts.matcher || new RegExp('.(js)$', 'i');
|
|
||||||
var jasmineEnv = jasmine.initialize(done, opts.verbose);
|
|
||||||
|
|
||||||
// Load the specs
|
|
||||||
specs.load(folder, fileMatcher, true, function() {
|
|
||||||
var specsList = specs.getSpecs();
|
|
||||||
var filename;
|
|
||||||
|
|
||||||
// Add the specs to the context
|
|
||||||
for (var i = 0, len = specsList.length; i < len; ++i) {
|
|
||||||
filename = specsList[i];
|
|
||||||
require(filename.path().replace(/\\/g, '/')
|
|
||||||
.replace(new RegExp('^' + jsdoc.env.dirname + '/test'), './')
|
|
||||||
.replace(/\.\w+$/, ''));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run Jasmine
|
|
||||||
jasmineEnv.execute();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function now() {
|
|
||||||
return new Date().getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
jasmine.asyncSpecWait = function() {
|
|
||||||
var wait = this.asyncSpecWait;
|
|
||||||
|
|
||||||
wait.start = now();
|
|
||||||
wait.done = false;
|
|
||||||
(function innerWait() {
|
|
||||||
waits(10);
|
|
||||||
runs(function() {
|
|
||||||
if (wait.start + wait.timeout < now()) {
|
|
||||||
expect('timeout waiting for spec').toBeNull();
|
|
||||||
} else if (wait.done) {
|
|
||||||
wait.done = false;
|
|
||||||
} else {
|
|
||||||
innerWait();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
};
|
|
||||||
jasmine.asyncSpecWait.timeout = 4 * 1000;
|
|
||||||
jasmine.asyncSpecDone = function() {
|
|
||||||
jasmine.asyncSpecWait.done = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.getDocSetFromFile = function(filename, parser, validate, augment) {
|
|
||||||
var doclets;
|
|
||||||
|
|
||||||
var sourceCode = fs.readFileSync( path.join(jsdoc.env.dirname, filename), 'utf8' );
|
|
||||||
var testParser = parser || jasmine.createParser();
|
|
||||||
|
|
||||||
jsdoc.src.handlers.attachTo(testParser);
|
|
||||||
|
|
||||||
/* eslint-disable no-script-url */
|
|
||||||
doclets = testParser.parse('javascript:' + sourceCode);
|
|
||||||
/* eslint-enable no-script-url */
|
|
||||||
|
|
||||||
if (augment !== false) {
|
|
||||||
jsdoc.augment.augmentAll(doclets);
|
|
||||||
}
|
|
||||||
|
|
||||||
// test assume borrows have not yet been resolved
|
|
||||||
// require('jsdoc/borrow').resolveBorrows(doclets);
|
|
||||||
|
|
||||||
// store the parse results for later validation
|
|
||||||
if (validate !== false) {
|
|
||||||
jasmine.addParseResults(filename, doclets);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
doclets: doclets,
|
|
||||||
getByLongname: function(longname) {
|
|
||||||
return doclets.filter(function(doclet) {
|
|
||||||
return (doclet.longname || doclet.name) === longname;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.replaceTagDictionary = function(dictionaryNames) {
|
|
||||||
var dict = new jsdoc.tag.dictionary.Dictionary();
|
|
||||||
var originalDictionaries = jsdoc.env.conf.tags.dictionaries.slice(0);
|
|
||||||
|
|
||||||
if (!Array.isArray(dictionaryNames)) {
|
|
||||||
dictionaryNames = [dictionaryNames];
|
|
||||||
}
|
|
||||||
|
|
||||||
jsdoc.env.conf.tags.dictionaries = dictionaryNames;
|
|
||||||
|
|
||||||
jsdoc.tag.definitions.defineTags(dict);
|
|
||||||
jsdoc.doclet._replaceDictionary(dict);
|
|
||||||
|
|
||||||
jsdoc.env.conf.tags.dictionaries = originalDictionaries;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.restoreTagDictionary = function() {
|
|
||||||
jsdoc.doclet._replaceDictionary(originalDictionary);
|
|
||||||
};
|
|
||||||
|
|
||||||
// set up jasmine's global functions
|
|
||||||
Object.keys(jasmine).forEach(function(key) {
|
|
||||||
exports[key] = global[key] = jasmine[key];
|
|
||||||
});
|
|
||||||
global.jasmine = jasmine;
|
|
||||||
require('./async-callback');
|
|
||||||
['spyOn', 'it', 'xit', 'expect', 'runs', 'waitsFor', 'beforeEach', 'afterEach', 'describe',
|
|
||||||
'xdescribe'].forEach(function(item) {
|
|
||||||
global[item] = jasmineAll[item];
|
|
||||||
});
|
|
||||||
2537
test/lib/jasmine.js
2537
test/lib/jasmine.js
File diff suppressed because it is too large
Load Diff
292
test/reporter.js
292
test/reporter.js
@ -1,292 +0,0 @@
|
|||||||
module.exports = function(jasmine) {
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var jasmineNode = {};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Helpers
|
|
||||||
//
|
|
||||||
function noop() {
|
|
||||||
}
|
|
||||||
|
|
||||||
jasmineNode.ANSIColors = {
|
|
||||||
pass : function() {
|
|
||||||
return '\033[32m';
|
|
||||||
}, // Green
|
|
||||||
fail : function() {
|
|
||||||
return '\033[31m';
|
|
||||||
}, // Red
|
|
||||||
neutral : function() {
|
|
||||||
return '\033[0m';
|
|
||||||
} // Normal
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmineNode.NoColors = {
|
|
||||||
pass : function() {
|
|
||||||
return '';
|
|
||||||
},
|
|
||||||
fail : function() {
|
|
||||||
return '';
|
|
||||||
},
|
|
||||||
neutral : function() {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmineNode.TerminalReporter = function(config) {
|
|
||||||
this.print_ = config.print || function (str) { process.stdout.write(util.format(str)); };
|
|
||||||
this.color_ = config.color ? jasmineNode.ANSIColors : jasmineNode.NoColors;
|
|
||||||
|
|
||||||
this.started_ = false;
|
|
||||||
this.finished_ = false;
|
|
||||||
|
|
||||||
this.callback_ = config.onComplete || false;
|
|
||||||
|
|
||||||
this.suites_ = [];
|
|
||||||
this.specResults_ = {};
|
|
||||||
this.failures_ = {};
|
|
||||||
this.failures_.length = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmineNode.TerminalReporter.prototype = {
|
|
||||||
reportRunnerStarting : function(runner) {
|
|
||||||
this.started_ = true;
|
|
||||||
this.startedAt = new Date();
|
|
||||||
var suites = runner.topLevelSuites();
|
|
||||||
for ( var i = 0; i < suites.length; i++) {
|
|
||||||
var suite = suites[i];
|
|
||||||
this.suites_.push(this.summarize_(suite));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
summarize_ : function(suiteOrSpec) {
|
|
||||||
var isSuite = suiteOrSpec instanceof jasmine.Suite;
|
|
||||||
|
|
||||||
// We could use a separate object for suite and spec
|
|
||||||
var summary = {
|
|
||||||
id : suiteOrSpec.id,
|
|
||||||
name : suiteOrSpec.description,
|
|
||||||
type : isSuite ? 'suite' : 'spec',
|
|
||||||
suiteNestingLevel : 0,
|
|
||||||
children : []
|
|
||||||
};
|
|
||||||
|
|
||||||
if (isSuite) {
|
|
||||||
var calculateNestingLevel = function(examinedSuite) {
|
|
||||||
var nestingLevel = 0;
|
|
||||||
while (examinedSuite.parentSuite !== null) {
|
|
||||||
nestingLevel += 1;
|
|
||||||
examinedSuite = examinedSuite.parentSuite;
|
|
||||||
}
|
|
||||||
return nestingLevel;
|
|
||||||
};
|
|
||||||
|
|
||||||
summary.suiteNestingLevel = calculateNestingLevel(suiteOrSpec);
|
|
||||||
|
|
||||||
var children = suiteOrSpec.children();
|
|
||||||
for ( var i = 0; i < children.length; i++) {
|
|
||||||
summary.children.push(this.summarize_(children[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return summary;
|
|
||||||
},
|
|
||||||
|
|
||||||
// This is heavily influenced by Jasmine's Html/Trivial Reporter
|
|
||||||
reportRunnerResults : function(runner) {
|
|
||||||
this.reportFailures_();
|
|
||||||
|
|
||||||
var results = runner.results();
|
|
||||||
var resultColor = (results.failedCount > 0) ? this.color_.fail() : this.color_.pass();
|
|
||||||
|
|
||||||
var specs = runner.specs();
|
|
||||||
var specCount = specs.length;
|
|
||||||
|
|
||||||
var message = "\n\nFinished in " +
|
|
||||||
((new Date().getTime() - this.startedAt.getTime()) / 1000) +
|
|
||||||
" seconds";
|
|
||||||
this.printLine_(message);
|
|
||||||
|
|
||||||
// This is what jasmine-html.js has
|
|
||||||
// message = "" + specCount + " spec" + ( specCount === 1 ? "" : "s") + ", " + results.failedCount + " failure" + ((results.failedCount === 1) ? "" : "s");
|
|
||||||
|
|
||||||
this.printLine_(this.stringWithColor_(this.printRunnerResults_(runner), resultColor));
|
|
||||||
|
|
||||||
this.finished_ = true;
|
|
||||||
if (this.callback_) {
|
|
||||||
this.callback_(runner);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
reportFailures_ : function() {
|
|
||||||
if (this.failures_.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var indent = ' ', failure, failures;
|
|
||||||
this.printLine_('\n');
|
|
||||||
|
|
||||||
this.print_('Failures:');
|
|
||||||
|
|
||||||
for ( var suite in this.failures_) {
|
|
||||||
if (this.failures_.hasOwnProperty(suite) && suite !== "length") {
|
|
||||||
this.printLine_('\n');
|
|
||||||
this.printLine_(suite);
|
|
||||||
failures = this.failures_[suite];
|
|
||||||
for ( var i = 0; i < failures.length; i++) {
|
|
||||||
failure = failures[i];
|
|
||||||
this.printLine_('\n');
|
|
||||||
this.printLine_(indent + (i + 1) + ') ' + failure.spec);
|
|
||||||
this.printLine_(indent + 'Message:');
|
|
||||||
this.printLine_(indent + indent + this.stringWithColor_(failure.message, this.color_.fail()));
|
|
||||||
this.printLine_(indent + 'Stacktrace:');
|
|
||||||
this.print_(indent + indent + failure.stackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
reportSuiteResults : function(suite) {
|
|
||||||
// Not used in this context
|
|
||||||
},
|
|
||||||
|
|
||||||
reportSpecResults : function(spec) {
|
|
||||||
var result = spec.results();
|
|
||||||
var msg = '';
|
|
||||||
if (result.skipped) {
|
|
||||||
msg = this.stringWithColor_('-', this.color_.ignore());
|
|
||||||
} else if (result.passed()) {
|
|
||||||
msg = this.stringWithColor_('.', this.color_.pass());
|
|
||||||
} else {
|
|
||||||
msg = this.stringWithColor_('F', this.color_.fail());
|
|
||||||
this.addFailureToFailures_(spec);
|
|
||||||
}
|
|
||||||
this.spec_results += msg;
|
|
||||||
this.print_(msg);
|
|
||||||
},
|
|
||||||
|
|
||||||
addFailureToFailures_ : function(spec) {
|
|
||||||
var result = spec.results();
|
|
||||||
var failureItem = null;
|
|
||||||
var suite = spec.suite.getFullName();
|
|
||||||
var failures = null;
|
|
||||||
var items_length = result.items_.length;
|
|
||||||
for ( var i = 0; i < items_length; i++) {
|
|
||||||
if (result.items_[i].passed_ === false) {
|
|
||||||
failureItem = result.items_[i];
|
|
||||||
var failure = {
|
|
||||||
spec : spec.description,
|
|
||||||
message : failureItem.message,
|
|
||||||
stackTrace : failureItem.trace.stack
|
|
||||||
};
|
|
||||||
failures = this.failures_[suite];
|
|
||||||
if (!failures) {
|
|
||||||
this.failures_[suite] = [];
|
|
||||||
}
|
|
||||||
this.failures_[suite].push(failure);
|
|
||||||
this.failures_.length++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
printRunnerResults_ : function(runner) {
|
|
||||||
var results = runner.results();
|
|
||||||
var specs = runner.specs();
|
|
||||||
var msg = '';
|
|
||||||
msg += specs.length + ' test' + ((specs.length === 1) ? '' : 's') + ', ';
|
|
||||||
msg += results.totalCount + ' assertion' + ((results.totalCount === 1) ? '' : 's') + ', ';
|
|
||||||
msg += results.failedCount + ' failure' + ((results.failedCount === 1) ? '' : 's') + '\n';
|
|
||||||
return msg;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Helper Methods //
|
|
||||||
stringWithColor_ : function(stringValue, color) {
|
|
||||||
return (color || this.color_.neutral()) + stringValue + this.color_.neutral();
|
|
||||||
},
|
|
||||||
|
|
||||||
printLine_ : function(stringValue) {
|
|
||||||
this.print_(stringValue);
|
|
||||||
this.print_('\n');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ***************************************************************
|
|
||||||
// TerminalVerboseReporter uses the TerminalReporter's constructor
|
|
||||||
// ***************************************************************
|
|
||||||
jasmineNode.TerminalVerboseReporter = function(config) {
|
|
||||||
jasmineNode.TerminalReporter.call(this, config);
|
|
||||||
// The extra field in this object
|
|
||||||
this.indent_ = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmineNode.TerminalVerboseReporter.prototype = {
|
|
||||||
reportSpecResults : function(spec) {
|
|
||||||
if (spec.results().failedCount > 0) {
|
|
||||||
this.addFailureToFailures_(spec);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.specResults_[spec.id] = {
|
|
||||||
messages : spec.results().getItems(),
|
|
||||||
result : spec.results().failedCount > 0 ? 'failed' : 'passed'
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
reportRunnerResults : function(runner) {
|
|
||||||
var messages = new Array();
|
|
||||||
this.buildMessagesFromResults_(messages, this.suites_);
|
|
||||||
|
|
||||||
var messages_length = messages.length;
|
|
||||||
for ( var i = 0; i < messages_length - 1; i++) {
|
|
||||||
this.printLine_(messages[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.print_(messages[messages_length - 1]);
|
|
||||||
|
|
||||||
// Call the parent object's method
|
|
||||||
jasmineNode.TerminalReporter.prototype.reportRunnerResults.call(this, runner);
|
|
||||||
},
|
|
||||||
|
|
||||||
buildMessagesFromResults_ : function(messages, results) {
|
|
||||||
var element, specResult, specIndentSpaces, msg = '';
|
|
||||||
|
|
||||||
var results_length = results.length;
|
|
||||||
for ( var i = 0; i < results_length; i++) {
|
|
||||||
element = results[i];
|
|
||||||
|
|
||||||
if (element.type === 'spec') {
|
|
||||||
specResult = this.specResults_[element.id.toString()];
|
|
||||||
|
|
||||||
specIndentSpaces = this.indent_ + 2;
|
|
||||||
if (specResult.result === 'passed') {
|
|
||||||
msg = this.stringWithColor_(this.indentMessage_(element.name, specIndentSpaces), this.color_.pass());
|
|
||||||
} else {
|
|
||||||
msg = this.stringWithColor_(this.indentMessage_(element.name, specIndentSpaces), this.color_.fail());
|
|
||||||
}
|
|
||||||
|
|
||||||
messages.push(msg);
|
|
||||||
} else {
|
|
||||||
this.indent_ = element.suiteNestingLevel * 2;
|
|
||||||
|
|
||||||
messages.push('');
|
|
||||||
messages.push(this.indentMessage_(element.name,this.indent_));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.buildMessagesFromResults_(messages, element.children);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
indentMessage_ : function(message, indentCount) {
|
|
||||||
var _indent = '';
|
|
||||||
for ( var i = 0; i < indentCount; i++) {
|
|
||||||
_indent += ' ';
|
|
||||||
}
|
|
||||||
return (_indent + message);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Inherit from TerminalReporter
|
|
||||||
jasmineNode.TerminalVerboseReporter.prototype.__proto__ = jasmineNode.TerminalReporter.prototype;
|
|
||||||
|
|
||||||
return jasmineNode;
|
|
||||||
};
|
|
||||||
@ -1,66 +0,0 @@
|
|||||||
/*global jasmine */
|
|
||||||
/*
|
|
||||||
* Test Steps:
|
|
||||||
* 1. Get Jasmine
|
|
||||||
* 2. Get the test options
|
|
||||||
* 3. Get the list of directories to run tests from
|
|
||||||
* 4. Run Jasmine on each directory
|
|
||||||
*/
|
|
||||||
var env = require('jsdoc/env');
|
|
||||||
var fs = require('jsdoc/fs');
|
|
||||||
var logger = require('jsdoc/util/logger');
|
|
||||||
var path = require('path');
|
|
||||||
|
|
||||||
fs.existsSync = fs.existsSync || path.existsSync;
|
|
||||||
|
|
||||||
require( path.join(env.dirname, 'test/jasmine-jsdoc') );
|
|
||||||
|
|
||||||
var hasOwnProp = Object.prototype.hasOwnProperty;
|
|
||||||
|
|
||||||
var opts = {
|
|
||||||
verbose: env.opts.verbose || false,
|
|
||||||
showColors: env.opts.nocolor === true ? false : true
|
|
||||||
};
|
|
||||||
|
|
||||||
var extensions = 'js';
|
|
||||||
var match = env.opts.match || '.';
|
|
||||||
if (match instanceof Array) {
|
|
||||||
match = match.join("|");
|
|
||||||
}
|
|
||||||
opts.matcher = new RegExp("(" + match + ")\\.(" + extensions + ")$", 'i');
|
|
||||||
|
|
||||||
var specFolders = [
|
|
||||||
path.join(env.dirname, 'test/specs'),
|
|
||||||
path.join(env.dirname, 'plugins/test/specs')
|
|
||||||
];
|
|
||||||
|
|
||||||
var failedCount = 0;
|
|
||||||
var index = 0;
|
|
||||||
|
|
||||||
var testsCompleteCallback;
|
|
||||||
var onComplete;
|
|
||||||
|
|
||||||
var runNextFolder = module.exports = function(callback) {
|
|
||||||
testsCompleteCallback = testsCompleteCallback || callback;
|
|
||||||
|
|
||||||
// silence the logger while we run the tests
|
|
||||||
logger.setLevel(logger.LEVELS.SILENT);
|
|
||||||
|
|
||||||
if (index < specFolders.length) {
|
|
||||||
jasmine.executeSpecsInFolder(specFolders[index], onComplete, opts);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
process.nextTick(function() {
|
|
||||||
testsCompleteCallback(null, failedCount);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onComplete = function(runner, log) {
|
|
||||||
if (runner.results().failedCount !== 0) {
|
|
||||||
failedCount += runner.results().failedCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
index++;
|
|
||||||
runNextFolder();
|
|
||||||
};
|
|
||||||
@ -1,98 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var fs = require('jsdoc/fs');
|
|
||||||
var path = require('jsdoc/path');
|
|
||||||
var klaw = require('klaw');
|
|
||||||
|
|
||||||
var specs = [];
|
|
||||||
var finalSpecs = [];
|
|
||||||
|
|
||||||
var createSpecObj = function(_path, root) {
|
|
||||||
function relativePath() {
|
|
||||||
return _path.replace(root, '').replace(/^[/\\]/, '').replace(/\\/g, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
path: function() {
|
|
||||||
return _path;
|
|
||||||
},
|
|
||||||
relativePath: relativePath,
|
|
||||||
directory: function() {
|
|
||||||
return _path.replace(/[/\\][\s\w.-]*$/, '').replace(/\\/g, '/');
|
|
||||||
},
|
|
||||||
relativeDirectory: function() {
|
|
||||||
return relativePath().replace(/[/\\][\s\w.-]*$/, '').replace(/\\/g, '/');
|
|
||||||
},
|
|
||||||
filename: function() {
|
|
||||||
return _path.replace(/^.*[\\/]/, '');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var clearSpecs = exports.clearSpecs = function() {
|
|
||||||
specs.splice(0, specs.length);
|
|
||||||
};
|
|
||||||
|
|
||||||
function addSpec(file, target) {
|
|
||||||
target = target || specs;
|
|
||||||
|
|
||||||
target.push( createSpecObj(file) );
|
|
||||||
}
|
|
||||||
|
|
||||||
function isValidSpec(file, matcher) {
|
|
||||||
var result;
|
|
||||||
|
|
||||||
// valid specs must...
|
|
||||||
try {
|
|
||||||
// ...be a file
|
|
||||||
result = fs.statSync(file).isFile() &&
|
|
||||||
// ...match the matcher
|
|
||||||
matcher.test( path.basename(file) );
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function shouldLoad(file, matcher) {
|
|
||||||
var result = false;
|
|
||||||
|
|
||||||
// should this spec run at the end?
|
|
||||||
if ( /schema\.js$/.test(file) && isValidSpec(file, matcher) ) {
|
|
||||||
addSpec(file, finalSpecs);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
result = isValidSpec(file, matcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.load = function(loadpath, matcher, clear, callback) {
|
|
||||||
var wannaBeSpecs = [];
|
|
||||||
|
|
||||||
if (clear === true) {
|
|
||||||
clearSpecs();
|
|
||||||
}
|
|
||||||
|
|
||||||
klaw(loadpath)
|
|
||||||
.on('data', function(spec) {
|
|
||||||
wannaBeSpecs.push(spec.path);
|
|
||||||
})
|
|
||||||
.on('end', function() {
|
|
||||||
for (var i = 0; i < wannaBeSpecs.length; i++) {
|
|
||||||
var file = wannaBeSpecs[i];
|
|
||||||
|
|
||||||
if ( shouldLoad(file, matcher) ) {
|
|
||||||
addSpec(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.getSpecs = function() {
|
|
||||||
return specs.concat(finalSpecs);
|
|
||||||
};
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
describe('aliases', () => {
|
describe('aliases', () => {
|
||||||
describe('standard', () => {
|
describe('standard', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/alias.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias.js');
|
||||||
const found = docSet.getByLongname('myObject').filter(({undocumented}) => !(undocumented));
|
const found = docSet.getByLongname('myObject').filter(({undocumented}) => !(undocumented));
|
||||||
const foundMember = docSet.getByLongname('myObject.myProperty');
|
const foundMember = docSet.getByLongname('myObject.myProperty');
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ describe('aliases', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is a member of an alias of a nested name it is documented as if the memberof is the nested alias value.', () => {
|
it('When a symbol is a member of an alias of a nested name it is documented as if the memberof is the nested alias value.', () => {
|
||||||
const docSet = jasmine.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).toEqual('ns.Myclass#myProperty');
|
||||||
@ -25,14 +25,14 @@ describe('aliases', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
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 = jasmine.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).toEqual('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', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/alias4.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias4.js');
|
||||||
const jacketClass = docSet.getByLongname('module:jacket').filter(({kind}) => kind === 'class');
|
const jacketClass = docSet.getByLongname('module:jacket').filter(({kind}) => kind === 'class');
|
||||||
|
|
||||||
expect(jacketClass.length).toBe(1);
|
expect(jacketClass.length).toBe(1);
|
||||||
@ -40,7 +40,7 @@ describe('aliases', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('formats', () => {
|
describe('formats', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/alias5.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias5.js');
|
||||||
const toast = docSet.getByLongname('Toaster#toast')[0];
|
const toast = docSet.getByLongname('Toaster#toast')[0];
|
||||||
const getInstance = docSet.getByLongname('Toaster.getInstance')[0];
|
const getInstance = docSet.getByLongname('Toaster.getInstance')[0];
|
||||||
const clean = docSet.getByLongname('Toaster#clean')[0];
|
const clean = docSet.getByLongname('Toaster#clean')[0];
|
||||||
@ -68,7 +68,7 @@ describe('aliases', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is a constructor of a class with an alias, the constructor should get the correct longname', () => {
|
it('When a symbol is a constructor of a class with an alias, the constructor should get the correct longname', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/alias6.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias6.js');
|
||||||
const constructor = docSet.getByLongname('module:example')[2];
|
const constructor = docSet.getByLongname('module:example')[2];
|
||||||
|
|
||||||
expect(constructor.undocumented).toBe(true);
|
expect(constructor.undocumented).toBe(true);
|
||||||
@ -77,14 +77,14 @@ describe('aliases', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('When a symbol is documented as a static member of <global>, its scope is "global" and not "static".', () => {
|
it('When a symbol is documented as a static member of <global>, its scope is "global" and not "static".', () => {
|
||||||
const docSet = jasmine.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).toEqual('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 = jasmine.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).toEqual('instance');
|
||||||
@ -93,14 +93,14 @@ describe('aliases', () => {
|
|||||||
|
|
||||||
describe('resolving', () => {
|
describe('resolving', () => {
|
||||||
it('When a local reference has alias, put all members into aliased definition. Local modifications should be visible to outside.', () => {
|
it('When a local reference has alias, put all members into aliased definition. Local modifications should be visible to outside.', () => {
|
||||||
const docSet = jasmine.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.length).toEqual(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 = jasmine.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.length).toEqual(1);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ describe('multiple doclets per symbol', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const docSet = jasmine.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);
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ describe('multiple doclets per symbol', () => {
|
|||||||
logger.addListener('logger:error', errorListener);
|
logger.addListener('logger:error', errorListener);
|
||||||
env.conf.tags.allowUnknownTags = false;
|
env.conf.tags.allowUnknownTags = false;
|
||||||
|
|
||||||
jasmine.getDocSetFromFile('test/fixtures/also2.js');
|
jsdoc.getDocSetFromFile('test/fixtures/also2.js');
|
||||||
expect(errors[0]).not.toBeDefined();
|
expect(errors[0]).not.toBeDefined();
|
||||||
|
|
||||||
logger.removeListener('logger:error', errorListener);
|
logger.removeListener('logger:error', errorListener);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('anonymous class', () => {
|
describe('anonymous class', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/anonymousclass.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/anonymousclass.js');
|
||||||
const klass = docSet.getByLongname('module:test').filter(({undocumented}) => !undocumented)[1];
|
const klass = docSet.getByLongname('module:test').filter(({undocumented}) => !undocumented)[1];
|
||||||
const foo = docSet.getByLongname('module:test#foo')[0];
|
const foo = docSet.getByLongname('module:test#foo')[0];
|
||||||
const klassTest = docSet.getByLongname('module:test#test')[0];
|
const klassTest = docSet.getByLongname('module:test#test')[0];
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
describe('anonymous class passed as a parameter', () => {
|
describe('anonymous class passed as a parameter', () => {
|
||||||
it('should not crash JSDoc', () => {
|
it('should not crash JSDoc', () => {
|
||||||
function loadFile() {
|
function loadFile() {
|
||||||
jasmine.getDocSetFromFile('test/fixtures/anonymousclassparam.js');
|
jsdoc.getDocSetFromFile('test/fixtures/anonymousclassparam.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(loadFile).not.toThrow();
|
expect(loadFile).not.toThrow();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('arrow functions', () => {
|
describe('arrow functions', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/arrowfunction.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/arrowfunction.js');
|
||||||
const increment = docSet.getByLongname('increment')[0];
|
const increment = docSet.getByLongname('increment')[0];
|
||||||
const print = docSet.getByLongname('print')[0];
|
const print = docSet.getByLongname('print')[0];
|
||||||
const name = docSet.getByLongname('<anonymous>#name');
|
const name = docSet.getByLongname('<anonymous>#name');
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('async functions', () => {
|
describe('async functions', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/asyncfunction.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/asyncfunction.js');
|
||||||
const add = docSet.getByLongname('add')[0];
|
const add = docSet.getByLongname('add')[0];
|
||||||
const subtract = docSet.getByLongname('subtract')[0];
|
const subtract = docSet.getByLongname('subtract')[0];
|
||||||
const adderAdd = docSet.getByLongname('Adder#add')[0];
|
const adderAdd = docSet.getByLongname('Adder#add')[0];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('callback tag', () => {
|
describe('callback tag', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/callbacktag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/callbacktag.js');
|
||||||
|
|
||||||
function callbackTests(callback) {
|
function callbackTests(callback) {
|
||||||
expect(callback).toBeDefined();
|
expect(callback).toBeDefined();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('class properties', () => {
|
describe('class properties', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/classproperties.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/classproperties.js');
|
||||||
const b = docSet.getByLongname('A#b')[0];
|
const b = docSet.getByLongname('A#b')[0];
|
||||||
const c = docSet.getByLongname('A#c')[0];
|
const c = docSet.getByLongname('A#c')[0];
|
||||||
const d = docSet.getByLongname('A#d')[0];
|
const d = docSet.getByLongname('A#d')[0];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('class without a name', () => {
|
describe('class without a name', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/classwithoutname.js').doclets
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/classwithoutname.js').doclets
|
||||||
.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', () => {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
describe('const declarations', () => {
|
describe('const declarations', () => {
|
||||||
it('should automatically set the doclet.kind to "constant" for const declarations', () => {
|
it('should automatically set the doclet.kind to "constant" for const declarations', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/constanttag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/constanttag.js');
|
||||||
const myPocket = docSet.getByLongname('myPocket')[0];
|
const myPocket = docSet.getByLongname('myPocket')[0];
|
||||||
|
|
||||||
expect(myPocket.kind).toBe('constant');
|
expect(myPocket.kind).toBe('constant');
|
||||||
@ -8,7 +8,7 @@ describe('const declarations', () => {
|
|||||||
|
|
||||||
describe('ES 2015 only', () => {
|
describe('ES 2015 only', () => {
|
||||||
it('should not override kind="class" when a const is autodetected', () => {
|
it('should not override kind="class" when a const is autodetected', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/constanttag2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/constanttag2.js');
|
||||||
const foo = docSet.getByLongname('Foo')[0];
|
const foo = docSet.getByLongname('Foo')[0];
|
||||||
|
|
||||||
expect(foo.kind).toBe('class');
|
expect(foo.kind).toBe('class');
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('default parameters', () => {
|
describe('default parameters', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/defaultparams.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/defaultparams.js');
|
||||||
|
|
||||||
const setActive = docSet.getByLongname('setActive')[0];
|
const setActive = docSet.getByLongname('setActive')[0];
|
||||||
const setBirthYear = docSet.getByLongname('setBirthYear')[0];
|
const setBirthYear = docSet.getByLongname('setBirthYear')[0];
|
||||||
@ -53,7 +53,7 @@ describe('default parameters', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('ES2015 methods', () => {
|
describe('ES2015 methods', () => {
|
||||||
const docSet2 = jasmine.getDocSetFromFile('test/fixtures/defaultparams2.js');
|
const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/defaultparams2.js');
|
||||||
|
|
||||||
const setSardines = docSet2.getByLongname('PizzaToppings#setSardines')[0];
|
const setSardines = docSet2.getByLongname('PizzaToppings#setSardines')[0];
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ const logger = require('jsdoc/util/logger');
|
|||||||
describe('empty JSDoc comments', () => {
|
describe('empty JSDoc comments', () => {
|
||||||
it('should not report an error when a JSDoc comment contains only whitespace', () => {
|
it('should not report an error when a JSDoc comment contains only whitespace', () => {
|
||||||
spyOn(logger, 'error');
|
spyOn(logger, 'error');
|
||||||
jasmine.getDocSetFromFile('test/fixtures/emptycomments.js');
|
jsdoc.getDocSetFromFile('test/fixtures/emptycomments.js');
|
||||||
|
|
||||||
expect(logger.error).not.toHaveBeenCalled();
|
expect(logger.error).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('export class', () => {
|
describe('export class', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/exportclass.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportclass.js');
|
||||||
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', () => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('export default', () => {
|
describe('export default', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/exportdefault.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportdefault.js');
|
||||||
const member = docSet.getByLongname('module:test')[1];
|
const member = docSet.getByLongname('module:test')[1];
|
||||||
|
|
||||||
it('should use the correct kind and description for the default export', () => {
|
it('should use the correct kind and description for the default export', () => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('export default class', () => {
|
describe('export default class', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/exportdefaultclass.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportdefaultclass.js');
|
||||||
const klass = docSet.getByLongname('module:test').filter(({undocumented}) => !undocumented)[1];
|
const klass = docSet.getByLongname('module:test').filter(({undocumented}) => !undocumented)[1];
|
||||||
|
|
||||||
it('should combine the classdesc and constructor description into a single doclet', () => {
|
it('should combine the classdesc and constructor description into a single doclet', () => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe("'exports' symbol in modules", () => {
|
describe("'exports' symbol in modules", () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/exports.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/exports.js');
|
||||||
const sayHello = docSet.getByLongname('module:hello/world.sayHello')[0];
|
const sayHello = docSet.getByLongname('module:hello/world.sayHello')[0];
|
||||||
const sayGoodbye = docSet.getByLongname('module:hello/world.sayGoodbye')[0];
|
const sayGoodbye = docSet.getByLongname('module:hello/world.sayGoodbye')[0];
|
||||||
|
|
||||||
|
|||||||
@ -15,14 +15,14 @@ describe('function expressions', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('standard', () => {
|
describe('standard', () => {
|
||||||
checkLongnames( jasmine.getDocSetFromFile('test/fixtures/funcExpression.js') );
|
checkLongnames( jsdoc.getDocSetFromFile('test/fixtures/funcExpression.js') );
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('global', () => {
|
describe('global', () => {
|
||||||
checkLongnames( jasmine.getDocSetFromFile('test/fixtures/funcExpression2.js') );
|
checkLongnames( jsdoc.getDocSetFromFile('test/fixtures/funcExpression2.js') );
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('as object literal property', () => {
|
describe('as object literal property', () => {
|
||||||
checkLongnames( jasmine.getDocSetFromFile('test/fixtures/funcExpression3.js'), 'ns.' );
|
checkLongnames( jsdoc.getDocSetFromFile('test/fixtures/funcExpression3.js'), 'ns.' );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('generator functions', () => {
|
describe('generator functions', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/generators.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/generators.js');
|
||||||
const startsAt0 = docSet.getByLongname('startsAt0')[0];
|
const startsAt0 = docSet.getByLongname('startsAt0')[0];
|
||||||
const startsAt1 = docSet.getByLongname('startsAt1')[0];
|
const startsAt1 = docSet.getByLongname('startsAt1')[0];
|
||||||
const startsAt2 = docSet.getByLongname('Generator#startsAt2')[0];
|
const startsAt2 = docSet.getByLongname('Generator#startsAt2')[0];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('When a getter or setter is part of a class', () => {
|
describe('When a getter or setter is part of a class', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/getset.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/getset.js');
|
||||||
|
|
||||||
describe('in an object literal', () => {
|
describe('in an object literal', () => {
|
||||||
const name = docSet.getByLongname('Person#name');
|
const name = docSet.getByLongname('Person#name');
|
||||||
@ -30,7 +30,7 @@ describe('When a getter or setter is part of a class', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('in an ES 2015 class', () => {
|
describe('in an ES 2015 class', () => {
|
||||||
const docSet2 = jasmine.getDocSetFromFile('test/fixtures/getset2.js');
|
const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/getset2.js');
|
||||||
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', () => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('inline comments', () => {
|
describe('inline comments', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/inlinecomment.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/inlinecomment.js');
|
||||||
const t = docSet.getByLongname('test');
|
const t = docSet.getByLongname('test');
|
||||||
const t2 = docSet.getByLongname('test2');
|
const t2 = docSet.getByLongname('test2');
|
||||||
|
|
||||||
|
|||||||
@ -2,14 +2,14 @@ describe('inline comments on function parameters', () => {
|
|||||||
it('should not crash when multiple parameters have inline comments that do not contain any' +
|
it('should not crash when multiple parameters have inline comments that do not contain any' +
|
||||||
'JSDoc tags', () => {
|
'JSDoc tags', () => {
|
||||||
function loadDocSet() {
|
function loadDocSet() {
|
||||||
jasmine.getDocSetFromFile('test/fixtures/inlineparamcomment.js');
|
jsdoc.getDocSetFromFile('test/fixtures/inlineparamcomment.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(loadDocSet).not.toThrow();
|
expect(loadDocSet).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ES 2015 only', () => {
|
describe('ES 2015 only', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/inlineparamcomment2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/inlineparamcomment2.js');
|
||||||
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', () => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('when a documented var memeber is inside a named function', () => {
|
describe('when a documented var memeber is inside a named function', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/inner.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/inner.js');
|
||||||
const found1 = docSet.getByLongname('sendMessage~encoding');
|
const found1 = docSet.getByLongname('sendMessage~encoding');
|
||||||
const found2 = docSet.getByLongname('sendMessage~encrypt');
|
const found2 = docSet.getByLongname('sendMessage~encrypt');
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
describe('inner scope', () => {
|
describe('inner scope', () => {
|
||||||
describe('Outer~inner.member cases', () => {
|
describe('Outer~inner.member cases', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/innerscope.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/innerscope.js');
|
||||||
const to = docSet.getByLongname('Message~headers.to');
|
const to = docSet.getByLongname('Message~headers.to');
|
||||||
const from = docSet.getByLongname('Message~headers.from');
|
const from = docSet.getByLongname('Message~headers.from');
|
||||||
const response = docSet.getByLongname('Message~response.code');
|
const response = docSet.getByLongname('Message~response.code');
|
||||||
@ -19,7 +19,7 @@ describe('inner scope', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('other cases', () => {
|
describe('other cases', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/innerscope2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/innerscope2.js');
|
||||||
const from = docSet.getByLongname('<anonymous>~headers.from');
|
const from = docSet.getByLongname('<anonymous>~headers.from');
|
||||||
const cache = docSet.getByLongname('<anonymous>~headers.cache');
|
const cache = docSet.getByLongname('<anonymous>~headers.cache');
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('Properties documented in instance methods', () => {
|
describe('Properties documented in instance methods', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/instanceproperty.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/instanceproperty.js');
|
||||||
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', () => {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ describe('JSX support', () => {
|
|||||||
const logger = require('jsdoc/util/logger');
|
const logger = require('jsdoc/util/logger');
|
||||||
|
|
||||||
function parseJsx() {
|
function parseJsx() {
|
||||||
return jasmine.getDocSetFromFile('test/fixtures/jsx.js');
|
return jsdoc.getDocSetFromFile('test/fixtures/jsx.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
spyOn(logger, 'error');
|
spyOn(logger, 'error');
|
||||||
|
|||||||
@ -5,7 +5,7 @@ describe('lends', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('standard case', () => {
|
describe('standard case', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/lends.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/lends.js');
|
||||||
const init = docSet.getByLongname('Person#initialize');
|
const init = docSet.getByLongname('Person#initialize');
|
||||||
const name = docSet.getByLongname('Person#name');
|
const name = docSet.getByLongname('Person#name');
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ describe('lends', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('case containing constructor', () => {
|
describe('case containing constructor', () => {
|
||||||
const docSet = jasmine.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)[0];
|
||||||
const name = docSet.getByLongname('Person#name');
|
const name = docSet.getByLongname('Person#name');
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ describe('lends', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('case that uses @lends in a multiline doclet', () => {
|
describe('case that uses @lends in a multiline doclet', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/lends3.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/lends3.js');
|
||||||
const init = docSet.getByLongname('Person#initialize');
|
const init = docSet.getByLongname('Person#initialize');
|
||||||
const name = docSet.getByLongname('Person#name');
|
const name = docSet.getByLongname('Person#name');
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ describe('lends', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('case that uses @lends within a closure', () => {
|
describe('case that uses @lends within a closure', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/lends4.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/lends4.js');
|
||||||
const person = docSet.getByLongname('Person');
|
const person = docSet.getByLongname('Person');
|
||||||
const say = docSet.getByLongname('Person#say');
|
const say = docSet.getByLongname('Person#say');
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ describe('lends', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('case that uses @lends within nested function calls', () => {
|
describe('case that uses @lends within nested function calls', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/lends5.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/lends5.js');
|
||||||
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];
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ describe('lends', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('case that uses @lends twice within a closure', () => {
|
describe('case that uses @lends twice within a closure', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/lends6.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/lends6.js');
|
||||||
|
|
||||||
it('The first class with a @lends tag should appear in the parse results', () => {
|
it('The first class with a @lends tag should appear in the parse results', () => {
|
||||||
const person = docSet.getByLongname('Person').filter(removeUndocumented)[0];
|
const person = docSet.getByLongname('Person').filter(removeUndocumented)[0];
|
||||||
@ -114,7 +114,7 @@ describe('lends', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when a documented member is inside an objlit associated with a @lends tag that has no value.', () => {
|
describe('when a documented member is inside an objlit associated with a @lends tag that has no value.', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/lendsglobal.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/lendsglobal.js');
|
||||||
const testf = docSet.getByLongname('test')[0];
|
const testf = docSet.getByLongname('test')[0];
|
||||||
const test12 = docSet.getByLongname('test1.test2')[0];
|
const test12 = docSet.getByLongname('test1.test2')[0];
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ describe('let keyword', () => {
|
|||||||
let exampleMethod;
|
let exampleMethod;
|
||||||
|
|
||||||
function getDocSet() {
|
function getDocSet() {
|
||||||
docSet = jasmine.getDocSetFromFile('test/fixtures/letkeyword.js');
|
docSet = jsdoc.getDocSetFromFile('test/fixtures/letkeyword.js');
|
||||||
exampleModule = docSet.getByLongname('module:exampleModule');
|
exampleModule = docSet.getByLongname('module:exampleModule');
|
||||||
exampleMethod = docSet.getByLongname('module:exampleModule.exampleMethod');
|
exampleMethod = docSet.getByLongname('module:exampleModule.exampleMethod');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('method definition inside a class declaration', () => {
|
describe('method definition inside a class declaration', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/methoddefinition.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/methoddefinition.js');
|
||||||
const runMethod = docSet.getByLongname('Test#run')[0];
|
const runMethod = docSet.getByLongname('Test#run')[0];
|
||||||
const staticRunMethod = docSet.getByLongname('Test.run')[0];
|
const staticRunMethod = docSet.getByLongname('Test.run')[0];
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ const name = require('jsdoc/name');
|
|||||||
|
|
||||||
describe('mixins', () => {
|
describe('mixins', () => {
|
||||||
describe('doclet augmentation', () => {
|
describe('doclet augmentation', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/mixintag2.js');
|
||||||
|
|
||||||
augment.augmentAll(docSet.doclets);
|
augment.augmentAll(docSet.doclets);
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ function filter({undocumented}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('module classes', () => {
|
describe('module classes', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/moduleclasses.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduleclasses.js');
|
||||||
const bar = docSet.getByLongname('module:foo~Bar').filter(filter)[0];
|
const bar = docSet.getByLongname('module:foo~Bar').filter(filter)[0];
|
||||||
const barBar = docSet.getByLongname('module:foo~Bar#bar')[0];
|
const barBar = docSet.getByLongname('module:foo~Bar#bar')[0];
|
||||||
const baz = docSet.getByLongname('module:foo.Baz').filter(filter)[0];
|
const baz = docSet.getByLongname('module:foo.Baz').filter(filter)[0];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('inner scope for modules', () => {
|
describe('inner scope for modules', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/moduleinner.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduleinner.js');
|
||||||
const fooIn = docSet.getByLongname('module:my/module~fooIn')[0];
|
const fooIn = docSet.getByLongname('module:my/module~fooIn')[0];
|
||||||
const fooOut = docSet.getByLongname('module:my/module~fooOut')[0];
|
const fooOut = docSet.getByLongname('module:my/module~fooOut')[0];
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
describe('module that exports a constructor', () => {
|
describe('module that exports a constructor', () => {
|
||||||
describe('pre-ES2015 module', () => {
|
describe('pre-ES2015 module', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/moduleisconstructor.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduleisconstructor.js');
|
||||||
const modules = docSet.doclets.filter(({kind}) => kind === 'module');
|
const modules = docSet.doclets.filter(({kind}) => kind === 'module');
|
||||||
const classes = docSet.doclets.filter(({kind}) => kind === 'class');
|
const classes = docSet.doclets.filter(({kind}) => kind === 'class');
|
||||||
const getId = docSet.getByLongname('module:mymodule/config#getId')[0];
|
const getId = docSet.getByLongname('module:mymodule/config#getId')[0];
|
||||||
@ -44,7 +44,7 @@ describe('module that exports a constructor', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('ES2015 module', () => {
|
describe('ES2015 module', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/moduleisconstructor2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduleisconstructor2.js');
|
||||||
const modules = docSet.doclets.filter(({kind}) => kind === 'module');
|
const modules = docSet.doclets.filter(({kind}) => kind === 'module');
|
||||||
const classes = docSet.doclets.filter(({kind, classdesc, description}) => kind === 'class' && classdesc && description);
|
const classes = docSet.doclets.filter(({kind, classdesc, description}) => kind === 'class' && classdesc && description);
|
||||||
const getId = docSet.getByLongname('module:mymodule/config#getId')[0];
|
const getId = docSet.getByLongname('module:mymodule/config#getId')[0];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('module that exports a function that is not a constructor', () => {
|
describe('module that exports a function that is not a constructor', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/moduleisfunction.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduleisfunction.js');
|
||||||
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"', () => {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ describe('module names', () => {
|
|||||||
env.opts._ = [path.normalize(`${env.pwd}/test/fixtures/modules/data/`)];
|
env.opts._ = [path.normalize(`${env.pwd}/test/fixtures/modules/data/`)];
|
||||||
env.pwd = env.dirname;
|
env.pwd = env.dirname;
|
||||||
env.sourceFiles = [];
|
env.sourceFiles = [];
|
||||||
srcParser = jasmine.createParser();
|
srcParser = jsdoc.createParser();
|
||||||
require('jsdoc/src/handlers').attachTo(srcParser);
|
require('jsdoc/src/handlers').attachTo(srcParser);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('object keys', () => {
|
describe('object keys', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/objectkeys.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/objectkeys.js');
|
||||||
|
|
||||||
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];
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
describe('object literals', () => {
|
describe('object literals', () => {
|
||||||
describe('When a child of an objlit has no @name or @memberof tags', () => {
|
describe('When a child of an objlit has no @name or @memberof tags', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/objectlit.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/objectlit.js');
|
||||||
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', () => {
|
||||||
@ -21,7 +21,7 @@ describe('object literals', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('When a parent of an objlit has no documentation', () => {
|
describe('When a parent of an objlit has no documentation', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/objectlit2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/objectlit2.js');
|
||||||
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', () => {
|
||||||
@ -46,7 +46,7 @@ describe('object literals', () => {
|
|||||||
let found;
|
let found;
|
||||||
|
|
||||||
function loadDocSet() {
|
function loadDocSet() {
|
||||||
docSet = jasmine.getDocSetFromFile('test/fixtures/objectlit3.js');
|
docSet = jsdoc.getDocSetFromFile('test/fixtures/objectlit3.js');
|
||||||
found = docSet.getByLongname('tokens."(".before');
|
found = docSet.getByLongname('tokens."(".before');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
describe('using existing Object properties as object literal keys', () => {
|
describe('using existing Object properties as object literal keys', () => {
|
||||||
function loadDocSet() {
|
function loadDocSet() {
|
||||||
jasmine.getDocSetFromFile('test/fixtures/objectpropertykeys.js');
|
jsdoc.getDocSetFromFile('test/fixtures/objectpropertykeys.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should not crash', () => {
|
it('should not crash', () => {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
describe('quoted names', () => {
|
describe('quoted names', () => {
|
||||||
describe('when found in square brackets', () => {
|
describe('when found in square brackets', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/quotename.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/quotename.js');
|
||||||
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', () => {
|
||||||
@ -10,7 +10,7 @@ describe('quoted names', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when found in an object literal', () => {
|
describe('when found in an object literal', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/quotename2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/quotename2.js');
|
||||||
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', () => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('rest parameters', () => {
|
describe('rest parameters', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/restparams.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/restparams.js');
|
||||||
const setAdmins = docSet.getByLongname('setAdmins')[0];
|
const setAdmins = docSet.getByLongname('setAdmins')[0];
|
||||||
const setManagers = docSet.getByLongname('setManagers')[0];
|
const setManagers = docSet.getByLongname('setManagers')[0];
|
||||||
const setWidgetAccess = docSet.getByLongname('setWidgetAccess')[0];
|
const setWidgetAccess = docSet.getByLongname('setWidgetAccess')[0];
|
||||||
@ -26,7 +26,7 @@ describe('rest parameters', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('ES2015 methods', () => {
|
describe('ES2015 methods', () => {
|
||||||
const docSet2 = jasmine.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];
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('longnames with special characters', () => {
|
describe('longnames with special characters', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/specialchars.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/specialchars.js');
|
||||||
const portNumber = docSet.getByLongname('Socket#\'port#number\'')[0];
|
const portNumber = docSet.getByLongname('Socket#\'port#number\'')[0];
|
||||||
const open = docSet.getByLongname('Socket#\'open~a.connection#now\'')[0];
|
const open = docSet.getByLongname('Socket#\'open~a.connection#now\'')[0];
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('documenting symbols with special names', () => {
|
describe('documenting symbols with special names', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/specialnames.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/specialnames.js');
|
||||||
const construct = docSet.getByLongname('constructor')[0];
|
const construct = docSet.getByLongname('constructor')[0];
|
||||||
const constructToString = docSet.getByLongname('constructor.toString')[0];
|
const constructToString = docSet.getByLongname('constructor.toString')[0];
|
||||||
const hasOwnProp = docSet.getByLongname('hasOwnProperty')[0];
|
const hasOwnProp = docSet.getByLongname('hasOwnProperty')[0];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('starbangstar', () => {
|
describe('starbangstar', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/starbangstar.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/starbangstar.js');
|
||||||
const mod = docSet.getByLongname('module:myscript/core')[0];
|
const mod = docSet.getByLongname('module:myscript/core')[0];
|
||||||
const x = docSet.getByLongname('module:myscript/core.x')[0];
|
const x = docSet.getByLongname('module:myscript/core.x')[0];
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
describe('this', () => {
|
describe('this', () => {
|
||||||
describe('attaching members to "this"', () => {
|
describe('attaching members to "this"', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/this.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/this.js');
|
||||||
const found1 = docSet.getByLongname('Singer#tralala');
|
const found1 = docSet.getByLongname('Singer#tralala');
|
||||||
const found2 = docSet.getByLongname('Singer#isSinging');
|
const found2 = docSet.getByLongname('Singer#isSinging');
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ describe('this', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when a contructor is nested inside another constructor', () => {
|
describe('when a contructor is nested inside another constructor', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/this2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/this2.js');
|
||||||
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', () => {
|
||||||
@ -63,7 +63,7 @@ describe('this', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('When a this is assigned to inside a non-constructor function', () => {
|
describe('When a this is assigned to inside a non-constructor function', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/this3.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/this3.js');
|
||||||
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"', () => {
|
||||||
@ -80,7 +80,7 @@ describe('this', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('When "this" is assigned inside an explicit definition of the class constructor', () => {
|
describe('When "this" is assigned inside an explicit definition of the class constructor', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/this4.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/this4.js');
|
||||||
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', () => {
|
||||||
@ -97,7 +97,7 @@ describe('this', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('When "this" is assigned in a chained declaration in a module', () => {
|
describe('When "this" is assigned in a chained declaration in a module', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/this5.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/this5.js');
|
||||||
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', () => {
|
||||||
@ -114,7 +114,7 @@ describe('this', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('When `this` is within the constructor in a class that has an `@alias` tag within a module', () => {
|
describe('When `this` is within the constructor in a class that has an `@alias` tag within a module', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/this6.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/this6.js');
|
||||||
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', () => {
|
||||||
@ -125,7 +125,7 @@ describe('this', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('When a member is nested inside an objectlit "this" property inside a constructor', () => {
|
describe('When a member is nested inside an objectlit "this" property inside a constructor', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/this-and-objectlit.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/this-and-objectlit.js');
|
||||||
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', () => {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
describe('trailing comment', () => {
|
describe('trailing comment', () => {
|
||||||
it('should not ignore trailing comments in a non-empty source file with a `use strict` ' +
|
it('should not ignore trailing comments in a non-empty source file with a `use strict` ' +
|
||||||
'declaration', () => {
|
'declaration', () => {
|
||||||
const docSet = jasmine.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.length).toBe(1);
|
||||||
@ -9,7 +9,7 @@ describe('trailing comment', () => {
|
|||||||
|
|
||||||
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` ' +
|
||||||
'declaration', () => {
|
'declaration', () => {
|
||||||
const docSet = jasmine.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.length).toBe(1);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
describe('@type tag inline with function parameters', () => {
|
describe('@type tag inline with function parameters', () => {
|
||||||
let info;
|
let info;
|
||||||
|
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/typetaginline.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/typetaginline.js');
|
||||||
|
|
||||||
function checkParams({params}, paramInfo) {
|
function checkParams({params}, paramInfo) {
|
||||||
expect(params).toBeDefined();
|
expect(params).toBeDefined();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('@type tag containing a newline character', () => {
|
describe('@type tag containing a newline character', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/typetagwithnewline.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/typetagwithnewline.js');
|
||||||
const mini = docSet.getByLongname('Matryoshka.mini')[0];
|
const mini = docSet.getByLongname('Matryoshka.mini')[0];
|
||||||
const mega = docSet.getByLongname('Matryoshka.mega')[0];
|
const mega = docSet.getByLongname('Matryoshka.mega')[0];
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('var statements', () => {
|
describe('var statements', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/var.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/var.js');
|
||||||
const found = [
|
const found = [
|
||||||
docSet.getByLongname('GREEN'),
|
docSet.getByLongname('GREEN'),
|
||||||
docSet.getByLongname('RED'),
|
docSet.getByLongname('RED'),
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('variations by name', () => {
|
describe('variations by name', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/variations.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/variations.js');
|
||||||
const fadein1 = docSet.getByLongname('anim.fadein(1)')[0];
|
const fadein1 = docSet.getByLongname('anim.fadein(1)')[0];
|
||||||
const fadein2 = docSet.getByLongname('anim.fadein(2)')[0];
|
const fadein2 = docSet.getByLongname('anim.fadein(2)')[0];
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
describe('virtual symbols', () => {
|
describe('virtual symbols', () => {
|
||||||
describe('simple cases', () => {
|
describe('simple cases', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/virtual.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/virtual.js');
|
||||||
const dimensions = docSet.getByLongname('dimensions');
|
const dimensions = docSet.getByLongname('dimensions');
|
||||||
const width = docSet.getByLongname('width');
|
const width = docSet.getByLongname('width');
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ describe('virtual symbols', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('complex cases', () => {
|
describe('complex cases', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/virtual2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/virtual2.js');
|
||||||
const say = docSet.getByLongname('Person#say')[0];
|
const say = docSet.getByLongname('Person#say')[0];
|
||||||
const sayCallback = docSet.getByLongname('Person~sayCallback')[0];
|
const sayCallback = docSet.getByLongname('Person~sayCallback')[0];
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ describe('virtual symbols', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('overloaded virtual symbols', () => {
|
describe('overloaded virtual symbols', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/virtual3.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/virtual3.js');
|
||||||
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', () => {
|
||||||
|
|||||||
@ -37,7 +37,7 @@ describe('jsdoc/augment', () => {
|
|||||||
|
|
||||||
describe('augmentAll', () => {
|
describe('augmentAll', () => {
|
||||||
it('should call all other methods that the module exports', () => {
|
it('should call all other methods that the module exports', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag2.js', null, null, false);
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/mixintag2.js', null, null, false);
|
||||||
const methodNames = Object.keys(augment).filter(name => name !== 'augmentAll');
|
const methodNames = Object.keys(augment).filter(name => name !== 'augmentAll');
|
||||||
|
|
||||||
methodNames.forEach(name => {
|
methodNames.forEach(name => {
|
||||||
@ -52,7 +52,7 @@ describe('jsdoc/augment', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should work when a class extends another class that implements an interface', () => {
|
it('should work when a class extends another class that implements an interface', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/augmentall.js', null, null, false);
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/augmentall.js', null, null, false);
|
||||||
let open;
|
let open;
|
||||||
|
|
||||||
augment.augmentAll(docSet.doclets);
|
augment.augmentAll(docSet.doclets);
|
||||||
@ -64,7 +64,7 @@ describe('jsdoc/augment', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should work when a class implements an interface that extends another interface', () => {
|
it('should work when a class implements an interface that extends another interface', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/augmentall2.js', null, null, false);
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/augmentall2.js', null, null, false);
|
||||||
let open;
|
let open;
|
||||||
|
|
||||||
augment.augmentAll(docSet.doclets);
|
augment.augmentAll(docSet.doclets);
|
||||||
|
|||||||
@ -1,12 +1,9 @@
|
|||||||
describe('jsdoc/config', () => {
|
describe('jsdoc/config', () => {
|
||||||
const jsdoc = {
|
const Config = require('jsdoc/config');
|
||||||
config: require('jsdoc/config')
|
|
||||||
};
|
|
||||||
const Config = jsdoc.config;
|
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(jsdoc.config).toBeDefined();
|
expect(Config).toBeDefined();
|
||||||
expect(typeof jsdoc.config).toBe('function');
|
expect(typeof Config).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a "get" instance function', () => {
|
it('should provide a "get" instance function', () => {
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
describe('jsdoc/doclet', () => {
|
describe('jsdoc/doclet', () => {
|
||||||
// TODO: more tests
|
// TODO: more tests
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const jsdoc = {
|
const doclet = require('jsdoc/doclet');
|
||||||
doclet: require('jsdoc/doclet')
|
const Doclet = doclet.Doclet;
|
||||||
};
|
|
||||||
const Doclet = jsdoc.doclet.Doclet;
|
|
||||||
|
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/doclet.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/doclet.js');
|
||||||
const test1 = docSet.getByLongname('test1')[0];
|
const test1 = docSet.getByLongname('test1')[0];
|
||||||
const test2 = docSet.getByLongname('test2')[0];
|
const test2 = docSet.getByLongname('test2')[0];
|
||||||
|
|
||||||
@ -27,9 +25,9 @@ describe('jsdoc/doclet', () => {
|
|||||||
describe('setScope', () => {
|
describe('setScope', () => {
|
||||||
it('should accept the correct scope names', () => {
|
it('should accept the correct scope names', () => {
|
||||||
function setScope(scopeName) {
|
function setScope(scopeName) {
|
||||||
const doclet = new Doclet('/** Huzzah, a doclet! */');
|
const newDoclet = new Doclet('/** Huzzah, a doclet! */');
|
||||||
|
|
||||||
doclet.setScope(scopeName);
|
newDoclet.setScope(scopeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
_.values(require('jsdoc/name').SCOPE.NAMES).forEach(scopeName => {
|
_.values(require('jsdoc/name').SCOPE.NAMES).forEach(scopeName => {
|
||||||
@ -39,9 +37,9 @@ describe('jsdoc/doclet', () => {
|
|||||||
|
|
||||||
it('should throw an error for invalid scope names', () => {
|
it('should throw an error for invalid scope names', () => {
|
||||||
function setScope() {
|
function setScope() {
|
||||||
const doclet = new Doclet('/** Woe betide this doclet. */');
|
const newDoclet = new Doclet('/** Woe betide this doclet. */');
|
||||||
|
|
||||||
doclet.setScope('fiddlesticks');
|
newDoclet.setScope('fiddlesticks');
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(setScope).toThrow();
|
expect(setScope).toThrow();
|
||||||
@ -61,7 +59,7 @@ describe('jsdoc/doclet', () => {
|
|||||||
* Hello!
|
* Hello!
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*/`);
|
*/`);
|
||||||
const newDoclet = jsdoc.doclet.combine(primaryDoclet, secondaryDoclet);
|
const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet);
|
||||||
|
|
||||||
Object.getOwnPropertyNames(newDoclet).forEach(property => {
|
Object.getOwnPropertyNames(newDoclet).forEach(property => {
|
||||||
expect(newDoclet[property]).toEqual(primaryDoclet[property]);
|
expect(newDoclet[property]).toEqual(primaryDoclet[property]);
|
||||||
@ -78,7 +76,7 @@ describe('jsdoc/doclet', () => {
|
|||||||
/**
|
/**
|
||||||
* Hello!
|
* Hello!
|
||||||
*/`);
|
*/`);
|
||||||
const newDoclet = jsdoc.doclet.combine(primaryDoclet, secondaryDoclet);
|
const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet);
|
||||||
|
|
||||||
expect(newDoclet.version).toBe('2.0.0');
|
expect(newDoclet.version).toBe('2.0.0');
|
||||||
});
|
});
|
||||||
@ -91,7 +89,7 @@ describe('jsdoc/doclet', () => {
|
|||||||
primaryDoclet.undocumented = true;
|
primaryDoclet.undocumented = true;
|
||||||
secondaryDoclet.undocumented = true;
|
secondaryDoclet.undocumented = true;
|
||||||
|
|
||||||
newDoclet = jsdoc.doclet.combine(primaryDoclet, secondaryDoclet);
|
newDoclet = doclet.combine(primaryDoclet, secondaryDoclet);
|
||||||
|
|
||||||
expect(newDoclet.undocumented).not.toBeDefined();
|
expect(newDoclet.undocumented).not.toBeDefined();
|
||||||
});
|
});
|
||||||
@ -113,7 +111,7 @@ describe('jsdoc/doclet', () => {
|
|||||||
* @param {string} foo - The foo.
|
* @param {string} foo - The foo.
|
||||||
* @property {number} bar - The bar.
|
* @property {number} bar - The bar.
|
||||||
*/`);
|
*/`);
|
||||||
const newDoclet = jsdoc.doclet.combine(primaryDoclet, secondaryDoclet);
|
const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet);
|
||||||
|
|
||||||
properties.forEach(property => {
|
properties.forEach(property => {
|
||||||
expect(newDoclet[property]).toEqual(primaryDoclet[property]);
|
expect(newDoclet[property]).toEqual(primaryDoclet[property]);
|
||||||
@ -128,7 +126,7 @@ describe('jsdoc/doclet', () => {
|
|||||||
* @property {number} bar - The bar.
|
* @property {number} bar - The bar.
|
||||||
*/`;
|
*/`;
|
||||||
const secondaryDoclet = new Doclet(secondaryComment);
|
const secondaryDoclet = new Doclet(secondaryComment);
|
||||||
const newDoclet = jsdoc.doclet.combine(primaryDoclet, secondaryDoclet);
|
const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet);
|
||||||
|
|
||||||
properties.forEach(property => {
|
properties.forEach(property => {
|
||||||
expect(newDoclet[property]).toEqual(secondaryDoclet[property]);
|
expect(newDoclet[property]).toEqual(secondaryDoclet[property]);
|
||||||
|
|||||||
@ -1,64 +1,62 @@
|
|||||||
describe('jsdoc/name', () => {
|
describe('jsdoc/name', () => {
|
||||||
const jsdoc = {
|
const { Doclet } = require('jsdoc/doclet');
|
||||||
doclet: require('jsdoc/doclet'),
|
const name = require('jsdoc/name');
|
||||||
name: require('jsdoc/name')
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(jsdoc.name).toBeDefined();
|
expect(name).toBeDefined();
|
||||||
expect(typeof jsdoc.name).toBe('object');
|
expect(typeof name).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'resolve' function", () => {
|
it("should export a 'resolve' function", () => {
|
||||||
expect(jsdoc.name.resolve).toBeDefined();
|
expect(name.resolve).toBeDefined();
|
||||||
expect(typeof jsdoc.name.resolve).toBe('function');
|
expect(typeof name.resolve).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export an 'applyNamespace' function", () => {
|
it("should export an 'applyNamespace' function", () => {
|
||||||
expect(jsdoc.name.applyNamespace).toBeDefined();
|
expect(name.applyNamespace).toBeDefined();
|
||||||
expect(typeof jsdoc.name.applyNamespace).toBe('function');
|
expect(typeof name.applyNamespace).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "stripNamespace" function', () => {
|
it('should export a "stripNamespace" function', () => {
|
||||||
expect(typeof jsdoc.name.stripNamespace).toBe('function');
|
expect(typeof name.stripNamespace).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "hasAncestor" function', () => {
|
it('should export a "hasAncestor" function', () => {
|
||||||
expect(typeof jsdoc.name.hasAncestor).toBe('function');
|
expect(typeof name.hasAncestor).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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(jsdoc.name.SCOPE).toBeDefined();
|
expect(name.SCOPE).toBeDefined();
|
||||||
expect(typeof jsdoc.name.SCOPE).toBe('object');
|
expect(typeof name.SCOPE).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'shorten' function", () => {
|
it("should export a 'shorten' function", () => {
|
||||||
expect(jsdoc.name.shorten).toBeDefined();
|
expect(name.shorten).toBeDefined();
|
||||||
expect(typeof jsdoc.name.shorten).toBe('function');
|
expect(typeof name.shorten).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "combine" function', () => {
|
it('should export a "combine" function', () => {
|
||||||
expect(jsdoc.name.combine).toBeDefined();
|
expect(name.combine).toBeDefined();
|
||||||
expect(typeof jsdoc.name.combine).toBe('function');
|
expect(typeof name.combine).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "stripVariation" function', () => {
|
it('should export a "stripVariation" function', () => {
|
||||||
expect(typeof jsdoc.name.stripVariation).toBe('function');
|
expect(typeof name.stripVariation).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "longnamesToTree" function', () => {
|
it('should export a "longnamesToTree" function', () => {
|
||||||
expect(jsdoc.name.longnamesToTree).toBeDefined();
|
expect(name.longnamesToTree).toBeDefined();
|
||||||
expect(typeof jsdoc.name.longnamesToTree).toBe('function');
|
expect(typeof name.longnamesToTree).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should export a 'splitName' function", () => {
|
it("should export a 'splitName' function", () => {
|
||||||
expect(jsdoc.name.splitName).toBeDefined();
|
expect(name.splitName).toBeDefined();
|
||||||
expect(typeof jsdoc.name.splitName).toBe('function');
|
expect(typeof name.splitName).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('SCOPE', () => {
|
describe('SCOPE', () => {
|
||||||
const SCOPE = jsdoc.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).toBeDefined();
|
||||||
@ -113,7 +111,7 @@ describe('jsdoc/name', () => {
|
|||||||
describe('shorten', () => {
|
describe('shorten', () => {
|
||||||
it('should break up a longname into the correct memberof, name and scope parts', () => {
|
it('should break up a longname into the correct memberof, name and scope parts', () => {
|
||||||
const startName = 'lib.Panel#open';
|
const startName = 'lib.Panel#open';
|
||||||
const parts = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('open');
|
expect(parts.name).toEqual('open');
|
||||||
expect(parts.memberof).toEqual('lib.Panel');
|
expect(parts.memberof).toEqual('lib.Panel');
|
||||||
@ -122,7 +120,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should work on static names', () => {
|
it('should work on static names', () => {
|
||||||
const startName = 'elements.selected.getVisible';
|
const startName = 'elements.selected.getVisible';
|
||||||
const parts = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('getVisible');
|
expect(parts.name).toEqual('getVisible');
|
||||||
expect(parts.memberof).toEqual('elements.selected');
|
expect(parts.memberof).toEqual('elements.selected');
|
||||||
@ -131,7 +129,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should work on protoyped names', () => {
|
it('should work on protoyped names', () => {
|
||||||
const startName = 'Validator.prototype.$element';
|
const startName = 'Validator.prototype.$element';
|
||||||
const parts = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('$element');
|
expect(parts.name).toEqual('$element');
|
||||||
expect(parts.memberof).toEqual('Validator');
|
expect(parts.memberof).toEqual('Validator');
|
||||||
@ -140,7 +138,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should work on inner names', () => {
|
it('should work on inner names', () => {
|
||||||
const startName = 'Button~_onclick';
|
const startName = 'Button~_onclick';
|
||||||
const parts = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('_onclick');
|
expect(parts.name).toEqual('_onclick');
|
||||||
expect(parts.memberof).toEqual('Button');
|
expect(parts.memberof).toEqual('Button');
|
||||||
@ -149,7 +147,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should work on global names', () => {
|
it('should work on global names', () => {
|
||||||
const startName = 'close';
|
const startName = 'close';
|
||||||
const parts = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('close');
|
expect(parts.name).toEqual('close');
|
||||||
expect(parts.memberof).toEqual('');
|
expect(parts.memberof).toEqual('');
|
||||||
@ -158,7 +156,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
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 = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('open');
|
expect(parts.name).toEqual('open');
|
||||||
expect(parts.memberof).toEqual('channels."#ops"');
|
expect(parts.memberof).toEqual('channels."#ops"');
|
||||||
@ -167,7 +165,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
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 = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('"log.max"');
|
expect(parts.name).toEqual('"log.max"');
|
||||||
expect(parts.memberof).toEqual('channels."#bots"');
|
expect(parts.memberof).toEqual('channels."#bots"');
|
||||||
@ -176,7 +174,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should work when a property uses single-quoted bracket notation', () => {
|
it('should work when a property uses single-quoted bracket notation', () => {
|
||||||
const startName = "channels['#ops']";
|
const startName = "channels['#ops']";
|
||||||
const parts = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toBe("'#ops'");
|
expect(parts.name).toBe("'#ops'");
|
||||||
expect(parts.memberof).toBe('channels');
|
expect(parts.memberof).toBe('channels');
|
||||||
@ -185,7 +183,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should work on double-quoted strings', () => {
|
it('should work on double-quoted strings', () => {
|
||||||
const startName = '"foo.bar"';
|
const startName = '"foo.bar"';
|
||||||
const parts = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toEqual('"foo.bar"');
|
expect(parts.name).toEqual('"foo.bar"');
|
||||||
expect(parts.longname).toEqual('"foo.bar"');
|
expect(parts.longname).toEqual('"foo.bar"');
|
||||||
@ -195,7 +193,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should work on single-quoted strings', () => {
|
it('should work on single-quoted strings', () => {
|
||||||
const startName = "'foo.bar'";
|
const startName = "'foo.bar'";
|
||||||
const parts = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.name).toBe("'foo.bar'");
|
expect(parts.name).toBe("'foo.bar'");
|
||||||
expect(parts.longname).toBe("'foo.bar'");
|
expect(parts.longname).toBe("'foo.bar'");
|
||||||
@ -205,7 +203,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should find the variation', () => {
|
it('should find the variation', () => {
|
||||||
const startName = 'anim.fadein(2)';
|
const startName = 'anim.fadein(2)';
|
||||||
const parts = jsdoc.name.shorten(startName);
|
const parts = name.shorten(startName);
|
||||||
|
|
||||||
expect(parts.variation).toEqual('2');
|
expect(parts.variation).toEqual('2');
|
||||||
expect(parts.name).toEqual('fadein');
|
expect(parts.name).toEqual('fadein');
|
||||||
@ -216,28 +214,28 @@ describe('jsdoc/name', () => {
|
|||||||
describe('applyNamespace', () => {
|
describe('applyNamespace', () => {
|
||||||
it('should insert the namespace only before the name part of the longname', () => {
|
it('should insert the namespace only before the name part of the longname', () => {
|
||||||
const startName = 'lib.Panel#open';
|
const startName = 'lib.Panel#open';
|
||||||
const endName = jsdoc.name.applyNamespace(startName, 'event');
|
const endName = name.applyNamespace(startName, 'event');
|
||||||
|
|
||||||
expect(endName, 'lib.Panel#event:open');
|
expect(endName, '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 = jsdoc.name.applyNamespace(startName, 'module');
|
const endName = name.applyNamespace(startName, 'module');
|
||||||
|
|
||||||
expect(endName, 'module:maths/bigint');
|
expect(endName, 'module:maths/bigint');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should treat quoted parts of the name as atomic and insert namespace before a quoted shortname', () => {
|
it('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 = jsdoc.name.applyNamespace(startName, 'event');
|
const endName = name.applyNamespace(startName, 'event');
|
||||||
|
|
||||||
expect(endName, 'foo.event:"*dont\'t.look~in#here!"');
|
expect(endName, '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 = jsdoc.name.applyNamespace(startName, 'event');
|
const endName = name.applyNamespace(startName, 'event');
|
||||||
|
|
||||||
expect(endName, 'lib.Panel#event:open');
|
expect(endName, 'lib.Panel#event:open');
|
||||||
});
|
});
|
||||||
@ -246,21 +244,21 @@ describe('jsdoc/name', () => {
|
|||||||
describe('stripNamespace', () => {
|
describe('stripNamespace', () => {
|
||||||
it('should not change longnames without a leading namespace', () => {
|
it('should not change longnames without a leading namespace', () => {
|
||||||
const startName = 'Foo#bar';
|
const startName = 'Foo#bar';
|
||||||
const endName = jsdoc.name.stripNamespace(startName);
|
const endName = name.stripNamespace(startName);
|
||||||
|
|
||||||
expect(endName).toBe(startName);
|
expect(endName).toBe(startName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not change longnames with an embedded namespace', () => {
|
it('should not change longnames with an embedded namespace', () => {
|
||||||
const startName = 'foo/bar.baz~event:qux';
|
const startName = 'foo/bar.baz~event:qux';
|
||||||
const endName = jsdoc.name.stripNamespace(startName);
|
const endName = name.stripNamespace(startName);
|
||||||
|
|
||||||
expect(endName).toBe(startName);
|
expect(endName).toBe(startName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove the leading namespace, if present', () => {
|
it('should remove the leading namespace, if present', () => {
|
||||||
const startName = 'module:foo/bar/baz';
|
const startName = 'module:foo/bar/baz';
|
||||||
const endName = jsdoc.name.stripNamespace(startName);
|
const endName = name.stripNamespace(startName);
|
||||||
|
|
||||||
expect(endName).toBe('foo/bar/baz');
|
expect(endName).toBe('foo/bar/baz');
|
||||||
});
|
});
|
||||||
@ -268,37 +266,37 @@ 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 = jsdoc.name.hasAncestor(null, 'foo');
|
const hasAncestor = name.hasAncestor(null, 'foo');
|
||||||
|
|
||||||
expect(hasAncestor).toBe(false);
|
expect(hasAncestor).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false if "child" is missing', () => {
|
it('should return false if "child" is missing', () => {
|
||||||
const hasAncestor = jsdoc.name.hasAncestor('foo');
|
const hasAncestor = name.hasAncestor('foo');
|
||||||
|
|
||||||
expect(hasAncestor).toBe(false);
|
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 = jsdoc.name.hasAncestor('module:foo', 'module:foo~bar');
|
const hasAncestor = name.hasAncestor('module:foo', 'module:foo~bar');
|
||||||
|
|
||||||
expect(hasAncestor).toBe(true);
|
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 = jsdoc.name.hasAncestor('module:foo', 'module:foo~bar.Baz#qux');
|
const hasAncestor = name.hasAncestor('module:foo', 'module:foo~bar.Baz#qux');
|
||||||
|
|
||||||
expect(hasAncestor).toBe(true);
|
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 = jsdoc.name.hasAncestor('module:foo', 'foo');
|
const hasAncestor = name.hasAncestor('module:foo', 'foo');
|
||||||
|
|
||||||
expect(hasAncestor).toBe(false);
|
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 = jsdoc.name.hasAncestor('module:foo', 'module:foo');
|
const hasAncestor = name.hasAncestor('module:foo', 'module:foo');
|
||||||
|
|
||||||
expect(hasAncestor).toBe(false);
|
expect(hasAncestor).toBe(false);
|
||||||
});
|
});
|
||||||
@ -311,14 +309,14 @@ describe('jsdoc/name', () => {
|
|||||||
describe('stripVariation', () => {
|
describe('stripVariation', () => {
|
||||||
it('should not change longnames without a variation', () => {
|
it('should not change longnames without a variation', () => {
|
||||||
const startName = 'Foo#bar';
|
const startName = 'Foo#bar';
|
||||||
const endName = jsdoc.name.stripVariation(startName);
|
const endName = name.stripVariation(startName);
|
||||||
|
|
||||||
expect(endName).toBe(startName);
|
expect(endName).toBe(startName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove the variation, if present', () => {
|
it('should remove the variation, if present', () => {
|
||||||
const startName = 'Foo#bar(qux)';
|
const startName = 'Foo#bar(qux)';
|
||||||
const endName = jsdoc.name.stripVariation(startName);
|
const endName = name.stripVariation(startName);
|
||||||
|
|
||||||
expect(endName).toBe('Foo#bar');
|
expect(endName).toBe('Foo#bar');
|
||||||
});
|
});
|
||||||
@ -331,7 +329,7 @@ describe('jsdoc/name', () => {
|
|||||||
describe('splitName', () => {
|
describe('splitName', () => {
|
||||||
it('should find the name and description.', () => {
|
it('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 = jsdoc.name.splitName(startName);
|
const parts = name.splitName(startName);
|
||||||
|
|
||||||
expect(parts.name, 'ns.Page#"last \\"sentence\\"".words~sort(2)');
|
expect(parts.name, 'ns.Page#"last \\"sentence\\"".words~sort(2)');
|
||||||
expect(parts.description, 'This is a description.');
|
expect(parts.description, 'This is a description.');
|
||||||
@ -339,7 +337,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
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', () => {
|
||||||
const startName = 'socket - The networking kind, not the wrench.';
|
const startName = 'socket - The networking kind, not the wrench.';
|
||||||
const parts = jsdoc.name.splitName(startName);
|
const parts = name.splitName(startName);
|
||||||
|
|
||||||
expect(parts.name).toBe('socket');
|
expect(parts.name).toBe('socket');
|
||||||
expect(parts.description).toBe('The networking kind, not the wrench.');
|
expect(parts.description).toBe('The networking kind, not the wrench.');
|
||||||
@ -347,7 +345,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should not strip a separator that is preceded by a line break', () => {
|
it('should not strip a separator that is preceded by a line break', () => {
|
||||||
const startName = 'socket\n - The networking kind, not the wrench.';
|
const startName = 'socket\n - The networking kind, not the wrench.';
|
||||||
const parts = jsdoc.name.splitName(startName);
|
const parts = name.splitName(startName);
|
||||||
|
|
||||||
expect(parts.name).toBe('socket');
|
expect(parts.name).toBe('socket');
|
||||||
expect(parts.description).toBe('- The networking kind, not the wrench.');
|
expect(parts.description).toBe('- The networking kind, not the wrench.');
|
||||||
@ -355,7 +353,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should allow default values to have brackets', () => {
|
it('should allow default values to have brackets', () => {
|
||||||
const startName = '[path=["home", "user"]] - Path split into components';
|
const startName = '[path=["home", "user"]] - Path split into components';
|
||||||
const parts = jsdoc.name.splitName(startName);
|
const parts = name.splitName(startName);
|
||||||
|
|
||||||
expect(parts.name).toBe('[path=["home", "user"]]');
|
expect(parts.name).toBe('[path=["home", "user"]]');
|
||||||
expect(parts.description).toBe('Path split into components');
|
expect(parts.description).toBe('Path split into components');
|
||||||
@ -363,7 +361,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should allow default values to have unmatched brackets inside strings', () => {
|
it('should allow default values to have unmatched brackets inside strings', () => {
|
||||||
const startName = '[path=["Unmatched begin: ["]] - Path split into components';
|
const startName = '[path=["Unmatched begin: ["]] - Path split into components';
|
||||||
const parts = jsdoc.name.splitName(startName);
|
const parts = name.splitName(startName);
|
||||||
|
|
||||||
expect(parts.name).toBe('[path=["Unmatched begin: ["]]');
|
expect(parts.name).toBe('[path=["Unmatched begin: ["]]');
|
||||||
expect(parts.description).toBe('Path split into components');
|
expect(parts.description).toBe('Path split into components');
|
||||||
@ -371,7 +369,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should fail gracefully when the default value has an unmatched bracket', () => {
|
it('should fail gracefully when the default value has an unmatched bracket', () => {
|
||||||
const startName = '[path=["home", "user"] - Path split into components';
|
const startName = '[path=["home", "user"] - Path split into components';
|
||||||
const parts = jsdoc.name.splitName(startName);
|
const parts = name.splitName(startName);
|
||||||
|
|
||||||
expect(parts).not.toBe(null);
|
expect(parts).not.toBe(null);
|
||||||
expect(parts.name).toBe('[path=["home", "user"]');
|
expect(parts.name).toBe('[path=["home", "user"]');
|
||||||
@ -380,7 +378,7 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
it('should fail gracefully when the default value has an unmatched quote', () => {
|
it('should fail gracefully when the default value has an unmatched quote', () => {
|
||||||
const startName = '[path=["home", "user] - Path split into components';
|
const startName = '[path=["home", "user] - Path split into components';
|
||||||
const parts = jsdoc.name.splitName(startName);
|
const parts = name.splitName(startName);
|
||||||
|
|
||||||
expect(parts).not.toBe(null);
|
expect(parts).not.toBe(null);
|
||||||
expect(parts.name).toBe('[path=["home", "user]');
|
expect(parts.name).toBe('[path=["home", "user]');
|
||||||
@ -394,7 +392,7 @@ describe('jsdoc/name', () => {
|
|||||||
function makeDoclet(tagStrings) {
|
function makeDoclet(tagStrings) {
|
||||||
const comment = `/**\n${tagStrings.join('\n')}\n*/`;
|
const comment = `/**\n${tagStrings.join('\n')}\n*/`;
|
||||||
|
|
||||||
return new jsdoc.doclet.Doclet(comment, {});
|
return new Doclet(comment, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('aliases', () => {
|
describe('aliases', () => {
|
||||||
@ -404,7 +402,7 @@ describe('jsdoc/name', () => {
|
|||||||
it('can resolve aliases that identify instance members', () => {
|
it('can resolve aliases that identify instance members', () => {
|
||||||
const doclet = makeDoclet(['@alias Foo#bar', '@name Foo#bar']);
|
const doclet = makeDoclet(['@alias Foo#bar', '@name Foo#bar']);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toBe('bar');
|
expect(doclet.name).toBe('bar');
|
||||||
expect(doclet.memberof).toBe('Foo');
|
expect(doclet.memberof).toBe('Foo');
|
||||||
@ -415,7 +413,7 @@ describe('jsdoc/name', () => {
|
|||||||
it('can resolve aliases that identify static members', () => {
|
it('can resolve aliases that identify static members', () => {
|
||||||
const doclet = makeDoclet(['@alias Foo.bar', '@name Foo.bar']);
|
const doclet = makeDoclet(['@alias Foo.bar', '@name Foo.bar']);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toBe('bar');
|
expect(doclet.name).toBe('bar');
|
||||||
expect(doclet.memberof).toBe('Foo');
|
expect(doclet.memberof).toBe('Foo');
|
||||||
@ -426,7 +424,7 @@ describe('jsdoc/name', () => {
|
|||||||
it('works when the alias only specifies the short name', () => {
|
it('works when the alias only specifies the short name', () => {
|
||||||
const doclet = makeDoclet(['@alias bar', '@name bar', '@memberof Foo', '@instance']);
|
const doclet = makeDoclet(['@alias bar', '@name bar', '@memberof Foo', '@instance']);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toBe('bar');
|
expect(doclet.name).toBe('bar');
|
||||||
expect(doclet.memberof).toBe('Foo');
|
expect(doclet.memberof).toBe('Foo');
|
||||||
@ -438,13 +436,13 @@ describe('jsdoc/name', () => {
|
|||||||
describe('events', () => {
|
describe('events', () => {
|
||||||
const event = '@event';
|
const event = '@event';
|
||||||
const memberOf = '@memberof MyClass';
|
const memberOf = '@memberof MyClass';
|
||||||
const name = '@name A';
|
const nameTag = '@name A';
|
||||||
|
|
||||||
// Test the basic @event that is not nested.
|
// Test the basic @event that is not nested.
|
||||||
it('unnested @event gets resolved correctly', () => {
|
it('unnested @event gets resolved correctly', () => {
|
||||||
const doclet = makeDoclet([event, name]);
|
const doclet = makeDoclet([event, nameTag]);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toBeUndefined();
|
expect(doclet.memberof).toBeUndefined();
|
||||||
@ -453,54 +451,54 @@ describe('jsdoc/name', () => {
|
|||||||
|
|
||||||
// test all permutations of @event @name [name] @memberof.
|
// test all permutations of @event @name [name] @memberof.
|
||||||
it('@event @name @memberof resolves correctly', () => {
|
it('@event @name @memberof resolves correctly', () => {
|
||||||
const doclet = makeDoclet([event, name, memberOf]);
|
const doclet = makeDoclet([event, nameTag, memberOf]);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toEqual('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toEqual('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@event @memberof @name resolves correctly', () => {
|
it('@event @memberof @name resolves correctly', () => {
|
||||||
const doclet = makeDoclet([event, memberOf, name]);
|
const doclet = makeDoclet([event, memberOf, nameTag]);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toEqual('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toEqual('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@name @event @memberof resolves correctly', () => {
|
it('@name @event @memberof resolves correctly', () => {
|
||||||
const doclet = makeDoclet([name, event, memberOf]);
|
const doclet = makeDoclet([nameTag, event, memberOf]);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toEqual('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toEqual('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@name @memberof @event resolves correctly', () => {
|
it('@name @memberof @event resolves correctly', () => {
|
||||||
const doclet = makeDoclet([name, memberOf, event]);
|
const doclet = makeDoclet([nameTag, memberOf, event]);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toEqual('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toEqual('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@memberof @event @name resolves correctly', () => {
|
it('@memberof @event @name resolves correctly', () => {
|
||||||
const doclet = makeDoclet([memberOf, event, name]);
|
const doclet = makeDoclet([memberOf, event, nameTag]);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toEqual('MyClass');
|
||||||
expect(doclet.longname).toEqual('MyClass.event:A');
|
expect(doclet.longname).toEqual('MyClass.event:A');
|
||||||
});
|
});
|
||||||
it('@memberof @name @event resolves correctly', () => {
|
it('@memberof @name @event resolves correctly', () => {
|
||||||
const doclet = makeDoclet([memberOf, name, event]);
|
const doclet = makeDoclet([memberOf, nameTag, event]);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toEqual('MyClass');
|
||||||
@ -511,7 +509,7 @@ describe('jsdoc/name', () => {
|
|||||||
it('@event [name] @memberof resolves correctly', () => {
|
it('@event [name] @memberof resolves correctly', () => {
|
||||||
const doclet = makeDoclet(['@event A', memberOf]);
|
const doclet = makeDoclet(['@event A', memberOf]);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toEqual('MyClass');
|
||||||
@ -520,7 +518,7 @@ describe('jsdoc/name', () => {
|
|||||||
it('@memberof @event [name] resolves correctly', () => {
|
it('@memberof @event [name] resolves correctly', () => {
|
||||||
const doclet = makeDoclet([memberOf, '@event A']);
|
const doclet = makeDoclet([memberOf, '@event A']);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toEqual('MyClass');
|
||||||
@ -531,7 +529,7 @@ describe('jsdoc/name', () => {
|
|||||||
it('full @event definition works', () => {
|
it('full @event definition works', () => {
|
||||||
const doclet = makeDoclet(['@event MyClass.A']);
|
const doclet = makeDoclet(['@event MyClass.A']);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toEqual('MyClass');
|
||||||
@ -540,7 +538,7 @@ describe('jsdoc/name', () => {
|
|||||||
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']);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('event:A');
|
expect(doclet.name).toEqual('event:A');
|
||||||
expect(doclet.memberof).toEqual('MyClass');
|
expect(doclet.memberof).toEqual('MyClass');
|
||||||
@ -551,7 +549,7 @@ describe('jsdoc/name', () => {
|
|||||||
it('@event @name MyClass.EventName @memberof somethingelse works', () => {
|
it('@event @name MyClass.EventName @memberof somethingelse works', () => {
|
||||||
const doclet = makeDoclet([event, '@name MyClass.A', '@memberof MyNamespace']);
|
const doclet = makeDoclet([event, '@name MyClass.A', '@memberof MyNamespace']);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toEqual('A');
|
expect(doclet.name).toEqual('A');
|
||||||
expect(doclet.memberof).toEqual('MyNamespace.MyClass');
|
expect(doclet.memberof).toEqual('MyNamespace.MyClass');
|
||||||
@ -569,7 +567,7 @@ describe('jsdoc/name', () => {
|
|||||||
'@param {string} qux'
|
'@param {string} qux'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
jsdoc.name.resolve(doclet);
|
name.resolve(doclet);
|
||||||
|
|
||||||
expect(doclet.name).toBe('baz');
|
expect(doclet.name).toBe('baz');
|
||||||
expect(doclet.memberof).toBe('module:foo.Bar');
|
expect(doclet.memberof).toBe('module:foo.Bar');
|
||||||
|
|||||||
@ -14,7 +14,7 @@ describe('jsdoc/package', () => {
|
|||||||
myPackage = new Package( JSON.stringify(obj) );
|
myPackage = new Package( JSON.stringify(obj) );
|
||||||
// add the package object to the cached parse results, so we can validate it against the
|
// add the package object to the cached parse results, so we can validate it against the
|
||||||
// doclet schema
|
// doclet schema
|
||||||
jasmine.addParseResults(`package-property-${name}.js`, [myPackage]);
|
jsdoc.addParseResults(`package-property-${name}.js`, [myPackage]);
|
||||||
|
|
||||||
// use toEqual so we can test array/object values
|
// use toEqual so we can test array/object values
|
||||||
expect(myPackage[name]).toEqual(value);
|
expect(myPackage[name]).toEqual(value);
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
describe('jsdoc/readme', () => {
|
describe('jsdoc/readme', () => {
|
||||||
const jsdoc = { readme: require('jsdoc/readme') };
|
const Readme = require('jsdoc/readme');
|
||||||
const Readme = 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', () => {
|
||||||
|
|||||||
@ -72,7 +72,7 @@ describe('jsdoc/schema', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not find any validation errors in the JSDoc parse results', () => {
|
it('should not find any validation errors in the JSDoc parse results', () => {
|
||||||
jasmine.getParseResults().forEach(doclets => {
|
jsdoc.getParseResults().forEach(doclets => {
|
||||||
const isValid = validate(doclets.doclets);
|
const isValid = validate(doclets.doclets);
|
||||||
|
|
||||||
// hack to get the filename/errors in the test results
|
// hack to get the filename/errors in the test results
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
describe('jsdoc/src/handlers', () => {
|
describe('jsdoc/src/handlers', () => {
|
||||||
const handlers = require('jsdoc/src/handlers');
|
const handlers = require('jsdoc/src/handlers');
|
||||||
|
|
||||||
const testParser = jasmine.createParser();
|
const testParser = jsdoc.createParser();
|
||||||
|
|
||||||
handlers.attachTo(testParser);
|
handlers.attachTo(testParser);
|
||||||
|
|
||||||
|
|||||||
@ -1,47 +1,41 @@
|
|||||||
/* eslint no-script-url: 0 */
|
/* eslint-disable no-script-url */
|
||||||
describe('jsdoc/src/parser', () => {
|
describe('jsdoc/src/parser', () => {
|
||||||
|
const { attachTo } = require('jsdoc/src/handlers');
|
||||||
|
const { dirname } = require('jsdoc/env');
|
||||||
const fs = require('jsdoc/fs');
|
const fs = require('jsdoc/fs');
|
||||||
const jsdoc = {
|
const jsdocParser = require('jsdoc/src/parser');
|
||||||
env: require('jsdoc/env'),
|
const logger = require('jsdoc/util/logger');
|
||||||
src: {
|
|
||||||
handlers: require('jsdoc/src/handlers'),
|
|
||||||
parser: require('jsdoc/src/parser')
|
|
||||||
},
|
|
||||||
util: {
|
|
||||||
logger: require('jsdoc/util/logger')
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const path = require('jsdoc/path');
|
const path = require('jsdoc/path');
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(jsdoc.src.parser).toBeDefined();
|
expect(jsdocParser).toBeDefined();
|
||||||
expect(typeof jsdoc.src.parser).toBe('object');
|
expect(typeof jsdocParser).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "createParser" method', () => {
|
it('should export a "createParser" method', () => {
|
||||||
expect(typeof jsdoc.src.parser.createParser).toBe('function');
|
expect(typeof jsdocParser.createParser).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a "Parser" constructor', () => {
|
it('should export a "Parser" constructor', () => {
|
||||||
expect(typeof jsdoc.src.parser.Parser).toBe('function');
|
expect(typeof jsdocParser.Parser).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('createParser', () => {
|
describe('createParser', () => {
|
||||||
it('should return a Parser when called without arguments', () => {
|
it('should return a Parser when called without arguments', () => {
|
||||||
expect(typeof jsdoc.src.parser.createParser()).toBe('object');
|
expect(typeof jsdocParser.createParser()).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
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 = jsdoc.src.parser.createParser('js');
|
const parser = jsdocParser.createParser('js');
|
||||||
|
|
||||||
expect(parser instanceof jsdoc.src.parser.Parser).toBe(true);
|
expect(parser instanceof jsdocParser.Parser).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log a fatal error on bad input', () => {
|
it('should log a fatal error on bad input', () => {
|
||||||
spyOn(jsdoc.util.logger, 'fatal');
|
spyOn(logger, 'fatal');
|
||||||
jsdoc.src.parser.createParser('not-a-real-parser-ever');
|
jsdocParser.createParser('not-a-real-parser-ever');
|
||||||
|
|
||||||
expect(jsdoc.util.logger.fatal).toHaveBeenCalled();
|
expect(logger.fatal).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -49,7 +43,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
let parser;
|
let parser;
|
||||||
|
|
||||||
function newParser() {
|
function newParser() {
|
||||||
parser = new jsdoc.src.parser.Parser();
|
parser = new jsdocParser.Parser();
|
||||||
}
|
}
|
||||||
|
|
||||||
newParser();
|
newParser();
|
||||||
@ -75,7 +69,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
};
|
};
|
||||||
const walker = {};
|
const walker = {};
|
||||||
|
|
||||||
const myParser = new jsdoc.src.parser.Parser(astBuilder, visitor, walker);
|
const myParser = new jsdocParser.Parser(astBuilder, visitor, walker);
|
||||||
|
|
||||||
expect(myParser.astBuilder).toBe(astBuilder);
|
expect(myParser.astBuilder).toBe(astBuilder);
|
||||||
expect(myParser.visitor).toBe(visitor);
|
expect(myParser.visitor).toBe(visitor);
|
||||||
@ -129,7 +123,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
|
|
||||||
parser.on('parseBegin', spy).parse(sourceFiles);
|
parser.on('parseBegin', spy).parse(sourceFiles);
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
expect(spy.mostRecentCall.args[0].sourcefiles).toBe(sourceFiles);
|
expect(spy.calls.mostRecent().args[0].sourcefiles).toBe(sourceFiles);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow 'parseBegin' handlers to modify the list of source files", () => {
|
it("should allow 'parseBegin' handlers to modify the list of source files", () => {
|
||||||
@ -153,7 +147,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
parser.on('jsdocCommentFound', spy).parse(sourceCode);
|
parser.on('jsdocCommentFound', spy).parse(sourceCode);
|
||||||
|
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
expect(spy.mostRecentCall.args[0].comment).toBe('/** @name bar */');
|
expect(spy.calls.mostRecent().args[0].comment).toBe('/** @name bar */');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fire "symbolFound" events when a source file contains named symbols', () => {
|
it('should fire "symbolFound" events when a source file contains named symbols', () => {
|
||||||
@ -185,7 +179,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
e.doclet.foo = 'bar';
|
e.doclet.foo = 'bar';
|
||||||
}
|
}
|
||||||
|
|
||||||
jsdoc.src.handlers.attachTo(parser);
|
attachTo(parser);
|
||||||
parser.on('newDoclet', handler).parse(sourceCode);
|
parser.on('newDoclet', handler).parse(sourceCode);
|
||||||
results = parser.results();
|
results = parser.results();
|
||||||
|
|
||||||
@ -205,7 +199,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
jsdoc.src.handlers.attachTo(parser);
|
attachTo(parser);
|
||||||
parser.addAstNodeVisitor(visitor);
|
parser.addAstNodeVisitor(visitor);
|
||||||
parser.parse(sourceCode);
|
parser.parse(sourceCode);
|
||||||
|
|
||||||
@ -225,7 +219,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
|
|
||||||
// args[2]: parser
|
// args[2]: parser
|
||||||
expect(typeof args[2]).toBe('object');
|
expect(typeof args[2]).toBe('object');
|
||||||
expect(args[2] instanceof jsdoc.src.parser.Parser).toBe(true);
|
expect(args[2] instanceof jsdocParser.Parser).toBe(true);
|
||||||
|
|
||||||
// args[3]: current source name
|
// args[3]: current source name
|
||||||
expect( String(args[3]) ).toBe('[[string0]]');
|
expect( String(args[3]) ).toBe('[[string0]]');
|
||||||
@ -242,7 +236,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
jsdoc.src.handlers.attachTo(parser);
|
attachTo(parser);
|
||||||
parser.addAstNodeVisitor(visitor);
|
parser.addAstNodeVisitor(visitor);
|
||||||
parser.parse(sourceCode);
|
parser.parse(sourceCode);
|
||||||
|
|
||||||
@ -259,12 +253,12 @@ describe('jsdoc/src/parser', () => {
|
|||||||
const spy = jasmine.createSpy();
|
const spy = jasmine.createSpy();
|
||||||
const sourceCode = ['javascript:/** @class */function Foo() {}'];
|
const sourceCode = ['javascript:/** @class */function Foo() {}'];
|
||||||
|
|
||||||
jsdoc.src.handlers.attachTo(parser);
|
attachTo(parser);
|
||||||
parser.on('parseComplete', spy).parse(sourceCode);
|
parser.on('parseComplete', spy).parse(sourceCode);
|
||||||
|
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
|
|
||||||
eventObject = spy.mostRecentCall.args[0];
|
eventObject = spy.calls.mostRecent().args[0];
|
||||||
expect(eventObject).toBeDefined();
|
expect(eventObject).toBeDefined();
|
||||||
expect( Array.isArray(eventObject.sourcefiles) ).toBe(true);
|
expect( Array.isArray(eventObject.sourcefiles) ).toBe(true);
|
||||||
expect(eventObject.sourcefiles.length).toBe(1);
|
expect(eventObject.sourcefiles.length).toBe(1);
|
||||||
@ -282,15 +276,15 @@ describe('jsdoc/src/parser', () => {
|
|||||||
parser.on('processingComplete', spy).fireProcessingComplete(doclets);
|
parser.on('processingComplete', spy).fireProcessingComplete(doclets);
|
||||||
|
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
expect(typeof spy.mostRecentCall.args[0]).toBe('object');
|
expect(typeof spy.calls.mostRecent().args[0]).toBe('object');
|
||||||
expect(spy.mostRecentCall.args[0].doclets).toBeDefined();
|
expect(spy.calls.mostRecent().args[0].doclets).toBeDefined();
|
||||||
expect(spy.mostRecentCall.args[0].doclets).toBe(doclets);
|
expect(spy.calls.mostRecent().args[0].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', () => {
|
||||||
function parse() {
|
function parse() {
|
||||||
const parserSrc = `javascript:${fs.readFileSync(
|
const parserSrc = `javascript:${fs.readFileSync(
|
||||||
path.join(jsdoc.env.dirname, 'test/fixtures/es6.js'), 'utf8')}`;
|
path.join(dirname, 'test/fixtures/es6.js'), 'utf8')}`;
|
||||||
|
|
||||||
parser.parse(parserSrc);
|
parser.parse(parserSrc);
|
||||||
}
|
}
|
||||||
@ -299,8 +293,8 @@ describe('jsdoc/src/parser', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to parse its own source file', () => {
|
it('should be able to parse its own source file', () => {
|
||||||
const parserSrc = `javascript:${fs.readFileSync(path.join(jsdoc.env.dirname,
|
const parserSrc = `javascript:${fs.readFileSync(path.join(dirname,
|
||||||
'lib/jsdoc/src/parser.js'), 'utf8')}`;
|
'lib/jsdoc/src/parser.js'), 'utf8')}`;
|
||||||
|
|
||||||
function parse() {
|
function parse() {
|
||||||
parser.parse(parserSrc);
|
parser.parse(parserSrc);
|
||||||
@ -335,7 +329,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
const source = 'javascript:var foo;';
|
const source = 'javascript:var foo;';
|
||||||
let results;
|
let results;
|
||||||
|
|
||||||
jsdoc.src.handlers.attachTo(parser);
|
attachTo(parser);
|
||||||
|
|
||||||
parser.parse(source);
|
parser.parse(source);
|
||||||
results = parser.results();
|
results = parser.results();
|
||||||
@ -355,7 +349,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
parser.on('jsdocCommentFound', e => {
|
parser.on('jsdocCommentFound', e => {
|
||||||
e.comment = e.comment.replace('replaceme', 'REPLACED!');
|
e.comment = e.comment.replace('replaceme', 'REPLACED!');
|
||||||
});
|
});
|
||||||
jsdoc.src.handlers.attachTo(parser);
|
attachTo(parser);
|
||||||
|
|
||||||
parser.parse(source);
|
parser.parse(source);
|
||||||
parser.results().forEach(({comment}) => {
|
parser.results().forEach(({comment}) => {
|
||||||
@ -371,7 +365,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
jsdocCommentFound: [],
|
jsdocCommentFound: [],
|
||||||
symbolFound: []
|
symbolFound: []
|
||||||
};
|
};
|
||||||
const source = fs.readFileSync(path.join(jsdoc.env.dirname,
|
const source = fs.readFileSync(path.join(dirname,
|
||||||
'test/fixtures/eventorder.js'), 'utf8');
|
'test/fixtures/eventorder.js'), 'utf8');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -395,7 +389,7 @@ describe('jsdoc/src/parser', () => {
|
|||||||
|
|
||||||
it('should fire interleaved jsdocCommentFound and symbolFound events, ' +
|
it('should fire interleaved jsdocCommentFound and symbolFound events, ' +
|
||||||
'in source order', () => {
|
'in source order', () => {
|
||||||
jsdoc.src.handlers.attachTo(parser);
|
attachTo(parser);
|
||||||
parser.parse(source);
|
parser.parse(source);
|
||||||
events.all.slice(0).sort(sourceOrderSort).forEach((e, i) => {
|
events.all.slice(0).sort(sourceOrderSort).forEach((e, i) => {
|
||||||
expect(e).toBe(events.all[i]);
|
expect(e).toBe(events.all[i]);
|
||||||
|
|||||||
@ -1,14 +1,10 @@
|
|||||||
describe('jsdoc/src/visitor', () => {
|
describe('jsdoc/src/visitor', () => {
|
||||||
// TODO: more tests
|
// TODO: more tests
|
||||||
|
|
||||||
const jsdoc = {
|
const { Parser } = require('jsdoc/src/parser');
|
||||||
src: {
|
const { Visitor } = require('jsdoc/src/visitor');
|
||||||
parser: require('jsdoc/src/parser'),
|
const parser = new Parser();
|
||||||
visitor: require('jsdoc/src/visitor')
|
const visitor = new Visitor();
|
||||||
}
|
|
||||||
};
|
|
||||||
const parser = new jsdoc.src.parser.Parser();
|
|
||||||
const visitor = new jsdoc.src.visitor.Visitor();
|
|
||||||
|
|
||||||
describe('visitNodeComments', () => {
|
describe('visitNodeComments', () => {
|
||||||
// TODO: more tests
|
// TODO: more tests
|
||||||
|
|||||||
@ -1,22 +1,20 @@
|
|||||||
const hasOwnProp = Object.prototype.hasOwnProperty;
|
const hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
|
|
||||||
describe('jsdoc/tag', () => {
|
describe('jsdoc/tag', () => {
|
||||||
const jsdoc = {
|
const env = require('jsdoc/env');
|
||||||
env: require('jsdoc/env'),
|
const jsdocDictionary = require('jsdoc/tag/dictionary');
|
||||||
tag: require('jsdoc/tag'),
|
const jsdocTag = require('jsdoc/tag');
|
||||||
dictionary: require('jsdoc/tag/dictionary'),
|
|
||||||
type: require('jsdoc/tag/type')
|
|
||||||
};
|
|
||||||
const logger = require('jsdoc/util/logger');
|
const logger = require('jsdoc/util/logger');
|
||||||
|
const parseType = require('jsdoc/tag/type').parse;
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(jsdoc.tag).toBeDefined();
|
expect(jsdocTag).toBeDefined();
|
||||||
expect(typeof jsdoc.tag).toBe('object');
|
expect(typeof jsdocTag).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a Tag function', () => {
|
it('should export a Tag function', () => {
|
||||||
expect(jsdoc.tag.Tag).toBeDefined();
|
expect(jsdocTag.Tag).toBeDefined();
|
||||||
expect(typeof jsdoc.tag.Tag).toBe('function');
|
expect(typeof jsdocTag.Tag).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Tag', () => {
|
describe('Tag', () => {
|
||||||
@ -50,17 +48,17 @@ describe('jsdoc/tag', () => {
|
|||||||
// allow each test to recreate the tags (for example, after enabling debug mode)
|
// allow each test to recreate the tags (for example, after enabling debug mode)
|
||||||
function createTags() {
|
function createTags() {
|
||||||
// synonym for @param; space in the title
|
// synonym for @param; space in the title
|
||||||
tagArg = new jsdoc.tag.Tag('arg ', text, meta);
|
tagArg = new jsdocTag.Tag('arg ', text, meta);
|
||||||
// @param with no type, but with optional and defaultvalue
|
// @param with no type, but with optional and defaultvalue
|
||||||
tagParam = new jsdoc.tag.Tag('param', '[foo=1]', meta);
|
tagParam = new jsdocTag.Tag('param', '[foo=1]', meta);
|
||||||
// @param with type and no type modifiers (such as optional)
|
// @param with type and no type modifiers (such as optional)
|
||||||
tagParamWithType = new jsdoc.tag.Tag('param', '{string} foo', meta);
|
tagParamWithType = new jsdocTag.Tag('param', '{string} foo', meta);
|
||||||
// @example that does not need indentation to be removed
|
// @example that does not need indentation to be removed
|
||||||
tagExample = new jsdoc.tag.Tag('example', textExample, meta);
|
tagExample = new jsdocTag.Tag('example', textExample, meta);
|
||||||
// @example that needs indentation to be removed
|
// @example that needs indentation to be removed
|
||||||
tagExampleIndented = new jsdoc.tag.Tag('example', textExampleIndented, meta);
|
tagExampleIndented = new jsdocTag.Tag('example', textExampleIndented, meta);
|
||||||
// for testing that onTagText is run when necessary
|
// for testing that onTagText is run when necessary
|
||||||
tagType = new jsdoc.tag.Tag('type', 'MyType ', meta);
|
tagType = new jsdocTag.Tag('type', 'MyType ', meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -82,9 +80,9 @@ describe('jsdoc/tag', () => {
|
|||||||
expect(typeof tagArg.title).toBe('string');
|
expect(typeof tagArg.title).toBe('string');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'title' property should be the normalised tag title", () => {
|
it("'title' property should be the normalized tag title", () => {
|
||||||
expect(tagArg.title).toBe(jsdoc.dictionary.normalise(tagArg.originalTitle));
|
expect(tagArg.title).toBe(jsdocDictionary.normalize(tagArg.originalTitle));
|
||||||
expect(tagExample.title).toBe(jsdoc.dictionary.normalise(tagExample.originalTitle));
|
expect(tagExample.title).toBe(jsdocDictionary.normalize(tagExample.originalTitle));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a 'text' property, a string", () => {
|
it("should have a 'text' property, a string", () => {
|
||||||
@ -108,7 +106,7 @@ 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 = jsdoc.dictionary.lookUp('type');
|
const def = jsdocDictionary.lookUp('type');
|
||||||
|
|
||||||
expect(def.onTagText).toBeDefined();
|
expect(def.onTagText).toBeDefined();
|
||||||
expect(typeof def.onTagText).toBe('function');
|
expect(typeof def.onTagText).toBe('function');
|
||||||
@ -126,10 +124,10 @@ describe('jsdoc/tag', () => {
|
|||||||
|
|
||||||
spyOn(logger, 'error');
|
spyOn(logger, 'error');
|
||||||
|
|
||||||
wsOnly = new jsdoc.tag.Tag('name', ' ', { code: { name: ' ' } });
|
wsOnly = new jsdocTag.Tag('name', ' ', { code: { name: ' ' } });
|
||||||
wsLeading = new jsdoc.tag.Tag('name', ' foo', { code: { name: ' foo' } });
|
wsLeading = new jsdocTag.Tag('name', ' foo', { code: { name: ' foo' } });
|
||||||
wsTrailing = new jsdoc.tag.Tag('name', 'foo ', { code: { name: 'foo ' } });
|
wsTrailing = new jsdocTag.Tag('name', 'foo ', { code: { name: 'foo ' } });
|
||||||
wsBoth = new jsdoc.tag.Tag('name', ' foo ', { code: { name: ' foo ' } });
|
wsBoth = new jsdocTag.Tag('name', ' foo ', { code: { name: ' foo ' } });
|
||||||
|
|
||||||
expect(logger.error).not.toHaveBeenCalled();
|
expect(logger.error).not.toHaveBeenCalled();
|
||||||
expect(wsOnly.text).toBe('" "');
|
expect(wsOnly.text).toBe('" "');
|
||||||
@ -156,10 +154,10 @@ describe('jsdoc/tag', () => {
|
|||||||
let descriptor;
|
let descriptor;
|
||||||
let info;
|
let info;
|
||||||
|
|
||||||
def = jsdoc.dictionary.lookUp(tag.title);
|
def = jsdocDictionary.lookUp(tag.title);
|
||||||
expect(def).not.toBe(false);
|
expect(def).not.toBe(false);
|
||||||
|
|
||||||
info = jsdoc.type.parse(tag.text, def.canHaveName, def.canHaveType);
|
info = parseType(tag.text, def.canHaveName, def.canHaveType);
|
||||||
|
|
||||||
['optional', 'nullable', 'variable', 'defaultvalue'].forEach(prop => {
|
['optional', 'nullable', 'variable', 'defaultvalue'].forEach(prop => {
|
||||||
if (hasOwnProp.call(info, prop)) {
|
if (hasOwnProp.call(info, prop)) {
|
||||||
@ -177,16 +175,16 @@ describe('jsdoc/tag', () => {
|
|||||||
expect(typeof tag.value.type.parsedType).toBe('object');
|
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(jsdoc.env.opts.debug) );
|
expect(descriptor.enumerable).toBe( Boolean(env.opts.debug) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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(jsdoc.env.opts.debug);
|
const debug = Boolean(env.opts.debug);
|
||||||
|
|
||||||
[true, false].forEach(bool => {
|
[true, false].forEach(bool => {
|
||||||
jsdoc.env.opts.debug = bool;
|
env.opts.debug = bool;
|
||||||
createTags();
|
createTags();
|
||||||
|
|
||||||
verifyTagType(tagType);
|
verifyTagType(tagType);
|
||||||
@ -194,7 +192,7 @@ describe('jsdoc/tag', () => {
|
|||||||
verifyTagType(tagParam);
|
verifyTagType(tagParam);
|
||||||
});
|
});
|
||||||
|
|
||||||
jsdoc.env.opts.debug = debug;
|
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', () => {
|
||||||
@ -226,7 +224,7 @@ describe('jsdoc/tag', () => {
|
|||||||
|
|
||||||
it('logs an error for tags with bad type expressions', () => {
|
it('logs an error for tags with bad type expressions', () => {
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
const tag = new jsdoc.tag.Tag('param', '{!*!*!*!} foo');
|
const tag = new jsdocTag.Tag('param', '{!*!*!*!} foo');
|
||||||
/* eslint-enable no-unused-vars */
|
/* eslint-enable no-unused-vars */
|
||||||
|
|
||||||
expect(logger.error).toHaveBeenCalled();
|
expect(logger.error).toHaveBeenCalled();
|
||||||
@ -234,7 +232,7 @@ describe('jsdoc/tag', () => {
|
|||||||
|
|
||||||
it('validates tags with no text', () => {
|
it('validates tags with no text', () => {
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
const tag = new jsdoc.tag.Tag('copyright');
|
const tag = new jsdocTag.Tag('copyright');
|
||||||
/* eslint-enable no-unused-vars */
|
/* eslint-enable no-unused-vars */
|
||||||
|
|
||||||
expect(logger.error).toHaveBeenCalled();
|
expect(logger.error).toHaveBeenCalled();
|
||||||
|
|||||||
@ -1,32 +1,28 @@
|
|||||||
describe('jsdoc/tag/inline', () => {
|
describe('jsdoc/tag/inline', () => {
|
||||||
const jsdoc = {
|
const inline = require('jsdoc/tag/inline');
|
||||||
tag: {
|
|
||||||
inline: require('jsdoc/tag/inline')
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(jsdoc.tag.inline).toBeDefined();
|
expect(inline).toBeDefined();
|
||||||
expect(typeof jsdoc.tag.inline).toBe('object');
|
expect(typeof inline).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an isInlineTag function', () => {
|
it('should export an isInlineTag function', () => {
|
||||||
expect(jsdoc.tag.inline.isInlineTag).toBeDefined();
|
expect(inline.isInlineTag).toBeDefined();
|
||||||
expect(typeof jsdoc.tag.inline.isInlineTag).toBe('function');
|
expect(typeof inline.isInlineTag).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a replaceInlineTag function', () => {
|
it('should export a replaceInlineTag function', () => {
|
||||||
expect(jsdoc.tag.inline.replaceInlineTag).toBeDefined();
|
expect(inline.replaceInlineTag).toBeDefined();
|
||||||
expect(typeof jsdoc.tag.inline.replaceInlineTag).toBe('function');
|
expect(typeof inline.replaceInlineTag).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export an extractInlineTag function', () => {
|
it('should export an extractInlineTag function', () => {
|
||||||
expect(jsdoc.tag.inline.extractInlineTag).toBeDefined();
|
expect(inline.extractInlineTag).toBeDefined();
|
||||||
expect(typeof jsdoc.tag.inline.replaceInlineTag).toBe('function');
|
expect(typeof inline.replaceInlineTag).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isInlineTag', () => {
|
describe('isInlineTag', () => {
|
||||||
const isInlineTag = jsdoc.tag.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') ).toBe(true);
|
||||||
@ -65,11 +61,11 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
describe('replaceInlineTag', () => {
|
describe('replaceInlineTag', () => {
|
||||||
it('should throw if the tag is matched and the replacer is invalid', () => {
|
it('should throw if the tag is matched and the replacer is invalid', () => {
|
||||||
function badReplacerUndefined() {
|
function badReplacerUndefined() {
|
||||||
jsdoc.tag.inline.replaceInlineTag('{@foo tag}', 'foo');
|
inline.replaceInlineTag('{@foo tag}', 'foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
function badReplacerString() {
|
function badReplacerString() {
|
||||||
jsdoc.tag.inline.replaceInlineTag('{@foo tag}', 'foo', 'hello');
|
inline.replaceInlineTag('{@foo tag}', 'foo', 'hello');
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(badReplacerUndefined).toThrow();
|
expect(badReplacerUndefined).toThrow();
|
||||||
@ -79,7 +75,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
it('should not find anything if there is no text in braces', () => {
|
it('should not find anything if there is no text in braces', () => {
|
||||||
const replacer = jasmine.createSpy('replacer');
|
const replacer = jasmine.createSpy('replacer');
|
||||||
|
|
||||||
jsdoc.tag.inline.replaceInlineTag('braceless text', 'foo', replacer);
|
inline.replaceInlineTag('braceless text', 'foo', replacer);
|
||||||
|
|
||||||
expect(replacer).not.toHaveBeenCalled();
|
expect(replacer).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -87,7 +83,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
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 replacer = jasmine.createSpy('replacer');
|
const replacer = jasmine.createSpy('replacer');
|
||||||
|
|
||||||
jsdoc.tag.inline.replaceInlineTag('bad {@foo escapement \\', 'foo', replacer);
|
inline.replaceInlineTag('bad {@foo escapement \\', 'foo', replacer);
|
||||||
|
|
||||||
expect(replacer).not.toHaveBeenCalled();
|
expect(replacer).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -101,7 +97,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
return completeTag;
|
return completeTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = jsdoc.tag.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]).toBeDefined();
|
||||||
@ -120,7 +116,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = jsdoc.tag.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]).toBeDefined();
|
||||||
@ -139,7 +135,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = jsdoc.tag.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]).toBeDefined();
|
||||||
@ -158,7 +154,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = jsdoc.tag.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]).toBeDefined();
|
||||||
expect(typeof result.tags[0]).toBe('object');
|
expect(typeof result.tags[0]).toBe('object');
|
||||||
@ -172,7 +168,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
return 'REPLACED!';
|
return 'REPLACED!';
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = jsdoc.tag.inline.replaceInlineTag('a {@foo test string}', 'foo', replacer);
|
const result = inline.replaceInlineTag('a {@foo test string}', 'foo', replacer);
|
||||||
|
|
||||||
expect(result.newString).toBe('REPLACED!');
|
expect(result.newString).toBe('REPLACED!');
|
||||||
});
|
});
|
||||||
@ -182,7 +178,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
return string.replace(completeTag, 'stuff');
|
return string.replace(completeTag, 'stuff');
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = jsdoc.tag.inline.replaceInlineTag('some {@foo text} with multiple ' +
|
const result = inline.replaceInlineTag('some {@foo text} with multiple ' +
|
||||||
'{@foo tags}, {@foo like} {@foo this}', 'foo', replacer);
|
'{@foo tags}, {@foo like} {@foo this}', 'foo', replacer);
|
||||||
|
|
||||||
expect(result.tags.length).toBe(4);
|
expect(result.tags.length).toBe(4);
|
||||||
@ -216,7 +212,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
it('should work with an empty replacer object', () => {
|
it('should work with an empty replacer object', () => {
|
||||||
const replacers = {};
|
const replacers = {};
|
||||||
const text = 'some {@foo text} to parse';
|
const text = 'some {@foo text} to parse';
|
||||||
const result = jsdoc.tag.inline.replaceInlineTags(text, replacers);
|
const result = inline.replaceInlineTags(text, replacers);
|
||||||
|
|
||||||
expect(result.newString).toBe(text);
|
expect(result.newString).toBe(text);
|
||||||
});
|
});
|
||||||
@ -231,7 +227,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
return string.replace(tagInfo.completeTag, 'stuff');
|
return string.replace(tagInfo.completeTag, 'stuff');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const result = jsdoc.tag.inline.replaceInlineTags(text, replacers);
|
const result = inline.replaceInlineTags(text, replacers);
|
||||||
|
|
||||||
expect(result.newString).toBe('some stuff with {@bar multiple} tags');
|
expect(result.newString).toBe('some stuff with {@bar multiple} tags');
|
||||||
});
|
});
|
||||||
@ -252,7 +248,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
return string.replace(tagInfo.completeTag, 'awesome');
|
return string.replace(tagInfo.completeTag, 'awesome');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const result = jsdoc.tag.inline.replaceInlineTags(text, replacers);
|
const result = inline.replaceInlineTags(text, replacers);
|
||||||
|
|
||||||
expect(result.newString).toBe('some stuff with awesome tags');
|
expect(result.newString).toBe('some stuff with awesome tags');
|
||||||
});
|
});
|
||||||
@ -261,7 +257,7 @@ describe('jsdoc/tag/inline', () => {
|
|||||||
// largely covered by the replaceInlineTag tests
|
// largely covered by the replaceInlineTag tests
|
||||||
describe('extractInlineTag', () => {
|
describe('extractInlineTag', () => {
|
||||||
it('should work when a tag is specified', () => {
|
it('should work when a tag is specified', () => {
|
||||||
const result = jsdoc.tag.inline.extractInlineTag('some {@tagged text}', 'tagged');
|
const result = inline.extractInlineTag('some {@tagged text}', 'tagged');
|
||||||
|
|
||||||
expect(result.tags[0]).toBeDefined();
|
expect(result.tags[0]).toBeDefined();
|
||||||
expect(typeof result.tags[0]).toBe('object');
|
expect(typeof result.tags[0]).toBe('object');
|
||||||
|
|||||||
@ -23,25 +23,21 @@ function buildText(type, name, desc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('jsdoc/tag/type', () => {
|
describe('jsdoc/tag/type', () => {
|
||||||
const jsdoc = {
|
const type = require('jsdoc/tag/type');
|
||||||
tag: {
|
|
||||||
type: require('jsdoc/tag/type')
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should exist', () => {
|
it('should exist', () => {
|
||||||
expect(jsdoc.tag.type).toBeDefined();
|
expect(type).toBeDefined();
|
||||||
expect(typeof jsdoc.tag.type).toBe('object');
|
expect(typeof type).toBe('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export a parse function', () => {
|
it('should export a parse function', () => {
|
||||||
expect(jsdoc.tag.type.parse).toBeDefined();
|
expect(type.parse).toBeDefined();
|
||||||
expect(typeof jsdoc.tag.type.parse).toBe('function');
|
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 = jsdoc.tag.type.parse('');
|
const info = type.parse('');
|
||||||
|
|
||||||
expect(info.name).toBeDefined();
|
expect(info.name).toBeDefined();
|
||||||
expect(info.type).toBeDefined();
|
expect(info.type).toBeDefined();
|
||||||
@ -50,7 +46,7 @@ describe('jsdoc/tag/type', () => {
|
|||||||
|
|
||||||
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 = jsdoc.tag.type.parse(desc);
|
const info = type.parse(desc);
|
||||||
|
|
||||||
expect(info.type).toEqual([]);
|
expect(info.type).toEqual([]);
|
||||||
expect(info.name).toBe('');
|
expect(info.name).toBe('');
|
||||||
@ -60,7 +56,7 @@ describe('jsdoc/tag/type', () => {
|
|||||||
it('should extract a name, but not a type, if canHaveName === true and canHaveType === false', () => {
|
it('should extract a name, but not a type, if canHaveName === true and canHaveType === false', () => {
|
||||||
const name = 'bar';
|
const name = 'bar';
|
||||||
const desc = 'The bar parameter.';
|
const desc = 'The bar parameter.';
|
||||||
const info = jsdoc.tag.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).toEqual([]);
|
||||||
expect(info.name).toBe(name);
|
expect(info.name).toBe(name);
|
||||||
@ -68,77 +64,77 @@ describe('jsdoc/tag/type', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should extract a type, but not a name, if canHaveName === false and canHaveType === true', () => {
|
it('should extract a type, but not a name, if canHaveName === false and canHaveType === true', () => {
|
||||||
const type = 'boolean';
|
const typeString = 'boolean';
|
||||||
const desc = 'Set to true on alternate Thursdays.';
|
const desc = 'Set to true on alternate Thursdays.';
|
||||||
const info = jsdoc.tag.type.parse( buildText(type, null, desc), false, true );
|
const info = type.parse(buildText(typeString, null, desc), false, true);
|
||||||
|
|
||||||
expect(info.type).toEqual([type]);
|
expect(info.type).toEqual([typeString]);
|
||||||
expect(info.name).toBe('');
|
expect(info.name).toBe('');
|
||||||
expect(info.text).toBe(desc);
|
expect(info.text).toBe(desc);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should extract a name and type if canHaveName and canHaveType are true', () => {
|
it('should extract a name and type if canHaveName and canHaveType are true', () => {
|
||||||
const type = 'string';
|
const typeString = 'string';
|
||||||
const name = 'baz';
|
const name = 'baz';
|
||||||
const desc = 'The baz parameter.';
|
const desc = 'The baz parameter.';
|
||||||
const info = jsdoc.tag.type.parse( buildText(type, name, desc), true, true );
|
const info = type.parse(buildText(typeString, name, desc), true, true);
|
||||||
|
|
||||||
expect(info.type).toEqual([type]);
|
expect(info.type).toEqual([typeString]);
|
||||||
expect(info.name).toBe(name);
|
expect(info.name).toBe(name);
|
||||||
expect(info.text).toBe(desc);
|
expect(info.text).toBe(desc);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should report optional types correctly no matter which syntax we use', () => {
|
it('should report optional types correctly no matter which syntax we use', () => {
|
||||||
let desc = '{string} [foo]';
|
let desc = '{string} [foo]';
|
||||||
let info = jsdoc.tag.type.parse(desc, true, true);
|
let info = type.parse(desc, true, true);
|
||||||
|
|
||||||
expect(info.optional).toBe(true);
|
expect(info.optional).toBe(true);
|
||||||
|
|
||||||
desc = '{string=} [foo]';
|
desc = '{string=} [foo]';
|
||||||
info = jsdoc.tag.type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.optional).toBe(true);
|
expect(info.optional).toBe(true);
|
||||||
|
|
||||||
desc = '[foo]';
|
desc = '[foo]';
|
||||||
info = jsdoc.tag.type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.optional).toBe(true);
|
expect(info.optional).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the types as an array', () => {
|
it('should return the types as an array', () => {
|
||||||
const desc = '{string} foo';
|
const desc = '{string} foo';
|
||||||
const info = jsdoc.tag.type.parse(desc, true, true);
|
const info = type.parse(desc, true, true);
|
||||||
|
|
||||||
expect(info.type).toEqual( ['string'] );
|
expect(info.type).toEqual( ['string'] );
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should recognize the entire list of possible types', () => {
|
it('should recognize the entire list of possible types', () => {
|
||||||
let desc = '{(string|number)} foo';
|
let desc = '{(string|number)} foo';
|
||||||
let info = jsdoc.tag.type.parse(desc, true, true);
|
let info = type.parse(desc, true, true);
|
||||||
|
|
||||||
expect(info.type).toEqual( ['string', 'number'] );
|
expect(info.type).toEqual( ['string', 'number'] );
|
||||||
|
|
||||||
desc = '{ ( string | number ) } foo';
|
desc = '{ ( string | number ) } foo';
|
||||||
info = jsdoc.tag.type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.type).toEqual( ['string', 'number'] );
|
expect(info.type).toEqual( ['string', 'number'] );
|
||||||
|
|
||||||
desc = '{ ( string | number)} foo';
|
desc = '{ ( string | number)} foo';
|
||||||
info = jsdoc.tag.type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.type).toEqual( ['string', 'number'] );
|
expect(info.type).toEqual( ['string', 'number'] );
|
||||||
|
|
||||||
desc = '{(string|number|boolean|function)} foo';
|
desc = '{(string|number|boolean|function)} foo';
|
||||||
info = jsdoc.tag.type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.type).toEqual( ['string', 'number', 'boolean', 'function'] );
|
expect(info.type).toEqual( ['string', 'number', 'boolean', 'function'] );
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not find any type if there is no text in braces', () => {
|
it('should not find any type if there is no text in braces', () => {
|
||||||
const desc = 'braceless text';
|
const desc = 'braceless text';
|
||||||
const info = jsdoc.tag.type.parse(desc, false, true);
|
const info = type.parse(desc, false, true);
|
||||||
|
|
||||||
expect(info.type).toEqual([]);
|
expect(info.type).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
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 = jsdoc.tag.type.parse(desc, false, true);
|
const info = type.parse(desc, false, true);
|
||||||
|
|
||||||
expect(info.type).toEqual([]);
|
expect(info.type).toEqual([]);
|
||||||
expect(info.text).toBe(desc);
|
expect(info.text).toBe(desc);
|
||||||
@ -146,21 +142,21 @@ describe('jsdoc/tag/type', () => {
|
|||||||
|
|
||||||
it('should handle escaped braces correctly', () => {
|
it('should handle escaped braces correctly', () => {
|
||||||
const desc = '{weirdObject."with\\}AnnoyingProperty"}';
|
const desc = '{weirdObject."with\\}AnnoyingProperty"}';
|
||||||
const info = jsdoc.tag.type.parse(desc, false, true);
|
const info = type.parse(desc, false, true);
|
||||||
|
|
||||||
expect(info.type[0]).toBe('weirdObject."with}AnnoyingProperty"');
|
expect(info.type[0]).toBe('weirdObject."with}AnnoyingProperty"');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work if the type expression is the entire string', () => {
|
it('should work if the type expression is the entire string', () => {
|
||||||
const desc = '{textInBraces}';
|
const desc = '{textInBraces}';
|
||||||
const info = jsdoc.tag.type.parse(desc, false, true);
|
const info = type.parse(desc, false, true);
|
||||||
|
|
||||||
expect(info.type[0]).toBe('textInBraces');
|
expect(info.type[0]).toBe('textInBraces');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work if the type expression is at the beginning of the string', () => {
|
it('should work if the type expression is at the beginning of the string', () => {
|
||||||
const desc = '{testString} ahoy';
|
const desc = '{testString} ahoy';
|
||||||
const info = jsdoc.tag.type.parse(desc, false, true);
|
const info = type.parse(desc, false, true);
|
||||||
|
|
||||||
expect(info.type[0]).toBe('testString');
|
expect(info.type[0]).toBe('testString');
|
||||||
expect(info.text).toBe('ahoy');
|
expect(info.text).toBe('ahoy');
|
||||||
@ -168,7 +164,7 @@ describe('jsdoc/tag/type', () => {
|
|||||||
|
|
||||||
it('should work if the type expression is in the middle of the string', () => {
|
it('should work if the type expression is in the middle of the string', () => {
|
||||||
const desc = 'a {testString} yay';
|
const desc = 'a {testString} yay';
|
||||||
const info = jsdoc.tag.type.parse(desc, false, true);
|
const info = type.parse(desc, false, true);
|
||||||
|
|
||||||
expect(info.type[0]).toBe('testString');
|
expect(info.type[0]).toBe('testString');
|
||||||
expect(info.text).toBe('a yay');
|
expect(info.text).toBe('a yay');
|
||||||
@ -176,7 +172,7 @@ describe('jsdoc/tag/type', () => {
|
|||||||
|
|
||||||
it('should work if the tag is at the end of the string', () => {
|
it('should work if the tag is at the end of the string', () => {
|
||||||
const desc = 'a {testString}';
|
const desc = 'a {testString}';
|
||||||
const info = jsdoc.tag.type.parse(desc, false, true);
|
const info = type.parse(desc, false, true);
|
||||||
|
|
||||||
expect(info.type[0]).toBe('testString');
|
expect(info.type[0]).toBe('testString');
|
||||||
expect(info.text).toBe('a');
|
expect(info.text).toBe('a');
|
||||||
@ -184,7 +180,7 @@ describe('jsdoc/tag/type', () => {
|
|||||||
|
|
||||||
it('should work when there are nested braces', () => {
|
it('should work when there are nested braces', () => {
|
||||||
const desc = 'some {{double}} braces';
|
const desc = 'some {{double}} braces';
|
||||||
const info = jsdoc.tag.type.parse(desc, false, true);
|
const info = type.parse(desc, false, true);
|
||||||
|
|
||||||
// we currently stringify all record types as 'Object'
|
// we currently stringify all record types as 'Object'
|
||||||
expect(info.type[0]).toBe('Object');
|
expect(info.type[0]).toBe('Object');
|
||||||
@ -193,28 +189,28 @@ describe('jsdoc/tag/type', () => {
|
|||||||
|
|
||||||
it('should override the type expression if an inline @type tag is specified', () => {
|
it('should override the type expression if an inline @type tag is specified', () => {
|
||||||
let desc = '{Object} cookie {@type Monster}';
|
let desc = '{Object} cookie {@type Monster}';
|
||||||
let info = jsdoc.tag.type.parse(desc, true, true);
|
let info = type.parse(desc, true, true);
|
||||||
|
|
||||||
expect(info.type).toEqual( ['Monster'] );
|
expect(info.type).toEqual( ['Monster'] );
|
||||||
expect(info.text).toBe('');
|
expect(info.text).toBe('');
|
||||||
|
|
||||||
desc = '{Object} cookie - {@type Monster}';
|
desc = '{Object} cookie - {@type Monster}';
|
||||||
info = jsdoc.tag.type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.type).toEqual( ['Monster'] );
|
expect(info.type).toEqual( ['Monster'] );
|
||||||
expect(info.text).toBe('');
|
expect(info.text).toBe('');
|
||||||
|
|
||||||
desc = '{Object} cookie - The cookie parameter. {@type Monster}';
|
desc = '{Object} cookie - The cookie parameter. {@type Monster}';
|
||||||
info = jsdoc.tag.type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.type).toEqual( ['Monster'] );
|
expect(info.type).toEqual( ['Monster'] );
|
||||||
expect(info.text).toBe('The cookie parameter.');
|
expect(info.text).toBe('The cookie parameter.');
|
||||||
|
|
||||||
desc = '{Object} cookie - The cookie parameter. {@type (Monster|Jar)}';
|
desc = '{Object} cookie - The cookie parameter. {@type (Monster|Jar)}';
|
||||||
info = jsdoc.tag.type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.type).toEqual( ['Monster', 'Jar'] );
|
expect(info.type).toEqual( ['Monster', 'Jar'] );
|
||||||
expect(info.text).toBe('The cookie parameter.');
|
expect(info.text).toBe('The cookie parameter.');
|
||||||
|
|
||||||
desc = '{Object} cookie - The cookie parameter. {@type (Monster|Jar)} Mmm, cookie.';
|
desc = '{Object} cookie - The cookie parameter. {@type (Monster|Jar)} Mmm, cookie.';
|
||||||
info = jsdoc.tag.type.parse(desc, true, true);
|
info = type.parse(desc, true, true);
|
||||||
expect(info.type).toEqual( ['Monster', 'Jar'] );
|
expect(info.type).toEqual( ['Monster', 'Jar'] );
|
||||||
expect(info.text).toBe('The cookie parameter. Mmm, cookie.');
|
expect(info.text).toBe('The cookie parameter. Mmm, cookie.');
|
||||||
});
|
});
|
||||||
@ -223,27 +219,27 @@ describe('jsdoc/tag/type', () => {
|
|||||||
it('should parse JSDoc-style optional parameters', () => {
|
it('should parse JSDoc-style optional parameters', () => {
|
||||||
let name = '[qux]';
|
let name = '[qux]';
|
||||||
const desc = 'The qux parameter.';
|
const desc = 'The qux parameter.';
|
||||||
let info = jsdoc.tag.type.parse( buildText(null, name, desc), true, false );
|
let 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).toBe(true);
|
||||||
|
|
||||||
name = '[ qux ]';
|
name = '[ qux ]';
|
||||||
info = jsdoc.tag.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).toBe(true);
|
||||||
|
|
||||||
name = '[qux=hooray]';
|
name = '[qux=hooray]';
|
||||||
info = jsdoc.tag.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).toBe(true);
|
||||||
expect(info.defaultvalue).toBe('hooray');
|
expect(info.defaultvalue).toBe('hooray');
|
||||||
|
|
||||||
name = '[ qux = hooray ]';
|
name = '[ qux = hooray ]';
|
||||||
info = jsdoc.tag.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).toBe(true);
|
||||||
@ -255,7 +251,7 @@ describe('jsdoc/tag/type', () => {
|
|||||||
describe('Closure Compiler-style type info', () => {
|
describe('Closure Compiler-style type info', () => {
|
||||||
it('should recognize variable (repeatable) parameters', () => {
|
it('should recognize variable (repeatable) parameters', () => {
|
||||||
const desc = '{...string} foo - Foo.';
|
const desc = '{...string} foo - Foo.';
|
||||||
const info = jsdoc.tag.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).toBe(true);
|
||||||
@ -264,7 +260,7 @@ describe('jsdoc/tag/type', () => {
|
|||||||
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',
|
||||||
() => {
|
() => {
|
||||||
const desc = '{Array.<(string|number)>} foo - Foo.';
|
const desc = '{Array.<(string|number)>} foo - Foo.';
|
||||||
const info = jsdoc.tag.type.parse(desc, true, true);
|
const info = type.parse(desc, true, true);
|
||||||
|
|
||||||
expect(info.type).toEqual(['Array.<(string|number)>']);
|
expect(info.type).toEqual(['Array.<(string|number)>']);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -21,6 +21,7 @@ describe('jsdoc/tag/validator', () => {
|
|||||||
const allowUnknown = Boolean(env.conf.tags.allowUnknownTags);
|
const allowUnknown = Boolean(env.conf.tags.allowUnknownTags);
|
||||||
const badTag = { title: 'lkjasdlkjfb' };
|
const badTag = { title: 'lkjasdlkjfb' };
|
||||||
const badTag2 = new tag.Tag('type', '{string} I am a string!');
|
const badTag2 = new tag.Tag('type', '{string} I am a string!');
|
||||||
|
let errorSpy;
|
||||||
const meta = {
|
const meta = {
|
||||||
filename: 'asdf.js',
|
filename: 'asdf.js',
|
||||||
lineno: 1,
|
lineno: 1,
|
||||||
@ -34,7 +35,7 @@ describe('jsdoc/tag/validator', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(logger, 'error');
|
errorSpy = spyOn(logger, 'error');
|
||||||
spyOn(logger, 'warn');
|
spyOn(logger, 'warn');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -106,7 +107,7 @@ describe('jsdoc/tag/validator', () => {
|
|||||||
env.conf.tags.allowUnknownTags = false;
|
env.conf.tags.allowUnknownTags = false;
|
||||||
validateTag(badTag);
|
validateTag(badTag);
|
||||||
|
|
||||||
expect(logger.error.mostRecentCall.args[0]).toContain(meta.comment);
|
expect(errorSpy.calls.mostRecent().args[0]).toContain(meta.comment);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -191,7 +191,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
|
|
||||||
describe("getUniqueFilename", () => {
|
describe("getUniqueFilename", () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jasmine.restoreTagDictionary();
|
jsdoc.restoreTagDictionary();
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: needs more tests for unusual values and things that get special treatment (such as
|
// TODO: needs more tests for unusual values and things that get special treatment (such as
|
||||||
@ -1111,7 +1111,7 @@ describe("jsdoc/util/templateHelper", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("addEventListeners", () => {
|
describe("addEventListeners", () => {
|
||||||
const doclets = ( taffy(doop(jasmine.getDocSetFromFile('test/fixtures/listenstag.js').doclets)) );
|
const doclets = ( taffy(doop(jsdoc.getDocSetFromFile('test/fixtures/listenstag.js').doclets)) );
|
||||||
const ev = helper.find(doclets, {longname: 'module:myModule.event:MyEvent'})[0];
|
const ev = helper.find(doclets, {longname: 'module:myModule.event:MyEvent'})[0];
|
||||||
const ev2 = helper.find(doclets, {longname: 'module:myModule~Events.event:Event2'})[0];
|
const ev2 = helper.find(doclets, {longname: 'module:myModule~Events.event:Event2'})[0];
|
||||||
const ev3 = helper.find(doclets, {longname: 'module:myModule#event:Event3'})[0];
|
const ev3 = helper.find(doclets, {longname: 'module:myModule#event:Event3'})[0];
|
||||||
|
|||||||
@ -11,13 +11,13 @@ describe('plugins', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// TODO: decouple this from the global parser
|
// TODO: decouple this from the global parser
|
||||||
app.jsdoc.parser = jasmine.createParser();
|
app.jsdoc.parser = jsdoc.createParser();
|
||||||
|
|
||||||
global.jsdocPluginsTest = global.jsdocPluginsTest || {};
|
global.jsdocPluginsTest = global.jsdocPluginsTest || {};
|
||||||
|
|
||||||
require('jsdoc/plugins').installPlugins(pluginPaths, app.jsdoc.parser);
|
require('jsdoc/plugins').installPlugins(pluginPaths, app.jsdoc.parser);
|
||||||
|
|
||||||
docSet = jasmine.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).toBeDefined();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('@abstract tag', () => {
|
describe('@abstract tag', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/abstracttag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/abstracttag.js');
|
||||||
const thingy = docSet.getByLongname('Thingy')[0];
|
const thingy = docSet.getByLongname('Thingy')[0];
|
||||||
const thingyPez = docSet.getByLongname('Thingy#pez')[0];
|
const thingyPez = docSet.getByLongname('Thingy#pez')[0];
|
||||||
const otherThingyPez = docSet.getByLongname('OtherThingy#pez')[0];
|
const otherThingyPez = docSet.getByLongname('OtherThingy#pez')[0];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('@access tag', () => {
|
describe('@access tag', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/accesstag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/accesstag.js');
|
||||||
const foo = docSet.getByLongname('Thingy~foo')[0];
|
const foo = docSet.getByLongname('Thingy~foo')[0];
|
||||||
const _bar = docSet.getByLongname('Thingy#_bar')[0];
|
const _bar = docSet.getByLongname('Thingy#_bar')[0];
|
||||||
const _gnu = docSet.getByLongname('Thingy#_gnu')[0];
|
const _gnu = docSet.getByLongname('Thingy#_gnu')[0];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('@alias tag', () => {
|
describe('@alias tag', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/alias.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias.js');
|
||||||
// there are two doclets with longname myObject, we want the second one
|
// there are two doclets with longname myObject, we want the second one
|
||||||
const myObject = docSet.getByLongname('myObject')[1];
|
const myObject = docSet.getByLongname('myObject')[1];
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('@async tag', () => {
|
describe('@async tag', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/asynctag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/asynctag.js');
|
||||||
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', () => {
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
describe('@augments tag', () => {
|
describe('@augments tag', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/augmentstag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/augmentstag.js');
|
||||||
const docSet2 = jasmine.getDocSetFromFile('test/fixtures/augmentstag2.js');
|
const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/augmentstag2.js');
|
||||||
const docSet3 = jasmine.getDocSetFromFile('test/fixtures/augmentstag3.js');
|
const docSet3 = jsdoc.getDocSetFromFile('test/fixtures/augmentstag3.js');
|
||||||
const docSet4 = jasmine.getDocSetFromFile('test/fixtures/augmentstag4.js');
|
const docSet4 = jsdoc.getDocSetFromFile('test/fixtures/augmentstag4.js');
|
||||||
const docSet5 = jasmine.getDocSetFromFile('test/fixtures/augmentstag5.js');
|
const docSet5 = jsdoc.getDocSetFromFile('test/fixtures/augmentstag5.js');
|
||||||
const docSet6 = jasmine.getDocSetFromFile('test/fixtures/augmentstag6.js');
|
const docSet6 = jsdoc.getDocSetFromFile('test/fixtures/augmentstag6.js');
|
||||||
|
|
||||||
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];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('@author tag', () => {
|
describe('@author tag', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/authortag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/authortag.js');
|
||||||
const Thingy = docSet.getByLongname('Thingy')[0];
|
const Thingy = docSet.getByLongname('Thingy')[0];
|
||||||
const Thingy2 = docSet.getByLongname('Thingy2')[0];
|
const Thingy2 = docSet.getByLongname('Thingy2')[0];
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ function filterUndocumented({undocumented}) {
|
|||||||
|
|
||||||
describe('@borrows tag', () => {
|
describe('@borrows tag', () => {
|
||||||
it('When a symbol has a @borrows-as tag, that is added to the symbol\'s "borrowed" property.', () => {
|
it('When a symbol has a @borrows-as tag, that is added to the symbol\'s "borrowed" property.', () => {
|
||||||
const docSet = jasmine.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.length).toBe(1);
|
||||||
@ -14,7 +14,7 @@ describe('@borrows tag', () => {
|
|||||||
|
|
||||||
it('When a symbol has a @borrows tag, the borrowed symbol is added to the symbol.', () => {
|
it('When a symbol has a @borrows tag, the borrowed symbol is added to the symbol.', () => {
|
||||||
const borrow = require('jsdoc/borrow');
|
const borrow = require('jsdoc/borrow');
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/borrowstag2.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/borrowstag2.js');
|
||||||
|
|
||||||
borrow.resolveBorrows(docSet.doclets);
|
borrow.resolveBorrows(docSet.doclets);
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ describe('@borrows tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
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 = jasmine.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.length).toBe(2);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('@classdesc tag', () => {
|
describe('@classdesc tag', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/classdesctag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/classdesctag.js');
|
||||||
const foo = docSet.getByLongname('Foo')[0];
|
const foo = docSet.getByLongname('Foo')[0];
|
||||||
const bar = docSet.getByLongname('Bar')[0];
|
const bar = docSet.getByLongname('Bar')[0];
|
||||||
const baz = docSet.getByLongname('Baz')[0];
|
const baz = docSet.getByLongname('Baz')[0];
|
||||||
|
|||||||
@ -3,7 +3,7 @@ function filter({undocumented}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('@class tag', () => {
|
describe('@class tag', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/classtag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/classtag.js');
|
||||||
const ticker = docSet.getByLongname('Ticker')[0];
|
const ticker = docSet.getByLongname('Ticker')[0];
|
||||||
const news = docSet.getByLongname('NewsSource')[0];
|
const news = docSet.getByLongname('NewsSource')[0];
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ describe('@class tag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('ES 2015 classes', () => {
|
describe('ES 2015 classes', () => {
|
||||||
const docSet2 = jasmine.getDocSetFromFile('test/fixtures/classtag2.js');
|
const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/classtag2.js');
|
||||||
const subscription = docSet2.getByLongname('Subscription').filter(filter)[0];
|
const subscription = docSet2.getByLongname('Subscription').filter(filter)[0];
|
||||||
const expire = docSet2.getByLongname('Subscription#expire')[0];
|
const expire = docSet2.getByLongname('Subscription#expire')[0];
|
||||||
const subscriber = docSet2.getByLongname('Subscriber').filter(filter)[0];
|
const subscriber = docSet2.getByLongname('Subscriber').filter(filter)[0];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
describe('@constant tag', () => {
|
describe('@constant tag', () => {
|
||||||
const docSet = jasmine.getDocSetFromFile('test/fixtures/constanttag.js');
|
const docSet = jsdoc.getDocSetFromFile('test/fixtures/constanttag.js');
|
||||||
const FOO = docSet.getByLongname('FOO')[0];
|
const FOO = docSet.getByLongname('FOO')[0];
|
||||||
const BAR = docSet.getByLongname('BAR')[0];
|
const BAR = docSet.getByLongname('BAR')[0];
|
||||||
const BAZ = docSet.getByLongname('BAZ')[0];
|
const BAZ = docSet.getByLongname('BAZ')[0];
|
||||||
|
|||||||
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