From f78a10c4b442352d0e116d25c21bd77b90d3844c Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Sat, 29 Jan 2011 17:08:01 +0000 Subject: [PATCH] Added additional tests for @exports. --- test/cases/exports.js | 15 +++++++++++++++ test/cases/exportstag3.js | 22 ++++++++++++++++++++++ test/runner.js | 1 + test/t/cases/exports.js | 13 +++++++++++++ test/t/cases/exportstag3.js | 19 +++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 test/cases/exports.js create mode 100644 test/cases/exportstag3.js create mode 100644 test/t/cases/exports.js create mode 100644 test/t/cases/exportstag3.js diff --git a/test/cases/exports.js b/test/cases/exports.js new file mode 100644 index 00000000..9c132478 --- /dev/null +++ b/test/cases/exports.js @@ -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'); +}; diff --git a/test/cases/exportstag3.js b/test/cases/exportstag3.js new file mode 100644 index 00000000..d48e94e2 --- /dev/null +++ b/test/cases/exportstag3.js @@ -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; + } +); \ No newline at end of file diff --git a/test/runner.js b/test/runner.js index aba33b2e..e7571a27 100644 --- a/test/runner.js +++ b/test/runner.js @@ -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'); diff --git a/test/t/cases/exports.js b/test/t/cases/exports.js new file mode 100644 index 00000000..fc80c8fc --- /dev/null +++ b/test/t/cases/exports.js @@ -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'); + }); +})(); \ No newline at end of file diff --git a/test/t/cases/exportstag3.js b/test/t/cases/exportstag3.js new file mode 100644 index 00000000..a75c9b37 --- /dev/null +++ b/test/t/cases/exportstag3.js @@ -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'); + }); + +})(); \ No newline at end of file