mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
set type name correctly for Closure Compiler types (#226)
This commit is contained in:
parent
589eb300c8
commit
c0d9b37cf5
@ -49,12 +49,12 @@ function parseVariable(type) {
|
|||||||
*/
|
*/
|
||||||
exports.parse = function(tagInfo) {
|
exports.parse = function(tagInfo) {
|
||||||
var optional = parseOptional(tagInfo.type),
|
var optional = parseOptional(tagInfo.type),
|
||||||
nullable = parseNullable(tagInfo.type),
|
nullable = parseNullable(optional.type),
|
||||||
variable = parseVariable(tagInfo.type);
|
variable = parseVariable(nullable.type);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: tagInfo.name,
|
name: tagInfo.name,
|
||||||
type: variable.type || nullable.type || optional.type,
|
type: variable.type,
|
||||||
text: tagInfo.text,
|
text: tagInfo.text,
|
||||||
optional: tagInfo.optional || optional.optional, // don't override if already true
|
optional: tagInfo.optional || optional.optional, // don't override if already true
|
||||||
nullable: nullable.nullable,
|
nullable: nullable.nullable,
|
||||||
|
|||||||
@ -1,3 +1,25 @@
|
|||||||
describe("jsdoc/tag/type/closureCompilerType", function() {
|
/*global describe: true, expect: true, it: true */
|
||||||
//TODO
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user