Added unit tests for @enum.

This commit is contained in:
Michael Mathews 2011-10-08 22:00:38 +01:00
parent a406e1cebc
commit badf1fcacd
5 changed files with 32 additions and 30 deletions

View File

@ -166,7 +166,7 @@ exports.defineTags = function(dictionary) {
onTagged: function(doclet, tag) {
doclet.kind = 'member';
doclet.isEnum = true;
doclet.type = tag.value.type;
if (tag.value && tag.value.type) { doclet.type = tag.value.type; }
}
});

View File

@ -1,29 +0,0 @@
/** @constructor */
function Data() {
/**
The current position.
@enum {number}
*/
this.point = {
/** The x coordinate of the point. */
x: 0,
/** The y coordinate of the point. */
y: 0
};
}
/**
* Enum for tri-state values.
* @enum {number}
*/
TriState = {
/** true */
TRUE: 1,
/** false */
FALSE: -1,
/** @type {boolean} */
MAYBE: true
};

12
test/cases/enumtag.js Normal file
View File

@ -0,0 +1,12 @@
/**
* Enum for tri-state values.
* @enum {number}
*/
var TriState = {
/** true */
TRUE: 1,
/** false */
FALSE: -1,
/** @type {boolean} */
MAYBE: true
};

View File

@ -123,6 +123,7 @@ testFile('test/t/cases/constructortag.js');
testFile('test/t/cases/copyrighttag.js');
testFile('test/t/cases/defaulttag.js');
testFile('test/t/cases/deprecatedtag.js');
testFile('test/t/cases/enumtag.js');
testFile('test/t/cases/eventfirestag.js');
testFile('test/t/cases/exports.js');
testFile('test/t/cases/exportstag.js');

18
test/t/cases/enumtag.js Normal file
View File

@ -0,0 +1,18 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/enumtag.js'),
tristate = docSet.getByLongname('TriState')[0];
//console.log(docSet);
test('When a symbol has a @enum tag, it has a properties array.', function() {
assert.equal(typeof tristate.properties, 'object');
});
test('If no @type is given for the property it is inherted from the enum.', function() {
assert.equal(tristate.properties[0].type.names.join(', '), 'number');
});
test('If a @type is given for the property it is reflected in the property value.', function() {
assert.equal(tristate.properties[2].type.names.join(', '), 'boolean');
});
})();