mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Added tests for scope.
This commit is contained in:
parent
e4a13db06d
commit
a84b8bcb19
@ -23,6 +23,8 @@ load(BASEDIR + '/test/tests/21_tag_const.js');
|
||||
load(BASEDIR + '/test/tests/22_tag_preserve.js');
|
||||
load(BASEDIR + '/test/tests/23_tag_fires.js');
|
||||
load(BASEDIR + '/test/tests/24_tag_exception.js');
|
||||
load(BASEDIR + '/test/tests/25_tag_scope.js');
|
||||
|
||||
|
||||
// see http://visionmedia.github.com/jspec/
|
||||
JSpec.run({
|
||||
|
||||
26
test/samples/tag_scope.js
Normal file
26
test/samples/tag_scope.js
Normal file
@ -0,0 +1,26 @@
|
||||
/** A global function
|
||||
@function
|
||||
*/
|
||||
function outie() {
|
||||
/** An inner function
|
||||
@function
|
||||
*/
|
||||
function innie(){}
|
||||
}
|
||||
|
||||
/** A static function
|
||||
@function
|
||||
*/
|
||||
outie.stat = function() {
|
||||
}
|
||||
|
||||
/** A global var function
|
||||
@function
|
||||
*/
|
||||
var varoutie = function() {
|
||||
/** An inner var function
|
||||
@function
|
||||
*/
|
||||
var varinnie = function() {
|
||||
}
|
||||
}
|
||||
98
test/tests/25_tag_scope.js
Normal file
98
test/tests/25_tag_scope.js
Normal file
@ -0,0 +1,98 @@
|
||||
(function() {
|
||||
var jsdoc,
|
||||
doclets;
|
||||
|
||||
JSpec.describe('@scope', function() {
|
||||
|
||||
before(function() {
|
||||
// docsets can only be created by parsers
|
||||
jsdoc = {
|
||||
tag: require('jsdoc/tag'),
|
||||
parser: require('jsdoc/parser')
|
||||
};
|
||||
jsdoc.parser.parseFiles(BASEDIR + 'test/samples/tag_scope.js');
|
||||
|
||||
doclets = jsdoc.parser.result.map(function($){ return $.toObject(); });
|
||||
});
|
||||
|
||||
describe('A doclet with global scope', function() {
|
||||
it('should have a `scope` property of type string equalling "global"', function() {
|
||||
var doclet = doclets[0];
|
||||
expect(doclet).to(have_property, 'scope');
|
||||
expect(doclet.scope).to(be_an, String);
|
||||
expect(doclet.scope).to(be, 'global');
|
||||
});
|
||||
|
||||
it('should have a `path` property of type string equalling its namepath', function() {
|
||||
var doclet = doclets[0];
|
||||
expect(doclet).to(have_property, 'path');
|
||||
expect(doclet.path).to(be_an, String);
|
||||
expect(doclet.path).to(be, 'outie');
|
||||
});
|
||||
});
|
||||
|
||||
describe('A doclet with inner scope', function() {
|
||||
it('should have a `scope` property of type string equalling "inner"', function() {
|
||||
var doclet = doclets[1];
|
||||
expect(doclet).to(have_property, 'scope');
|
||||
expect(doclet.scope).to(be_an, String);
|
||||
expect(doclet.scope).to(be, 'inner');
|
||||
});
|
||||
|
||||
it('should have a `path` property of type string equalling its namepath', function() {
|
||||
var doclet = doclets[1];
|
||||
expect(doclet).to(have_property, 'path');
|
||||
expect(doclet.path).to(be_an, String);
|
||||
expect(doclet.path).to(be, 'outie~innie');
|
||||
});
|
||||
});
|
||||
|
||||
describe('A doclet with static scope', function() {
|
||||
it('should have a `scope` property of type string equalling "static"', function() {
|
||||
var doclet = doclets[2];
|
||||
expect(doclet).to(have_property, 'scope');
|
||||
expect(doclet.scope).to(be_an, String);
|
||||
expect(doclet.scope).to(be, 'static');
|
||||
});
|
||||
|
||||
it('should have a `path` property of type string equalling its namepath', function() {
|
||||
var doclet = doclets[2];
|
||||
expect(doclet).to(have_property, 'path');
|
||||
expect(doclet.path).to(be_an, String);
|
||||
expect(doclet.path).to(be, 'outie.stat');
|
||||
});
|
||||
});
|
||||
|
||||
describe('A var doclet with global scope', function() {
|
||||
it('should have a `scope` property of type string equalling "global"', function() {
|
||||
var doclet = doclets[3];
|
||||
expect(doclet).to(have_property, 'scope');
|
||||
expect(doclet.scope).to(be_an, String);
|
||||
expect(doclet.scope).to(be, 'global');
|
||||
});
|
||||
|
||||
it('should have a `path` property of type string equalling its namepath', function() {
|
||||
var doclet = doclets[3];
|
||||
expect(doclet).to(have_property, 'path');
|
||||
expect(doclet.path).to(be_an, String);
|
||||
expect(doclet.path).to(be, 'varoutie');
|
||||
});
|
||||
});
|
||||
|
||||
describe('A var doclet with inner scope', function() {
|
||||
it('should have a `scope` property of type string equalling "inner"', function() {
|
||||
var doclet = doclets[4];
|
||||
expect(doclet).to(have_property, 'scope');
|
||||
expect(doclet.scope).to(be_an, String);
|
||||
expect(doclet.scope).to(be, 'inner');
|
||||
});
|
||||
|
||||
it('should have a `path` property of type string equalling its namepath', function() {
|
||||
var doclet = doclets[4];
|
||||
expect(doclet).to(have_property, 'path');
|
||||
expect(doclet.path).to(be_an, String);
|
||||
expect(doclet.path).to(be, 'varoutie~varinnie');
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user