mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Added unit tests for @enum.
This commit is contained in:
parent
a406e1cebc
commit
badf1fcacd
@ -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; }
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -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
12
test/cases/enumtag.js
Normal file
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Enum for tri-state values.
|
||||
* @enum {number}
|
||||
*/
|
||||
var TriState = {
|
||||
/** true */
|
||||
TRUE: 1,
|
||||
/** false */
|
||||
FALSE: -1,
|
||||
/** @type {boolean} */
|
||||
MAYBE: true
|
||||
};
|
||||
@ -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
18
test/t/cases/enumtag.js
Normal 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');
|
||||
});
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user