From c0d9b37cf5f676bbff246c730e43c714fbb2982b Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Sun, 28 Oct 2012 20:07:04 -0700 Subject: [PATCH] set type name correctly for Closure Compiler types (#226) --- .../jsdoc/tag/type/closureCompilerType.js | 6 ++--- .../jsdoc/tag/type/closureCompilerType.js | 26 +++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/rhino_modules/jsdoc/tag/type/closureCompilerType.js b/rhino_modules/jsdoc/tag/type/closureCompilerType.js index 5cc7086d..2b2f8aa6 100644 --- a/rhino_modules/jsdoc/tag/type/closureCompilerType.js +++ b/rhino_modules/jsdoc/tag/type/closureCompilerType.js @@ -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, diff --git a/test/specs/jsdoc/tag/type/closureCompilerType.js b/test/specs/jsdoc/tag/type/closureCompilerType.js index 0a3ba24f..61c556ca 100644 --- a/test/specs/jsdoc/tag/type/closureCompilerType.js +++ b/test/specs/jsdoc/tag/type/closureCompilerType.js @@ -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); + }); + }); });