diff --git a/Apache_License_2.0.txt b/LICENSE similarity index 100% rename from Apache_License_2.0.txt rename to LICENSE diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 956400bd..00000000 --- a/LICENSE.md +++ /dev/null @@ -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 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 diff --git a/cli.js b/cli.js index 9ff63b20..0362b0bf 100644 --- a/cli.js +++ b/cli.js @@ -117,22 +117,26 @@ module.exports = (() => { cli.exit(1); } - if (env.opts.debug) { - logger.setLevel(logger.LEVELS.DEBUG); - } - else if (env.opts.verbose) { - logger.setLevel(logger.LEVELS.INFO); - } + if (env.opts.test) { + logger.setLevel(logger.LEVELS.SILENT); + } else { + if (env.opts.debug) { + logger.setLevel(logger.LEVELS.DEBUG); + } + else if (env.opts.verbose) { + logger.setLevel(logger.LEVELS.INFO); + } - if (env.opts.pedantic) { - logger.once('logger:warn', recoverableError); - logger.once('logger:error', fatalError); - } - else { - logger.once('logger:error', recoverableError); - } + if (env.opts.pedantic) { + logger.once('logger:warn', recoverableError); + logger.once('logger:error', fatalError); + } + else { + logger.once('logger:error', recoverableError); + } - logger.once('logger:fatal', fatalError); + logger.once('logger:fatal', fatalError); + } return cli; }; @@ -201,15 +205,7 @@ module.exports = (() => { }; // TODO: docs - cli.runTests = () => { - const path = require('jsdoc/path'); - - const runner = Promise.promisify(require( path.join(env.dirname, 'test/runner') )); - - console.log('Running tests...'); - - return runner(); - }; + cli.runTests = () => require('./test')(); // TODO: docs cli.getVersion = () => `JSDoc ${env.version.number} (${env.version.revision})`; diff --git a/jsdoc.js b/jsdoc.js index 95b10972..d316fe2c 100755 --- a/jsdoc.js +++ b/jsdoc.js @@ -64,13 +64,9 @@ global.app = (() => require('./lib/jsdoc/app'))(); } cli.setVersionInfo() - .loadConfig(); - - if (!env.opts.test) { - cli.configureLogger(); - } - - cli.logStart(); + .loadConfig() + .configureLogger() + .logStart(); if (env.opts.debug) { /** diff --git a/package-lock.json b/package-lock.json index 4b1e1e3a..00863bd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", @@ -677,6 +683,12 @@ "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": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", @@ -1004,6 +1016,23 @@ "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=", "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": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -2436,7 +2465,8 @@ "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true }, "gulp": { "version": "4.0.1", @@ -3036,6 +3066,36 @@ "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": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.10.0.tgz", @@ -3065,14 +3125,6 @@ "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": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -3109,12 +3161,13 @@ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "dev": true }, - "klaw": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", - "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", + "klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "dev": true, "requires": { - "graceful-fs": "^4.1.9" + "graceful-fs": "^4.1.11" } }, "last-run": { @@ -3230,6 +3283,21 @@ "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", "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": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", @@ -3533,6 +3601,15 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "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": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", @@ -3953,6 +4030,37 @@ "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": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz", @@ -4167,6 +4275,12 @@ "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": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -5475,6 +5589,15 @@ "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": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -5554,11 +5677,6 @@ "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": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", diff --git a/package.json b/package.json index 781a1b6c..91b917db 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,6 @@ "code-prettify": "^0.1.0", "color-themes-for-google-code-prettify": "^2.0.4", "escape-string-regexp": "^2.0.0", - "js2xmlparser": "^4.0.0", - "klaw": "^3.0.0", "lodash": "^4.17.11", "markdown-it": "^8.4.2", "markdown-it-anchor": "^5.0.2", @@ -36,6 +34,9 @@ "gulp": "^4.0.1", "gulp-eslint": "^5.0.0", "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" }, "engines": { diff --git a/plugins/test/specs/commentConvert.js b/plugins/test/specs/commentConvert.js index 583678c0..cd310ea8 100644 --- a/plugins/test/specs/commentConvert.js +++ b/plugins/test/specs/commentConvert.js @@ -1,20 +1,20 @@ -'use strict'; +/* global jsdoc */ -describe('commentConvert plugin', function() { - var env = require('jsdoc/env'); - var path = require('jsdoc/path'); +describe('commentConvert plugin', () => { + const env = require('jsdoc/env'); + const path = require('jsdoc/path'); - var docSet; - var parser = jasmine.createParser(); - var pluginPath = 'plugins/commentConvert'; - var pluginPathResolved = path.join(env.dirname, pluginPath); - var plugin = require(pluginPathResolved); + let docSet; + const parser = jsdoc.createParser(); + const pluginPath = 'plugins/commentConvert'; + const pluginPathResolved = path.join(env.dirname, pluginPath); 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); }); }); diff --git a/plugins/test/specs/escapeHtml.js b/plugins/test/specs/escapeHtml.js index d7497964..6f808535 100644 --- a/plugins/test/specs/escapeHtml.js +++ b/plugins/test/specs/escapeHtml.js @@ -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() { - var env = require('jsdoc/env'); - var path = require('jsdoc/path'); - - var docSet; - var parser = jasmine.createParser(); - var pluginPath = 'plugins/escapeHtml'; - var pluginPathResolved = path.join(env.dirname, pluginPath); + let docSet; + const parser = jsdoc.createParser(); + const pluginPath = 'plugins/escapeHtml'; + const pluginPathResolved = path.join(env.dirname, pluginPath); 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() { - var doclet = docSet.getByLongname('module:plugins/escapeHtml.handlers.newDoclet'); + it("should escape '&', '<' and newlines in doclet descriptions", () => { + 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'); }); }); diff --git a/plugins/test/specs/markdown.js b/plugins/test/specs/markdown.js index 8c8d74c0..1d58ddb2 100644 --- a/plugins/test/specs/markdown.js +++ b/plugins/test/specs/markdown.js @@ -1,19 +1,18 @@ -'use strict'; +/* global jsdoc */ +const env = require('jsdoc/env'); +const path = require('jsdoc/path'); -var env = require('jsdoc/env'); -var path = require('jsdoc/path'); +describe('markdown plugin', () => { + const pluginPath = 'plugins/markdown'; + const pluginPathResolved = path.join(env.dirname, pluginPath); + const plugin = require(pluginPathResolved); -describe('markdown plugin', function() { - var pluginPath = 'plugins/markdown'; - var pluginPathResolved = path.join(env.dirname, pluginPath); - var plugin = require(pluginPathResolved); - - var docSet = jasmine.getDocSetFromFile('plugins/test/fixtures/markdown.js'); + const docSet = jsdoc.getDocSetFromFile('plugins/test/fixtures/markdown.js'); // TODO: more tests; refactor the plugin so multiple settings can be tested - it('should process the correct tags by default', function() { - var myClass = docSet.getByLongname('MyClass')[0]; + it('should process the correct tags by default', () => { + const myClass = docSet.getByLongname('MyClass')[0]; plugin.handlers.newDoclet({ doclet: myClass }); [ @@ -26,14 +25,14 @@ describe('markdown plugin', function() { myClass.returns[0].description, myClass.see, myClass.summary - ].forEach(function(value) { + ].forEach(value => { // if we processed the value, it should be wrapped in a

tag expect( /^

(?:.+)<\/p>$/.test(value) ).toBe(true); }); }); - it('should unescape " entities in inline tags, but not elsewhere', function() { - var myOtherClass = docSet.getByLongname('MyOtherClass')[0]; + it('should unescape " entities in inline tags, but not elsewhere', () => { + const myOtherClass = docSet.getByLongname('MyOtherClass')[0]; plugin.handlers.newDoclet({ doclet: myOtherClass }); @@ -41,17 +40,17 @@ describe('markdown plugin', function() { expect(myOtherClass.description).toContain('"See"'); }); - describe('@see tag support', function() { - var foo = docSet.getByLongname('foo')[0]; - var bar = docSet.getByLongname('bar')[0]; + describe('@see tag support', () => { + const foo = docSet.getByLongname('foo')[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 }); expect(typeof foo).toEqual('object'); expect(foo.see[0]).toEqual('

Nowhere

'); }); - 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 }); expect(typeof bar).toEqual('object'); expect(bar.see[0]).toEqual('AnObject#myProperty'); diff --git a/plugins/test/specs/overloadHelper.js b/plugins/test/specs/overloadHelper.js index 3e69ea6b..c7c95f9e 100644 --- a/plugins/test/specs/overloadHelper.js +++ b/plugins/test/specs/overloadHelper.js @@ -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() { - var env = require('jsdoc/env'); - var path = require('jsdoc/path'); - - var docSet; - var parser = jasmine.createParser(); - var pluginPath = 'plugins/overloadHelper'; - var pluginPathResolved = path.resolve(env.dirname, pluginPath); - var plugin = require(pluginPathResolved); + let docSet; + const parser = jsdoc.createParser(); + const pluginPath = 'plugins/overloadHelper'; + const pluginPathResolved = path.resolve(env.dirname, pluginPath); + const plugin = require(pluginPathResolved); 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(typeof plugin).toBe('object'); }); - it('should export handlers', function() { + it('should export handlers', () => { expect(plugin.handlers).toBeDefined(); 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(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(typeof plugin.handlers.parseComplete).toBe('function'); }); - describe('newDoclet handler', function() { - it('should not add unique longnames to constructors', function() { - var soup = docSet.getByLongname('Soup'); - var soup1 = docSet.getByLongname('Soup()'); - var soup2 = docSet.getByLongname('Soup(spiciness)'); + describe('newDoclet handler', () => { + it('should not add unique longnames to constructors', () => { + const soup = docSet.getByLongname('Soup'); + const soup1 = docSet.getByLongname('Soup()'); + const soup2 = docSet.getByLongname('Soup(spiciness)'); expect(soup.length).toBe(2); expect(soup1.length).toBe(0); expect(soup2.length).toBe(0); }); - it('should add unique longnames to methods', function() { - var slurp = docSet.getByLongname('Soup#slurp'); - var slurp1 = docSet.getByLongname('Soup#slurp()'); - var slurp2 = docSet.getByLongname('Soup#slurp(dBA)'); + it('should add unique longnames to methods', () => { + const slurp = docSet.getByLongname('Soup#slurp'); + const slurp1 = docSet.getByLongname('Soup#slurp()'); + const slurp2 = docSet.getByLongname('Soup#slurp(dBA)'); expect(slurp.length).toBe(0); expect(slurp1.length).toBe(1); expect(slurp2.length).toBe(1); }); - it('should update the "variation" property of the method', function() { - var slurp1 = docSet.getByLongname('Soup#slurp()')[0]; - var slurp2 = docSet.getByLongname('Soup#slurp(dBA)')[0]; + it('should update the "variation" property of the method', () => { + const slurp1 = docSet.getByLongname('Soup#slurp()')[0]; + const slurp2 = docSet.getByLongname('Soup#slurp(dBA)')[0]; expect(slurp1.variation).toBe(''); expect(slurp2.variation).toBe('dBA'); }); - it('should not add to or change existing variations that are unique', function() { - var salt1 = docSet.getByLongname('Soup#salt'); - var salt2 = docSet.getByLongname('Soup#salt(mg)'); + it('should not add to or change existing variations that are unique', () => { + const salt1 = docSet.getByLongname('Soup#salt'); + const salt2 = docSet.getByLongname('Soup#salt(mg)'); expect(salt1.length).toBe(1); expect(salt2.length).toBe(1); }); - it('should not duplicate the names of existing numeric variations', function() { - var heat1 = docSet.getByLongname('Soup#heat(1)'); - var heat2 = docSet.getByLongname('Soup#heat(2)'); - var heat3 = docSet.getByLongname('Soup#heat(3)'); + it('should not duplicate the names of existing numeric variations', () => { + const heat1 = docSet.getByLongname('Soup#heat(1)'); + const heat2 = docSet.getByLongname('Soup#heat(2)'); + const heat3 = docSet.getByLongname('Soup#heat(3)'); expect(heat1.length).toBe(1); expect(heat2.length).toBe(1); expect(heat3.length).toBe(1); }); - it('should replace identical variations with new, unique variations', function() { - var discard1 = docSet.getByLongname('Soup#discard()'); - var discard2 = docSet.getByLongname('Soup#discard(container)'); + it('should replace identical variations with new, unique variations', () => { + const discard1 = docSet.getByLongname('Soup#discard()'); + const discard2 = docSet.getByLongname('Soup#discard(container)'); expect(discard1.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... - xit('should not retain parse results between parser runs', function() { + xit('should not retain parse results between parser runs', () => { parser.clear(); - docSet = jasmine.getDocSetFromFile('plugins/test/fixtures/overloadHelper.js', parser); - var heat = docSet.getByLongname('Soup#heat(4)'); + docSet = jsdoc.getDocSetFromFile('plugins/test/fixtures/overloadHelper.js', parser); + const heat = docSet.getByLongname('Soup#heat(4)'); expect(heat.length).toBe(0); }); diff --git a/plugins/test/specs/railsTemplate.js b/plugins/test/specs/railsTemplate.js index abd39d32..9de1d64a 100644 --- a/plugins/test/specs/railsTemplate.js +++ b/plugins/test/specs/railsTemplate.js @@ -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() { - var env = require('jsdoc/env'); - var path = require('jsdoc/path'); - - var parser = jasmine.createParser(); - var pluginPath = path.join(env.dirname, 'plugins/railsTemplate'); - var plugin = require(pluginPath); + const parser = jsdoc.createParser(); + const pluginPath = path.join(env.dirname, 'plugins/railsTemplate'); require('jsdoc/plugins').installPlugins([pluginPath], parser); require('jsdoc/src/handlers').attachTo(parser); - it('should remove <% %> rails template tags from the source of *.erb files', function() { - var docSet = parser.parse([path.join(env.dirname, 'plugins/test/fixtures/railsTemplate.js.erb')]); + it('should remove <% %> rails template tags from the source of *.erb files', () => { + 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. )'); }); diff --git a/plugins/test/specs/shout.js b/plugins/test/specs/shout.js index c0bfe7a9..cb8d2c75 100644 --- a/plugins/test/specs/shout.js +++ b/plugins/test/specs/shout.js @@ -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() { - var env = require('jsdoc/env'); - var path = require('jsdoc/path'); - - var docSet; - var parser = jasmine.createParser(); - var pluginPath = 'plugins/shout'; - var pluginPathResolved = path.join(env.dirname, pluginPath); - var plugin = require(pluginPathResolved); + let docSet; + const parser = jsdoc.createParser(); + const pluginPath = 'plugins/shout'; + const pluginPathResolved = path.join(env.dirname, pluginPath); 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.'); }); }); diff --git a/plugins/test/specs/sourcetag.js b/plugins/test/specs/sourcetag.js index d0948a27..600ba059 100644 --- a/plugins/test/specs/sourcetag.js +++ b/plugins/test/specs/sourcetag.js @@ -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() { - var env = require('jsdoc/env'); - var path = require('jsdoc/path'); - - var docSet; - var parser = jasmine.createParser(); - var pluginPath = 'plugins/sourcetag'; - var pluginPathResolved = path.join(env.dirname, pluginPath); + let docSet; + const parser = jsdoc.createParser(); + const pluginPath = 'plugins/sourcetag'; + const pluginPathResolved = path.join(env.dirname, pluginPath); 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() { - var doclet = docSet.getByLongname('module:plugins/sourcetag.handlers.newDoclet'); + it("should set the lineno and filename of the doclet's meta property", () => { + const doclet = docSet.getByLongname('module:plugins/sourcetag.handlers.newDoclet'); expect(doclet[0].meta).toBeDefined(); expect(doclet[0].meta.filename).toEqual('sourcetag.js'); diff --git a/plugins/test/specs/summarize.js b/plugins/test/specs/summarize.js index 9fb5ab80..b259628a 100644 --- a/plugins/test/specs/summarize.js +++ b/plugins/test/specs/summarize.js @@ -1,23 +1,20 @@ -/*global describe, expect, it */ -'use strict'; +const summarize = require('../../summarize'); -var summarize = require('../../summarize'); - -describe('summarize', function() { - it('should export handlers', function() { +describe('summarize', () => { + it('should export handlers', () => { expect(summarize.handlers).toBeDefined(); 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(typeof summarize.handlers.newDoclet).toBe('function'); }); - describe('newDoclet handler', function() { - var handler = summarize.handlers.newDoclet; + describe('newDoclet handler', () => { + 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() { return handler({}); } @@ -25,85 +22,92 @@ describe('summarize', function() { expect(noDoclet).not.toThrow(); }); - it('should not change the summary if it is already defined', function() { - var doclet = { + it('should not change the summary if it is already defined', () => { + const doclet = { summary: 'This is a summary.', description: 'Descriptions are good.' }; + handler({ doclet: doclet }); expect(doclet.summary).not.toBe(doclet.description); }); - it('should not do anything if the description is missing', function() { - var doclet = {}; + it('should not do anything if the description is missing', () => { + const doclet = {}; + handler({ doclet: doclet }); expect(doclet.summary).not.toBeDefined(); }); - it('should use the first sentence as the summary', function() { - var doclet = { + it('should use the first sentence as the summary', () => { + const doclet = { description: 'This sentence is the summary. This sentence is not.' }; + handler({ doclet: doclet }); 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', - function() { - var doclet = { + it('should not add an extra period if there is only one sentence in the description', () => { + const doclet = { description: 'This description has only one sentence.' }; + handler({ doclet: doclet }); 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 ' + - 'does not contain a period', function() { - var doclet = { + 'does not contain a period', () => { + const doclet = { description: 'This is a description' }; + handler({ doclet: doclet }); expect(doclet.summary).toBe('This is a description.'); }); it('should use the entire description as the summary if the description contains only ' + - 'one sentence', function() { - var doclet = { + 'one sentence', () => { + const doclet = { description: 'This is a description.' }; + handler({ doclet: doclet }); expect(doclet.description).toBe('This is a description.'); }); - it('should work when an HTML tag immediately follows the first sentence', function() { - var doclet = { + it('should work when an HTML tag immediately follows the first sentence', () => { + const doclet = { description: 'This sentence is the summary.This sentence is small.' }; + handler({ doclet: doclet }); 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', - function() { - var doclet = { + it('should generate valid HTML if a tag is opened, but not closed, in the summary', () => { + const doclet = { description: 'This description has a tag. The tag straddles sentences.' }; + handler({ doclet: doclet }); expect(doclet.summary).toBe('This description has a tag.'); }); - it('should not include a

tag in the summary', function() { - var doclet = { + it('should not include a

tag in the summary', () => { + const doclet = { description: '

This description contains HTML.

And plenty of it!

' }; + handler({ doclet: doclet }); expect(doclet.summary).toBe('This description contains HTML.'); diff --git a/plugins/test/specs/underscore.js b/plugins/test/specs/underscore.js index 506671a6..c6db7f38 100644 --- a/plugins/test/specs/underscore.js +++ b/plugins/test/specs/underscore.js @@ -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 () { - var env = require('jsdoc/env'); - var path = require('jsdoc/path'); - - var docSet; - 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); + let docSet; + const parser = jsdoc.createParser(); + const pluginPath = 'plugins/underscore'; + const fixturePath = 'plugins/test/fixtures/underscore'; + const pluginPathResolved = path.join(env.dirname, pluginPath); 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 - var normal = docSet.getByLongname('normal'); + const normal = docSet.getByLongname('normal'); + expect(normal[0].access).toBeUndefined(); - var realPrivate = docSet.getByLongname('Klass#privateProp'); + const realPrivate = docSet.getByLongname('Klass#privateProp'); + expect(realPrivate[0].access).toEqual('private'); }); - it('should hide doclet for symbols beginning with an underscore under normal circumstances', function () { - var hidden = docSet.getByLongname('_hidden'); + it('should hide doclet for symbols beginning with an underscore under normal circumstances', () => { + const hidden = docSet.getByLongname('_hidden'); + expect(hidden[0].access).toEqual('private'); }); - it('picks up "this"', function() { - var privateUnderscore = docSet.getByLongname('Klass#_privateProp'); + it('picks up "this"', () => { + const privateUnderscore = docSet.getByLongname('Klass#_privateProp'); + expect(privateUnderscore[0].access).toEqual('private'); }); }); diff --git a/test/.eslintrc.js b/test/.eslintrc.js new file mode 100644 index 00000000..cc9e75af --- /dev/null +++ b/test/.eslintrc.js @@ -0,0 +1,5 @@ +module.exports = { + globals: { + jsdoc: 'readonly' + } +}; diff --git a/test/README.md b/test/README.md index 8bd7fa9b..9425d78b 100644 --- a/test/README.md +++ b/test/README.md @@ -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 -and run the following command on Windows: +## Running tests - 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 -make sure tags and the parser, etc. are working properly), tests for plugins, and/or -tests for templates. - -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 ++ **JSDoc itself**. See the `test` directory. Test specs are in `test/specs`, and fixtures used by +the tests are in `test/fixtures`. ++ **Plugins**. See the `plugins/test` directory. ++ **Packages**. See the `packages/**/test` directories. diff --git a/test/async-callback.js b/test/async-callback.js deleted file mode 100644 index d2388fa4..00000000 --- a/test/async-callback.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/test/helpers/jsdoc.js b/test/helpers/jsdoc.js new file mode 100644 index 00000000..354cf561 --- /dev/null +++ b/test/helpers/jsdoc.js @@ -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); + } +}; diff --git a/test/index.js b/test/index.js new file mode 100644 index 00000000..a0e52bba --- /dev/null +++ b/test/index.js @@ -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; +}; + diff --git a/test/jasmine-jsdoc.js b/test/jasmine-jsdoc.js deleted file mode 100644 index 1fef89fd..00000000 --- a/test/jasmine-jsdoc.js +++ /dev/null @@ -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]; -}); diff --git a/test/lib/jasmine.js b/test/lib/jasmine.js deleted file mode 100644 index 2e71dda6..00000000 --- a/test/lib/jasmine.js +++ /dev/null @@ -1,2537 +0,0 @@ -var isCommonJS = typeof window == "undefined"; - -/** - * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework. - * - * @namespace - */ -var jasmine = {}; -if (isCommonJS){exports.jasmine = jasmine;} -/** - * @private - */ -jasmine.unimplementedMethod_ = function() { - throw new Error("unimplemented method"); -}; - -/** - * Use jasmine.undefined instead of undefined, since undefined is just - * a plain old variable and may be redefined by somebody else. - * - * @private - */ -jasmine.undefined = jasmine.___undefined___; - -/** - * Show diagnostic messages in the console if set to true - * - */ -jasmine.VERBOSE = false; - -/** - * Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed. - * - */ -jasmine.DEFAULT_UPDATE_INTERVAL = 250; - -/** - * Default timeout interval in milliseconds for waitsFor() blocks. - */ -jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; - -jasmine.getGlobal = function() { - function getGlobal() { - return this; - } - - return getGlobal(); -}; - -/** - * Allows for bound functions to be compared. Internal use only. - * - * @ignore - * @private - * @param base {Object} bound 'this' for the function - * @param name {Function} function to find - */ -jasmine.bindOriginal_ = function(base, name) { - var original = base[name]; - if (original.apply) { - return function() { - return original.apply(base, arguments); - }; - } else { - // IE support - return jasmine.getGlobal()[name]; - } -}; - -jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout'); -jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout'); -jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval'); -jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval'); - -jasmine.MessageResult = function(values) { - this.type = 'log'; - this.values = values; - this.trace = new Error(); // todo: test better -}; - -jasmine.MessageResult.prototype.toString = function() { - var text = ""; - for (var i = 0; i < this.values.length; i++) { - if (i > 0){text += " ";} - if (jasmine.isString_(this.values[i])) { - text += this.values[i]; - } else { - text += jasmine.pp(this.values[i]); - } - } - return text; -}; - -jasmine.ExpectationResult = function(params) { - this.type = 'expect'; - this.matcherName = params.matcherName; - this.passed_ = params.passed; - this.expected = params.expected; - this.actual = params.actual; - this.message = this.passed_ ? 'Passed.' : params.message; - - var trace = (params.trace || new Error(this.message)); - this.trace = this.passed_ ? '' : trace; -}; - -jasmine.ExpectationResult.prototype.toString = function () { - return this.message; -}; - -jasmine.ExpectationResult.prototype.passed = function () { - return this.passed_; -}; - -/** - * Getter for the Jasmine environment. Ensures one gets created - */ -jasmine.getEnv = function() { - var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); - return env; -}; - -/** - * @ignore - * @private - * @param value - * @returns {Boolean} - */ -jasmine.isArray_ = function(value) { - return jasmine.isA_("Array", value); -}; - -/** - * @ignore - * @private - * @param value - * @returns {Boolean} - */ -jasmine.isString_ = function(value) { - return jasmine.isA_("String", value); -}; - -/** - * @ignore - * @private - * @param value - * @returns {Boolean} - */ -jasmine.isNumber_ = function(value) { - return jasmine.isA_("Number", value); -}; - -/** - * @ignore - * @private - * @param {String} typeName - * @param value - * @returns {Boolean} - */ -jasmine.isA_ = function(typeName, value) { - return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; -}; - -/** - * Pretty printer for expecations. Takes any object and turns it into a human-readable string. - * - * @param value {Object} an object to be outputted - * @returns {String} - */ -jasmine.pp = function(value) { - var stringPrettyPrinter = new jasmine.StringPrettyPrinter(); - stringPrettyPrinter.format(value); - return stringPrettyPrinter.string; -}; - -/** - * Returns true if the object is a DOM Node. - * - * @param {Object} obj object to check - * @returns {Boolean} - */ -jasmine.isDomNode = function(obj) { - return obj.nodeType > 0; -}; - -/** - * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter. - * - * @example - * // don't care about which function is passed in, as long as it's a function - * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function)); - * - * @param {Class} clazz - * @returns matchable object of the type clazz - */ -jasmine.any = function(clazz) { - return new jasmine.Matchers.Any(clazz); -}; - -/** - * Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the - * attributes on the object. - * - * @example - * // don't care about any other attributes than foo. - * expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"}); - * - * @param sample {Object} sample - * @returns matchable object for the sample - */ -jasmine.objectContaining = function (sample) { - return new jasmine.Matchers.ObjectContaining(sample); -}; - -/** - * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks. - * - * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine - * expectation syntax. Spies can be checked if they were called or not and what the calling params were. - * - * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs). - * - * Spies are torn down at the end of every spec. - * - * Note: Do not call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj. - * - * @example - * // a stub - * var myStub = jasmine.createSpy('myStub'); // can be used anywhere - * - * // spy example - * var foo = { - * not: function(bool) { return !bool; } - * } - * - * // actual foo.not will not be called, execution stops - * spyOn(foo, 'not'); - - // foo.not spied upon, execution will continue to implementation - * spyOn(foo, 'not').andCallThrough(); - * - * // fake example - * var foo = { - * not: function(bool) { return !bool; } - * } - * - * // foo.not(val) will return val - * spyOn(foo, 'not').andCallFake(function(value) {return value;}); - * - * // mock example - * foo.not(7 == 7); - * expect(foo.not).toHaveBeenCalled(); - * expect(foo.not).toHaveBeenCalledWith(true); - * - * @constructor - * @see spyOn, jasmine.createSpy, jasmine.createSpyObj - * @param {String} name - */ -jasmine.Spy = function(name) { - /** - * The name of the spy, if provided. - */ - this.identity = name || 'unknown'; - /** - * Is this Object a spy? - */ - this.isSpy = true; - /** - * The actual function this spy stubs. - */ - this.plan = function() { - }; - /** - * Tracking of the most recent call to the spy. - * @example - * var mySpy = jasmine.createSpy('foo'); - * mySpy(1, 2); - * mySpy.mostRecentCall.args = [1, 2]; - */ - this.mostRecentCall = {}; - - /** - * Holds arguments for each call to the spy, indexed by call count - * @example - * var mySpy = jasmine.createSpy('foo'); - * mySpy(1, 2); - * mySpy(7, 8); - * mySpy.mostRecentCall.args = [7, 8]; - * mySpy.argsForCall[0] = [1, 2]; - * mySpy.argsForCall[1] = [7, 8]; - */ - this.argsForCall = []; - this.calls = []; -}; - -/** - * Tells a spy to call through to the actual implemenatation. - * - * @example - * var foo = { - * bar: function() { // do some stuff } - * } - * - * // defining a spy on an existing property: foo.bar - * spyOn(foo, 'bar').andCallThrough(); - */ -jasmine.Spy.prototype.andCallThrough = function() { - this.plan = this.originalValue; - return this; -}; - -/** - * For setting the return value of a spy. - * - * @example - * // defining a spy from scratch: foo() returns 'baz' - * var foo = jasmine.createSpy('spy on foo').andReturn('baz'); - * - * // defining a spy on an existing property: foo.bar() returns 'baz' - * spyOn(foo, 'bar').andReturn('baz'); - * - * @param {Object} value - */ -jasmine.Spy.prototype.andReturn = function(value) { - this.plan = function() { - return value; - }; - return this; -}; - -/** - * For throwing an exception when a spy is called. - * - * @example - * // defining a spy from scratch: foo() throws an exception w/ message 'ouch' - * var foo = jasmine.createSpy('spy on foo').andThrow('baz'); - * - * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch' - * spyOn(foo, 'bar').andThrow('baz'); - * - * @param {String} exceptionMsg - */ -jasmine.Spy.prototype.andThrow = function(exceptionMsg) { - this.plan = function() { - throw exceptionMsg; - }; - return this; -}; - -/** - * Calls an alternate implementation when a spy is called. - * - * @example - * var baz = function() { - * // do some stuff, return something - * } - * // defining a spy from scratch: foo() calls the function baz - * var foo = jasmine.createSpy('spy on foo').andCall(baz); - * - * // defining a spy on an existing property: foo.bar() calls an anonymnous function - * spyOn(foo, 'bar').andCall(function() { return 'baz';} ); - * - * @param {Function} fakeFunc - */ -jasmine.Spy.prototype.andCallFake = function(fakeFunc) { - this.plan = fakeFunc; - return this; -}; - -/** - * Resets all of a spy's the tracking variables so that it can be used again. - * - * @example - * spyOn(foo, 'bar'); - * - * foo.bar(); - * - * expect(foo.bar.callCount).toEqual(1); - * - * foo.bar.reset(); - * - * expect(foo.bar.callCount).toEqual(0); - */ -jasmine.Spy.prototype.reset = function() { - this.wasCalled = false; - this.callCount = 0; - this.argsForCall = []; - this.calls = []; - this.mostRecentCall = {}; -}; - -jasmine.createSpy = function(name) { - - var spyObj = function() { - spyObj.wasCalled = true; - spyObj.callCount++; - var args = jasmine.util.argsToArray(arguments); - spyObj.mostRecentCall.object = this; - spyObj.mostRecentCall.args = args; - spyObj.argsForCall.push(args); - spyObj.calls.push({object: this, args: args}); - return spyObj.plan.apply(this, arguments); - }; - - var spy = new jasmine.Spy(name); - - for (var prop in spy) { - spyObj[prop] = spy[prop]; - } - - spyObj.reset(); - - return spyObj; -}; - -/** - * Determines whether an object is a spy. - * - * @param {jasmine.Spy|Object} putativeSpy - * @returns {Boolean} - */ -jasmine.isSpy = function(putativeSpy) { - return putativeSpy && putativeSpy.isSpy; -}; - -/** - * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something - * large in one call. - * - * @param {String} baseName name of spy class - * @param {Array} methodNames array of names of methods to make spies - */ -jasmine.createSpyObj = function(baseName, methodNames) { - if (!jasmine.isArray_(methodNames) || methodNames.length === 0) { - throw new Error('createSpyObj requires a non-empty array of method names to create spies for'); - } - var obj = {}; - for (var i = 0; i < methodNames.length; i++) { - obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]); - } - return obj; -}; - -/** - * All parameters are pretty-printed and concatenated together, then written to the current spec's output. - * - * Be careful not to leave calls to jasmine.log in production code. - */ -jasmine.log = function() { - var spec = jasmine.getEnv().currentSpec; - spec.log.apply(spec, arguments); -}; - -/** - * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy. - * - * @example - * // spy example - * var foo = { - * not: function(bool) { return !bool; } - * } - * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops - * - * @see jasmine.createSpy - * @param obj - * @param methodName - * @returns a Jasmine spy that can be chained with all spy methods - */ -var spyOn = function(obj, methodName) { - return jasmine.getEnv().currentSpec.spyOn(obj, methodName); -}; -if (isCommonJS){exports.spyOn = spyOn;} - -/** - * Creates a Jasmine spec that will be added to the current suite. - * - * // TODO: pending tests - * - * @example - * it('should be true', function() { - * expect(true).toEqual(true); - * }); - * - * @param {String} desc description of this specification - * @param {Function} func defines the preconditions and expectations of the spec - */ -var it = function(desc, func) { - return jasmine.getEnv().it(desc, func); -}; -if (isCommonJS){exports.it = it;} - -/** - * Creates a disabled Jasmine spec. - * - * A convenience method that allows existing specs to be disabled temporarily during development. - * - * @param {String} desc description of this specification - * @param {Function} func defines the preconditions and expectations of the spec - */ -var xit = function(desc, func) { - return jasmine.getEnv().xit(desc, func); -}; -if (isCommonJS){exports.xit = xit;} - -/** - * Starts a chain for a Jasmine expectation. - * - * It is passed an Object that is the actual value and should chain to one of the many - * jasmine.Matchers functions. - * - * @param {Object} actual Actual value to test against and expected value - */ -var expect = function(actual) { - return jasmine.getEnv().currentSpec.expect(actual); -}; -if (isCommonJS){exports.expect = expect;} - -/** - * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. - * - * @param {Function} func Function that defines part of a jasmine spec. - */ -var runs = function(func) { - jasmine.getEnv().currentSpec.runs(func); -}; -if (isCommonJS){exports.runs = runs;} - -/** - * Waits a fixed time period before moving to the next block. - * - * @deprecated Use waitsFor() instead - * @param {Number} timeout milliseconds to wait - */ -var waits = function(timeout) { - jasmine.getEnv().currentSpec.waits(timeout); -}; -if (isCommonJS){exports.waits = waits;} - -/** - * Waits for the latchFunction to return true before proceeding to the next block. - * - * @param {Function} latchFunction - * @param {String} optional_timeoutMessage - * @param {Number} optional_timeout - */ -var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { - jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments); -}; -if (isCommonJS){exports.waitsFor = waitsFor;} - -/** - * A function that is called before each spec in a suite. - * - * Used for spec setup, including validating assumptions. - * - * @param {Function} beforeEachFunction - */ -var beforeEach = function(beforeEachFunction) { - jasmine.getEnv().beforeEach(beforeEachFunction); -}; -if (isCommonJS){exports.beforeEach = beforeEach;} - -/** - * A function that is called after each spec in a suite. - * - * Used for restoring any state that is hijacked during spec execution. - * - * @param {Function} afterEachFunction - */ -var afterEach = function(afterEachFunction) { - jasmine.getEnv().afterEach(afterEachFunction); -}; -if (isCommonJS){exports.afterEach = afterEach;} - -/** - * Defines a suite of specifications. - * - * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared - * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization - * of setup in some tests. - * - * @example - * // TODO: a simple suite - * - * // TODO: a simple suite with a nested describe block - * - * @param {String} description A string, usually the class under test. - * @param {Function} specDefinitions function that defines several specs. - */ -var describe = function(description, specDefinitions) { - return jasmine.getEnv().describe(description, specDefinitions); -}; -if (isCommonJS){exports.describe = describe;} - -/** - * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. - * - * @param {String} description A string, usually the class under test. - * @param {Function} specDefinitions function that defines several specs. - */ -var xdescribe = function(description, specDefinitions) { - return jasmine.getEnv().xdescribe(description, specDefinitions); -}; -if (isCommonJS){exports.xdescribe = xdescribe;} - -// Provide the XMLHttpRequest class for IE 5.x-6.x: -jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() { - function tryIt(f) { - try { - return f(); - } catch (e) { - } - return null; - } - - var xhr = tryIt(function() { - return new ActiveXObject("Msxml2.XMLHTTP.6.0"); - }) || - tryIt(function() { - return new ActiveXObject("Msxml2.XMLHTTP.3.0"); - }) || - tryIt(function() { - return new ActiveXObject("Msxml2.XMLHTTP"); - }) || - tryIt(function() { - return new ActiveXObject("Microsoft.XMLHTTP"); - }); - - if (!xhr) { - throw new Error("This browser does not support XMLHttpRequest."); -} - - return xhr; -} : XMLHttpRequest; -/** - * @namespace - */ -jasmine.util = {}; - -/** - * Declare that a child class inherit it's prototype from the parent class. - * - * @private - * @param {Function} childClass - * @param {Function} parentClass - */ -jasmine.util.inherit = function(childClass, parentClass) { - /** - * @private - */ - var subclass = function() { - }; - subclass.prototype = parentClass.prototype; - childClass.prototype = new subclass(); -}; - -jasmine.util.formatException = function(e) { - var lineNumber; - if (e.line) { - lineNumber = e.line; - } - else if (e.lineNumber) { - lineNumber = e.lineNumber; - } - - var file; - - if (e.sourceURL) { - file = e.sourceURL; - } - else if (e.fileName) { - file = e.fileName; - } - - var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString(); - - if (file && lineNumber) { - message += ' in ' + file + ' (line ' + lineNumber + ')'; - } - - return message; -}; - -jasmine.util.htmlEscape = function(str) { - if (!str) { - return str; -} - return str.replace(/&/g, '&') - .replace(//g, '>'); -}; - -jasmine.util.argsToArray = function(args) { - var arrayOfArgs = []; - for (var i = 0; i < args.length; i++) {arrayOfArgs.push(args[i]);} - return arrayOfArgs; -}; - -jasmine.util.extend = function(destination, source) { - for (var property in source) destination[property] = source[property]; - return destination; -}; - -/** - * Environment for Jasmine - * - * @constructor - */ -jasmine.Env = function() { - this.currentSpec = null; - this.currentSuite = null; - this.currentRunner_ = new jasmine.Runner(this); - - this.reporter = new jasmine.MultiReporter(); - - this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL; - this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL; - this.lastUpdate = 0; - this.specFilter = function() { - return true; - }; - - this.nextSpecId_ = 0; - this.nextSuiteId_ = 0; - this.equalityTesters_ = []; - - // wrap matchers - this.matchersClass = function() { - jasmine.Matchers.apply(this, arguments); - }; - jasmine.util.inherit(this.matchersClass, jasmine.Matchers); - - jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass); -}; - -jasmine.Env.prototype.setTimeout = jasmine.setTimeout; -jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout; -jasmine.Env.prototype.setInterval = jasmine.setInterval; -jasmine.Env.prototype.clearInterval = jasmine.clearInterval; - -/** - * @returns an object containing jasmine version build info, if set. - */ -jasmine.Env.prototype.version = function () { - if (jasmine.version_) { - return jasmine.version_; - } else { - throw new Error('Version not set'); - } -}; - -/** - * @returns string containing jasmine version build info, if set. - */ -jasmine.Env.prototype.versionString = function() { - if (!jasmine.version_) { - return "version unknown"; - } - - var version = this.version(); - var versionString = version.major + "." + version.minor + "." + version.build; - if (version.release_candidate) { - versionString += ".rc" + version.release_candidate; - } - versionString += " revision " + version.revision; - return versionString; -}; - -/** - * @returns a sequential integer starting at 0 - */ -jasmine.Env.prototype.nextSpecId = function () { - return this.nextSpecId_++; -}; - -/** - * @returns a sequential integer starting at 0 - */ -jasmine.Env.prototype.nextSuiteId = function () { - return this.nextSuiteId_++; -}; - -/** - * Register a reporter to receive status updates from Jasmine. - * @param {jasmine.Reporter} reporter An object which will receive status updates. - */ -jasmine.Env.prototype.addReporter = function(reporter) { - this.reporter.addReporter(reporter); -}; - -jasmine.Env.prototype.execute = function() { - this.currentRunner_.execute(); -}; - -jasmine.Env.prototype.describe = function(description, specDefinitions) { - var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); - - var parentSuite = this.currentSuite; - if (parentSuite) { - parentSuite.add(suite); - } else { - this.currentRunner_.add(suite); - } - - this.currentSuite = suite; - - var declarationError = null; - try { - specDefinitions.call(suite); - } catch (e) { - declarationError = e; - } - - if (declarationError) { - this.it("encountered a declaration exception", function() { - throw declarationError; - }); - } - - this.currentSuite = parentSuite; - - return suite; -}; - -jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { - if (this.currentSuite) { - this.currentSuite.beforeEach(beforeEachFunction); - } else { - this.currentRunner_.beforeEach(beforeEachFunction); - } -}; - -jasmine.Env.prototype.currentRunner = function () { - return this.currentRunner_; -}; - -jasmine.Env.prototype.afterEach = function(afterEachFunction) { - if (this.currentSuite) { - this.currentSuite.afterEach(afterEachFunction); - } else { - this.currentRunner_.afterEach(afterEachFunction); - } - -}; - -jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { - return { - execute: function() { - } - }; -}; - -jasmine.Env.prototype.it = function(description, func) { - var spec = new jasmine.Spec(this, this.currentSuite, description); - this.currentSuite.add(spec); - this.currentSpec = spec; - - if (func) { - spec.runs(func); - } - - return spec; -}; - -jasmine.Env.prototype.xit = function(desc, func) { - return { - id: this.nextSpecId(), - runs: function() { - } - }; -}; - -jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { - if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { - return true; - } - - a.__Jasmine_been_here_before__ = b; - b.__Jasmine_been_here_before__ = a; - - var hasKey = function(obj, keyName) { - return obj !== null && obj[keyName] !== jasmine.undefined; - }; - - for (var property in b) { - if (!hasKey(a, property) && hasKey(b, property)) { - mismatchKeys.push("expected has key '" + property + "', but missing from actual."); - } - } - for (property in a) { - if (!hasKey(b, property) && hasKey(a, property)) { - mismatchKeys.push("expected missing key '" + property + "', but present in actual."); - } - } - for (property in b) { - if (property == '__Jasmine_been_here_before__') { - continue; - } - if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { - mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual."); - } - } - - if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { - mismatchValues.push("arrays were not the same length"); - } - - delete a.__Jasmine_been_here_before__; - delete b.__Jasmine_been_here_before__; - return (mismatchKeys.length === 0 && mismatchValues.length === 0); -}; - -jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { - mismatchKeys = mismatchKeys || []; - mismatchValues = mismatchValues || []; - - for (var i = 0; i < this.equalityTesters_.length; i++) { - var equalityTester = this.equalityTesters_[i]; - var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); - if (result !== jasmine.undefined) { - return result; - } - } - - if (a === b) { - return true; -} - - if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) { - return (a == jasmine.undefined && b == jasmine.undefined); - } - - if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { - return a === b; - } - - if (a instanceof Date && b instanceof Date) { - return a.getTime() == b.getTime(); - } - - if (a.jasmineMatches) { - return a.jasmineMatches(b); - } - - if (b.jasmineMatches) { - return b.jasmineMatches(a); - } - - if (a instanceof jasmine.Matchers.ObjectContaining) { - return a.matches(b); - } - - if (b instanceof jasmine.Matchers.ObjectContaining) { - return b.matches(a); - } - - if (jasmine.isString_(a) && jasmine.isString_(b)) { - return (a == b); - } - - if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) { - return (a == b); - } - - if (typeof a === "object" && typeof b === "object") { - return this.compareObjects_(a, b, mismatchKeys, mismatchValues); - } - - //Straight check - return (a === b); -}; - -jasmine.Env.prototype.contains_ = function(haystack, needle) { - if (jasmine.isArray_(haystack)) { - for (var i = 0; i < haystack.length; i++) { - if (this.equals_(haystack[i], needle)) { - return true; - } - } - return false; - } - return haystack.indexOf(needle) >= 0; -}; - -jasmine.Env.prototype.addEqualityTester = function(equalityTester) { - this.equalityTesters_.push(equalityTester); -}; -/** No-op base class for Jasmine reporters. - * - * @constructor - */ -jasmine.Reporter = function() { -}; - -//noinspection JSUnusedLocalSymbols -jasmine.Reporter.prototype.reportRunnerStarting = function(runner) { -}; - -//noinspection JSUnusedLocalSymbols -jasmine.Reporter.prototype.reportRunnerResults = function(runner) { -}; - -//noinspection JSUnusedLocalSymbols -jasmine.Reporter.prototype.reportSuiteResults = function(suite) { -}; - -//noinspection JSUnusedLocalSymbols -jasmine.Reporter.prototype.reportSpecStarting = function(spec) { -}; - -//noinspection JSUnusedLocalSymbols -jasmine.Reporter.prototype.reportSpecResults = function(spec) { -}; - -//noinspection JSUnusedLocalSymbols -jasmine.Reporter.prototype.log = function(str) { -}; - -/** - * Blocks are functions with executable code that make up a spec. - * - * @constructor - * @param {jasmine.Env} env - * @param {Function} func - * @param {jasmine.Spec} spec - */ -jasmine.Block = function(env, func, spec) { - this.env = env; - this.func = func; - this.spec = spec; -}; - -jasmine.Block.prototype.execute = function(onComplete) { - try { - this.func.apply(this.spec); - } catch (e) { - this.spec.fail(e); - } - onComplete(); -}; -/** JavaScript API reporter. - * - * @constructor - */ -jasmine.JsApiReporter = function() { - this.started = false; - this.finished = false; - this.suites_ = []; - this.results_ = {}; -}; - -jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { - this.started = true; - var suites = runner.topLevelSuites(); - for (var i = 0; i < suites.length; i++) { - var suite = suites[i]; - this.suites_.push(this.summarize_(suite)); - } -}; - -jasmine.JsApiReporter.prototype.suites = function() { - return this.suites_; -}; - -jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { - var isSuite = suiteOrSpec instanceof jasmine.Suite; - var summary = { - id: suiteOrSpec.id, - name: suiteOrSpec.description, - type: isSuite ? 'suite' : 'spec', - children: [] - }; - - if (isSuite) { - var children = suiteOrSpec.children(); - for (var i = 0; i < children.length; i++) { - summary.children.push(this.summarize_(children[i])); - } - } - return summary; -}; - -jasmine.JsApiReporter.prototype.results = function() { - return this.results_; -}; - -jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) { - return this.results_[specId]; -}; - -//noinspection JSUnusedLocalSymbols -jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) { - this.finished = true; -}; - -//noinspection JSUnusedLocalSymbols -jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) { -}; - -//noinspection JSUnusedLocalSymbols -jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) { - this.results_[spec.id] = { - messages: spec.results().getItems(), - result: spec.results().failedCount > 0 ? "failed" : "passed" - }; -}; - -//noinspection JSUnusedLocalSymbols -jasmine.JsApiReporter.prototype.log = function(str) { -}; - -jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){ - var results = {}; - for (var i = 0; i < specIds.length; i++) { - var specId = specIds[i]; - results[specId] = this.summarizeResult_(this.results_[specId]); - } - return results; -}; - -jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){ - var summaryMessages = []; - var messagesLength = result.messages.length; - for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) { - var resultMessage = result.messages[messageIndex]; - summaryMessages.push({ - text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined, - passed: resultMessage.passed ? resultMessage.passed() : true, - type: resultMessage.type, - message: resultMessage.message, - trace: { - stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined - } - }); - } - - return { - result : result.result, - messages : summaryMessages - }; -}; - -/** - * @constructor - * @param {jasmine.Env} env - * @param actual - * @param {jasmine.Spec} spec - */ -jasmine.Matchers = function(env, actual, spec, opt_isNot) { - this.env = env; - this.actual = actual; - this.spec = spec; - this.isNot = opt_isNot || false; - this.reportWasCalled_ = false; -}; - -// todo: @deprecated as of Jasmine 0.11, remove soon [xw] -jasmine.Matchers.pp = function(str) { - throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!"); -}; - -// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw] -jasmine.Matchers.prototype.report = function(result, failing_message, details) { - throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs"); -}; - -jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) { - for (var methodName in prototype) { - if (methodName == 'report') { - continue; - } - var orig = prototype[methodName]; - matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig); - } -}; - -jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) { - return function() { - var matcherArgs = jasmine.util.argsToArray(arguments); - var result = matcherFunction.apply(this, arguments); - - if (this.isNot) { - result = !result; - } - - if (this.reportWasCalled_) { - return result; - } - - var message; - if (!result) { - if (this.message) { - message = this.message.apply(this, arguments); - if (jasmine.isArray_(message)) { - message = message[this.isNot ? 1 : 0]; - } - } else { - var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); - message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate; - if (matcherArgs.length > 0) { - for (var i = 0; i < matcherArgs.length; i++) { - if (i > 0){message += ",";} - message += " " + jasmine.pp(matcherArgs[i]); - } - } - message += "."; - } - } - var expectationResult = new jasmine.ExpectationResult({ - matcherName: matcherName, - passed: result, - expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0], - actual: this.actual, - message: message - }); - this.spec.addMatcherResult(expectationResult); - return jasmine.undefined; - }; -}; - -/** - * toBe: compares the actual to the expected using === - * @param expected - */ -jasmine.Matchers.prototype.toBe = function(expected) { - return this.actual === expected; -}; - -/** - * toNotBe: compares the actual to the expected using !== - * @param expected - * @deprecated as of 1.0. Use not.toBe() instead. - */ -jasmine.Matchers.prototype.toNotBe = function(expected) { - return this.actual !== expected; -}; - -/** - * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. - * - * @param expected - */ -jasmine.Matchers.prototype.toEqual = function(expected) { - return this.env.equals_(this.actual, expected); -}; - -/** - * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual - * @param expected - * @deprecated as of 1.0. Use not.toEqual() instead. - */ -jasmine.Matchers.prototype.toNotEqual = function(expected) { - return !this.env.equals_(this.actual, expected); -}; - -/** - * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes - * a pattern or a String. - * - * @param expected - */ -jasmine.Matchers.prototype.toMatch = function(expected) { - return new RegExp(expected).test(this.actual); -}; - -/** - * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch - * @param expected - * @deprecated as of 1.0. Use not.toMatch() instead. - */ -jasmine.Matchers.prototype.toNotMatch = function(expected) { - return !(new RegExp(expected).test(this.actual)); -}; - -/** - * Matcher that compares the actual to jasmine.undefined. - */ -jasmine.Matchers.prototype.toBeDefined = function() { - return (this.actual !== jasmine.undefined); -}; - -/** - * Matcher that compares the actual to jasmine.undefined. - */ -jasmine.Matchers.prototype.toBeUndefined = function() { - return (this.actual === jasmine.undefined); -}; - -/** - * Matcher that compares the actual to null. - */ -jasmine.Matchers.prototype.toBeNull = function() { - return (this.actual === null); -}; - -/** - * Matcher that boolean not-nots the actual. - */ -jasmine.Matchers.prototype.toBeTruthy = function() { - return !!this.actual; -}; - -/** - * Matcher that boolean nots the actual. - */ -jasmine.Matchers.prototype.toBeFalsy = function() { - return !this.actual; -}; - -/** - * Matcher that checks to see if the actual, a Jasmine spy, was called. - */ -jasmine.Matchers.prototype.toHaveBeenCalled = function() { - if (arguments.length > 0) { - throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith'); - } - - if (!jasmine.isSpy(this.actual)) { - throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); - } - - this.message = function() { - return [ - "Expected spy " + this.actual.identity + " to have been called.", - "Expected spy " + this.actual.identity + " not to have been called." - ]; - }; - - return this.actual.wasCalled; -}; - -/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */ -jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled; - -/** - * Matcher that checks to see if the actual, a Jasmine spy, was not called. - * - * @deprecated Use expect(xxx).not.toHaveBeenCalled() instead - */ -jasmine.Matchers.prototype.wasNotCalled = function() { - if (arguments.length > 0) { - throw new Error('wasNotCalled does not take arguments'); - } - - if (!jasmine.isSpy(this.actual)) { - throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); - } - - this.message = function() { - return [ - "Expected spy " + this.actual.identity + " to not have been called.", - "Expected spy " + this.actual.identity + " to have been called." - ]; - }; - - return !this.actual.wasCalled; -}; - -/** - * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters. - * - * @example - * - */ -jasmine.Matchers.prototype.toHaveBeenCalledWith = function() { - var expectedArgs = jasmine.util.argsToArray(arguments); - if (!jasmine.isSpy(this.actual)) { - throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); - } - this.message = function() { - if (this.actual.callCount === 0) { - // todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw] - return [ - "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.", - "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was." - ]; - } else { - return [ - "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall), - "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall) - ]; - } - }; - - return this.env.contains_(this.actual.argsForCall, expectedArgs); -}; - -/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */ -jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith; - -/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */ -jasmine.Matchers.prototype.wasNotCalledWith = function() { - var expectedArgs = jasmine.util.argsToArray(arguments); - if (!jasmine.isSpy(this.actual)) { - throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); - } - - this.message = function() { - return [ - "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was", - "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was" - ]; - }; - - return !this.env.contains_(this.actual.argsForCall, expectedArgs); -}; - -/** - * Matcher that checks that the expected item is an element in the actual Array. - * - * @param {Object} expected - */ -jasmine.Matchers.prototype.toContain = function(expected) { - return this.env.contains_(this.actual, expected); -}; - -/** - * Matcher that checks that the expected item is NOT an element in the actual Array. - * - * @param {Object} expected - * @deprecated as of 1.0. Use not.toContain() instead. - */ -jasmine.Matchers.prototype.toNotContain = function(expected) { - return !this.env.contains_(this.actual, expected); -}; - -jasmine.Matchers.prototype.toBeLessThan = function(expected) { - return this.actual < expected; -}; - -jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { - return this.actual > expected; -}; - -/** - * Matcher that checks that the expected item is equal to the actual item - * up to a given level of decimal precision (default 2). - * - * @param {Number} expected - * @param {Number} precision - */ -jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) { - if (!(precision === 0)) { - precision = precision || 2; - } - var multiplier = Math.pow(10, precision); - var actual = Math.round(this.actual * multiplier); - expected = Math.round(expected * multiplier); - return expected == actual; -}; - -/** - * Matcher that checks that the expected exception was thrown by the actual. - * - * @param {String} expected - */ -jasmine.Matchers.prototype.toThrow = function(expected) { - var result = false; - var exception; - if (typeof this.actual != 'function') { - throw new Error('Actual is not a function'); - } - try { - this.actual(); - } catch (e) { - exception = e; - } - if (exception) { - result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected)); - } - - var not = this.isNot ? "not " : ""; - - this.message = function() { - if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) { - return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' '); - } else { - return "Expected function to throw an exception."; - } - }; - - return result; -}; - -jasmine.Matchers.Any = function(expectedClass) { - this.expectedClass = expectedClass; -}; - -jasmine.Matchers.Any.prototype.jasmineMatches = function(other) { - if (this.expectedClass == String) { - return typeof other == 'string' || other instanceof String; - } - - if (this.expectedClass == Number) { - return typeof other == 'number' || other instanceof Number; - } - - if (this.expectedClass == Function) { - return typeof other == 'function' || other instanceof Function; - } - - if (this.expectedClass == Object) { - return typeof other == 'object'; - } - - return other instanceof this.expectedClass; -}; - -jasmine.Matchers.Any.prototype.jasmineToString = function() { - return ''; -}; - -jasmine.Matchers.ObjectContaining = function (sample) { - this.sample = sample; -}; - -jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) { - mismatchKeys = mismatchKeys || []; - mismatchValues = mismatchValues || []; - - var env = jasmine.getEnv(); - - var hasKey = function(obj, keyName) { - return obj != null && obj[keyName] !== jasmine.undefined; - }; - - for (var property in this.sample) { - if (!hasKey(other, property) && hasKey(this.sample, property)) { - mismatchKeys.push("expected has key '" + property + "', but missing from actual."); - } - else if (!env.equals_(this.sample[property], other[property], mismatchKeys, mismatchValues)) { - mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual."); - } - } - - return (mismatchKeys.length === 0 && mismatchValues.length === 0); -}; - -jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function () { - return ""; -}; -// Mock setTimeout, clearTimeout -// Contributed by Pivotal Computer Systems, www.pivotalsf.com - -jasmine.FakeTimer = function() { - this.reset(); - - var self = this; - self.setTimeout = function(funcToCall, millis) { - self.timeoutsMade++; - self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false); - return self.timeoutsMade; - }; - - self.setInterval = function(funcToCall, millis) { - self.timeoutsMade++; - self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); - return self.timeoutsMade; - }; - - self.clearTimeout = function(timeoutKey) { - self.scheduledFunctions[timeoutKey] = jasmine.undefined; - }; - - self.clearInterval = function(timeoutKey) { - self.scheduledFunctions[timeoutKey] = jasmine.undefined; - }; - -}; - -jasmine.FakeTimer.prototype.reset = function() { - this.timeoutsMade = 0; - this.scheduledFunctions = {}; - this.nowMillis = 0; -}; - -jasmine.FakeTimer.prototype.tick = function(millis) { - var oldMillis = this.nowMillis; - var newMillis = oldMillis + millis; - this.runFunctionsWithinRange(oldMillis, newMillis); - this.nowMillis = newMillis; -}; - -jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) { - var scheduledFunc; - var funcsToRun = []; - for (var timeoutKey in this.scheduledFunctions) { - scheduledFunc = this.scheduledFunctions[timeoutKey]; - if (scheduledFunc != jasmine.undefined && - scheduledFunc.runAtMillis >= oldMillis && - scheduledFunc.runAtMillis <= nowMillis) { - funcsToRun.push(scheduledFunc); - this.scheduledFunctions[timeoutKey] = jasmine.undefined; - } - } - - if (funcsToRun.length > 0) { - funcsToRun.sort(function(a, b) { - return a.runAtMillis - b.runAtMillis; - }); - for (var i = 0; i < funcsToRun.length; ++i) { - try { - var funcToRun = funcsToRun[i]; - this.nowMillis = funcToRun.runAtMillis; - funcToRun.funcToCall(); - if (funcToRun.recurring) { - this.scheduleFunction(funcToRun.timeoutKey, - funcToRun.funcToCall, - funcToRun.millis, - true); - } - } catch (e) { - } - } - this.runFunctionsWithinRange(oldMillis, nowMillis); - } -}; - -jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) { - this.scheduledFunctions[timeoutKey] = { - runAtMillis: this.nowMillis + millis, - funcToCall: funcToCall, - recurring: recurring, - timeoutKey: timeoutKey, - millis: millis - }; -}; - -/** - * @namespace - */ -jasmine.Clock = { - defaultFakeTimer: new jasmine.FakeTimer(), - - reset: function() { - jasmine.Clock.assertInstalled(); - jasmine.Clock.defaultFakeTimer.reset(); - }, - - tick: function(millis) { - jasmine.Clock.assertInstalled(); - jasmine.Clock.defaultFakeTimer.tick(millis); - }, - - runFunctionsWithinRange: function(oldMillis, nowMillis) { - jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis); - }, - - scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { - jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring); - }, - - useMock: function() { - if (!jasmine.Clock.isInstalled()) { - var spec = jasmine.getEnv().currentSpec; - spec.after(jasmine.Clock.uninstallMock); - - jasmine.Clock.installMock(); - } - }, - - installMock: function() { - jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; - }, - - uninstallMock: function() { - jasmine.Clock.assertInstalled(); - jasmine.Clock.installed = jasmine.Clock.real; - }, - - real: { - setTimeout: jasmine.getGlobal().setTimeout, - clearTimeout: jasmine.getGlobal().clearTimeout, - setInterval: jasmine.getGlobal().setInterval, - clearInterval: jasmine.getGlobal().clearInterval - }, - - assertInstalled: function() { - if (!jasmine.Clock.isInstalled()) { - throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); - } - }, - - isInstalled: function() { - return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer; - }, - - installed: null -}; -jasmine.Clock.installed = jasmine.Clock.real; - -//else for IE support -jasmine.getGlobal().setTimeout = function(funcToCall, millis) { - if (jasmine.Clock.installed.setTimeout.apply) { - return jasmine.Clock.installed.setTimeout.apply(this, arguments); - } else { - return jasmine.Clock.installed.setTimeout(funcToCall, millis); - } -}; - -jasmine.getGlobal().setInterval = function(funcToCall, millis) { - if (jasmine.Clock.installed.setInterval.apply) { - return jasmine.Clock.installed.setInterval.apply(this, arguments); - } else { - return jasmine.Clock.installed.setInterval(funcToCall, millis); - } -}; - -jasmine.getGlobal().clearTimeout = function(timeoutKey) { - if (jasmine.Clock.installed.clearTimeout.apply) { - return jasmine.Clock.installed.clearTimeout.apply(this, arguments); - } else { - return jasmine.Clock.installed.clearTimeout(timeoutKey); - } -}; - -jasmine.getGlobal().clearInterval = function(timeoutKey) { - if (jasmine.Clock.installed.clearTimeout.apply) { - return jasmine.Clock.installed.clearInterval.apply(this, arguments); - } else { - return jasmine.Clock.installed.clearInterval(timeoutKey); - } -}; - -/** - * @constructor - */ -jasmine.MultiReporter = function() { - this.subReporters_ = []; -}; -jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter); - -jasmine.MultiReporter.prototype.addReporter = function(reporter) { - this.subReporters_.push(reporter); -}; - -(function() { - var functionNames = [ - "reportRunnerStarting", - "reportRunnerResults", - "reportSuiteResults", - "reportSpecStarting", - "reportSpecResults", - "log" - ]; - for (var i = 0; i < functionNames.length; i++) { - var functionName = functionNames[i]; - jasmine.MultiReporter.prototype[functionName] = (function(functionName) { - return function() { - for (var j = 0; j < this.subReporters_.length; j++) { - var subReporter = this.subReporters_[j]; - if (subReporter[functionName]) { - subReporter[functionName].apply(subReporter, arguments); - } - } - }; - })(functionName); - } -})(); -/** - * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults - * - * @constructor - */ -jasmine.NestedResults = function() { - /** - * The total count of results - */ - this.totalCount = 0; - /** - * Number of passed results - */ - this.passedCount = 0; - /** - * Number of failed results - */ - this.failedCount = 0; - /** - * Was this suite/spec skipped? - */ - this.skipped = false; - /** - * @ignore - */ - this.items_ = []; -}; - -/** - * Roll up the result counts. - * - * @param result - */ -jasmine.NestedResults.prototype.rollupCounts = function(result) { - this.totalCount += result.totalCount; - this.passedCount += result.passedCount; - this.failedCount += result.failedCount; -}; - -/** - * Adds a log message. - * @param values Array of message parts which will be concatenated later. - */ -jasmine.NestedResults.prototype.log = function(values) { - this.items_.push(new jasmine.MessageResult(values)); -}; - -/** - * Getter for the results: message & results. - */ -jasmine.NestedResults.prototype.getItems = function() { - return this.items_; -}; - -/** - * Adds a result, tracking counts (total, passed, & failed) - * @param {jasmine.ExpectationResult|jasmine.NestedResults} result - */ -jasmine.NestedResults.prototype.addResult = function(result) { - if (result.type != 'log') { - if (result.items_) { - this.rollupCounts(result); - } else { - this.totalCount++; - if (result.passed()) { - this.passedCount++; - } else { - this.failedCount++; - } - } - } - this.items_.push(result); -}; - -/** - * @returns {Boolean} True if everything below passed - */ -jasmine.NestedResults.prototype.passed = function() { - return this.passedCount === this.totalCount; -}; -/** - * Base class for pretty printing for expectation results. - */ -jasmine.PrettyPrinter = function() { - this.ppNestLevel_ = 0; -}; - -/** - * Formats a value in a nice, human-readable string. - * - * @param value - */ -jasmine.PrettyPrinter.prototype.format = function(value) { - if (this.ppNestLevel_ > 40) { - throw new Error('jasmine.PrettyPrinter: format() nested too deeply!'); - } - - this.ppNestLevel_++; - try { - if (value === jasmine.undefined) { - this.emitScalar('undefined'); - } else if (value === null) { - this.emitScalar('null'); - } else if (value === jasmine.getGlobal()) { - this.emitScalar(''); - } else if (value.jasmineToString) { - this.emitScalar(value.jasmineToString()); - } else if (typeof value === 'string') { - this.emitString(value); - } else if (jasmine.isSpy(value)) { - this.emitScalar("spy on " + value.identity); - } else if (value instanceof RegExp) { - this.emitScalar(value.toString()); - } else if (typeof value === 'function') { - this.emitScalar('Function'); - } else if (typeof value.nodeType === 'number') { - this.emitScalar('HTMLNode'); - } else if (value instanceof Date) { - this.emitScalar('Date(' + value + ')'); - } else if (value.__Jasmine_been_here_before__) { - this.emitScalar(''); - } else if (jasmine.isArray_(value) || typeof value == 'object') { - value.__Jasmine_been_here_before__ = true; - if (jasmine.isArray_(value)) { - this.emitArray(value); - } else { - this.emitObject(value); - } - delete value.__Jasmine_been_here_before__; - } else { - this.emitScalar(value.toString()); - } - } finally { - this.ppNestLevel_--; - } -}; - -jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { - for (var property in obj) { - if (property == '__Jasmine_been_here_before__') { - continue; - } - fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined && - obj.__lookupGetter__(property) !== null) : false); - } -}; - -jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_; -jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_; -jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_; -jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_; - -jasmine.StringPrettyPrinter = function() { - jasmine.PrettyPrinter.call(this); - - this.string = ''; -}; -jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter); - -jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) { - this.append(value); -}; - -jasmine.StringPrettyPrinter.prototype.emitString = function(value) { - this.append("'" + value + "'"); -}; - -jasmine.StringPrettyPrinter.prototype.emitArray = function(array) { - this.append('[ '); - for (var i = 0; i < array.length; i++) { - if (i > 0) { - this.append(', '); - } - this.format(array[i]); - } - this.append(' ]'); -}; - -jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) { - var self = this; - this.append('{ '); - var first = true; - - this.iterateObject(obj, function(property, isGetter) { - if (first) { - first = false; - } else { - self.append(', '); - } - - self.append(property); - self.append(' : '); - if (isGetter) { - self.append(''); - } else { - self.format(obj[property]); - } - }); - - this.append(' }'); -}; - -jasmine.StringPrettyPrinter.prototype.append = function(value) { - this.string += value; -}; -jasmine.Queue = function(env) { - this.env = env; - this.blocks = []; - this.running = false; - this.index = 0; - this.offset = 0; - this.abort = false; -}; - -jasmine.Queue.prototype.addBefore = function(block) { - this.blocks.unshift(block); -}; - -jasmine.Queue.prototype.add = function(block) { - this.blocks.push(block); -}; - -jasmine.Queue.prototype.insertNext = function(block) { - this.blocks.splice((this.index + this.offset + 1), 0, block); - this.offset++; -}; - -jasmine.Queue.prototype.start = function(onComplete) { - this.running = true; - this.onComplete = onComplete; - this.next_(); -}; - -jasmine.Queue.prototype.isRunning = function() { - return this.running; -}; - -jasmine.Queue.LOOP_DONT_RECURSE = true; - -jasmine.Queue.prototype.next_ = function() { - var self = this; - var goAgain = true; - - while (goAgain) { - goAgain = false; - if (self.index < self.blocks.length && !this.abort) { - var calledSynchronously = true; - var completedSynchronously = false; - - var onComplete = function () { - if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) { - completedSynchronously = true; - return; - } - - if (self.blocks[self.index].abort) { - self.abort = true; - } - - self.offset = 0; - self.index++; - - var now = new Date().getTime(); - if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) { - self.env.lastUpdate = now; - self.env.setTimeout(function() { - self.next_(); - }, 0); - } else { - if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) { - goAgain = true; - } else { - self.next_(); - } - } - }; - self.blocks[self.index].execute(onComplete); - - calledSynchronously = false; - if (completedSynchronously) { - onComplete(); - } - - } else { - self.running = false; - if (self.onComplete) { - self.onComplete(); - } - } - } -}; - -jasmine.Queue.prototype.results = function() { - var results = new jasmine.NestedResults(); - for (var i = 0; i < this.blocks.length; i++) { - if (this.blocks[i].results) { - results.addResult(this.blocks[i].results()); - } - } - return results; -}; - -/** - * Runner - * - * @constructor - * @param {jasmine.Env} env - */ -jasmine.Runner = function(env) { - var self = this; - self.env = env; - self.queue = new jasmine.Queue(env); - self.before_ = []; - self.after_ = []; - self.suites_ = []; -}; - -jasmine.Runner.prototype.execute = function() { - var self = this; - if (self.env.reporter.reportRunnerStarting) { - self.env.reporter.reportRunnerStarting(this); - } - self.queue.start(function () { - self.finishCallback(); - }); -}; - -jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) { - beforeEachFunction.typeName = 'beforeEach'; - this.before_.splice(0,0,beforeEachFunction); -}; - -jasmine.Runner.prototype.afterEach = function(afterEachFunction) { - afterEachFunction.typeName = 'afterEach'; - this.after_.splice(0,0,afterEachFunction); -}; - -jasmine.Runner.prototype.finishCallback = function() { - this.env.reporter.reportRunnerResults(this); -}; - -jasmine.Runner.prototype.addSuite = function(suite) { - this.suites_.push(suite); -}; - -jasmine.Runner.prototype.add = function(block) { - if (block instanceof jasmine.Suite) { - this.addSuite(block); - } - this.queue.add(block); -}; - -jasmine.Runner.prototype.specs = function () { - var suites = this.suites(); - var specs = []; - for (var i = 0; i < suites.length; i++) { - specs = specs.concat(suites[i].specs()); - } - return specs; -}; - -jasmine.Runner.prototype.suites = function() { - return this.suites_; -}; - -jasmine.Runner.prototype.topLevelSuites = function() { - var topLevelSuites = []; - for (var i = 0; i < this.suites_.length; i++) { - if (!this.suites_[i].parentSuite) { - topLevelSuites.push(this.suites_[i]); - } - } - return topLevelSuites; -}; - -jasmine.Runner.prototype.results = function() { - return this.queue.results(); -}; -/** - * Internal representation of a Jasmine specification, or test. - * - * @constructor - * @param {jasmine.Env} env - * @param {jasmine.Suite} suite - * @param {String} description - */ -jasmine.Spec = function(env, suite, description) { - if (!env) { - throw new Error('jasmine.Env() required'); - } - if (!suite) { - throw new Error('jasmine.Suite() required'); - } - var spec = this; - spec.id = env.nextSpecId ? env.nextSpecId() : null; - spec.env = env; - spec.suite = suite; - spec.description = description; - spec.queue = new jasmine.Queue(env); - - spec.afterCallbacks = []; - spec.spies_ = []; - - spec.results_ = new jasmine.NestedResults(); - spec.results_.description = description; - spec.matchersClass = null; -}; - -jasmine.Spec.prototype.getFullName = function() { - return this.suite.getFullName() + ' ' + this.description + '.'; -}; - -jasmine.Spec.prototype.results = function() { - return this.results_; -}; - -/** - * All parameters are pretty-printed and concatenated together, then written to the spec's output. - * - * Be careful not to leave calls to jasmine.log in production code. - */ -jasmine.Spec.prototype.log = function() { - return this.results_.log(arguments); -}; - -jasmine.Spec.prototype.runs = function (func) { - var block = new jasmine.Block(this.env, func, this); - this.addToQueue(block); - return this; -}; - -jasmine.Spec.prototype.addToQueue = function (block) { - if (this.queue.isRunning()) { - this.queue.insertNext(block); - } else { - this.queue.add(block); - } -}; - -/** - * @param {jasmine.ExpectationResult} result - */ -jasmine.Spec.prototype.addMatcherResult = function(result) { - this.results_.addResult(result); -}; - -jasmine.Spec.prototype.expect = function(actual) { - var positive = new (this.getMatchersClass_())(this.env, actual, this); - positive.not = new (this.getMatchersClass_())(this.env, actual, this, true); - return positive; -}; - -/** - * Waits a fixed time period before moving to the next block. - * - * @deprecated Use waitsFor() instead - * @param {Number} timeout milliseconds to wait - */ -jasmine.Spec.prototype.waits = function(timeout) { - var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); - this.addToQueue(waitsFunc); - return this; -}; - -/** - * Waits for the latchFunction to return true before proceeding to the next block. - * - * @param {Function} latchFunction - * @param {String} optional_timeoutMessage - * @param {Number} optional_timeout - */ -jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { - var latchFunction_ = null; - var optional_timeoutMessage_ = null; - var optional_timeout_ = null; - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - switch (typeof arg) { - case 'function': - latchFunction_ = arg; - break; - case 'string': - optional_timeoutMessage_ = arg; - break; - case 'number': - optional_timeout_ = arg; - break; - } - } - - var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this); - this.addToQueue(waitsForFunc); - return this; -}; - -jasmine.Spec.prototype.fail = function (e) { - var expectationResult = new jasmine.ExpectationResult({ - passed: false, - message: e ? jasmine.util.formatException(e) : 'Exception', - trace: { stack: e.stack } - }); - this.results_.addResult(expectationResult); -}; - -jasmine.Spec.prototype.getMatchersClass_ = function() { - return this.matchersClass || this.env.matchersClass; -}; - -jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { - var parent = this.getMatchersClass_(); - var newMatchersClass = function() { - parent.apply(this, arguments); - }; - jasmine.util.inherit(newMatchersClass, parent); - jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass); - this.matchersClass = newMatchersClass; -}; - -jasmine.Spec.prototype.finishCallback = function() { - this.env.reporter.reportSpecResults(this); -}; - -jasmine.Spec.prototype.finish = function(onComplete) { - this.removeAllSpies(); - this.finishCallback(); - if (onComplete) { - onComplete(); - } -}; - -jasmine.Spec.prototype.after = function(doAfter) { - if (this.queue.isRunning()) { - this.queue.add(new jasmine.Block(this.env, doAfter, this)); - } else { - this.afterCallbacks.unshift(doAfter); - } -}; - -jasmine.Spec.prototype.execute = function(onComplete) { - var spec = this; - if (!spec.env.specFilter(spec)) { - spec.results_.skipped = true; - spec.finish(onComplete); - return; - } - - this.env.reporter.reportSpecStarting(this); - - spec.env.currentSpec = spec; - - spec.addBeforesAndAftersToQueue(); - - spec.queue.start(function () { - spec.finish(onComplete); - }); -}; - -jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { - var runner = this.env.currentRunner(); - var i; - - for (var suite = this.suite; suite; suite = suite.parentSuite) { - for (i = 0; i < suite.before_.length; i++) { - this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this)); - } - } - for (i = 0; i < runner.before_.length; i++) { - this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this)); - } - for (i = 0; i < this.afterCallbacks.length; i++) { - this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); - } - for (suite = this.suite; suite; suite = suite.parentSuite) { - for (i = 0; i < suite.after_.length; i++) { - this.queue.add(new jasmine.Block(this.env, suite.after_[i], this)); - } - } - for (i = 0; i < runner.after_.length; i++) { - this.queue.add(new jasmine.Block(this.env, runner.after_[i], this)); - } -}; - -jasmine.Spec.prototype.explodes = function() { - throw 'explodes function should not have been called'; -}; - -jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { - if (obj == jasmine.undefined) { - throw "spyOn could not find an object to spy upon for " + methodName + "()"; - } - - if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) { - throw methodName + '() method does not exist'; - } - - if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { - throw new Error(methodName + ' has already been spied upon'); - } - - var spyObj = jasmine.createSpy(methodName); - - this.spies_.push(spyObj); - spyObj.baseObj = obj; - spyObj.methodName = methodName; - spyObj.originalValue = obj[methodName]; - - obj[methodName] = spyObj; - - return spyObj; -}; - -jasmine.Spec.prototype.removeAllSpies = function() { - for (var i = 0; i < this.spies_.length; i++) { - var spy = this.spies_[i]; - spy.baseObj[spy.methodName] = spy.originalValue; - } - this.spies_ = []; -}; - -/** - * Internal representation of a Jasmine suite. - * - * @constructor - * @param {jasmine.Env} env - * @param {String} description - * @param {Function} specDefinitions - * @param {jasmine.Suite} parentSuite - */ -jasmine.Suite = function(env, description, specDefinitions, parentSuite) { - var self = this; - self.id = env.nextSuiteId ? env.nextSuiteId() : null; - self.description = description; - self.queue = new jasmine.Queue(env); - self.parentSuite = parentSuite; - self.env = env; - self.before_ = []; - self.after_ = []; - self.children_ = []; - self.suites_ = []; - self.specs_ = []; -}; - -jasmine.Suite.prototype.getFullName = function() { - var fullName = this.description; - for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { - fullName = parentSuite.description + ' ' + fullName; - } - return fullName; -}; - -jasmine.Suite.prototype.finish = function(onComplete) { - this.env.reporter.reportSuiteResults(this); - this.finished = true; - if (typeof(onComplete) == 'function') { - onComplete(); - } -}; - -jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { - beforeEachFunction.typeName = 'beforeEach'; - this.before_.unshift(beforeEachFunction); -}; - -jasmine.Suite.prototype.afterEach = function(afterEachFunction) { - afterEachFunction.typeName = 'afterEach'; - this.after_.unshift(afterEachFunction); -}; - -jasmine.Suite.prototype.results = function() { - return this.queue.results(); -}; - -jasmine.Suite.prototype.add = function(suiteOrSpec) { - this.children_.push(suiteOrSpec); - if (suiteOrSpec instanceof jasmine.Suite) { - this.suites_.push(suiteOrSpec); - this.env.currentRunner().addSuite(suiteOrSpec); - } else { - this.specs_.push(suiteOrSpec); - } - this.queue.add(suiteOrSpec); -}; - -jasmine.Suite.prototype.specs = function() { - return this.specs_; -}; - -jasmine.Suite.prototype.suites = function() { - return this.suites_; -}; - -jasmine.Suite.prototype.children = function() { - return this.children_; -}; - -jasmine.Suite.prototype.execute = function(onComplete) { - var self = this; - this.queue.start(function () { - self.finish(onComplete); - }); -}; -jasmine.WaitsBlock = function(env, timeout, spec) { - this.timeout = timeout; - jasmine.Block.call(this, env, null, spec); -}; - -jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); - -jasmine.WaitsBlock.prototype.execute = function (onComplete) { - if (jasmine.VERBOSE) { - this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); - } - this.env.setTimeout(function () { - onComplete(); - }, this.timeout); -}; -/** - * A block which waits for some condition to become true, with timeout. - * - * @constructor - * @extends jasmine.Block - * @param {jasmine.Env} env The Jasmine environment. - * @param {Number} timeout The maximum time in milliseconds to wait for the condition to become true. - * @param {Function} latchFunction A function which returns true when the desired condition has been met. - * @param {String} message The message to display if the desired condition hasn't been met within the given time period. - * @param {jasmine.Spec} spec The Jasmine spec. - */ -jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) { - this.timeout = timeout || env.defaultTimeoutInterval; - this.latchFunction = latchFunction; - this.message = message; - this.totalTimeSpentWaitingForLatch = 0; - jasmine.Block.call(this, env, null, spec); -}; -jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); - -jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10; - -jasmine.WaitsForBlock.prototype.execute = function(onComplete) { - if (jasmine.VERBOSE) { - this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen')); - } - var latchFunctionResult; - try { - latchFunctionResult = this.latchFunction.apply(this.spec); - } catch (e) { - this.spec.fail(e); - onComplete(); - return; - } - - if (latchFunctionResult) { - onComplete(); - } else if (this.totalTimeSpentWaitingForLatch >= this.timeout) { - var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen'); - this.spec.fail({ - name: 'timeout', - message: message - }); - - this.abort = true; - onComplete(); - } else { - this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; - var self = this; - this.env.setTimeout(function() { - self.execute(onComplete); - }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); - } -}; - -jasmine.version_= { - "major": 1, - "minor": 2, - "build": 0, - "revision": 1333557965, - "release_candidate": 3 -}; diff --git a/test/reporter.js b/test/reporter.js deleted file mode 100644 index b4d0ca06..00000000 --- a/test/reporter.js +++ /dev/null @@ -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; -}; \ No newline at end of file diff --git a/test/runner.js b/test/runner.js deleted file mode 100644 index 828cdda4..00000000 --- a/test/runner.js +++ /dev/null @@ -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(); -}; diff --git a/test/spec-collection.js b/test/spec-collection.js deleted file mode 100644 index 1b940714..00000000 --- a/test/spec-collection.js +++ /dev/null @@ -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); -}; diff --git a/test/specs/documentation/alias.js b/test/specs/documentation/alias.js index 390082c0..7c89ee5d 100644 --- a/test/specs/documentation/alias.js +++ b/test/specs/documentation/alias.js @@ -1,6 +1,6 @@ describe('aliases', () => { 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 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.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/alias2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias2.js'); const foundMember = docSet.getByLongname('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.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/alias3.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias3.js'); const tcmValue = docSet.getByLongname('trackr.CookieManager#value')[0]; 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', () => { - 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'); expect(jacketClass.length).toBe(1); @@ -40,7 +40,7 @@ describe('aliases', () => { }); 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 getInstance = docSet.getByLongname('Toaster.getInstance')[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', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/alias6.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/alias6.js'); const constructor = docSet.getByLongname('module:example')[2]; expect(constructor.undocumented).toBe(true); @@ -77,14 +77,14 @@ describe('aliases', () => { }); it('When a symbol is documented as a static member of , 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]; expect(log.scope).toEqual('global'); }); it('When a symbol is documented as an instance member of , 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]; expect(run.scope).toEqual('instance'); @@ -93,14 +93,14 @@ describe('aliases', () => { describe('resolving', () => { 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'); 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.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/aliasresolve2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/aliasresolve2.js'); const method = docSet.getByLongname('A.F.method'); expect(method.length).toEqual(1); diff --git a/test/specs/documentation/also.js b/test/specs/documentation/also.js index 2fb5d5d4..a94874e4 100644 --- a/test/specs/documentation/also.js +++ b/test/specs/documentation/also.js @@ -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 shape = docSet.getByLongname('Asset#shape').filter(undocumented); @@ -60,7 +60,7 @@ describe('multiple doclets per symbol', () => { logger.addListener('logger:error', errorListener); env.conf.tags.allowUnknownTags = false; - jasmine.getDocSetFromFile('test/fixtures/also2.js'); + jsdoc.getDocSetFromFile('test/fixtures/also2.js'); expect(errors[0]).not.toBeDefined(); logger.removeListener('logger:error', errorListener); diff --git a/test/specs/documentation/anonymousclass.js b/test/specs/documentation/anonymousclass.js index c6214bd9..931aa7c0 100644 --- a/test/specs/documentation/anonymousclass.js +++ b/test/specs/documentation/anonymousclass.js @@ -1,5 +1,5 @@ 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 foo = docSet.getByLongname('module:test#foo')[0]; const klassTest = docSet.getByLongname('module:test#test')[0]; diff --git a/test/specs/documentation/anonymousclassparam.js b/test/specs/documentation/anonymousclassparam.js index 6eb2d68f..aef79f70 100644 --- a/test/specs/documentation/anonymousclassparam.js +++ b/test/specs/documentation/anonymousclassparam.js @@ -1,7 +1,7 @@ describe('anonymous class passed as a parameter', () => { it('should not crash JSDoc', () => { function loadFile() { - jasmine.getDocSetFromFile('test/fixtures/anonymousclassparam.js'); + jsdoc.getDocSetFromFile('test/fixtures/anonymousclassparam.js'); } expect(loadFile).not.toThrow(); diff --git a/test/specs/documentation/arrowfunction.js b/test/specs/documentation/arrowfunction.js index aed919dc..297e525f 100644 --- a/test/specs/documentation/arrowfunction.js +++ b/test/specs/documentation/arrowfunction.js @@ -1,5 +1,5 @@ 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 print = docSet.getByLongname('print')[0]; const name = docSet.getByLongname('#name'); diff --git a/test/specs/documentation/asyncfunction.js b/test/specs/documentation/asyncfunction.js index d4aa5dcc..9dac664b 100644 --- a/test/specs/documentation/asyncfunction.js +++ b/test/specs/documentation/asyncfunction.js @@ -1,5 +1,5 @@ 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 subtract = docSet.getByLongname('subtract')[0]; const adderAdd = docSet.getByLongname('Adder#add')[0]; diff --git a/test/specs/documentation/callback.js b/test/specs/documentation/callback.js index 1c4c4c94..6e205eae 100644 --- a/test/specs/documentation/callback.js +++ b/test/specs/documentation/callback.js @@ -1,5 +1,5 @@ describe('callback tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/callbacktag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/callbacktag.js'); function callbackTests(callback) { expect(callback).toBeDefined(); diff --git a/test/specs/documentation/classproperties.js b/test/specs/documentation/classproperties.js index 1189ba8b..393e823f 100644 --- a/test/specs/documentation/classproperties.js +++ b/test/specs/documentation/classproperties.js @@ -1,5 +1,5 @@ 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 c = docSet.getByLongname('A#c')[0]; const d = docSet.getByLongname('A#d')[0]; diff --git a/test/specs/documentation/classwithoutname.js b/test/specs/documentation/classwithoutname.js index 462805f1..0b3a5356 100644 --- a/test/specs/documentation/classwithoutname.js +++ b/test/specs/documentation/classwithoutname.js @@ -1,5 +1,5 @@ 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 === ''); it('When the doclet for a class has an empty name, it should also have an empty longname', () => { diff --git a/test/specs/documentation/const.js b/test/specs/documentation/const.js index 5e4d0b8b..1f7e818d 100644 --- a/test/specs/documentation/const.js +++ b/test/specs/documentation/const.js @@ -1,6 +1,6 @@ describe('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]; expect(myPocket.kind).toBe('constant'); @@ -8,7 +8,7 @@ describe('const declarations', () => { describe('ES 2015 only', () => { 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]; expect(foo.kind).toBe('class'); diff --git a/test/specs/documentation/defaultparams.js b/test/specs/documentation/defaultparams.js index 2f816a30..70b0d61b 100644 --- a/test/specs/documentation/defaultparams.js +++ b/test/specs/documentation/defaultparams.js @@ -1,5 +1,5 @@ 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 setBirthYear = docSet.getByLongname('setBirthYear')[0]; @@ -53,7 +53,7 @@ describe('default parameters', () => { }); 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]; diff --git a/test/specs/documentation/emptycomments.js b/test/specs/documentation/emptycomments.js index dc68fa59..e3b2879b 100644 --- a/test/specs/documentation/emptycomments.js +++ b/test/specs/documentation/emptycomments.js @@ -3,7 +3,7 @@ const logger = require('jsdoc/util/logger'); describe('empty JSDoc comments', () => { it('should not report an error when a JSDoc comment contains only whitespace', () => { spyOn(logger, 'error'); - jasmine.getDocSetFromFile('test/fixtures/emptycomments.js'); + jsdoc.getDocSetFromFile('test/fixtures/emptycomments.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/documentation/exportclass.js b/test/specs/documentation/exportclass.js index 3565de14..10345c8d 100644 --- a/test/specs/documentation/exportclass.js +++ b/test/specs/documentation/exportclass.js @@ -1,5 +1,5 @@ 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]; it('should name exported classes correctly', () => { diff --git a/test/specs/documentation/exportdefault.js b/test/specs/documentation/exportdefault.js index aef55902..5511014e 100644 --- a/test/specs/documentation/exportdefault.js +++ b/test/specs/documentation/exportdefault.js @@ -1,5 +1,5 @@ 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]; it('should use the correct kind and description for the default export', () => { diff --git a/test/specs/documentation/exportdefaultclass.js b/test/specs/documentation/exportdefaultclass.js index 199425f1..5ec8d6ed 100644 --- a/test/specs/documentation/exportdefaultclass.js +++ b/test/specs/documentation/exportdefaultclass.js @@ -1,5 +1,5 @@ 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]; it('should combine the classdesc and constructor description into a single doclet', () => { diff --git a/test/specs/documentation/exports.js b/test/specs/documentation/exports.js index 5da32086..8b1b81af 100644 --- a/test/specs/documentation/exports.js +++ b/test/specs/documentation/exports.js @@ -1,5 +1,5 @@ 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 sayGoodbye = docSet.getByLongname('module:hello/world.sayGoodbye')[0]; diff --git a/test/specs/documentation/funcExpression.js b/test/specs/documentation/funcExpression.js index 98f988ae..2caf60a9 100644 --- a/test/specs/documentation/funcExpression.js +++ b/test/specs/documentation/funcExpression.js @@ -15,14 +15,14 @@ describe('function expressions', () => { } describe('standard', () => { - checkLongnames( jasmine.getDocSetFromFile('test/fixtures/funcExpression.js') ); + checkLongnames( jsdoc.getDocSetFromFile('test/fixtures/funcExpression.js') ); }); describe('global', () => { - checkLongnames( jasmine.getDocSetFromFile('test/fixtures/funcExpression2.js') ); + checkLongnames( jsdoc.getDocSetFromFile('test/fixtures/funcExpression2.js') ); }); describe('as object literal property', () => { - checkLongnames( jasmine.getDocSetFromFile('test/fixtures/funcExpression3.js'), 'ns.' ); + checkLongnames( jsdoc.getDocSetFromFile('test/fixtures/funcExpression3.js'), 'ns.' ); }); }); diff --git a/test/specs/documentation/generators.js b/test/specs/documentation/generators.js index 5b1aa96b..9d37847e 100644 --- a/test/specs/documentation/generators.js +++ b/test/specs/documentation/generators.js @@ -1,5 +1,5 @@ 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 startsAt1 = docSet.getByLongname('startsAt1')[0]; const startsAt2 = docSet.getByLongname('Generator#startsAt2')[0]; diff --git a/test/specs/documentation/getset.js b/test/specs/documentation/getset.js index b7d9bb3b..edaf2a54 100644 --- a/test/specs/documentation/getset.js +++ b/test/specs/documentation/getset.js @@ -1,5 +1,5 @@ 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', () => { 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', () => { - const docSet2 = jasmine.getDocSetFromFile('test/fixtures/getset2.js'); + const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/getset2.js'); const location = docSet2.getByLongname('Employee#location'); it('should have a doclet with the correct longname', () => { diff --git a/test/specs/documentation/inlinecomment.js b/test/specs/documentation/inlinecomment.js index 314fde08..7c5f1e0a 100644 --- a/test/specs/documentation/inlinecomment.js +++ b/test/specs/documentation/inlinecomment.js @@ -1,5 +1,5 @@ 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 t2 = docSet.getByLongname('test2'); diff --git a/test/specs/documentation/inlineparamcomment.js b/test/specs/documentation/inlineparamcomment.js index 83d6dccf..b2a5b769 100644 --- a/test/specs/documentation/inlineparamcomment.js +++ b/test/specs/documentation/inlineparamcomment.js @@ -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' + 'JSDoc tags', () => { function loadDocSet() { - jasmine.getDocSetFromFile('test/fixtures/inlineparamcomment.js'); + jsdoc.getDocSetFromFile('test/fixtures/inlineparamcomment.js'); } expect(loadDocSet).not.toThrow(); }); 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]; it('should attach inline comments to default parameters', () => { diff --git a/test/specs/documentation/inner.js b/test/specs/documentation/inner.js index b7397856..a59f0a90 100644 --- a/test/specs/documentation/inner.js +++ b/test/specs/documentation/inner.js @@ -1,5 +1,5 @@ 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 found2 = docSet.getByLongname('sendMessage~encrypt'); diff --git a/test/specs/documentation/innerscope.js b/test/specs/documentation/innerscope.js index 703d27f2..411dee9c 100644 --- a/test/specs/documentation/innerscope.js +++ b/test/specs/documentation/innerscope.js @@ -1,6 +1,6 @@ describe('inner scope', () => { 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 from = docSet.getByLongname('Message~headers.from'); const response = docSet.getByLongname('Message~response.code'); @@ -19,7 +19,7 @@ describe('inner scope', () => { }); describe('other cases', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/innerscope2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/innerscope2.js'); const from = docSet.getByLongname('~headers.from'); const cache = docSet.getByLongname('~headers.cache'); diff --git a/test/specs/documentation/instanceproperty.js b/test/specs/documentation/instanceproperty.js index e81a200a..6a32f7e9 100644 --- a/test/specs/documentation/instanceproperty.js +++ b/test/specs/documentation/instanceproperty.js @@ -1,5 +1,5 @@ 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]; it('should set the correct longname when a property is documented in an instance method', () => { diff --git a/test/specs/documentation/jsx.js b/test/specs/documentation/jsx.js index 9854cc58..a8c8b7d5 100644 --- a/test/specs/documentation/jsx.js +++ b/test/specs/documentation/jsx.js @@ -3,7 +3,7 @@ describe('JSX support', () => { const logger = require('jsdoc/util/logger'); function parseJsx() { - return jasmine.getDocSetFromFile('test/fixtures/jsx.js'); + return jsdoc.getDocSetFromFile('test/fixtures/jsx.js'); } spyOn(logger, 'error'); diff --git a/test/specs/documentation/lends.js b/test/specs/documentation/lends.js index 3bc2ccf4..9d1603a9 100644 --- a/test/specs/documentation/lends.js +++ b/test/specs/documentation/lends.js @@ -5,7 +5,7 @@ describe('lends', () => { } 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 name = docSet.getByLongname('Person#name'); @@ -19,7 +19,7 @@ describe('lends', () => { }); 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 name = docSet.getByLongname('Person#name'); @@ -37,7 +37,7 @@ describe('lends', () => { }); 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 name = docSet.getByLongname('Person#name'); @@ -51,7 +51,7 @@ describe('lends', () => { }); 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 say = docSet.getByLongname('Person#say'); @@ -67,7 +67,7 @@ describe('lends', () => { }); 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 say = docSet.getByLongname('Person#say').filter(removeUndocumented)[0]; @@ -83,7 +83,7 @@ describe('lends', () => { }); 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', () => { 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.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/lendsglobal.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/lendsglobal.js'); const testf = docSet.getByLongname('test')[0]; const test12 = docSet.getByLongname('test1.test2')[0]; diff --git a/test/specs/documentation/letkeyword.js b/test/specs/documentation/letkeyword.js index d5583df6..eceb4902 100644 --- a/test/specs/documentation/letkeyword.js +++ b/test/specs/documentation/letkeyword.js @@ -4,7 +4,7 @@ describe('let keyword', () => { let exampleMethod; function getDocSet() { - docSet = jasmine.getDocSetFromFile('test/fixtures/letkeyword.js'); + docSet = jsdoc.getDocSetFromFile('test/fixtures/letkeyword.js'); exampleModule = docSet.getByLongname('module:exampleModule'); exampleMethod = docSet.getByLongname('module:exampleModule.exampleMethod'); } diff --git a/test/specs/documentation/methoddefinition.js b/test/specs/documentation/methoddefinition.js index ce444839..4377695b 100644 --- a/test/specs/documentation/methoddefinition.js +++ b/test/specs/documentation/methoddefinition.js @@ -1,5 +1,5 @@ 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 staticRunMethod = docSet.getByLongname('Test.run')[0]; diff --git a/test/specs/documentation/mixins.js b/test/specs/documentation/mixins.js index 5ca0a075..40bfaf85 100644 --- a/test/specs/documentation/mixins.js +++ b/test/specs/documentation/mixins.js @@ -3,7 +3,7 @@ const name = require('jsdoc/name'); describe('mixins', () => { describe('doclet augmentation', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/mixintag2.js'); augment.augmentAll(docSet.doclets); diff --git a/test/specs/documentation/moduleclasses.js b/test/specs/documentation/moduleclasses.js index a6e161c1..56767cd3 100644 --- a/test/specs/documentation/moduleclasses.js +++ b/test/specs/documentation/moduleclasses.js @@ -3,7 +3,7 @@ function filter({undocumented}) { } 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 barBar = docSet.getByLongname('module:foo~Bar#bar')[0]; const baz = docSet.getByLongname('module:foo.Baz').filter(filter)[0]; diff --git a/test/specs/documentation/moduleinner.js b/test/specs/documentation/moduleinner.js index e60cecb5..840d32df 100644 --- a/test/specs/documentation/moduleinner.js +++ b/test/specs/documentation/moduleinner.js @@ -1,5 +1,5 @@ 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 fooOut = docSet.getByLongname('module:my/module~fooOut')[0]; diff --git a/test/specs/documentation/moduleisconstructor.js b/test/specs/documentation/moduleisconstructor.js index 3b3260d9..f0e54bcf 100644 --- a/test/specs/documentation/moduleisconstructor.js +++ b/test/specs/documentation/moduleisconstructor.js @@ -1,6 +1,6 @@ describe('module that exports a constructor', () => { 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 classes = docSet.doclets.filter(({kind}) => kind === 'class'); const getId = docSet.getByLongname('module:mymodule/config#getId')[0]; @@ -44,7 +44,7 @@ describe('module that exports a constructor', () => { }); 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 classes = docSet.doclets.filter(({kind, classdesc, description}) => kind === 'class' && classdesc && description); const getId = docSet.getByLongname('module:mymodule/config#getId')[0]; diff --git a/test/specs/documentation/moduleisfunction.js b/test/specs/documentation/moduleisfunction.js index 9a7b50c3..e47ac8dd 100644 --- a/test/specs/documentation/moduleisfunction.js +++ b/test/specs/documentation/moduleisfunction.js @@ -1,5 +1,5 @@ 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'); it('should include one doclet whose kind is "function"', () => { diff --git a/test/specs/documentation/modules.js b/test/specs/documentation/modules.js index d10623dc..5969a61e 100644 --- a/test/specs/documentation/modules.js +++ b/test/specs/documentation/modules.js @@ -13,7 +13,7 @@ describe('module names', () => { env.opts._ = [path.normalize(`${env.pwd}/test/fixtures/modules/data/`)]; env.pwd = env.dirname; env.sourceFiles = []; - srcParser = jasmine.createParser(); + srcParser = jsdoc.createParser(); require('jsdoc/src/handlers').attachTo(srcParser); }); diff --git a/test/specs/documentation/objectkeys.js b/test/specs/documentation/objectkeys.js index 277f790c..9afbf158 100644 --- a/test/specs/documentation/objectkeys.js +++ b/test/specs/documentation/objectkeys.js @@ -1,5 +1,5 @@ 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', () => { const bar = docSet.getByLongname('myObject.bar')[0]; diff --git a/test/specs/documentation/objectlit.js b/test/specs/documentation/objectlit.js index 96789cde..85b99df1 100644 --- a/test/specs/documentation/objectlit.js +++ b/test/specs/documentation/objectlit.js @@ -1,6 +1,6 @@ describe('object literals', () => { 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'); 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', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/objectlit2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/objectlit2.js'); const found = docSet.getByLongname('position.axis.x'); it('should have a doclet with the correct longname', () => { @@ -46,7 +46,7 @@ describe('object literals', () => { let found; function loadDocSet() { - docSet = jasmine.getDocSetFromFile('test/fixtures/objectlit3.js'); + docSet = jsdoc.getDocSetFromFile('test/fixtures/objectlit3.js'); found = docSet.getByLongname('tokens."(".before'); } diff --git a/test/specs/documentation/objectpropertykeys.js b/test/specs/documentation/objectpropertykeys.js index fb97755b..88b78030 100644 --- a/test/specs/documentation/objectpropertykeys.js +++ b/test/specs/documentation/objectpropertykeys.js @@ -1,6 +1,6 @@ describe('using existing Object properties as object literal keys', () => { function loadDocSet() { - jasmine.getDocSetFromFile('test/fixtures/objectpropertykeys.js'); + jsdoc.getDocSetFromFile('test/fixtures/objectpropertykeys.js'); } it('should not crash', () => { diff --git a/test/specs/documentation/quotename.js b/test/specs/documentation/quotename.js index 6dfc090e..c0286e73 100644 --- a/test/specs/documentation/quotename.js +++ b/test/specs/documentation/quotename.js @@ -1,6 +1,6 @@ describe('quoted names', () => { 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]; it('should have correct name and memberof', () => { @@ -10,7 +10,7 @@ describe('quoted names', () => { }); 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]; it('should have correct name and memberof', () => { diff --git a/test/specs/documentation/restparams.js b/test/specs/documentation/restparams.js index 6289f057..abc244e1 100644 --- a/test/specs/documentation/restparams.js +++ b/test/specs/documentation/restparams.js @@ -1,5 +1,5 @@ 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 setManagers = docSet.getByLongname('setManagers')[0]; const setWidgetAccess = docSet.getByLongname('setWidgetAccess')[0]; @@ -26,7 +26,7 @@ describe('rest parameters', () => { }); 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]; diff --git a/test/specs/documentation/specialchars.js b/test/specs/documentation/specialchars.js index d8e320fc..63e1d0ae 100644 --- a/test/specs/documentation/specialchars.js +++ b/test/specs/documentation/specialchars.js @@ -1,5 +1,5 @@ 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 open = docSet.getByLongname('Socket#\'open~a.connection#now\'')[0]; diff --git a/test/specs/documentation/specialnames.js b/test/specs/documentation/specialnames.js index a1016cb2..253267fd 100644 --- a/test/specs/documentation/specialnames.js +++ b/test/specs/documentation/specialnames.js @@ -1,5 +1,5 @@ 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 constructToString = docSet.getByLongname('constructor.toString')[0]; const hasOwnProp = docSet.getByLongname('hasOwnProperty')[0]; diff --git a/test/specs/documentation/starbangstar.js b/test/specs/documentation/starbangstar.js index 79329f02..a0bb59f7 100644 --- a/test/specs/documentation/starbangstar.js +++ b/test/specs/documentation/starbangstar.js @@ -1,5 +1,5 @@ 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 x = docSet.getByLongname('module:myscript/core.x')[0]; diff --git a/test/specs/documentation/this.js b/test/specs/documentation/this.js index 5c7ee779..70af38ad 100644 --- a/test/specs/documentation/this.js +++ b/test/specs/documentation/this.js @@ -1,6 +1,6 @@ describe('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 found2 = docSet.getByLongname('Singer#isSinging'); @@ -42,7 +42,7 @@ describe('this', () => { }); 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'); 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', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/this3.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/this3.js'); const found = docSet.getByLongname('position'); 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', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/this4.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/this4.js'); const found = docSet.getByLongname('Template#render'); 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', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/this5.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/this5.js'); const found = docSet.getByLongname('module:template.Template#view'); 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', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/this6.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/this6.js'); const someProperty = docSet.getByLongname('module:example#_someProperty')[0]; 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', () => { - 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'); it('should have a longname like Constructor#objlit.member', () => { diff --git a/test/specs/documentation/trailingcomment.js b/test/specs/documentation/trailingcomment.js index 78b10568..5e0854e7 100644 --- a/test/specs/documentation/trailingcomment.js +++ b/test/specs/documentation/trailingcomment.js @@ -1,7 +1,7 @@ describe('trailing comment', () => { it('should not ignore trailing comments in a non-empty source file with a `use strict` ' + 'declaration', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/trailingcomment.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/trailingcomment.js'); const foo = docSet.getByLongname('external:foo'); 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` ' + 'declaration', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/trailingcomment2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/trailingcomment2.js'); const foo = docSet.getByLongname('external:foo'); expect(foo.length).toBe(1); diff --git a/test/specs/documentation/typetaginline.js b/test/specs/documentation/typetaginline.js index 36142d82..1842224a 100644 --- a/test/specs/documentation/typetaginline.js +++ b/test/specs/documentation/typetaginline.js @@ -1,7 +1,7 @@ describe('@type tag inline with function parameters', () => { let info; - const docSet = jasmine.getDocSetFromFile('test/fixtures/typetaginline.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typetaginline.js'); function checkParams({params}, paramInfo) { expect(params).toBeDefined(); diff --git a/test/specs/documentation/typetagwithnewline.js b/test/specs/documentation/typetagwithnewline.js index bb79a06b..e9405c4f 100644 --- a/test/specs/documentation/typetagwithnewline.js +++ b/test/specs/documentation/typetagwithnewline.js @@ -1,5 +1,5 @@ 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 mega = docSet.getByLongname('Matryoshka.mega')[0]; diff --git a/test/specs/documentation/var.js b/test/specs/documentation/var.js index 0cb99124..4113fc86 100644 --- a/test/specs/documentation/var.js +++ b/test/specs/documentation/var.js @@ -1,5 +1,5 @@ describe('var statements', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/var.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/var.js'); const found = [ docSet.getByLongname('GREEN'), docSet.getByLongname('RED'), diff --git a/test/specs/documentation/variations.js b/test/specs/documentation/variations.js index 94e92daa..10939796 100644 --- a/test/specs/documentation/variations.js +++ b/test/specs/documentation/variations.js @@ -1,5 +1,5 @@ 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 fadein2 = docSet.getByLongname('anim.fadein(2)')[0]; diff --git a/test/specs/documentation/virtual.js b/test/specs/documentation/virtual.js index fdc4efff..595eca22 100644 --- a/test/specs/documentation/virtual.js +++ b/test/specs/documentation/virtual.js @@ -1,6 +1,6 @@ describe('virtual symbols', () => { 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 width = docSet.getByLongname('width'); @@ -14,7 +14,7 @@ describe('virtual symbols', () => { }); 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 sayCallback = docSet.getByLongname('Person~sayCallback')[0]; @@ -30,7 +30,7 @@ describe('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'); it('should create multiple doclets for overloaded virtual symbols', () => { diff --git a/test/specs/jsdoc/augment.js b/test/specs/jsdoc/augment.js index 8c15e027..b4e5facb 100644 --- a/test/specs/jsdoc/augment.js +++ b/test/specs/jsdoc/augment.js @@ -37,7 +37,7 @@ describe('jsdoc/augment', () => { describe('augmentAll', () => { 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'); methodNames.forEach(name => { @@ -52,7 +52,7 @@ describe('jsdoc/augment', () => { }); 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; augment.augmentAll(docSet.doclets); @@ -64,7 +64,7 @@ describe('jsdoc/augment', () => { }); 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; augment.augmentAll(docSet.doclets); diff --git a/test/specs/jsdoc/config.js b/test/specs/jsdoc/config.js index 888c6c6c..43b66291 100644 --- a/test/specs/jsdoc/config.js +++ b/test/specs/jsdoc/config.js @@ -1,12 +1,9 @@ describe('jsdoc/config', () => { - const jsdoc = { - config: require('jsdoc/config') - }; - const Config = jsdoc.config; + const Config = require('jsdoc/config'); it('should exist', () => { - expect(jsdoc.config).toBeDefined(); - expect(typeof jsdoc.config).toBe('function'); + expect(Config).toBeDefined(); + expect(typeof Config).toBe('function'); }); it('should provide a "get" instance function', () => { diff --git a/test/specs/jsdoc/doclet.js b/test/specs/jsdoc/doclet.js index 200ce4c4..8b5f739d 100644 --- a/test/specs/jsdoc/doclet.js +++ b/test/specs/jsdoc/doclet.js @@ -1,12 +1,10 @@ describe('jsdoc/doclet', () => { // TODO: more tests const _ = require('lodash'); - const jsdoc = { - doclet: require('jsdoc/doclet') - }; - const Doclet = jsdoc.doclet.Doclet; + const doclet = require('jsdoc/doclet'); + const Doclet = 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 test2 = docSet.getByLongname('test2')[0]; @@ -27,9 +25,9 @@ describe('jsdoc/doclet', () => { describe('setScope', () => { it('should accept the correct scope names', () => { 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 => { @@ -39,9 +37,9 @@ describe('jsdoc/doclet', () => { it('should throw an error for invalid scope names', () => { 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(); @@ -61,7 +59,7 @@ describe('jsdoc/doclet', () => { * Hello! * @version 1.0.0 */`); - const newDoclet = jsdoc.doclet.combine(primaryDoclet, secondaryDoclet); + const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet); Object.getOwnPropertyNames(newDoclet).forEach(property => { expect(newDoclet[property]).toEqual(primaryDoclet[property]); @@ -78,7 +76,7 @@ describe('jsdoc/doclet', () => { /** * Hello! */`); - const newDoclet = jsdoc.doclet.combine(primaryDoclet, secondaryDoclet); + const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet); expect(newDoclet.version).toBe('2.0.0'); }); @@ -91,7 +89,7 @@ describe('jsdoc/doclet', () => { primaryDoclet.undocumented = true; secondaryDoclet.undocumented = true; - newDoclet = jsdoc.doclet.combine(primaryDoclet, secondaryDoclet); + newDoclet = doclet.combine(primaryDoclet, secondaryDoclet); expect(newDoclet.undocumented).not.toBeDefined(); }); @@ -113,7 +111,7 @@ describe('jsdoc/doclet', () => { * @param {string} foo - The foo. * @property {number} bar - The bar. */`); - const newDoclet = jsdoc.doclet.combine(primaryDoclet, secondaryDoclet); + const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet); properties.forEach(property => { expect(newDoclet[property]).toEqual(primaryDoclet[property]); @@ -128,7 +126,7 @@ describe('jsdoc/doclet', () => { * @property {number} bar - The bar. */`; const secondaryDoclet = new Doclet(secondaryComment); - const newDoclet = jsdoc.doclet.combine(primaryDoclet, secondaryDoclet); + const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet); properties.forEach(property => { expect(newDoclet[property]).toEqual(secondaryDoclet[property]); diff --git a/test/specs/jsdoc/name.js b/test/specs/jsdoc/name.js index d78a7809..c3721245 100644 --- a/test/specs/jsdoc/name.js +++ b/test/specs/jsdoc/name.js @@ -1,64 +1,62 @@ describe('jsdoc/name', () => { - const jsdoc = { - doclet: require('jsdoc/doclet'), - name: require('jsdoc/name') - }; + const { Doclet } = require('jsdoc/doclet'); + const name = require('jsdoc/name'); it('should exist', () => { - expect(jsdoc.name).toBeDefined(); - expect(typeof jsdoc.name).toBe('object'); + expect(name).toBeDefined(); + expect(typeof name).toBe('object'); }); it("should export a 'resolve' function", () => { - expect(jsdoc.name.resolve).toBeDefined(); - expect(typeof jsdoc.name.resolve).toBe('function'); + expect(name.resolve).toBeDefined(); + expect(typeof name.resolve).toBe('function'); }); it("should export an 'applyNamespace' function", () => { - expect(jsdoc.name.applyNamespace).toBeDefined(); - expect(typeof jsdoc.name.applyNamespace).toBe('function'); + expect(name.applyNamespace).toBeDefined(); + expect(typeof name.applyNamespace).toBe('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', () => { - expect(typeof jsdoc.name.hasAncestor).toBe('function'); + expect(typeof name.hasAncestor).toBe('function'); }); // TODO: add tests for other exported constants it('should export a SCOPE enum', () => { - expect(jsdoc.name.SCOPE).toBeDefined(); - expect(typeof jsdoc.name.SCOPE).toBe('object'); + expect(name.SCOPE).toBeDefined(); + expect(typeof name.SCOPE).toBe('object'); }); it("should export a 'shorten' function", () => { - expect(jsdoc.name.shorten).toBeDefined(); - expect(typeof jsdoc.name.shorten).toBe('function'); + expect(name.shorten).toBeDefined(); + expect(typeof name.shorten).toBe('function'); }); it('should export a "combine" function', () => { - expect(jsdoc.name.combine).toBeDefined(); - expect(typeof jsdoc.name.combine).toBe('function'); + expect(name.combine).toBeDefined(); + expect(typeof name.combine).toBe('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', () => { - expect(jsdoc.name.longnamesToTree).toBeDefined(); - expect(typeof jsdoc.name.longnamesToTree).toBe('function'); + expect(name.longnamesToTree).toBeDefined(); + expect(typeof name.longnamesToTree).toBe('function'); }); it("should export a 'splitName' function", () => { - expect(jsdoc.name.splitName).toBeDefined(); - expect(typeof jsdoc.name.splitName).toBe('function'); + expect(name.splitName).toBeDefined(); + expect(typeof name.splitName).toBe('function'); }); describe('SCOPE', () => { - const SCOPE = jsdoc.name.SCOPE; + const SCOPE = name.SCOPE; it('should have a "NAMES" property', () => { expect(SCOPE.NAMES).toBeDefined(); @@ -113,7 +111,7 @@ describe('jsdoc/name', () => { describe('shorten', () => { it('should break up a longname into the correct memberof, name and scope parts', () => { const startName = 'lib.Panel#open'; - const parts = jsdoc.name.shorten(startName); + const parts = name.shorten(startName); expect(parts.name).toEqual('open'); expect(parts.memberof).toEqual('lib.Panel'); @@ -122,7 +120,7 @@ describe('jsdoc/name', () => { it('should work on static names', () => { const startName = 'elements.selected.getVisible'; - const parts = jsdoc.name.shorten(startName); + const parts = name.shorten(startName); expect(parts.name).toEqual('getVisible'); expect(parts.memberof).toEqual('elements.selected'); @@ -131,7 +129,7 @@ describe('jsdoc/name', () => { it('should work on protoyped names', () => { const startName = 'Validator.prototype.$element'; - const parts = jsdoc.name.shorten(startName); + const parts = name.shorten(startName); expect(parts.name).toEqual('$element'); expect(parts.memberof).toEqual('Validator'); @@ -140,7 +138,7 @@ describe('jsdoc/name', () => { it('should work on inner names', () => { const startName = 'Button~_onclick'; - const parts = jsdoc.name.shorten(startName); + const parts = name.shorten(startName); expect(parts.name).toEqual('_onclick'); expect(parts.memberof).toEqual('Button'); @@ -149,7 +147,7 @@ describe('jsdoc/name', () => { it('should work on global names', () => { const startName = 'close'; - const parts = jsdoc.name.shorten(startName); + const parts = name.shorten(startName); expect(parts.name).toEqual('close'); expect(parts.memberof).toEqual(''); @@ -158,7 +156,7 @@ describe('jsdoc/name', () => { it('should work when a single property uses bracket notation', () => { const startName = 'channels["#ops"]#open'; - const parts = jsdoc.name.shorten(startName); + const parts = name.shorten(startName); expect(parts.name).toEqual('open'); expect(parts.memberof).toEqual('channels."#ops"'); @@ -167,7 +165,7 @@ describe('jsdoc/name', () => { it('should work when consecutive properties use bracket notation', () => { 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.memberof).toEqual('channels."#bots"'); @@ -176,7 +174,7 @@ describe('jsdoc/name', () => { it('should work when a property uses single-quoted bracket notation', () => { const startName = "channels['#ops']"; - const parts = jsdoc.name.shorten(startName); + const parts = name.shorten(startName); expect(parts.name).toBe("'#ops'"); expect(parts.memberof).toBe('channels'); @@ -185,7 +183,7 @@ describe('jsdoc/name', () => { it('should work on double-quoted strings', () => { const startName = '"foo.bar"'; - const parts = jsdoc.name.shorten(startName); + const parts = name.shorten(startName); expect(parts.name).toEqual('"foo.bar"'); expect(parts.longname).toEqual('"foo.bar"'); @@ -195,7 +193,7 @@ describe('jsdoc/name', () => { it('should work on single-quoted strings', () => { const startName = "'foo.bar'"; - const parts = jsdoc.name.shorten(startName); + const parts = name.shorten(startName); expect(parts.name).toBe("'foo.bar'"); expect(parts.longname).toBe("'foo.bar'"); @@ -205,7 +203,7 @@ describe('jsdoc/name', () => { it('should find the variation', () => { const startName = 'anim.fadein(2)'; - const parts = jsdoc.name.shorten(startName); + const parts = name.shorten(startName); expect(parts.variation).toEqual('2'); expect(parts.name).toEqual('fadein'); @@ -216,28 +214,28 @@ describe('jsdoc/name', () => { describe('applyNamespace', () => { it('should insert the namespace only before the name part of the longname', () => { const startName = 'lib.Panel#open'; - const endName = jsdoc.name.applyNamespace(startName, 'event'); + const endName = name.applyNamespace(startName, 'event'); expect(endName, 'lib.Panel#event:open'); }); it('should insert the namespace before a global name', () => { const startName = 'maths/bigint'; - const endName = jsdoc.name.applyNamespace(startName, 'module'); + const endName = name.applyNamespace(startName, 'module'); expect(endName, 'module:maths/bigint'); }); 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 endName = jsdoc.name.applyNamespace(startName, 'event'); + const endName = name.applyNamespace(startName, 'event'); expect(endName, 'foo.event:"*dont\'t.look~in#here!"'); }); it('should not add another namespace if one already exists.', () => { 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'); }); @@ -246,21 +244,21 @@ describe('jsdoc/name', () => { describe('stripNamespace', () => { it('should not change longnames without a leading namespace', () => { const startName = 'Foo#bar'; - const endName = jsdoc.name.stripNamespace(startName); + const endName = name.stripNamespace(startName); expect(endName).toBe(startName); }); it('should not change longnames with an embedded namespace', () => { const startName = 'foo/bar.baz~event:qux'; - const endName = jsdoc.name.stripNamespace(startName); + const endName = name.stripNamespace(startName); expect(endName).toBe(startName); }); it('should remove the leading namespace, if present', () => { const startName = 'module:foo/bar/baz'; - const endName = jsdoc.name.stripNamespace(startName); + const endName = name.stripNamespace(startName); expect(endName).toBe('foo/bar/baz'); }); @@ -268,37 +266,37 @@ describe('jsdoc/name', () => { describe('hasAncestor', () => { 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); }); it('should return false if "child" is missing', () => { - const hasAncestor = jsdoc.name.hasAncestor('foo'); + const hasAncestor = name.hasAncestor('foo'); expect(hasAncestor).toBe(false); }); 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); }); 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); }); 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); }); 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); }); @@ -311,14 +309,14 @@ describe('jsdoc/name', () => { describe('stripVariation', () => { it('should not change longnames without a variation', () => { const startName = 'Foo#bar'; - const endName = jsdoc.name.stripVariation(startName); + const endName = name.stripVariation(startName); expect(endName).toBe(startName); }); it('should remove the variation, if present', () => { const startName = 'Foo#bar(qux)'; - const endName = jsdoc.name.stripVariation(startName); + const endName = name.stripVariation(startName); expect(endName).toBe('Foo#bar'); }); @@ -331,7 +329,7 @@ describe('jsdoc/name', () => { describe('splitName', () => { it('should find the name and 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.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', () => { 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.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', () => { 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.description).toBe('- The networking kind, not the wrench.'); @@ -355,7 +353,7 @@ describe('jsdoc/name', () => { it('should allow default values to have brackets', () => { 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.description).toBe('Path split into components'); @@ -363,7 +361,7 @@ describe('jsdoc/name', () => { it('should allow default values to have unmatched brackets inside strings', () => { 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.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', () => { 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.name).toBe('[path=["home", "user"]'); @@ -380,7 +378,7 @@ describe('jsdoc/name', () => { it('should fail gracefully when the default value has an unmatched quote', () => { 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.name).toBe('[path=["home", "user]'); @@ -394,7 +392,7 @@ describe('jsdoc/name', () => { function makeDoclet(tagStrings) { const comment = `/**\n${tagStrings.join('\n')}\n*/`; - return new jsdoc.doclet.Doclet(comment, {}); + return new Doclet(comment, {}); } describe('aliases', () => { @@ -404,7 +402,7 @@ describe('jsdoc/name', () => { it('can resolve aliases that identify instance members', () => { const doclet = makeDoclet(['@alias Foo#bar', '@name Foo#bar']); - jsdoc.name.resolve(doclet); + name.resolve(doclet); expect(doclet.name).toBe('bar'); expect(doclet.memberof).toBe('Foo'); @@ -415,7 +413,7 @@ describe('jsdoc/name', () => { it('can resolve aliases that identify static members', () => { const doclet = makeDoclet(['@alias Foo.bar', '@name Foo.bar']); - jsdoc.name.resolve(doclet); + name.resolve(doclet); expect(doclet.name).toBe('bar'); expect(doclet.memberof).toBe('Foo'); @@ -426,7 +424,7 @@ describe('jsdoc/name', () => { it('works when the alias only specifies the short name', () => { const doclet = makeDoclet(['@alias bar', '@name bar', '@memberof Foo', '@instance']); - jsdoc.name.resolve(doclet); + name.resolve(doclet); expect(doclet.name).toBe('bar'); expect(doclet.memberof).toBe('Foo'); @@ -438,13 +436,13 @@ describe('jsdoc/name', () => { describe('events', () => { const event = '@event'; const memberOf = '@memberof MyClass'; - const name = '@name A'; + const nameTag = '@name A'; // Test the basic @event that is not nested. 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.memberof).toBeUndefined(); @@ -453,54 +451,54 @@ describe('jsdoc/name', () => { // test all permutations of @event @name [name] @memberof. 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.memberof).toEqual('MyClass'); expect(doclet.longname).toEqual('MyClass.event:A'); }); 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.memberof).toEqual('MyClass'); expect(doclet.longname).toEqual('MyClass.event:A'); }); 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.memberof).toEqual('MyClass'); expect(doclet.longname).toEqual('MyClass.event:A'); }); 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.memberof).toEqual('MyClass'); expect(doclet.longname).toEqual('MyClass.event:A'); }); 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.memberof).toEqual('MyClass'); expect(doclet.longname).toEqual('MyClass.event:A'); }); 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.memberof).toEqual('MyClass'); @@ -511,7 +509,7 @@ describe('jsdoc/name', () => { it('@event [name] @memberof resolves correctly', () => { const doclet = makeDoclet(['@event A', memberOf]); - jsdoc.name.resolve(doclet); + name.resolve(doclet); expect(doclet.name).toEqual('A'); expect(doclet.memberof).toEqual('MyClass'); @@ -520,7 +518,7 @@ describe('jsdoc/name', () => { it('@memberof @event [name] resolves correctly', () => { const doclet = makeDoclet([memberOf, '@event A']); - jsdoc.name.resolve(doclet); + name.resolve(doclet); expect(doclet.name).toEqual('A'); expect(doclet.memberof).toEqual('MyClass'); @@ -531,7 +529,7 @@ describe('jsdoc/name', () => { it('full @event definition works', () => { const doclet = makeDoclet(['@event MyClass.A']); - jsdoc.name.resolve(doclet); + name.resolve(doclet); expect(doclet.name).toEqual('A'); expect(doclet.memberof).toEqual('MyClass'); @@ -540,7 +538,7 @@ describe('jsdoc/name', () => { it('full @event definition with event: works', () => { const doclet = makeDoclet(['@event MyClass.event:A']); - jsdoc.name.resolve(doclet); + name.resolve(doclet); expect(doclet.name).toEqual('event:A'); expect(doclet.memberof).toEqual('MyClass'); @@ -551,7 +549,7 @@ describe('jsdoc/name', () => { it('@event @name MyClass.EventName @memberof somethingelse works', () => { const doclet = makeDoclet([event, '@name MyClass.A', '@memberof MyNamespace']); - jsdoc.name.resolve(doclet); + name.resolve(doclet); expect(doclet.name).toEqual('A'); expect(doclet.memberof).toEqual('MyNamespace.MyClass'); @@ -569,7 +567,7 @@ describe('jsdoc/name', () => { '@param {string} qux' ]); - jsdoc.name.resolve(doclet); + name.resolve(doclet); expect(doclet.name).toBe('baz'); expect(doclet.memberof).toBe('module:foo.Bar'); diff --git a/test/specs/jsdoc/package.js b/test/specs/jsdoc/package.js index b804ecfa..8f6d25fe 100644 --- a/test/specs/jsdoc/package.js +++ b/test/specs/jsdoc/package.js @@ -14,7 +14,7 @@ describe('jsdoc/package', () => { myPackage = new Package( JSON.stringify(obj) ); // add the package object to the cached parse results, so we can validate it against the // 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 expect(myPackage[name]).toEqual(value); diff --git a/test/specs/jsdoc/readme.js b/test/specs/jsdoc/readme.js index 78ffd176..c3092210 100644 --- a/test/specs/jsdoc/readme.js +++ b/test/specs/jsdoc/readme.js @@ -1,6 +1,5 @@ describe('jsdoc/readme', () => { - const jsdoc = { readme: require('jsdoc/readme') }; - const Readme = jsdoc.readme; + const Readme = require('jsdoc/readme'); const html = (new Readme('test/fixtures/markdowntest.md')).html; it('should convert Markdown files to HTML', () => { diff --git a/test/specs/jsdoc/schema.js b/test/specs/jsdoc/schema.js index 9f298d50..27d2c2a2 100644 --- a/test/specs/jsdoc/schema.js +++ b/test/specs/jsdoc/schema.js @@ -72,7 +72,7 @@ describe('jsdoc/schema', () => { }); 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); // hack to get the filename/errors in the test results diff --git a/test/specs/jsdoc/src/handlers.js b/test/specs/jsdoc/src/handlers.js index 925e32d9..a984198c 100644 --- a/test/specs/jsdoc/src/handlers.js +++ b/test/specs/jsdoc/src/handlers.js @@ -1,7 +1,7 @@ describe('jsdoc/src/handlers', () => { const handlers = require('jsdoc/src/handlers'); - const testParser = jasmine.createParser(); + const testParser = jsdoc.createParser(); handlers.attachTo(testParser); diff --git a/test/specs/jsdoc/src/parser.js b/test/specs/jsdoc/src/parser.js index 84b56a72..25f7b29b 100644 --- a/test/specs/jsdoc/src/parser.js +++ b/test/specs/jsdoc/src/parser.js @@ -1,47 +1,41 @@ -/* eslint no-script-url: 0 */ +/* eslint-disable no-script-url */ describe('jsdoc/src/parser', () => { + const { attachTo } = require('jsdoc/src/handlers'); + const { dirname } = require('jsdoc/env'); const fs = require('jsdoc/fs'); - const jsdoc = { - env: require('jsdoc/env'), - src: { - handlers: require('jsdoc/src/handlers'), - parser: require('jsdoc/src/parser') - }, - util: { - logger: require('jsdoc/util/logger') - } - }; + const jsdocParser = require('jsdoc/src/parser'); + const logger = require('jsdoc/util/logger'); const path = require('jsdoc/path'); it('should exist', () => { - expect(jsdoc.src.parser).toBeDefined(); - expect(typeof jsdoc.src.parser).toBe('object'); + expect(jsdocParser).toBeDefined(); + expect(typeof jsdocParser).toBe('object'); }); 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', () => { - expect(typeof jsdoc.src.parser.Parser).toBe('function'); + expect(typeof jsdocParser.Parser).toBe('function'); }); describe('createParser', () => { 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"', () => { - 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', () => { - spyOn(jsdoc.util.logger, 'fatal'); - jsdoc.src.parser.createParser('not-a-real-parser-ever'); + spyOn(logger, 'fatal'); + 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; function newParser() { - parser = new jsdoc.src.parser.Parser(); + parser = new jsdocParser.Parser(); } newParser(); @@ -75,7 +69,7 @@ describe('jsdoc/src/parser', () => { }; 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.visitor).toBe(visitor); @@ -129,7 +123,7 @@ describe('jsdoc/src/parser', () => { parser.on('parseBegin', spy).parse(sourceFiles); 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", () => { @@ -153,7 +147,7 @@ describe('jsdoc/src/parser', () => { parser.on('jsdocCommentFound', spy).parse(sourceCode); 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', () => { @@ -185,7 +179,7 @@ describe('jsdoc/src/parser', () => { e.doclet.foo = 'bar'; } - jsdoc.src.handlers.attachTo(parser); + attachTo(parser); parser.on('newDoclet', handler).parse(sourceCode); results = parser.results(); @@ -205,7 +199,7 @@ describe('jsdoc/src/parser', () => { } }; - jsdoc.src.handlers.attachTo(parser); + attachTo(parser); parser.addAstNodeVisitor(visitor); parser.parse(sourceCode); @@ -225,7 +219,7 @@ describe('jsdoc/src/parser', () => { // args[2]: parser 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 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.parse(sourceCode); @@ -259,12 +253,12 @@ describe('jsdoc/src/parser', () => { const spy = jasmine.createSpy(); const sourceCode = ['javascript:/** @class */function Foo() {}']; - jsdoc.src.handlers.attachTo(parser); + attachTo(parser); parser.on('parseComplete', spy).parse(sourceCode); expect(spy).toHaveBeenCalled(); - eventObject = spy.mostRecentCall.args[0]; + eventObject = spy.calls.mostRecent().args[0]; expect(eventObject).toBeDefined(); expect( Array.isArray(eventObject.sourcefiles) ).toBe(true); expect(eventObject.sourcefiles.length).toBe(1); @@ -282,15 +276,15 @@ describe('jsdoc/src/parser', () => { parser.on('processingComplete', spy).fireProcessingComplete(doclets); expect(spy).toHaveBeenCalled(); - expect(typeof spy.mostRecentCall.args[0]).toBe('object'); - expect(spy.mostRecentCall.args[0].doclets).toBeDefined(); - expect(spy.mostRecentCall.args[0].doclets).toBe(doclets); + expect(typeof spy.calls.mostRecent().args[0]).toBe('object'); + expect(spy.calls.mostRecent().args[0].doclets).toBeDefined(); + expect(spy.calls.mostRecent().args[0].doclets).toBe(doclets); }); it('should not throw errors when parsing files with ES6 syntax', () => { function parse() { 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); } @@ -299,8 +293,8 @@ describe('jsdoc/src/parser', () => { }); it('should be able to parse its own source file', () => { - const parserSrc = `javascript:${fs.readFileSync(path.join(jsdoc.env.dirname, - 'lib/jsdoc/src/parser.js'), 'utf8')}`; + const parserSrc = `javascript:${fs.readFileSync(path.join(dirname, + 'lib/jsdoc/src/parser.js'), 'utf8')}`; function parse() { parser.parse(parserSrc); @@ -335,7 +329,7 @@ describe('jsdoc/src/parser', () => { const source = 'javascript:var foo;'; let results; - jsdoc.src.handlers.attachTo(parser); + attachTo(parser); parser.parse(source); results = parser.results(); @@ -355,7 +349,7 @@ describe('jsdoc/src/parser', () => { parser.on('jsdocCommentFound', e => { e.comment = e.comment.replace('replaceme', 'REPLACED!'); }); - jsdoc.src.handlers.attachTo(parser); + attachTo(parser); parser.parse(source); parser.results().forEach(({comment}) => { @@ -371,7 +365,7 @@ describe('jsdoc/src/parser', () => { jsdocCommentFound: [], symbolFound: [] }; - const source = fs.readFileSync(path.join(jsdoc.env.dirname, + const source = fs.readFileSync(path.join(dirname, 'test/fixtures/eventorder.js'), 'utf8'); /* @@ -395,7 +389,7 @@ describe('jsdoc/src/parser', () => { it('should fire interleaved jsdocCommentFound and symbolFound events, ' + 'in source order', () => { - jsdoc.src.handlers.attachTo(parser); + attachTo(parser); parser.parse(source); events.all.slice(0).sort(sourceOrderSort).forEach((e, i) => { expect(e).toBe(events.all[i]); diff --git a/test/specs/jsdoc/src/visitor.js b/test/specs/jsdoc/src/visitor.js index cf8b3a8d..3ee717e8 100644 --- a/test/specs/jsdoc/src/visitor.js +++ b/test/specs/jsdoc/src/visitor.js @@ -1,14 +1,10 @@ describe('jsdoc/src/visitor', () => { // TODO: more tests - const jsdoc = { - src: { - parser: require('jsdoc/src/parser'), - visitor: require('jsdoc/src/visitor') - } - }; - const parser = new jsdoc.src.parser.Parser(); - const visitor = new jsdoc.src.visitor.Visitor(); + const { Parser } = require('jsdoc/src/parser'); + const { Visitor } = require('jsdoc/src/visitor'); + const parser = new Parser(); + const visitor = new Visitor(); describe('visitNodeComments', () => { // TODO: more tests diff --git a/test/specs/jsdoc/tag.js b/test/specs/jsdoc/tag.js index 1bd06492..932febf2 100644 --- a/test/specs/jsdoc/tag.js +++ b/test/specs/jsdoc/tag.js @@ -1,22 +1,20 @@ const hasOwnProp = Object.prototype.hasOwnProperty; describe('jsdoc/tag', () => { - const jsdoc = { - env: require('jsdoc/env'), - tag: require('jsdoc/tag'), - dictionary: require('jsdoc/tag/dictionary'), - type: require('jsdoc/tag/type') - }; + const env = require('jsdoc/env'); + const jsdocDictionary = require('jsdoc/tag/dictionary'); + const jsdocTag = require('jsdoc/tag'); const logger = require('jsdoc/util/logger'); + const parseType = require('jsdoc/tag/type').parse; it('should exist', () => { - expect(jsdoc.tag).toBeDefined(); - expect(typeof jsdoc.tag).toBe('object'); + expect(jsdocTag).toBeDefined(); + expect(typeof jsdocTag).toBe('object'); }); it('should export a Tag function', () => { - expect(jsdoc.tag.Tag).toBeDefined(); - expect(typeof jsdoc.tag.Tag).toBe('function'); + expect(jsdocTag.Tag).toBeDefined(); + expect(typeof jsdocTag.Tag).toBe('function'); }); describe('Tag', () => { @@ -50,17 +48,17 @@ describe('jsdoc/tag', () => { // allow each test to recreate the tags (for example, after enabling debug mode) function createTags() { // 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 - 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) - 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 - tagExample = new jsdoc.tag.Tag('example', textExample, meta); + tagExample = new jsdocTag.Tag('example', textExample, meta); // @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 - tagType = new jsdoc.tag.Tag('type', 'MyType ', meta); + tagType = new jsdocTag.Tag('type', 'MyType ', meta); } beforeEach(() => { @@ -82,9 +80,9 @@ describe('jsdoc/tag', () => { expect(typeof tagArg.title).toBe('string'); }); - it("'title' property should be the normalised tag title", () => { - expect(tagArg.title).toBe(jsdoc.dictionary.normalise(tagArg.originalTitle)); - expect(tagExample.title).toBe(jsdoc.dictionary.normalise(tagExample.originalTitle)); + it("'title' property should be the normalized tag title", () => { + expect(tagArg.title).toBe(jsdocDictionary.normalize(tagArg.originalTitle)); + expect(tagExample.title).toBe(jsdocDictionary.normalize(tagExample.originalTitle)); }); 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.", () => { - const def = jsdoc.dictionary.lookUp('type'); + const def = jsdocDictionary.lookUp('type'); expect(def.onTagText).toBeDefined(); expect(typeof def.onTagText).toBe('function'); @@ -126,10 +124,10 @@ describe('jsdoc/tag', () => { spyOn(logger, 'error'); - wsOnly = new jsdoc.tag.Tag('name', ' ', { code: { name: ' ' } }); - wsLeading = new jsdoc.tag.Tag('name', ' foo', { code: { name: ' foo' } }); - wsTrailing = new jsdoc.tag.Tag('name', 'foo ', { code: { name: 'foo ' } }); - wsBoth = new jsdoc.tag.Tag('name', ' foo ', { code: { name: ' foo ' } }); + wsOnly = new jsdocTag.Tag('name', ' ', { code: { name: ' ' } }); + wsLeading = new jsdocTag.Tag('name', ' foo', { code: { name: ' foo' } }); + wsTrailing = new jsdocTag.Tag('name', 'foo ', { code: { name: 'foo ' } }); + wsBoth = new jsdocTag.Tag('name', ' foo ', { code: { name: ' foo ' } }); expect(logger.error).not.toHaveBeenCalled(); expect(wsOnly.text).toBe('" "'); @@ -156,10 +154,10 @@ describe('jsdoc/tag', () => { let descriptor; let info; - def = jsdoc.dictionary.lookUp(tag.title); + def = jsdocDictionary.lookUp(tag.title); 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 => { if (hasOwnProp.call(info, prop)) { @@ -177,16 +175,16 @@ describe('jsdoc/tag', () => { expect(typeof tag.value.type.parsedType).toBe('object'); 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', () => { // 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 => { - jsdoc.env.opts.debug = bool; + env.opts.debug = bool; createTags(); verifyTagType(tagType); @@ -194,7 +192,7 @@ describe('jsdoc/tag', () => { 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', () => { @@ -226,7 +224,7 @@ describe('jsdoc/tag', () => { it('logs an error for tags with bad type expressions', () => { /* 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 */ expect(logger.error).toHaveBeenCalled(); @@ -234,7 +232,7 @@ describe('jsdoc/tag', () => { it('validates tags with no text', () => { /* eslint-disable no-unused-vars */ - const tag = new jsdoc.tag.Tag('copyright'); + const tag = new jsdocTag.Tag('copyright'); /* eslint-enable no-unused-vars */ expect(logger.error).toHaveBeenCalled(); diff --git a/test/specs/jsdoc/tag/inline.js b/test/specs/jsdoc/tag/inline.js index 651b4290..0b0e42ce 100644 --- a/test/specs/jsdoc/tag/inline.js +++ b/test/specs/jsdoc/tag/inline.js @@ -1,32 +1,28 @@ describe('jsdoc/tag/inline', () => { - const jsdoc = { - tag: { - inline: require('jsdoc/tag/inline') - } - }; + const inline = require('jsdoc/tag/inline'); it('should exist', () => { - expect(jsdoc.tag.inline).toBeDefined(); - expect(typeof jsdoc.tag.inline).toBe('object'); + expect(inline).toBeDefined(); + expect(typeof inline).toBe('object'); }); it('should export an isInlineTag function', () => { - expect(jsdoc.tag.inline.isInlineTag).toBeDefined(); - expect(typeof jsdoc.tag.inline.isInlineTag).toBe('function'); + expect(inline.isInlineTag).toBeDefined(); + expect(typeof inline.isInlineTag).toBe('function'); }); it('should export a replaceInlineTag function', () => { - expect(jsdoc.tag.inline.replaceInlineTag).toBeDefined(); - expect(typeof jsdoc.tag.inline.replaceInlineTag).toBe('function'); + expect(inline.replaceInlineTag).toBeDefined(); + expect(typeof inline.replaceInlineTag).toBe('function'); }); it('should export an extractInlineTag function', () => { - expect(jsdoc.tag.inline.extractInlineTag).toBeDefined(); - expect(typeof jsdoc.tag.inline.replaceInlineTag).toBe('function'); + expect(inline.extractInlineTag).toBeDefined(); + expect(typeof inline.replaceInlineTag).toBe('function'); }); describe('isInlineTag', () => { - const isInlineTag = jsdoc.tag.inline.isInlineTag; + const isInlineTag = inline.isInlineTag; it('should correctly identify an inline tag', () => { expect( isInlineTag('{@mytag hooray}', 'mytag') ).toBe(true); @@ -65,11 +61,11 @@ describe('jsdoc/tag/inline', () => { describe('replaceInlineTag', () => { it('should throw if the tag is matched and the replacer is invalid', () => { function badReplacerUndefined() { - jsdoc.tag.inline.replaceInlineTag('{@foo tag}', 'foo'); + inline.replaceInlineTag('{@foo tag}', 'foo'); } function badReplacerString() { - jsdoc.tag.inline.replaceInlineTag('{@foo tag}', 'foo', 'hello'); + inline.replaceInlineTag('{@foo tag}', 'foo', 'hello'); } expect(badReplacerUndefined).toThrow(); @@ -79,7 +75,7 @@ describe('jsdoc/tag/inline', () => { it('should not find anything if there is no text in braces', () => { const replacer = jasmine.createSpy('replacer'); - jsdoc.tag.inline.replaceInlineTag('braceless text', 'foo', replacer); + inline.replaceInlineTag('braceless text', 'foo', replacer); expect(replacer).not.toHaveBeenCalled(); }); @@ -87,7 +83,7 @@ describe('jsdoc/tag/inline', () => { it('should cope with bad escapement at the end of the string', () => { 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(); }); @@ -101,7 +97,7 @@ describe('jsdoc/tag/inline', () => { return completeTag; } - const result = jsdoc.tag.inline.replaceInlineTag('{@foo text in braces}', 'foo', + const result = inline.replaceInlineTag('{@foo text in braces}', 'foo', replacer); expect(result.tags[0]).toBeDefined(); @@ -120,7 +116,7 @@ describe('jsdoc/tag/inline', () => { return string; } - const result = jsdoc.tag.inline.replaceInlineTag('{@foo test string} ahoy', 'foo', + const result = inline.replaceInlineTag('{@foo test string} ahoy', 'foo', replacer); expect(result.tags[0]).toBeDefined(); @@ -139,7 +135,7 @@ describe('jsdoc/tag/inline', () => { 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); expect(result.tags[0]).toBeDefined(); @@ -158,7 +154,7 @@ describe('jsdoc/tag/inline', () => { 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(typeof result.tags[0]).toBe('object'); @@ -172,7 +168,7 @@ describe('jsdoc/tag/inline', () => { 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!'); }); @@ -182,7 +178,7 @@ describe('jsdoc/tag/inline', () => { 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); expect(result.tags.length).toBe(4); @@ -216,7 +212,7 @@ describe('jsdoc/tag/inline', () => { it('should work with an empty replacer object', () => { const replacers = {}; 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); }); @@ -231,7 +227,7 @@ describe('jsdoc/tag/inline', () => { 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'); }); @@ -252,7 +248,7 @@ describe('jsdoc/tag/inline', () => { 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'); }); @@ -261,7 +257,7 @@ describe('jsdoc/tag/inline', () => { // largely covered by the replaceInlineTag tests describe('extractInlineTag', () => { 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(typeof result.tags[0]).toBe('object'); diff --git a/test/specs/jsdoc/tag/type.js b/test/specs/jsdoc/tag/type.js index f13e6629..02bb59ac 100644 --- a/test/specs/jsdoc/tag/type.js +++ b/test/specs/jsdoc/tag/type.js @@ -23,25 +23,21 @@ function buildText(type, name, desc) { } describe('jsdoc/tag/type', () => { - const jsdoc = { - tag: { - type: require('jsdoc/tag/type') - } - }; + const type = require('jsdoc/tag/type'); it('should exist', () => { - expect(jsdoc.tag.type).toBeDefined(); - expect(typeof jsdoc.tag.type).toBe('object'); + expect(type).toBeDefined(); + expect(typeof type).toBe('object'); }); it('should export a parse function', () => { - expect(jsdoc.tag.type.parse).toBeDefined(); - expect(typeof jsdoc.tag.type.parse).toBe('function'); + expect(type.parse).toBeDefined(); + expect(typeof type.parse).toBe('function'); }); describe('parse', () => { 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.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', () => { 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.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', () => { const name = 'bar'; 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.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', () => { - const type = 'boolean'; + const typeString = 'boolean'; 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.text).toBe(desc); }); it('should extract a name and type if canHaveName and canHaveType are true', () => { - const type = 'string'; + const typeString = 'string'; const name = 'baz'; 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.text).toBe(desc); }); it('should report optional types correctly no matter which syntax we use', () => { 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); desc = '{string=} [foo]'; - info = jsdoc.tag.type.parse(desc, true, true); + info = type.parse(desc, true, true); expect(info.optional).toBe(true); desc = '[foo]'; - info = jsdoc.tag.type.parse(desc, true, true); + info = type.parse(desc, true, true); expect(info.optional).toBe(true); }); it('should return the types as an array', () => { 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'] ); }); it('should recognize the entire list of possible types', () => { 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'] ); desc = '{ ( string | number ) } foo'; - info = jsdoc.tag.type.parse(desc, true, true); + info = type.parse(desc, true, true); expect(info.type).toEqual( ['string', 'number'] ); desc = '{ ( string | number)} foo'; - info = jsdoc.tag.type.parse(desc, true, true); + info = type.parse(desc, true, true); expect(info.type).toEqual( ['string', 'number'] ); 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'] ); }); it('should not find any type if there is no text in braces', () => { const desc = 'braceless text'; - const info = jsdoc.tag.type.parse(desc, false, true); + const info = type.parse(desc, false, true); expect(info.type).toEqual([]); }); it('should cope with bad escapement at the end of the string', () => { 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.text).toBe(desc); @@ -146,21 +142,21 @@ describe('jsdoc/tag/type', () => { it('should handle escaped braces correctly', () => { 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"'); }); it('should work if the type expression is the entire string', () => { 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'); }); it('should work if the type expression is at the beginning of the string', () => { 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.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', () => { 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.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', () => { 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.text).toBe('a'); @@ -184,7 +180,7 @@ describe('jsdoc/tag/type', () => { it('should work when there are nested 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' 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', () => { 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.text).toBe(''); 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.text).toBe(''); 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.text).toBe('The cookie parameter.'); 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.text).toBe('The cookie parameter.'); 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.text).toBe('The cookie parameter. Mmm, cookie.'); }); @@ -223,27 +219,27 @@ describe('jsdoc/tag/type', () => { it('should parse JSDoc-style optional parameters', () => { let name = '[qux]'; 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.text).toBe(desc); expect(info.optional).toBe(true); 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.text).toBe(desc); expect(info.optional).toBe(true); 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.text).toBe(desc); expect(info.optional).toBe(true); expect(info.defaultvalue).toBe('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.text).toBe(desc); expect(info.optional).toBe(true); @@ -255,7 +251,7 @@ describe('jsdoc/tag/type', () => { describe('Closure Compiler-style type info', () => { it('should recognize variable (repeatable) parameters', () => { 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.variable).toBe(true); @@ -264,7 +260,7 @@ describe('jsdoc/tag/type', () => { it('should set the type correctly for type applications that contain type unions', () => { 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)>']); }); diff --git a/test/specs/jsdoc/tag/validator.js b/test/specs/jsdoc/tag/validator.js index b7ac1697..f55b457f 100644 --- a/test/specs/jsdoc/tag/validator.js +++ b/test/specs/jsdoc/tag/validator.js @@ -21,6 +21,7 @@ describe('jsdoc/tag/validator', () => { const allowUnknown = Boolean(env.conf.tags.allowUnknownTags); const badTag = { title: 'lkjasdlkjfb' }; const badTag2 = new tag.Tag('type', '{string} I am a string!'); + let errorSpy; const meta = { filename: 'asdf.js', lineno: 1, @@ -34,7 +35,7 @@ describe('jsdoc/tag/validator', () => { } beforeEach(() => { - spyOn(logger, 'error'); + errorSpy = spyOn(logger, 'error'); spyOn(logger, 'warn'); }); @@ -106,7 +107,7 @@ describe('jsdoc/tag/validator', () => { env.conf.tags.allowUnknownTags = false; validateTag(badTag); - expect(logger.error.mostRecentCall.args[0]).toContain(meta.comment); + expect(errorSpy.calls.mostRecent().args[0]).toContain(meta.comment); }); }); }); diff --git a/test/specs/jsdoc/util/templateHelper.js b/test/specs/jsdoc/util/templateHelper.js index 6fe2dcda..04e73220 100644 --- a/test/specs/jsdoc/util/templateHelper.js +++ b/test/specs/jsdoc/util/templateHelper.js @@ -191,7 +191,7 @@ describe("jsdoc/util/templateHelper", () => { describe("getUniqueFilename", () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); // 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", () => { - 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 ev2 = helper.find(doclets, {longname: 'module:myModule~Events.event:Event2'})[0]; const ev3 = helper.find(doclets, {longname: 'module:myModule#event:Event3'})[0]; diff --git a/test/specs/plugins/plugins.js b/test/specs/plugins/plugins.js index 2152020f..09e1d8ad 100644 --- a/test/specs/plugins/plugins.js +++ b/test/specs/plugins/plugins.js @@ -11,13 +11,13 @@ describe('plugins', () => { ]; // TODO: decouple this from the global parser - app.jsdoc.parser = jasmine.createParser(); + app.jsdoc.parser = jsdoc.createParser(); global.jsdocPluginsTest = global.jsdocPluginsTest || {}; 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", () => { expect(global.jsdocPluginsTest.plugin1.fileBegin).toBeDefined(); diff --git a/test/specs/tags/abstracttag.js b/test/specs/tags/abstracttag.js index 1da28cc4..78982955 100644 --- a/test/specs/tags/abstracttag.js +++ b/test/specs/tags/abstracttag.js @@ -1,5 +1,5 @@ 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 thingyPez = docSet.getByLongname('Thingy#pez')[0]; const otherThingyPez = docSet.getByLongname('OtherThingy#pez')[0]; diff --git a/test/specs/tags/accesstag.js b/test/specs/tags/accesstag.js index 3b4f1ac6..8712b323 100644 --- a/test/specs/tags/accesstag.js +++ b/test/specs/tags/accesstag.js @@ -1,5 +1,5 @@ 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 _bar = docSet.getByLongname('Thingy#_bar')[0]; const _gnu = docSet.getByLongname('Thingy#_gnu')[0]; diff --git a/test/specs/tags/aliastag.js b/test/specs/tags/aliastag.js index 93729c65..a9f012f6 100644 --- a/test/specs/tags/aliastag.js +++ b/test/specs/tags/aliastag.js @@ -1,5 +1,5 @@ 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 const myObject = docSet.getByLongname('myObject')[1]; diff --git a/test/specs/tags/asynctag.js b/test/specs/tags/asynctag.js index be939aad..1441e070 100644 --- a/test/specs/tags/asynctag.js +++ b/test/specs/tags/asynctag.js @@ -1,5 +1,5 @@ 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]; it('should add an `async` property to the doclet', () => { diff --git a/test/specs/tags/augmentstag.js b/test/specs/tags/augmentstag.js index 7731c534..3a777320 100644 --- a/test/specs/tags/augmentstag.js +++ b/test/specs/tags/augmentstag.js @@ -1,10 +1,10 @@ describe('@augments tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/augmentstag.js'); - const docSet2 = jasmine.getDocSetFromFile('test/fixtures/augmentstag2.js'); - const docSet3 = jasmine.getDocSetFromFile('test/fixtures/augmentstag3.js'); - const docSet4 = jasmine.getDocSetFromFile('test/fixtures/augmentstag4.js'); - const docSet5 = jasmine.getDocSetFromFile('test/fixtures/augmentstag5.js'); - const docSet6 = jasmine.getDocSetFromFile('test/fixtures/augmentstag6.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/augmentstag.js'); + const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/augmentstag2.js'); + const docSet3 = jsdoc.getDocSetFromFile('test/fixtures/augmentstag3.js'); + const docSet4 = jsdoc.getDocSetFromFile('test/fixtures/augmentstag4.js'); + const docSet5 = jsdoc.getDocSetFromFile('test/fixtures/augmentstag5.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.', () => { const bar = docSet.getByLongname('Bar')[0]; diff --git a/test/specs/tags/authortag.js b/test/specs/tags/authortag.js index d136c57b..e97b7658 100644 --- a/test/specs/tags/authortag.js +++ b/test/specs/tags/authortag.js @@ -1,5 +1,5 @@ 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 Thingy2 = docSet.getByLongname('Thingy2')[0]; diff --git a/test/specs/tags/borrowstag.js b/test/specs/tags/borrowstag.js index b7904763..b91b467b 100644 --- a/test/specs/tags/borrowstag.js +++ b/test/specs/tags/borrowstag.js @@ -4,7 +4,7 @@ function filterUndocumented({undocumented}) { describe('@borrows tag', () => { 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]; 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.', () => { 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); @@ -24,7 +24,7 @@ describe('@borrows tag', () => { }); 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]; expect(util.borrowed.length).toBe(2); diff --git a/test/specs/tags/classdesctag.js b/test/specs/tags/classdesctag.js index 29ab56bb..22fc97c6 100644 --- a/test/specs/tags/classdesctag.js +++ b/test/specs/tags/classdesctag.js @@ -1,5 +1,5 @@ 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 bar = docSet.getByLongname('Bar')[0]; const baz = docSet.getByLongname('Baz')[0]; diff --git a/test/specs/tags/classtag.js b/test/specs/tags/classtag.js index a2c520a7..54c94147 100644 --- a/test/specs/tags/classtag.js +++ b/test/specs/tags/classtag.js @@ -3,7 +3,7 @@ function filter({undocumented}) { } 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 news = docSet.getByLongname('NewsSource')[0]; @@ -17,7 +17,7 @@ describe('@class tag', () => { }); 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 expire = docSet2.getByLongname('Subscription#expire')[0]; const subscriber = docSet2.getByLongname('Subscriber').filter(filter)[0]; diff --git a/test/specs/tags/constanttag.js b/test/specs/tags/constanttag.js index b3e73af6..84068730 100644 --- a/test/specs/tags/constanttag.js +++ b/test/specs/tags/constanttag.js @@ -1,5 +1,5 @@ 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 BAR = docSet.getByLongname('BAR')[0]; const BAZ = docSet.getByLongname('BAZ')[0]; diff --git a/test/specs/tags/constructortag.js b/test/specs/tags/constructortag.js index 6aa8fd52..41106f9e 100644 --- a/test/specs/tags/constructortag.js +++ b/test/specs/tags/constructortag.js @@ -1,5 +1,5 @@ describe('@constructor tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/constructortag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/constructortag.js'); const feed = docSet.getByLongname('Feed')[0]; it('When a symbol has an @constructor tag, it is documented as a class.', () => { diff --git a/test/specs/tags/constructstag.js b/test/specs/tags/constructstag.js index 73056b87..56ec1e55 100644 --- a/test/specs/tags/constructstag.js +++ b/test/specs/tags/constructstag.js @@ -1,6 +1,6 @@ describe('@constructs tag', () => { it('When a symbol has a @constructs tag, it is documented as a class with that name.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/constructstag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/constructstag.js'); const textblock = docSet.getByLongname('TextBlock')[0]; expect(textblock.kind).toBe('class'); @@ -8,7 +8,7 @@ describe('@constructs tag', () => { }); it('When a symbol has a @constructs tag, it is documented as a class.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/constructstag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/constructstag2.js'); const menu = docSet.getByLongname('Menu')[0]; expect(menu.name).toBe('Menu'); @@ -16,7 +16,7 @@ describe('@constructs tag', () => { }); it('When a function symbol has a @constructs tag, any this-variables are ducumented as instance members of the class.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/constructstag3.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/constructstag3.js'); const personName = docSet.getByLongname('Person#name')[0]; expect(personName.memberof).toBe('Person'); @@ -24,14 +24,14 @@ describe('@constructs tag', () => { }); it('When a function symbol has a @constructs tag with no value, in a @lends block with a "Name#" value, the function is documented as a constructor of "Name".', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/constructstag4.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/constructstag4.js'); const person = docSet.getByLongname('Person').filter(({undocumented}) => !(undocumented))[0]; expect(person.kind).toBe('class'); }); it('When a function symbol has a @constructs tag with no value, any this-variables are documented as instance members of the class.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/constructstag4.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/constructstag4.js'); const personName = docSet.getByLongname('Person#name')[0]; expect(personName.memberof).toBe('Person'); @@ -39,7 +39,7 @@ describe('@constructs tag', () => { }); it('When a object literal property has a @constructs tag with no value, and the object has a @lends, the property is documented as the lent class.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/constructstag5.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/constructstag5.js'); const duck = docSet.getByLongname('Duck').filter(({undocumented}) => !(undocumented))[0]; expect(duck.longname).toBe('Duck'); diff --git a/test/specs/tags/copyrighttag.js b/test/specs/tags/copyrighttag.js index e982fec6..36cd0fc8 100644 --- a/test/specs/tags/copyrighttag.js +++ b/test/specs/tags/copyrighttag.js @@ -1,5 +1,5 @@ describe('@copyright tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/copyrighttag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/copyrighttag.js'); const Thingy = docSet.getByLongname('Thingy')[0]; it('When a symbol has a @copyright tag, the doclet has a copyright property with that value.', () => { diff --git a/test/specs/tags/defaulttag.js b/test/specs/tags/defaulttag.js index 516358ac..9c935422 100644 --- a/test/specs/tags/defaulttag.js +++ b/test/specs/tags/defaulttag.js @@ -1,5 +1,5 @@ describe('@default tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/defaulttag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/defaulttag.js'); it('When symbol set to null has a @default tag with no text, the doclet\'s defaultValue property should be: null', () => { const request = docSet.getByLongname('request')[0]; diff --git a/test/specs/tags/definetag.js b/test/specs/tags/definetag.js index fbb07b2b..dc7f0fe8 100644 --- a/test/specs/tags/definetag.js +++ b/test/specs/tags/definetag.js @@ -7,16 +7,16 @@ describe('@define tag', () => { const allowUnknownTags = Boolean(env.conf.tags.allowUnknownTags); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); it('should not recognize the @define tag', () => { env.conf.tags.allowUnknownTags = false; - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); spyOn(logger, 'error'); - jasmine.getDocSetFromFile('test/fixtures/definetag.js'); + jsdoc.getDocSetFromFile('test/fixtures/definetag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -24,15 +24,15 @@ describe('@define tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('should recognize the @define tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/definetag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/definetag.js'); const enableDebug = docSet.getByLongname('ENABLE_DEBUG')[0]; expect(enableDebug.kind).toBe('constant'); diff --git a/test/specs/tags/deprecatedtag.js b/test/specs/tags/deprecatedtag.js index ead4ae3d..2ecd0811 100644 --- a/test/specs/tags/deprecatedtag.js +++ b/test/specs/tags/deprecatedtag.js @@ -1,5 +1,5 @@ describe('@deprecated tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/deprecatedtag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/deprecatedtag.js'); const foo = docSet.getByLongname('foo')[0]; const bar = docSet.getByLongname('bar')[0]; diff --git a/test/specs/tags/descriptiontag.js b/test/specs/tags/descriptiontag.js index 5725d21f..606a9728 100644 --- a/test/specs/tags/descriptiontag.js +++ b/test/specs/tags/descriptiontag.js @@ -1,5 +1,5 @@ describe('@description tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/descriptiontag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/descriptiontag.js'); const doc = docSet.getByLongname('x')[0]; const doc2 = docSet.getByLongname('y')[0]; diff --git a/test/specs/tags/dicttag.js b/test/specs/tags/dicttag.js index c095c806..b0dbac13 100644 --- a/test/specs/tags/dicttag.js +++ b/test/specs/tags/dicttag.js @@ -10,17 +10,17 @@ describe('@dict tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @dict tag', () => { - jasmine.getDocSetFromFile('test/fixtures/dicttag.js'); + jsdoc.getDocSetFromFile('test/fixtures/dicttag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@dict tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @dict tag', () => { - jasmine.getDocSetFromFile('test/fixtures/dicttag.js'); + jsdoc.getDocSetFromFile('test/fixtures/dicttag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/enumtag.js b/test/specs/tags/enumtag.js index 2e3e0d38..277bd7a2 100644 --- a/test/specs/tags/enumtag.js +++ b/test/specs/tags/enumtag.js @@ -1,5 +1,5 @@ describe('@enum tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/enumtag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/enumtag.js'); const tristate = docSet.getByLongname('TriState')[0]; it('When a symbol has an @enum tag, it has a properties array.', () => { @@ -39,7 +39,7 @@ describe('@enum tag', () => { }); describe('chained assignments', () => { - const docSet2 = jasmine.getDocSetFromFile('test/fixtures/enumtag2.js'); + const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/enumtag2.js'); const pentaState = docSet2.getByLongname('module:my/enums.PentaState')[0]; const PENTASTATE = docSet2.getByLongname('module:my/enums.PENTASTATE')[0]; const quadState = docSet2.getByLongname('module:my/enums.QuadState')[0]; @@ -59,7 +59,7 @@ describe('@enum tag', () => { }); describe('combined with @exports tag', () => { - const docSet3 = jasmine.getDocSetFromFile('test/fixtures/enumtag3.js'); + const docSet3 = jsdoc.getDocSetFromFile('test/fixtures/enumtag3.js'); const mymodule = docSet3.getByLongname('module:mymodule')[0]; it('When a symbol has both an @exports tag and an @enum tag, its kind is set to `module`', () => { diff --git a/test/specs/tags/eventfirestag.js b/test/specs/tags/eventfirestag.js index 9f074f84..b5a0fb34 100644 --- a/test/specs/tags/eventfirestag.js +++ b/test/specs/tags/eventfirestag.js @@ -1,5 +1,5 @@ describe('@event and @fires/@emits tags', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/eventfirestag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/eventfirestag.js'); const snowballMethod = docSet.getByLongname('Hurl#snowball')[0]; const snowballEvent = docSet.getByLongname('Hurl#event:snowball')[0]; const footballMatchMethod = docSet.getByLongname('Hurl#footballMatch')[0]; diff --git a/test/specs/tags/exampletag.js b/test/specs/tags/exampletag.js index e4338ab8..eab3a5e6 100644 --- a/test/specs/tags/exampletag.js +++ b/test/specs/tags/exampletag.js @@ -1,5 +1,5 @@ describe('@example tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/exampletag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/exampletag.js'); const doc = docSet.getByLongname('x')[0]; const doc2 = docSet.getByLongname('y')[0]; const txtRegExp = new RegExp('console\\.log\\("foo"\\);[\\r\\n]{1,2}console\\.log\\("bar"\\);'); diff --git a/test/specs/tags/exceptiontag.js b/test/specs/tags/exceptiontag.js index dd9839ac..62c8f045 100644 --- a/test/specs/tags/exceptiontag.js +++ b/test/specs/tags/exceptiontag.js @@ -1,5 +1,5 @@ describe('@exception tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/exceptiontag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/exceptiontag.js'); const foo = docSet.getByLongname('foo')[0]; const bar = docSet.getByLongname('bar')[0]; const pez = docSet.getByLongname('pez')[0]; diff --git a/test/specs/tags/exportstag.js b/test/specs/tags/exportstag.js index ab115e78..8293aabf 100644 --- a/test/specs/tags/exportstag.js +++ b/test/specs/tags/exportstag.js @@ -1,6 +1,6 @@ describe('@exports tag', () => { describe('object literals', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/exportstag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportstag.js'); const shirt = docSet.getByLongname('module:my/shirt')[0]; const color = docSet.getByLongname('module:my/shirt.color')[0]; const tneck = docSet.getByLongname('module:my/shirt.Turtleneck')[0]; @@ -37,7 +37,7 @@ describe('@exports tag', () => { }); describe('functions', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/exportstag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportstag2.js'); const coat = docSet.getByLongname('module:my/coat')[0]; const wool = docSet.getByLongname('module:my/coat#wool')[0]; @@ -65,7 +65,7 @@ describe('@exports tag', () => { }); describe("functions and 'exports' object", () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/exportstag3.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportstag3.js'); const html = docSet.getByLongname('module:html/utils')[0]; const getstyle = docSet.getByLongname('module:html/utils.getStyleProperty')[0]; const inhead = docSet.getByLongname('module:html/utils.isInHead')[0]; @@ -86,7 +86,7 @@ describe('@exports tag', () => { }); describe('inner classes', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/exportstag4.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportstag4.js'); const module = docSet.getByLongname('module:some/module')[0]; const innerClass = docSet.getByLongname('module:some/module~myClass')[0]; const method = docSet.getByLongname('module:some/module~myClass#myMethod')[0]; @@ -105,7 +105,7 @@ describe('@exports tag', () => { }); describe('variable shadowing', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/exportstag5.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportstag5.js'); const foo = docSet.getByLongname('module:Foo')[0]; const method = docSet.getByLongname('module:Foo#bar')[0]; @@ -119,7 +119,7 @@ describe('@exports tag', () => { }); describe("'exports' object as a parameter to 'define'", () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/exportstag6.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportstag6.js'); const shirt = docSet.getByLongname('module:my/shirt')[0]; const color = docSet.getByLongname('module:my/shirt.color')[0]; const tneck = docSet.getByLongname('module:my/shirt.Turtleneck')[0]; @@ -156,7 +156,7 @@ describe('@exports tag', () => { }); describe("alias to the 'exports' object", () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/exportstag7.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportstag7.js'); const shirt = docSet.getByLongname('module:my/shirt')[0]; const color = docSet.getByLongname('module:my/shirt.color')[0]; const tneck = docSet.getByLongname('module:my/shirt.Turtleneck')[0]; @@ -199,7 +199,7 @@ describe('@exports tag', () => { }); describe('"module:" namespace included in the name', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/exportstag8.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/exportstag8.js'); const shirt = docSet.getByLongname('module:my/shirt')[0]; it('When the name for an @exports tag begins with the "module:" namespace, we remove the namespace', () => { diff --git a/test/specs/tags/exporttag.js b/test/specs/tags/exporttag.js index e3bb6e29..a0f6d9af 100644 --- a/test/specs/tags/exporttag.js +++ b/test/specs/tags/exporttag.js @@ -10,17 +10,17 @@ describe('@export tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @export tag', () => { - jasmine.getDocSetFromFile('test/fixtures/exporttag.js'); + jsdoc.getDocSetFromFile('test/fixtures/exporttag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@export tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @export tag', () => { - jasmine.getDocSetFromFile('test/fixtures/exporttag.js'); + jsdoc.getDocSetFromFile('test/fixtures/exporttag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/externaltag.js b/test/specs/tags/externaltag.js index b5a34cc9..dc326eae 100644 --- a/test/specs/tags/externaltag.js +++ b/test/specs/tags/externaltag.js @@ -1,8 +1,8 @@ describe('@external tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/externaltag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/externaltag.js'); // TODO: why don't we test anything from docSet2? - // var docSet2 = jasmine.getDocSetFromFile('test/fixtures/externaltag2.js'); - const docSet3 = jasmine.getDocSetFromFile('test/fixtures/externaltag3.js'); + // var docSet2 = jsdoc.getDocSetFromFile('test/fixtures/externaltag2.js'); + const docSet3 = jsdoc.getDocSetFromFile('test/fixtures/externaltag3.js'); const fooBarBazExternal = docSet3.getByLongname('external:"foo.bar.baz"')[0]; const jQueryExternal = docSet.getByLongname('external:"jQuery.fn"')[0]; diff --git a/test/specs/tags/externstag.js b/test/specs/tags/externstag.js index b842bc3d..7e0d61e1 100644 --- a/test/specs/tags/externstag.js +++ b/test/specs/tags/externstag.js @@ -10,17 +10,17 @@ describe('@externs tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @externs tag', () => { - jasmine.getDocSetFromFile('test/fixtures/externstag.js'); + jsdoc.getDocSetFromFile('test/fixtures/externstag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@externs tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @externs tag', () => { - jasmine.getDocSetFromFile('test/fixtures/externstag.js'); + jsdoc.getDocSetFromFile('test/fixtures/externstag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/fileoverviewtag.js b/test/specs/tags/fileoverviewtag.js index 7f3d7e98..0084a0bf 100644 --- a/test/specs/tags/fileoverviewtag.js +++ b/test/specs/tags/fileoverviewtag.js @@ -4,7 +4,7 @@ describe('@fileoverview tag', () => { }); describe('Closure Compiler tags', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/fileoverviewtag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/fileoverviewtag.js'); const fileDoc = docSet.getByLongname('[[string0]]')[0]; it('should set the doclet\'s name and longname to the file name', () => { diff --git a/test/specs/tags/functiontag.js b/test/specs/tags/functiontag.js index 64938c4e..bfb8165d 100644 --- a/test/specs/tags/functiontag.js +++ b/test/specs/tags/functiontag.js @@ -1,5 +1,5 @@ describe('@function tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/functiontag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/functiontag.js'); const doc = docSet.getByLongname('Foo')[0]; const doc2 = docSet.getByLongname('Bar')[0]; diff --git a/test/specs/tags/generatortag.js b/test/specs/tags/generatortag.js index a09141fb..85bc2a1d 100644 --- a/test/specs/tags/generatortag.js +++ b/test/specs/tags/generatortag.js @@ -1,5 +1,5 @@ describe('@generator tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/generatortag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/generatortag.js'); const idMaker = docSet.getByLongname('idMaker')[0]; it('should mark the symbol as a generator function', () => { diff --git a/test/specs/tags/globaltag.js b/test/specs/tags/globaltag.js index 5b787998..0c0a7cf1 100644 --- a/test/specs/tags/globaltag.js +++ b/test/specs/tags/globaltag.js @@ -1,5 +1,5 @@ describe('@global tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/globaltag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/globaltag.js'); it('When an inner symbol has a @global tag it is documented as if it were global.', () => { const found = docSet.getByLongname('foo').filter(({undocumented}) => !(undocumented)); diff --git a/test/specs/tags/hideconstructortag.js b/test/specs/tags/hideconstructortag.js index b3d62f2f..7d53c6b0 100644 --- a/test/specs/tags/hideconstructortag.js +++ b/test/specs/tags/hideconstructortag.js @@ -1,5 +1,5 @@ describe('@hideconstructor tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/hideconstructortag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/hideconstructortag.js'); const toaster = docSet.getByLongname('Toaster')[0]; const waffleIron = docSet.getByLongname('WaffleIron').filter(({undocumented}) => !undocumented)[0]; diff --git a/test/specs/tags/ignoretag.js b/test/specs/tags/ignoretag.js index 481b38c2..c8c759b4 100644 --- a/test/specs/tags/ignoretag.js +++ b/test/specs/tags/ignoretag.js @@ -1,5 +1,5 @@ describe('@ignore tag', () => { - let docSet = jasmine.getDocSetFromFile('test/fixtures/ignoretag.js'); + let docSet = jsdoc.getDocSetFromFile('test/fixtures/ignoretag.js'); let foo = docSet.getByLongname('foo')[0]; it('When a symbol has an @ignore tag, the doclet has a ignore property set to true.', () => { @@ -8,7 +8,7 @@ describe('@ignore tag', () => { it('When a symbol has an @ignore tag with a value an error is thrown', () => { try { - docSet = jasmine.getDocSetFromFile('test/fixtures/ignoretag2.js'); + docSet = jsdoc.getDocSetFromFile('test/fixtures/ignoretag2.js'); foo = docSet.getByLongname('foo')[0]; } catch (e) { expect(e instanceof Error).toBe(true); diff --git a/test/specs/tags/implementstag.js b/test/specs/tags/implementstag.js index c59a1282..f06944c6 100644 --- a/test/specs/tags/implementstag.js +++ b/test/specs/tags/implementstag.js @@ -1,5 +1,5 @@ describe('@implements tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/interface-implements.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/interface-implements.js'); const myTester = docSet.getByLongname('MyTester')[0]; const beforeEachMethod = docSet.getByLongname('MyTester#beforeEach')[0]; diff --git a/test/specs/tags/implicitcasttag.js b/test/specs/tags/implicitcasttag.js index ddcde365..e634383c 100644 --- a/test/specs/tags/implicitcasttag.js +++ b/test/specs/tags/implicitcasttag.js @@ -10,17 +10,17 @@ describe('@implicitCast tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @implicitCast tag', () => { - jasmine.getDocSetFromFile('test/fixtures/implicitcasttag.js'); + jsdoc.getDocSetFromFile('test/fixtures/implicitcasttag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@implicitCast tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @implicitCast tag', () => { - jasmine.getDocSetFromFile('test/fixtures/implicitcasttag.js'); + jsdoc.getDocSetFromFile('test/fixtures/implicitcasttag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/inheritdoctag.js b/test/specs/tags/inheritdoctag.js index e2f66107..c0064599 100644 --- a/test/specs/tags/inheritdoctag.js +++ b/test/specs/tags/inheritdoctag.js @@ -1,5 +1,5 @@ describe('@inheritdoc tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/inheritdoctag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/inheritdoctag.js'); function ignored({ignore}) { return ignore !== true; diff --git a/test/specs/tags/interfacetag.js b/test/specs/tags/interfacetag.js index 692cdb78..d886ca5f 100644 --- a/test/specs/tags/interfacetag.js +++ b/test/specs/tags/interfacetag.js @@ -1,7 +1,7 @@ describe('@interface tag', () => { const logger = require('jsdoc/util/logger'); - const docSet = jasmine.getDocSetFromFile('test/fixtures/interface-implements.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/interface-implements.js'); const testerInterface = docSet.getByLongname('ITester')[0]; const testerImplementation = docSet.getByLongname('MyTester')[0]; @@ -19,16 +19,16 @@ describe('@interface tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('should support virtual doclets with the JSDoc tag dictionary', () => { let docSet2; let virtualInterface; - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); - docSet2 = jasmine.getDocSetFromFile('test/fixtures/interfacetag2.js'); + docSet2 = jsdoc.getDocSetFromFile('test/fixtures/interfacetag2.js'); virtualInterface = docSet2.getByLongname('VirtualInterface')[0]; expect(logger.warn).not.toHaveBeenCalled(); @@ -40,9 +40,9 @@ describe('@interface tag', () => { let docSet2; let virtualInterface; - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); - docSet2 = jasmine.getDocSetFromFile('test/fixtures/interfacetag2.js'); + docSet2 = jsdoc.getDocSetFromFile('test/fixtures/interfacetag2.js'); virtualInterface = docSet2.getByLongname('VirtualInterface')[0]; expect(logger.warn).toHaveBeenCalled(); @@ -52,16 +52,16 @@ describe('@interface tag', () => { describe('Closure Compiler tags', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('should support @record as a synonym for @interface', () => { let docSet2; let myStructuralInterface; - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); - docSet2 = jasmine.getDocSetFromFile('test/fixtures/interfacetag3.js'); + docSet2 = jsdoc.getDocSetFromFile('test/fixtures/interfacetag3.js'); myStructuralInterface = docSet2.getByLongname('MyStructuralInterface')[0]; expect(myStructuralInterface.kind).toBe('interface'); diff --git a/test/specs/tags/kindtag.js b/test/specs/tags/kindtag.js index 1faeaa08..55ba177d 100644 --- a/test/specs/tags/kindtag.js +++ b/test/specs/tags/kindtag.js @@ -1,5 +1,5 @@ describe('@kind tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/kindtag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/kindtag.js'); const doc = docSet.getByLongname('x')[0]; it("sets the doclet's 'kind' property to the tag value", () => { diff --git a/test/specs/tags/licensetag.js b/test/specs/tags/licensetag.js index 76636444..eb57c3fe 100644 --- a/test/specs/tags/licensetag.js +++ b/test/specs/tags/licensetag.js @@ -1,5 +1,5 @@ describe('@license tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/licensetag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/licensetag.js'); const doc = docSet.getByLongname('x')[0]; it("sets the doclet's 'license' property to the tag value", () => { diff --git a/test/specs/tags/listenstag.js b/test/specs/tags/listenstag.js index bc160446..89b15a8e 100644 --- a/test/specs/tags/listenstag.js +++ b/test/specs/tags/listenstag.js @@ -1,5 +1,5 @@ describe('@listens tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/listenstag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/listenstag.js'); const doc = docSet.getByLongname('module:myModule~MyHandler')[0]; it("should create a 'listens' property on the doclet, an array, with the events that are listened to (with event namespace)", () => { diff --git a/test/specs/tags/memberoftag.js b/test/specs/tags/memberoftag.js index 3f63327d..8ee2f4e7 100644 --- a/test/specs/tags/memberoftag.js +++ b/test/specs/tags/memberoftag.js @@ -1,6 +1,6 @@ describe('@memberof tag', () => { it('When a symbol has a @member tag, the doclet has a long name that includes the parent.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/memberoftag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/memberoftag.js'); const Data = docSet.getByLongname('mathlib.Data')[0]; const point = docSet.getByLongname('mathlib.Data#point')[0]; @@ -12,7 +12,7 @@ describe('@memberof tag', () => { }); it('A symbol within a namespace for which no scope is specified.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/memberoftag4.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/memberoftag4.js'); const doOtherStuff = docSet.getByLongname('doStuff.doOtherStuff')[0]; expect(doOtherStuff).toBeDefined(); @@ -20,7 +20,7 @@ describe('@memberof tag', () => { }); it('A symbol in which name === memberof.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/memberoftag4.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/memberoftag4.js'); const doStuff = docSet.getByLongname('doStuff.doStuff')[0]; expect(doStuff).toBeDefined(); @@ -28,7 +28,7 @@ describe('@memberof tag', () => { }); describe('static', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/memberoftag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/memberoftag2.js'); const publish = docSet.getByLongname('Observable#publish')[0]; const cache = docSet.getByLongname('Observable.cache')[0]; @@ -52,7 +52,7 @@ describe('@memberof tag', () => { }); describe('forced', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/memberoftagforced.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/memberoftagforced.js'); const maproutes = docSet.getByLongname('map.routes')[0]; const datapointy = docSet.getByLongname('Data#point.y')[0]; @@ -66,21 +66,21 @@ describe('@memberof tag', () => { }); it('A symbol that is a nested class with a @memberof tag.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/memberoftag3.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/memberoftag3.js'); const tree = docSet.getByLongname('module:terrain.Forest#Tree')[0]; expect(tree.longname, 'module:terrain.Forest#Tree'); }); it('A symbol that is an instance member of a nested class with a @memberof tag.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/memberoftag3.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/memberoftag3.js'); const leaf = docSet.getByLongname('module:terrain.Forest#Tree#leaf')[0]; expect(leaf.longname, 'module:terrain.Forest#Tree#leaf'); }); it('Properties of a symbol with a @memberof tag inherit the @memberof info.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/memberoftag5.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/memberoftag5.js'); const open = docSet.getByLongname('module:network.Socket#open')[0]; const uid = docSet.getByLongname('module:network.Socket.uid')[0]; diff --git a/test/specs/tags/membertag.js b/test/specs/tags/membertag.js index 3213664f..34f8ed34 100644 --- a/test/specs/tags/membertag.js +++ b/test/specs/tags/membertag.js @@ -1,5 +1,5 @@ describe('@member tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/membertag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/membertag.js'); const doc = docSet.getByLongname('x')[0]; const doc2 = docSet.getByLongname('foobar')[0]; const doc3 = docSet.getByLongname('baz')[0]; diff --git a/test/specs/tags/mixestag.js b/test/specs/tags/mixestag.js index 08d5d828..fe1fe9db 100644 --- a/test/specs/tags/mixestag.js +++ b/test/specs/tags/mixestag.js @@ -1,5 +1,5 @@ describe('@mixes tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/mixintag.js'); const FormButton = docSet.getByLongname('FormButton')[0]; const MyClass = docSet.getByLongname('MyClass')[0]; diff --git a/test/specs/tags/mixintag.js b/test/specs/tags/mixintag.js index ca16c053..d2485a27 100644 --- a/test/specs/tags/mixintag.js +++ b/test/specs/tags/mixintag.js @@ -1,5 +1,5 @@ describe('@mixin tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/mixintag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/mixintag.js'); const Eventful = docSet.getByLongname('Eventful')[0]; const Mixin = docSet.getByLongname('AnotherMixin')[0]; diff --git a/test/specs/tags/modifiestag.js b/test/specs/tags/modifiestag.js index aaff3ee8..01c2a77d 100644 --- a/test/specs/tags/modifiestag.js +++ b/test/specs/tags/modifiestag.js @@ -1,5 +1,5 @@ describe('@modifies tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/modifiestag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/modifiestag.js'); const mutator = docSet.getByLongname('mutator')[0]; it('should add the specified types to the doclet\'s `modifies` property', () => { diff --git a/test/specs/tags/moduletag.js b/test/specs/tags/moduletag.js index 0550c038..3b46f076 100644 --- a/test/specs/tags/moduletag.js +++ b/test/specs/tags/moduletag.js @@ -4,7 +4,7 @@ function filter({undocumented}) { describe('@module tag', () => { describe("using 'this'", () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduletag.js'); const book = docSet.getByLongname('module:bookshelf.Book')[0]; const title = docSet.getByLongname('module:bookshelf.Book#title')[0]; @@ -20,7 +20,7 @@ describe('@module tag', () => { }); describe('misc', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduletag2.js'); const mixer = docSet.getByLongname('module:color/mixer').filter(filter)[0]; const blend = docSet.getByLongname('module:color/mixer.blend')[0]; const darken = docSet.getByLongname('module:color/mixer.darken')[0]; @@ -46,7 +46,7 @@ describe('@module tag', () => { }); describe('virtual comments', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag4.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduletag4.js'); const clickProperties = docSet.getByLongname('module:M1~ClickProperties')[0]; const virtFunc = docSet.getByLongname('module:M1.VirtualComment')[0]; const virtFunc2 = docSet.getByLongname('module:M1#VirtualComment2')[0]; @@ -75,7 +75,7 @@ describe('@module tag', () => { }); describe('"module:" namespace included in the name', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag5.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduletag5.js'); const bookshelf = docSet.getByLongname('module:bookshelf')[0]; it('When the name for a @module tag begins with the "module:" namespace, we remove the namespace', () => { @@ -87,7 +87,7 @@ describe('@module tag', () => { describe('ES 2015 modules', () => { describe('that export a default', () => { describe('value type', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag6.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduletag6.js'); const exports = docSet.getByLongname('module:appname').filter(({kind}) => kind === 'member')[0]; it('When a value type is exported, it has the same name as the module longname', () => { @@ -96,7 +96,7 @@ describe('@module tag', () => { }); describe('object', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag7.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduletag7.js'); const blend = docSet.getByLongname('module:color/mixer.blend')[0]; it('When an object is exported, its members have the correct name, memberof, and kind', () => { @@ -108,7 +108,7 @@ describe('@module tag', () => { }); describe('that export named values', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag8.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduletag8.js'); const blend = docSet.getByLongname('module:color/mixer.blend')[0]; const lastColor = docSet.getByLongname('module:color/mixer.lastColor')[0]; const name = docSet.getByLongname('module:color/mixer.name')[0]; @@ -142,7 +142,7 @@ describe('@module tag', () => { describe('that export another module in its entirety', () => { it('should not crash JSDoc', () => { function getDocSet() { - jasmine.getDocSetFromFile('test/fixtures/moduletag9.js'); + jsdoc.getDocSetFromFile('test/fixtures/moduletag9.js'); } expect(getDocSet).not.toThrow(); @@ -152,7 +152,7 @@ describe('@module tag', () => { describe('that export an unnamed default function', () => { it('should not crash JSDoc', () => { function getDocSet() { - jasmine.getDocSetFromFile('test/fixtures/moduletag10.js'); + jsdoc.getDocSetFromFile('test/fixtures/moduletag10.js'); } expect(getDocSet).not.toThrow(); @@ -160,7 +160,7 @@ describe('@module tag', () => { }); describe('that export a class', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag11.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/moduletag11.js'); const foo = docSet.getByLongname('module:foo.Foo').filter(filter)[0]; const testMethod = docSet.getByLongname('module:foo.Foo#testMethod')[0]; diff --git a/test/specs/tags/namespacetag.js b/test/specs/tags/namespacetag.js index 758f1ab0..c1cd9cb8 100644 --- a/test/specs/tags/namespacetag.js +++ b/test/specs/tags/namespacetag.js @@ -1,5 +1,5 @@ describe('@namespace tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/namespacetag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/namespacetag.js'); const x = docSet.getByLongname('x')[0]; const Foo = docSet.getByLongname('Foo')[0]; const Bar = docSet.getByLongname('Bar')[0]; diff --git a/test/specs/tags/nametag.js b/test/specs/tags/nametag.js index 1e6abe3f..ba934911 100644 --- a/test/specs/tags/nametag.js +++ b/test/specs/tags/nametag.js @@ -1,5 +1,5 @@ describe('@name tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/nametag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/nametag.js'); const view = docSet.getByLongname('View')[0]; const controller = docSet.getByLongname('Controller')[0]; const addToParent = docSet.getByLongname('MvcHelpers~addToParent')[0]; diff --git a/test/specs/tags/noaliastag.js b/test/specs/tags/noaliastag.js index 9f28abe1..fea1d9db 100644 --- a/test/specs/tags/noaliastag.js +++ b/test/specs/tags/noaliastag.js @@ -10,17 +10,17 @@ describe('@noalias tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @noalias tag', () => { - jasmine.getDocSetFromFile('test/fixtures/noaliastag.js'); + jsdoc.getDocSetFromFile('test/fixtures/noaliastag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@noalias tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @noalias tag', () => { - jasmine.getDocSetFromFile('test/fixtures/noaliastag.js'); + jsdoc.getDocSetFromFile('test/fixtures/noaliastag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/nocollapsetag.js b/test/specs/tags/nocollapsetag.js index 0c82478d..099b27bf 100644 --- a/test/specs/tags/nocollapsetag.js +++ b/test/specs/tags/nocollapsetag.js @@ -10,17 +10,17 @@ describe('@nocollapse tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @nocollapse tag', () => { - jasmine.getDocSetFromFile('test/fixtures/nocollapsetag.js'); + jsdoc.getDocSetFromFile('test/fixtures/nocollapsetag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@nocollapse tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @nocollapse tag', () => { - jasmine.getDocSetFromFile('test/fixtures/nocollapsetag.js'); + jsdoc.getDocSetFromFile('test/fixtures/nocollapsetag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/nocompiletag.js b/test/specs/tags/nocompiletag.js index 19570828..d048951f 100644 --- a/test/specs/tags/nocompiletag.js +++ b/test/specs/tags/nocompiletag.js @@ -10,17 +10,17 @@ describe('@nocompile tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @nocompile tag', () => { - jasmine.getDocSetFromFile('test/fixtures/nocompiletag.js'); + jsdoc.getDocSetFromFile('test/fixtures/nocompiletag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@nocompile tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @nocompile tag', () => { - jasmine.getDocSetFromFile('test/fixtures/nocompiletag.js'); + jsdoc.getDocSetFromFile('test/fixtures/nocompiletag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/nosideeffectstag.js b/test/specs/tags/nosideeffectstag.js index dfdca3a1..497cee65 100644 --- a/test/specs/tags/nosideeffectstag.js +++ b/test/specs/tags/nosideeffectstag.js @@ -1,15 +1,15 @@ describe('@nosideeffects tag', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should set the doclet\'s `modifies` property to an empty array', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/nosideeffectstag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/nosideeffectstag.js'); const doNothing = docSet.getByLongname('doNothing')[0]; expect(Array.isArray(doNothing.modifies)).toBe(true); diff --git a/test/specs/tags/overridetag.js b/test/specs/tags/overridetag.js index 22ff3323..0328c1c9 100644 --- a/test/specs/tags/overridetag.js +++ b/test/specs/tags/overridetag.js @@ -1,6 +1,6 @@ describe('@override tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/overridetag.js'); - const docSet2 = jasmine.getDocSetFromFile('test/fixtures/overridetag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/overridetag.js'); + const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/overridetag2.js'); function ignored({ignore}) { return ignore !== true; diff --git a/test/specs/tags/overviewtag.js b/test/specs/tags/overviewtag.js index 24049f65..37e1f85e 100644 --- a/test/specs/tags/overviewtag.js +++ b/test/specs/tags/overviewtag.js @@ -13,7 +13,7 @@ describe('@overview tag', () => { env.opts._ = [path.normalize(`${env.pwd}/test/fixtures/`)]; env.pwd = env.dirname; env.sourceFiles = []; - srcParser = jasmine.createParser(); + srcParser = jsdoc.createParser(); require('jsdoc/src/handlers').attachTo(srcParser); }); diff --git a/test/specs/tags/packagetag.js b/test/specs/tags/packagetag.js index 2075caa5..b567b44d 100644 --- a/test/specs/tags/packagetag.js +++ b/test/specs/tags/packagetag.js @@ -1,7 +1,7 @@ const logger = require('jsdoc/util/logger'); describe('@package tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/packagetag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/packagetag.js'); const foo = docSet.getByLongname('foo')[0]; it('When a symbol has a @package tag, the doclet has an `access` property set to `package`.', @@ -11,14 +11,14 @@ describe('@package tag', () => { describe('JSDoc tags', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('When JSDoc tags are enabled, the @package tag does not accept a value.', () => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); spyOn(logger, 'warn'); - jasmine.getDocSetFromFile('test/fixtures/packagetag2.js'); + jsdoc.getDocSetFromFile('test/fixtures/packagetag2.js'); expect(logger.warn).toHaveBeenCalled(); }); @@ -26,7 +26,7 @@ describe('@package tag', () => { describe('Closure Compiler tags', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('When Closure Compiler tags are enabled, the @package tag accepts a type expression.', @@ -34,10 +34,10 @@ describe('@package tag', () => { let connectionPorts; let privateDocs; - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); spyOn(logger, 'warn'); - privateDocs = jasmine.getDocSetFromFile('test/fixtures/packagetag2.js'); + privateDocs = jsdoc.getDocSetFromFile('test/fixtures/packagetag2.js'); connectionPorts = privateDocs.getByLongname('connectionPorts')[0]; expect(logger.warn).not.toHaveBeenCalled(); diff --git a/test/specs/tags/paramtag.js b/test/specs/tags/paramtag.js index 2cc42a97..e8f703ba 100644 --- a/test/specs/tags/paramtag.js +++ b/test/specs/tags/paramtag.js @@ -1,6 +1,6 @@ describe('@param tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/paramtag.js'); - const docSet2 = jasmine.getDocSetFromFile('test/fixtures/paramtag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/paramtag.js'); + const docSet2 = jsdoc.getDocSetFromFile('test/fixtures/paramtag2.js'); it('When a symbol has an @param tag with a type before the name, the doclet has a params property that includes that param.', () => { const find = docSet.getByLongname('find')[0]; @@ -100,7 +100,7 @@ describe('@param tag', () => { }); it('When a symbol has a @param tag with an invalid type expression, the JSDoc comment is ignored.', () => { - const badDocSet = jasmine.getDocSetFromFile('test/fixtures/paramtaginvalidtype.js'); + const badDocSet = jsdoc.getDocSetFromFile('test/fixtures/paramtaginvalidtype.js'); const test = badDocSet.getByLongname('Test#test')[0]; expect(test).toBeDefined(); diff --git a/test/specs/tags/polymerbehaviortag.js b/test/specs/tags/polymerbehaviortag.js index 8a05b22a..941b1766 100644 --- a/test/specs/tags/polymerbehaviortag.js +++ b/test/specs/tags/polymerbehaviortag.js @@ -10,17 +10,17 @@ describe('@polymerBehavior tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @polymerBehavior tag', () => { - jasmine.getDocSetFromFile('test/fixtures/polymerbehaviortag.js'); + jsdoc.getDocSetFromFile('test/fixtures/polymerbehaviortag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@polymerBehavior tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @polymerBehavior tag', () => { - jasmine.getDocSetFromFile('test/fixtures/polymerbehaviortag.js'); + jsdoc.getDocSetFromFile('test/fixtures/polymerbehaviortag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/polymertag.js b/test/specs/tags/polymertag.js index 57f593fc..e3c3f4c5 100644 --- a/test/specs/tags/polymertag.js +++ b/test/specs/tags/polymertag.js @@ -10,17 +10,17 @@ describe('@polymer tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @polymer tag', () => { - jasmine.getDocSetFromFile('test/fixtures/polymertag.js'); + jsdoc.getDocSetFromFile('test/fixtures/polymertag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@polymer tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @polymer tag', () => { - jasmine.getDocSetFromFile('test/fixtures/polymertag.js'); + jsdoc.getDocSetFromFile('test/fixtures/polymertag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/preservetag.js b/test/specs/tags/preservetag.js index b6405836..9fea1afc 100644 --- a/test/specs/tags/preservetag.js +++ b/test/specs/tags/preservetag.js @@ -10,17 +10,17 @@ describe('@preserve tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @preserve tag', () => { - jasmine.getDocSetFromFile('test/fixtures/preservetag.js'); + jsdoc.getDocSetFromFile('test/fixtures/preservetag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@preserve tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should set the doclet\'s `license` property to the tag value', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/preservetag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/preservetag.js'); const x = docSet.getByLongname('x')[0]; expect(x.license).toBe('My cool license goes here.'); diff --git a/test/specs/tags/privatetag.js b/test/specs/tags/privatetag.js index bc2b3ea3..799d4ae7 100644 --- a/test/specs/tags/privatetag.js +++ b/test/specs/tags/privatetag.js @@ -1,7 +1,7 @@ const logger = require('jsdoc/util/logger'); describe('@private tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/privatetag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/privatetag.js'); const foo = docSet.getByLongname('Foo')[0]; const bar = docSet.getByLongname('Foo#bar')[0]; @@ -17,14 +17,14 @@ describe('@private tag', () => { describe('JSDoc tags', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('When JSDoc tags are enabled, the @private tag does not accept a value.', () => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); spyOn(logger, 'warn'); - jasmine.getDocSetFromFile('test/fixtures/privatetag2.js'); + jsdoc.getDocSetFromFile('test/fixtures/privatetag2.js'); expect(logger.warn).toHaveBeenCalled(); }); @@ -32,7 +32,7 @@ describe('@private tag', () => { describe('Closure Compiler tags', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('When Closure Compiler tags are enabled, the @private tag accepts a type expression.', @@ -40,10 +40,10 @@ describe('@private tag', () => { let connectionPorts; let privateDocs; - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); spyOn(logger, 'warn'); - privateDocs = jasmine.getDocSetFromFile('test/fixtures/privatetag2.js'); + privateDocs = jsdoc.getDocSetFromFile('test/fixtures/privatetag2.js'); connectionPorts = privateDocs.getByLongname('connectionPorts')[0]; expect(logger.warn).not.toHaveBeenCalled(); diff --git a/test/specs/tags/propertytag.js b/test/specs/tags/propertytag.js index ae0736e3..8a6159bf 100644 --- a/test/specs/tags/propertytag.js +++ b/test/specs/tags/propertytag.js @@ -1,6 +1,6 @@ describe('@property tag', () => { it('When a symbol has a @property tag, the property appears in the doclet.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/propertytag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/propertytag.js'); const myobject = docSet.getByLongname('myobject')[0]; expect(typeof myobject.properties).toBe('object'); @@ -19,7 +19,7 @@ describe('@property tag', () => { }); it('When a symbol has a @property tag for a numeric property, the property appears in the doclet.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/numericpropertytag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/numericpropertytag.js'); const numericObject = docSet.getByLongname('numericObject')[0]; expect(typeof numericObject.properties).toBe('object'); diff --git a/test/specs/tags/protectedtag.js b/test/specs/tags/protectedtag.js index 028f8c8e..fc1ad1d5 100644 --- a/test/specs/tags/protectedtag.js +++ b/test/specs/tags/protectedtag.js @@ -1,7 +1,7 @@ const logger = require('jsdoc/util/logger'); describe('@protected tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/protectedtag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/protectedtag.js'); const uidCounter = docSet.getByLongname('module:uid~uidCounter')[0]; const uidRoot = docSet.getByLongname('module:uid~uidObjects.root')[0]; @@ -17,14 +17,14 @@ describe('@protected tag', () => { describe('JSDoc tags', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('When JSDoc tags are enabled, the @protected tag does not accept a value.', () => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); spyOn(logger, 'warn'); - jasmine.getDocSetFromFile('test/fixtures/protectedtag2.js'); + jsdoc.getDocSetFromFile('test/fixtures/protectedtag2.js'); expect(logger.warn).toHaveBeenCalled(); }); @@ -32,7 +32,7 @@ describe('@protected tag', () => { describe('Closure Compiler tags', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('When Closure Compiler tags are enabled, the @private tag accepts a type expression.', @@ -40,10 +40,10 @@ describe('@protected tag', () => { let counter; let protectedDocs; - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); spyOn(logger, 'warn'); - protectedDocs = jasmine.getDocSetFromFile('test/fixtures/protectedtag2.js'); + protectedDocs = jsdoc.getDocSetFromFile('test/fixtures/protectedtag2.js'); counter = protectedDocs.getByLongname('uidCounter')[0]; expect(logger.warn).not.toHaveBeenCalled(); diff --git a/test/specs/tags/publictag.js b/test/specs/tags/publictag.js index d596b146..67ebea8a 100644 --- a/test/specs/tags/publictag.js +++ b/test/specs/tags/publictag.js @@ -1,15 +1,15 @@ describe('@public tag', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should set the doclet\'s `access` property to `public`', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/publictag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/publictag.js'); const foo = docSet.getByLongname('Foo')[0]; expect(foo.access).toBe('public'); @@ -18,18 +18,18 @@ describe('@public tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should set the doclet\'s `access` property to `public`', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/publictag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/publictag2.js'); const bar = docSet.getByLongname('bar')[0]; expect(bar.access).toBe('public'); }); it('should include the type if one is provided', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/publictag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/publictag2.js'); const bar = docSet.getByLongname('bar')[0]; expect(bar.type).toBeDefined(); diff --git a/test/specs/tags/readonlytag.js b/test/specs/tags/readonlytag.js index 8faf9ea1..f6929ffe 100644 --- a/test/specs/tags/readonlytag.js +++ b/test/specs/tags/readonlytag.js @@ -1,5 +1,5 @@ describe('@readonly tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/readonlytag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/readonlytag.js'); const length = docSet.getByLongname('Collection#length')[0]; it('When a symbol has an @readonly tag, the doclet has an readonly property that is true.', () => { diff --git a/test/specs/tags/requirestag.js b/test/specs/tags/requirestag.js index e7e6e78e..45b842dd 100644 --- a/test/specs/tags/requirestag.js +++ b/test/specs/tags/requirestag.js @@ -1,5 +1,5 @@ describe('@requires tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/requirestag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/requirestag.js'); const foo = docSet.getByLongname('foo')[0]; const bar = docSet.getByLongname('bar')[0]; const baz = docSet.getByLongname('baz')[0]; diff --git a/test/specs/tags/returnstag.js b/test/specs/tags/returnstag.js index 0014656a..5c282609 100644 --- a/test/specs/tags/returnstag.js +++ b/test/specs/tags/returnstag.js @@ -1,5 +1,5 @@ describe('@returns tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/returnstag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/returnstag.js'); it('When a symbol has a @returns tag with a type and description, the doclet has a "returns" property that includes that info.', () => { const find = docSet.getByLongname('find')[0]; diff --git a/test/specs/tags/scopetags.js b/test/specs/tags/scopetags.js index 82808895..25ca8f70 100644 --- a/test/specs/tags/scopetags.js +++ b/test/specs/tags/scopetags.js @@ -1,5 +1,5 @@ describe('scope tags', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/scopetags.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/scopetags.js'); // @inner, @instance, @static (@global has its own file) describe('@inner tag', () => { diff --git a/test/specs/tags/seetag.js b/test/specs/tags/seetag.js index 129c83dd..2ae1de99 100644 --- a/test/specs/tags/seetag.js +++ b/test/specs/tags/seetag.js @@ -1,5 +1,5 @@ describe('@see tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/seetag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/seetag.js'); const foo = docSet.getByLongname('foo')[0]; const bar = docSet.getByLongname('bar')[0]; diff --git a/test/specs/tags/sincetag.js b/test/specs/tags/sincetag.js index 4d1f854c..cf2279b3 100644 --- a/test/specs/tags/sincetag.js +++ b/test/specs/tags/sincetag.js @@ -1,5 +1,5 @@ describe('@since tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/sincetag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/sincetag.js'); const foo = docSet.getByLongname('foo')[0]; it('When a symbol has an @since tag, the doclet has a since property set to true.', () => { diff --git a/test/specs/tags/structtag.js b/test/specs/tags/structtag.js index ba9ebf7f..e8749da5 100644 --- a/test/specs/tags/structtag.js +++ b/test/specs/tags/structtag.js @@ -10,17 +10,17 @@ describe('@struct tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @struct tag', () => { - jasmine.getDocSetFromFile('test/fixtures/structtag.js'); + jsdoc.getDocSetFromFile('test/fixtures/structtag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@struct tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @struct tag', () => { - jasmine.getDocSetFromFile('test/fixtures/structtag.js'); + jsdoc.getDocSetFromFile('test/fixtures/structtag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/summarytag.js b/test/specs/tags/summarytag.js index ea2fb2f2..b04616a3 100644 --- a/test/specs/tags/summarytag.js +++ b/test/specs/tags/summarytag.js @@ -1,5 +1,5 @@ describe('@summary tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/summarytag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/summarytag.js'); const doc = docSet.getByLongname('Sam')[0]; it("sets the doclet's 'summary' property to the tag value", () => { diff --git a/test/specs/tags/suppresstag.js b/test/specs/tags/suppresstag.js index 910b0194..0145a2c9 100644 --- a/test/specs/tags/suppresstag.js +++ b/test/specs/tags/suppresstag.js @@ -10,17 +10,17 @@ describe('@suppress tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @suppress tag', () => { - jasmine.getDocSetFromFile('test/fixtures/suppresstag.js'); + jsdoc.getDocSetFromFile('test/fixtures/suppresstag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@suppress tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @suppress tag', () => { - jasmine.getDocSetFromFile('test/fixtures/suppresstag.js'); + jsdoc.getDocSetFromFile('test/fixtures/suppresstag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/templatetag.js b/test/specs/tags/templatetag.js index 5f6cff1a..6e2db022 100644 --- a/test/specs/tags/templatetag.js +++ b/test/specs/tags/templatetag.js @@ -10,17 +10,17 @@ describe('@template tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @template tag', () => { - jasmine.getDocSetFromFile('test/fixtures/templatetag.js'); + jsdoc.getDocSetFromFile('test/fixtures/templatetag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@template tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @template tag', () => { - jasmine.getDocSetFromFile('test/fixtures/templatetag.js'); + jsdoc.getDocSetFromFile('test/fixtures/templatetag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/thistag.js b/test/specs/tags/thistag.js index e789299a..19ffc539 100644 --- a/test/specs/tags/thistag.js +++ b/test/specs/tags/thistag.js @@ -1,22 +1,22 @@ describe('@this tag', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should add a `this` property set to the @this tag\'s value', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/thistag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/thistag.js'); const setName = docSet.getByLongname('setName')[0]; expect(setName.this).toBe('Foo'); }); it('should change the memberof for symbols like `this.foo`', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/thistag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/thistag.js'); const fooName = docSet.getByLongname('Foo#name')[0]; expect(typeof fooName).toBe('object'); @@ -28,18 +28,18 @@ describe('@this tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should add a `this` property set to the @this tag\'s type expression', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/thistag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/thistag2.js'); const setName = docSet.getByLongname('setName')[0]; expect(setName.this).toBe('Foo'); }); it('should change the memberof for symbols like `this.foo`', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/thistag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/thistag2.js'); const fooName = docSet.getByLongname('Foo#name')[0]; expect(typeof fooName).toBe('object'); @@ -49,7 +49,7 @@ describe('@this tag', () => { }); it('should work with type unions', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/thistag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/thistag2.js'); const getName = docSet.getByLongname('getName')[0]; expect(getName.this).toBe('(Foo|Bar)'); diff --git a/test/specs/tags/todotag.js b/test/specs/tags/todotag.js index 27bc2937..c70ad134 100644 --- a/test/specs/tags/todotag.js +++ b/test/specs/tags/todotag.js @@ -1,5 +1,5 @@ describe('@todo tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/todotag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/todotag.js'); const doc = docSet.getByLongname('x')[0]; it("adds the entries into a 'todo' array on the doclet", () => { diff --git a/test/specs/tags/tutorialtag.js b/test/specs/tags/tutorialtag.js index ef5ad0d5..7791ef68 100644 --- a/test/specs/tags/tutorialtag.js +++ b/test/specs/tags/tutorialtag.js @@ -1,6 +1,6 @@ describe('@tutorial tag', () => { // these are tests for the block usage, not the inline usage. see util/templateHelper for that. - const docSet = jasmine.getDocSetFromFile('test/fixtures/tutorialtag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/tutorialtag.js'); const doc = docSet.getByLongname('x')[0]; it("adds the listed tutorials to a 'tutorials' array on the doclet", () => { diff --git a/test/specs/tags/typedeftag.js b/test/specs/tags/typedeftag.js index 8e5d2db9..0e9da470 100644 --- a/test/specs/tags/typedeftag.js +++ b/test/specs/tags/typedeftag.js @@ -1,22 +1,22 @@ describe('@typedef tag', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('When a comment has a @typedef tag, the doclet has a kind property set to "typedef".', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typedeftag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag.js'); const numberlike = docSet.getByLongname('calc.NumberLike')[0]; expect(numberlike.kind).toBe('typedef'); }); it('When a comment has a @typedef tag with a type, the doclet has a type property set to that type.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typedeftag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag.js'); const numberlike = docSet.getByLongname('calc.NumberLike')[0]; expect(typeof numberlike.type).toBe('object'); @@ -27,7 +27,7 @@ describe('@typedef tag', () => { }); it('When a comment has a @typedef tag with a name, the doclet has a name property set to that name.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typedeftag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag.js'); const numberlike = docSet.getByLongname('calc.NumberLike')[0]; expect(numberlike.name).toBe('NumberLike'); @@ -35,7 +35,7 @@ describe('@typedef tag', () => { }); it('When a symbol has a @typedef tag without a name, the doclet has a name property set to the symbol name.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typedeftag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag.js'); const operator = docSet.getByLongname('calc.Operator')[0]; expect(operator.name).toBe('Operator'); @@ -43,7 +43,7 @@ describe('@typedef tag', () => { }); it('When a symbol has a @typedef tag with a name, the name in the tag takes precedence over the symbol name.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typedeftag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag.js'); const result = docSet.getByLongname('calc.Result')[0]; expect(result.name).toBe('Result'); @@ -51,7 +51,7 @@ describe('@typedef tag', () => { }); it('When a symbol has a @typedef tag with a name and no scope, the scope defaults to `global`.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typedeftag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag.js'); const calculatorBattery = docSet.getByLongname('CalculatorBattery')[0]; expect(calculatorBattery).toBeDefined(); @@ -61,18 +61,18 @@ describe('@typedef tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('When a comment has a @typedef tag, the doclet has a kind property set to "typedef".', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typedeftag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag2.js'); const numberlike = docSet.getByLongname('calc.NumberLike')[0]; expect(numberlike.kind).toBe('typedef'); }); it('When a comment has a @typedef tag with a type, the doclet has a type property set to that type.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typedeftag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag2.js'); const numberlike = docSet.getByLongname('calc.NumberLike')[0]; expect(typeof numberlike.type).toBe('object'); @@ -83,7 +83,7 @@ describe('@typedef tag', () => { }); it('When a symbol has a @typedef tag, the doclet has a name property set to the symbol name.', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typedeftag2.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag2.js'); const numberlike = docSet.getByLongname('calc.NumberLike')[0]; expect(numberlike.name).toBe('NumberLike'); diff --git a/test/specs/tags/typekind.js b/test/specs/tags/typekind.js index 02306a02..176a275f 100644 --- a/test/specs/tags/typekind.js +++ b/test/specs/tags/typekind.js @@ -1,5 +1,5 @@ describe('@kind tag with type', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typekind.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typekind.js'); const blog = docSet.getByLongname('module:blog/server')[0]; const port = docSet.getByLongname('module:blog/server.port')[0]; diff --git a/test/specs/tags/typetag.js b/test/specs/tags/typetag.js index 4392469a..20945f12 100644 --- a/test/specs/tags/typetag.js +++ b/test/specs/tags/typetag.js @@ -1,7 +1,7 @@ const logger = require('jsdoc/util/logger'); describe('@type tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/typetag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/typetag.js'); it('When a symbol has a @type tag, the doclet has a type property set to that value\'s type.', () => { const foo = docSet.getByLongname('foo')[0]; @@ -25,14 +25,14 @@ describe('@type tag', () => { describe('JSDoc tags', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('When JSDoc tags are enabled, the @type tag does not accept a description.', () => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); spyOn(logger, 'warn'); - jasmine.getDocSetFromFile('test/fixtures/typetag2.js'); + jsdoc.getDocSetFromFile('test/fixtures/typetag2.js'); expect(logger.warn).toHaveBeenCalled(); }); @@ -40,17 +40,17 @@ describe('@type tag', () => { describe('Closure tags', () => { afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); }); it('When Closure tags are enabled, the @type tag accepts a description.', () => { let stringOrNumber; let typeDocs; - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); spyOn(logger, 'warn'); - typeDocs = jasmine.getDocSetFromFile('test/fixtures/typetag2.js'); + typeDocs = jsdoc.getDocSetFromFile('test/fixtures/typetag2.js'); stringOrNumber = typeDocs.getByLongname('stringOrNumber')[0]; expect(logger.warn).not.toHaveBeenCalled(); diff --git a/test/specs/tags/undocumentedtag.js b/test/specs/tags/undocumentedtag.js index cb2c2532..d42a570a 100644 --- a/test/specs/tags/undocumentedtag.js +++ b/test/specs/tags/undocumentedtag.js @@ -1,5 +1,5 @@ describe('@undocumented tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/undocumentedtag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/undocumentedtag.js'); const doc = docSet.getByLongname('x')[0]; it("sets the doclet's 'undocumented' property to true", () => { diff --git a/test/specs/tags/unrestrictedtag.js b/test/specs/tags/unrestrictedtag.js index 5ac404f3..23cf2c98 100644 --- a/test/specs/tags/unrestrictedtag.js +++ b/test/specs/tags/unrestrictedtag.js @@ -10,17 +10,17 @@ describe('@unrestricted tag', () => { }); afterEach(() => { - jasmine.restoreTagDictionary(); + jsdoc.restoreTagDictionary(); env.conf.tags.allowUnknownTags = allowUnknownTags; }); describe('JSDoc tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('jsdoc'); + jsdoc.replaceTagDictionary('jsdoc'); }); it('should not recognize the @unrestricted tag', () => { - jasmine.getDocSetFromFile('test/fixtures/unrestrictedtag.js'); + jsdoc.getDocSetFromFile('test/fixtures/unrestrictedtag.js'); expect(logger.error).toHaveBeenCalled(); }); @@ -28,11 +28,11 @@ describe('@unrestricted tag', () => { describe('Closure Compiler tags', () => { beforeEach(() => { - jasmine.replaceTagDictionary('closure'); + jsdoc.replaceTagDictionary('closure'); }); it('should recognize the @unrestricted tag', () => { - jasmine.getDocSetFromFile('test/fixtures/unrestrictedtag.js'); + jsdoc.getDocSetFromFile('test/fixtures/unrestrictedtag.js'); expect(logger.error).not.toHaveBeenCalled(); }); diff --git a/test/specs/tags/variationtag.js b/test/specs/tags/variationtag.js index 34f89f2c..31f6bf83 100644 --- a/test/specs/tags/variationtag.js +++ b/test/specs/tags/variationtag.js @@ -1,5 +1,5 @@ describe('@variation tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/variationtag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/variationtag.js'); const someObject2 = docSet.getByLongname('someObject(2)')[0]; const someObject2Method = docSet.getByLongname('someObject(2).someMethod')[0]; const someObject3 = docSet.getByLongname('someObject(3)')[0]; diff --git a/test/specs/tags/versiontag.js b/test/specs/tags/versiontag.js index 3931d30d..48a4db68 100644 --- a/test/specs/tags/versiontag.js +++ b/test/specs/tags/versiontag.js @@ -1,5 +1,5 @@ describe('@version tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/versiontag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/versiontag.js'); const foo = docSet.getByLongname('foo')[0]; it('When a symbol has a @version tag, the doclet has a version property set to that value.', () => { diff --git a/test/specs/tags/yieldstag.js b/test/specs/tags/yieldstag.js index f92a0225..24d47c03 100644 --- a/test/specs/tags/yieldstag.js +++ b/test/specs/tags/yieldstag.js @@ -1,5 +1,5 @@ describe('@yields tag', () => { - const docSet = jasmine.getDocSetFromFile('test/fixtures/yieldstag.js'); + const docSet = jsdoc.getDocSetFromFile('test/fixtures/yieldstag.js'); const fibonacci = docSet.getByLongname('fibonacci')[0]; const fibonacci2 = docSet.getByLongname('fibonacci2')[0]; const fibonacci3 = docSet.getByLongname('fibonacci3')[0];