set type name correctly for Closure Compiler types (#226)

This commit is contained in:
Jeff Williams 2012-10-28 20:07:04 -07:00
parent 589eb300c8
commit c0d9b37cf5
2 changed files with 27 additions and 5 deletions

View File

@ -49,12 +49,12 @@ function parseVariable(type) {
*/
exports.parse = function(tagInfo) {
var optional = parseOptional(tagInfo.type),
nullable = parseNullable(tagInfo.type),
variable = parseVariable(tagInfo.type);
nullable = parseNullable(optional.type),
variable = parseVariable(nullable.type);
return {
name: tagInfo.name,
type: variable.type || nullable.type || optional.type,
type: variable.type,
text: tagInfo.text,
optional: tagInfo.optional || optional.optional, // don't override if already true
nullable: nullable.nullable,

View File

@ -1,3 +1,25 @@
describe("jsdoc/tag/type/closureCompilerType", function() {
//TODO
/*global describe: true, expect: true, it: true */
describe('jsdoc/tag/type/closureCompilerType', function() {
// TODO: more tests
var type = require('jsdoc/tag/type/closureCompilerType');
it('should exist', function() {
expect(type).toBeDefined();
expect(typeof type).toEqual('object');
});
it('should export a parse function', function() {
expect(type.parse).toBeDefined();
expect(typeof type.parse).toEqual('function');
});
describe('parse', function() {
it('should correctly parse types that are both optional and nullable', function() {
var info = type.parse( {type: '?string='} );
expect(info.type).toEqual('string');
expect(info.optional).toEqual(true);
expect(info.nullable).toEqual(true);
});
});
});