mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
add jasmine.replaceTagDictionary and jasmine.restoreTagDictionary test helpers
This commit is contained in:
parent
f4bf81606f
commit
857a346f4b
@ -1,4 +1,4 @@
|
||||
/* global expect, jasmine: true, runs, waits */
|
||||
/* global jasmine: true */
|
||||
'use strict';
|
||||
|
||||
var fs = require('jsdoc/fs');
|
||||
@ -6,15 +6,21 @@ var path = require('jsdoc/path');
|
||||
|
||||
var jsdoc = {
|
||||
augment: require('jsdoc/augment'),
|
||||
borrow: require('jsdoc/borrow'),
|
||||
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);
|
||||
@ -171,6 +177,26 @@ jasmine.getDocSetFromFile = function(filename, parser, validate, augment) {
|
||||
};
|
||||
};
|
||||
|
||||
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];
|
||||
|
||||
@ -193,10 +193,7 @@ describe("jsdoc/util/templateHelper", function() {
|
||||
|
||||
describe("getUniqueFilename", function() {
|
||||
afterEach(function() {
|
||||
var dict = new dictionary.Dictionary();
|
||||
|
||||
definitions.defineTags(dict);
|
||||
doclet._replaceDictionary(dict);
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
// TODO: needs more tests for unusual values and things that get special treatment (such as
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
describe('@interface tag', function() {
|
||||
var definitions = require('jsdoc/tag/dictionary/definitions');
|
||||
var Dictionary = require('jsdoc/tag/dictionary').Dictionary;
|
||||
var doclet = require('jsdoc/doclet');
|
||||
var logger = require('jsdoc/util/logger');
|
||||
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/interface-implements.js');
|
||||
@ -19,25 +16,19 @@ describe('@interface tag', function() {
|
||||
});
|
||||
|
||||
describe('virtual doclets', function() {
|
||||
var tagDict;
|
||||
|
||||
beforeEach(function() {
|
||||
spyOn(logger, 'warn');
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
tagDict = new Dictionary();
|
||||
definitions.defineTags(tagDict);
|
||||
doclet._replaceDictionary(tagDict);
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
it('should support virtual doclets with the JSDoc tag dictionary', function() {
|
||||
var docSet2;
|
||||
var virtualInterface;
|
||||
|
||||
tagDict = new Dictionary();
|
||||
definitions.defineTags(tagDict, definitions.jsdocTags);
|
||||
doclet._replaceDictionary(tagDict);
|
||||
jasmine.replaceTagDictionary('jsdoc');
|
||||
|
||||
docSet2 = jasmine.getDocSetFromFile('test/fixtures/interfacetag2.js');
|
||||
virtualInterface = docSet2.getByLongname('VirtualInterface')[0];
|
||||
@ -51,9 +42,7 @@ describe('@interface tag', function() {
|
||||
var docSet2;
|
||||
var virtualInterface;
|
||||
|
||||
tagDict = new Dictionary();
|
||||
definitions.defineTags(tagDict, definitions.closureTags);
|
||||
doclet._replaceDictionary(tagDict);
|
||||
jasmine.replaceTagDictionary('closure');
|
||||
|
||||
docSet2 = jasmine.getDocSetFromFile('test/fixtures/interfacetag2.js');
|
||||
virtualInterface = docSet2.getByLongname('VirtualInterface')[0];
|
||||
|
||||
@ -1,13 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var definitions = require('jsdoc/tag/dictionary/definitions');
|
||||
var dictionary = require('jsdoc/tag/dictionary');
|
||||
var Dictionary = dictionary.Dictionary;
|
||||
var doclet = require('jsdoc/doclet');
|
||||
var logger = require('jsdoc/util/logger');
|
||||
|
||||
var originalDictionary = dictionary;
|
||||
|
||||
describe('@package tag', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/packagetag.js');
|
||||
var foo = docSet.getByLongname('foo')[0];
|
||||
@ -19,14 +13,11 @@ describe('@package tag', function() {
|
||||
|
||||
describe('JSDoc tags', function() {
|
||||
afterEach(function() {
|
||||
doclet._replaceDictionary(originalDictionary);
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
it('When JSDoc tags are enabled, the @package tag does not accept a value.', function() {
|
||||
var dict = new Dictionary();
|
||||
|
||||
definitions.defineTags(dict, definitions.jsdocTags);
|
||||
doclet._replaceDictionary(dict);
|
||||
jasmine.replaceTagDictionary('jsdoc');
|
||||
spyOn(logger, 'warn');
|
||||
|
||||
jasmine.getDocSetFromFile('test/fixtures/packagetag2.js');
|
||||
@ -37,17 +28,15 @@ describe('@package tag', function() {
|
||||
|
||||
describe('Closure Compiler tags', function() {
|
||||
afterEach(function() {
|
||||
doclet._replaceDictionary(originalDictionary);
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
it('When Closure Compiler tags are enabled, the @package tag accepts a type expression.',
|
||||
function() {
|
||||
var connectionPorts;
|
||||
var dict = new Dictionary();
|
||||
var privateDocs;
|
||||
|
||||
definitions.defineTags(dict, definitions.closureTags);
|
||||
doclet._replaceDictionary(dict);
|
||||
jasmine.replaceTagDictionary('closure');
|
||||
spyOn(logger, 'warn');
|
||||
|
||||
privateDocs = jasmine.getDocSetFromFile('test/fixtures/packagetag2.js');
|
||||
|
||||
@ -1,13 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var definitions = require('jsdoc/tag/dictionary/definitions');
|
||||
var dictionary = require('jsdoc/tag/dictionary');
|
||||
var Dictionary = dictionary.Dictionary;
|
||||
var doclet = require('jsdoc/doclet');
|
||||
var logger = require('jsdoc/util/logger');
|
||||
|
||||
var originalDictionary = dictionary;
|
||||
|
||||
describe('@private tag', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/privatetag.js');
|
||||
var foo = docSet.getByLongname('Foo')[0];
|
||||
@ -25,14 +19,11 @@ describe('@private tag', function() {
|
||||
|
||||
describe('JSDoc tags', function() {
|
||||
afterEach(function() {
|
||||
doclet._replaceDictionary(originalDictionary);
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
it('When JSDoc tags are enabled, the @private tag does not accept a value.', function() {
|
||||
var dict = new Dictionary();
|
||||
|
||||
definitions.defineTags(dict, definitions.jsdocTags);
|
||||
doclet._replaceDictionary(dict);
|
||||
jasmine.replaceTagDictionary('jsdoc');
|
||||
spyOn(logger, 'warn');
|
||||
|
||||
jasmine.getDocSetFromFile('test/fixtures/privatetag2.js');
|
||||
@ -43,17 +34,15 @@ describe('@private tag', function() {
|
||||
|
||||
describe('Closure Compiler tags', function() {
|
||||
afterEach(function() {
|
||||
doclet._replaceDictionary(originalDictionary);
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
it('When Closure Compiler tags are enabled, the @private tag accepts a type expression.',
|
||||
function() {
|
||||
var connectionPorts;
|
||||
var dict = new Dictionary();
|
||||
var privateDocs;
|
||||
|
||||
definitions.defineTags(dict, definitions.closureTags);
|
||||
doclet._replaceDictionary(dict);
|
||||
jasmine.replaceTagDictionary('closure');
|
||||
spyOn(logger, 'warn');
|
||||
|
||||
privateDocs = jasmine.getDocSetFromFile('test/fixtures/privatetag2.js');
|
||||
|
||||
@ -1,13 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var definitions = require('jsdoc/tag/dictionary/definitions');
|
||||
var dictionary = require('jsdoc/tag/dictionary');
|
||||
var Dictionary = dictionary.Dictionary;
|
||||
var doclet = require('jsdoc/doclet');
|
||||
var logger = require('jsdoc/util/logger');
|
||||
|
||||
var originalDictionary = dictionary;
|
||||
|
||||
describe('@protected tag', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/protectedtag.js');
|
||||
var uidCounter = docSet.getByLongname('module:uid~uidCounter')[0];
|
||||
@ -25,14 +19,11 @@ describe('@protected tag', function() {
|
||||
|
||||
describe('JSDoc tags', function() {
|
||||
afterEach(function() {
|
||||
doclet._replaceDictionary(originalDictionary);
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
it('When JSDoc tags are enabled, the @protected tag does not accept a value.', function() {
|
||||
var dict = new Dictionary();
|
||||
|
||||
definitions.defineTags(dict, definitions.jsdocTags);
|
||||
doclet._replaceDictionary(dict);
|
||||
jasmine.replaceTagDictionary('jsdoc');
|
||||
spyOn(logger, 'warn');
|
||||
|
||||
jasmine.getDocSetFromFile('test/fixtures/protectedtag2.js');
|
||||
@ -43,17 +34,15 @@ describe('@protected tag', function() {
|
||||
|
||||
describe('Closure Compiler tags', function() {
|
||||
afterEach(function() {
|
||||
doclet._replaceDictionary(originalDictionary);
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
it('When Closure Compiler tags are enabled, the @private tag accepts a type expression.',
|
||||
function() {
|
||||
var dict = new Dictionary();
|
||||
var protectedDocs;
|
||||
var counter;
|
||||
var protectedDocs;
|
||||
|
||||
definitions.defineTags(dict, definitions.closureTags);
|
||||
doclet._replaceDictionary(dict);
|
||||
jasmine.replaceTagDictionary('closure');
|
||||
spyOn(logger, 'warn');
|
||||
|
||||
protectedDocs = jasmine.getDocSetFromFile('test/fixtures/protectedtag2.js');
|
||||
|
||||
@ -1,13 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var definitions = require('jsdoc/tag/dictionary/definitions');
|
||||
var dictionary = require('jsdoc/tag/dictionary');
|
||||
var Dictionary = dictionary.Dictionary;
|
||||
var doclet = require('jsdoc/doclet');
|
||||
var logger = require('jsdoc/util/logger');
|
||||
|
||||
var originalDictionary = dictionary;
|
||||
|
||||
describe('@type tag', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/typetag.js');
|
||||
|
||||
@ -33,14 +27,11 @@ describe('@type tag', function() {
|
||||
|
||||
describe('JSDoc tags', function() {
|
||||
afterEach(function() {
|
||||
doclet._replaceDictionary(originalDictionary);
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
it('When JSDoc tags are enabled, the @type tag does not accept a description.', function() {
|
||||
var dict = new Dictionary();
|
||||
|
||||
definitions.defineTags(dict, definitions.jsdocTags);
|
||||
doclet._replaceDictionary(dict);
|
||||
jasmine.replaceTagDictionary('jsdoc');
|
||||
spyOn(logger, 'warn');
|
||||
|
||||
jasmine.getDocSetFromFile('test/fixtures/typetag2.js');
|
||||
@ -51,16 +42,14 @@ describe('@type tag', function() {
|
||||
|
||||
describe('Closure tags', function() {
|
||||
afterEach(function() {
|
||||
doclet._replaceDictionary(originalDictionary);
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
it('When Closure tags are enabled, the @type tag accepts a description.', function() {
|
||||
var dict = new Dictionary();
|
||||
var stringOrNumber;
|
||||
var typeDocs;
|
||||
|
||||
definitions.defineTags(dict, definitions.closureTags);
|
||||
doclet._replaceDictionary(dict);
|
||||
jasmine.replaceTagDictionary('closure');
|
||||
spyOn(logger, 'warn');
|
||||
|
||||
typeDocs = jasmine.getDocSetFromFile('test/fixtures/typetag2.js');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user