Added additional tests for @exports.

This commit is contained in:
Michael Mathews 2011-01-29 17:08:01 +00:00
parent f7a62a913a
commit f78a10c4b4
5 changed files with 70 additions and 0 deletions

15
test/cases/exports.js Normal file
View File

@ -0,0 +1,15 @@
/**
* An example of a server-side JavaScript module.
* @module hello/world
* @example
* var g = require('hello/world').sayHello('Gracie');
*/
/**
* Generate a greeting.
* @param {string} [subject="world"] To whom we greet.
* @returns {string}
*/
exports.sayHello = function(subject) {
return 'Hello ' + (subject || 'World');
};

22
test/cases/exportstag3.js Normal file
View File

@ -0,0 +1,22 @@
define(
/**
Utility functions to ease working with DOM elements.
@exports html/utils
*/
function () {
var exports = {
/** Get the value of a property on an element. */
getStyleProperty: function(element, propertyName) {
// ...
}
};
/** Determine if an element is in the document head. */
exports.isInHead = function(element) {
// ...
}
return exports;
}
);

View File

@ -102,6 +102,7 @@ testFile('test/t/cases/deprecatedtag.js');
testFile('test/t/cases/exports.js');
testFile('test/t/cases/exportstag.js');
testFile('test/t/cases/exportstag2.js');
testFile('test/t/cases/exportstag3.js');
testFile('test/t/cases/exceptiontag.js');
testFile('test/t/cases/globaltag.js');
testFile('test/t/cases/ignoretag.js');

13
test/t/cases/exports.js Normal file
View File

@ -0,0 +1,13 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/exports.js'),
helloworld = docSet.getByLongname('module:hello/world')[0],
sayhello = docSet.getByLongname('module:hello/world.sayHello')[0];
//dump(docSet.doclets); exit(0);
test('When a symbol starts with the special name "exports" and is in a file with a @module tag, the symbol is documented as a member of that module.', function() {
assert.equal(typeof sayhello, 'object');
assert.equal(sayhello.kind, 'function');
assert.equal(sayhello.memberof, 'module:hello/world');
});
})();

View File

@ -0,0 +1,19 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/exportstag3.js'),
html = docSet.getByLongname('module:html/utils')[0],
getstyle = docSet.getByLongname('module:html/utils.getStyleProperty')[0],
inhead = docSet.getByLongname('module:html/utils.isInHead')[0];
//dump(docSet.doclets); exit(0);
test('When a function symbol has an @exports tag and there is an objlit named "exports" the members are documented as members of the module.', function() {
assert.equal(typeof getstyle, 'object');
assert.equal(getstyle.memberof, 'module:html/utils');
});
test('When a function symbol has an @exports tag and there are members assinged to an "exports" name, the members are documented as members of the module.', function() {
assert.equal(typeof inhead, 'object');
assert.equal(inhead.memberof, 'module:html/utils');
});
})();