From 4815da019e8db46865c449b753560eecf7bb0967 Mon Sep 17 00:00:00 2001 From: Tomek Wiszniewski Date: Mon, 23 Mar 2015 11:07:40 +0100 Subject: [PATCH] Update tests --- test/dox.jsdoccomplex.test.js | 13 +++++++++++++ test/dox.multilinetags.test.js | 8 ++++++++ test/dox.test.js | 13 +++++++++++++ 3 files changed, 34 insertions(+) diff --git a/test/dox.jsdoccomplex.test.js b/test/dox.jsdoccomplex.test.js index e2afdaf8..3dcaeb94 100644 --- a/test/dox.jsdoccomplex.test.js +++ b/test/dox.jsdoccomplex.test.js @@ -36,6 +36,8 @@ module.exports = { ]); complexTypeParamAndReturn.tags[0].typesDescription.should .equal('number|string|{ name: string, age: number }'); + complexTypeParamAndReturn.tags[0].string.should + .equal('{number|string|{name:string,age:number}} a'); complexTypeParamAndReturn.tags[1].types.should.be.eql([ 'number', @@ -47,6 +49,8 @@ module.exports = { ]); complexTypeParamAndReturn.tags[1].typesDescription.should .equal('number|{ name: string, age: number }|Array'); + complexTypeParamAndReturn.tags[1].string.should + .equal('{number|{name:string,age:number}|Array} a'); complexTypeParamAndReturn.tags[2].types.should.be.eql([ { @@ -56,6 +60,8 @@ module.exports = { ]); complexTypeParamAndReturn.tags[2].typesDescription.should .equal('{ name: string, age: number }'); + complexTypeParamAndReturn.tags[2].string.should + .equal('{{name:string,age:number}}'); ///////////////////////////////////// // nestedComplexTypeParam @@ -75,30 +81,36 @@ module.exports = { }] } ]); + nestedComplexTypeParam.tags[0].string.should + .equal('{number | string | {length: number, type: {name: {first: string, last: string}, id: number | string}}} a Description of param'); ///////////////////////////////////// // optionalParam ///////////////////////////////////// optionalParam.tags.should.with.lengthOf(1); optionalParam.tags[0].optional.should.be.true; + optionalParam.tags[0].string.should.equal('{number=} a'); ///////////////////////////////////// // nullableParam ///////////////////////////////////// nullableParam.tags.should.with.lengthOf(1); nullableParam.tags[0].nullable.should.be.true; + nullableParam.tags[0].string.should.equal('{?number} a'); ///////////////////////////////////// // nonNullableParam ///////////////////////////////////// nonNullableParam.tags.should.with.lengthOf(1); nonNullableParam.tags[0].nonNullable.should.be.true; + nonNullableParam.tags[0].string.should.equal('{!number} a'); ///////////////////////////////////// // variableParam ///////////////////////////////////// variableParam.tags.should.with.lengthOf(1); variableParam.tags[0].variable.should.be.true; + variableParam.tags[0].string.should.equal('{...number} a'); ///////////////////////////////////// // optionalVariableNullableParam @@ -107,6 +119,7 @@ module.exports = { optionalVariableNullableParam.tags[0].optional.should.be.true; optionalVariableNullableParam.tags[0].variable.should.be.true; optionalVariableNullableParam.tags[0].nullable.should.be.true; + optionalVariableNullableParam.tags[0].string.should.equal('{?...number=} a'); done(); }); diff --git a/test/dox.multilinetags.test.js b/test/dox.multilinetags.test.js index 1ed9f10b..abfd21d4 100644 --- a/test/dox.multilinetags.test.js +++ b/test/dox.multilinetags.test.js @@ -54,11 +54,13 @@ module.exports = { onlyParam.tags[0].name.should.equal('foo'); onlyParam.tags[0].types.should.eql(['String']); onlyParam.tags[0].description.should.equal('

one
two
three

'); + onlyParam.tags[0].string.should.equal('{String} foo\none\ntwo\nthree'); firstParam.tags.should.with.lengthOf(2); firstParam.tags[0].type.should.equal('param'); firstParam.tags[0].name.should.equal('foo'); firstParam.tags[0].types.should.eql(['String']); firstParam.tags[0].description.should.equal('

one
two
three

'); + firstParam.tags[0].string.should.equal('{String} foo\none\ntwo\nthree'); firstParam.tags[1].string.should.equal('last'); firstParam.tags[1].html.should.equal('

last

'); lastParam.tags.should.with.lengthOf(2); @@ -68,6 +70,7 @@ module.exports = { lastParam.tags[1].name.should.equal('foo'); lastParam.tags[1].types.should.eql(['String']); lastParam.tags[1].description.should.equal('

one
two
three

'); + lastParam.tags[1].string.should.equal('{String} foo\none\ntwo\nthree'); midParam.tags.should.with.lengthOf(3); midParam.tags[0].string.should.equal('first'); midParam.tags[0].html.should.equal('

first

'); @@ -75,6 +78,7 @@ module.exports = { midParam.tags[1].name.should.equal('foo'); midParam.tags[1].types.should.eql(['String']); midParam.tags[1].description.should.equal('

one
two
three

'); + midParam.tags[1].string.should.equal('{String} foo\none\ntwo\nthree'); midParam.tags[2].string.should.equal('last'); midParam.tags[2].html.should.equal('

last

'); @@ -82,10 +86,12 @@ module.exports = { onlyReturn.tags[0].type.should.equal('return'); onlyReturn.tags[0].types.should.eql(['String']); onlyReturn.tags[0].description.should.equal('

one
two
three

'); + onlyReturn.tags[0].string.should.equal('{String}\none\ntwo\nthree'); firstReturn.tags.should.with.lengthOf(2); firstReturn.tags[0].type.should.equal('return'); firstReturn.tags[0].types.should.eql(['String']); firstReturn.tags[0].description.should.equal('

one
two
three

'); + firstReturn.tags[0].string.should.equal('{String}\none\ntwo\nthree'); firstReturn.tags[1].string.should.equal('last'); firstReturn.tags[1].html.should.equal('

last

'); lastReturn.tags.should.with.lengthOf(2); @@ -94,12 +100,14 @@ module.exports = { lastReturn.tags[1].type.should.equal('return'); lastReturn.tags[1].types.should.eql(['String']); lastReturn.tags[1].description.should.equal('

one
two
three

'); + lastReturn.tags[1].string.should.equal('{String}\none\ntwo\nthree'); midReturn.tags.should.with.lengthOf(3); midReturn.tags[0].string.should.equal('first'); midReturn.tags[0].html.should.equal('

first

'); midReturn.tags[1].type.should.equal('return'); midReturn.tags[1].types.should.eql(['String']); midReturn.tags[1].description.should.equal('

one
two
three

'); + midReturn.tags[1].string.should.equal('{String}\none\ntwo\nthree'); midReturn.tags[2].string.should.equal('last'); midReturn.tags[2].html.should.equal('

last

'); diff --git a/test/dox.test.js b/test/dox.test.js index fe19d4ce..f7fbe34b 100644 --- a/test/dox.test.js +++ b/test/dox.test.js @@ -46,8 +46,10 @@ module.exports = { version.tags.should.have.length(2); version.tags[0].type.should.equal('type'); version.tags[0].types.should.eql(['String']); + version.tags[0].string.should.equal('{String}'); version.tags[1].type.should.equal('api'); version.tags[1].visibility.should.equal('public'); + version.tags[1].string.should.equal('public'); version.ctx.type.should.equal('property'); version.ctx.receiver.should.equal('exports'); version.ctx.name.should.equal('version'); @@ -606,6 +608,7 @@ module.exports = { tag.types.should.eql(['String', 'Buffer']); tag.name.should.equal(''); tag.description.should.equal(''); + tag.string.should.equal('{String|Buffer}'); tag.optional.should.be.false; }, @@ -615,6 +618,7 @@ module.exports = { tag.types.should.eql(['string']); tag.name.should.equal('[foo]'); tag.description.should.equal(''); + tag.string.should.equal('{string} [foo]'); tag.optional.should.be.true; var tag = dox.parseTag('@param {string=} foo') @@ -622,6 +626,7 @@ module.exports = { tag.types.should.eql(['string']); tag.name.should.equal('foo'); tag.description.should.equal(''); + tag.string.should.equal('{string=} foo'); tag.optional.should.be.true; var tag = dox.parseTag('@param {string?} foo') @@ -629,6 +634,7 @@ module.exports = { tag.types.should.eql(['string']); tag.name.should.equal('foo'); tag.description.should.equal(''); + tag.string.should.equal('{string?} foo'); tag.nullable.should.be.true; var tag = dox.parseTag('@param {string|Buffer=} foo') @@ -636,6 +642,7 @@ module.exports = { tag.types.should.eql(['string', 'Buffer']); tag.name.should.equal('foo'); tag.description.should.equal(''); + tag.string.should.equal('{string|Buffer=} foo'); tag.optional.should.be.true; }, @@ -644,12 +651,14 @@ module.exports = { tag.type.should.equal('return'); tag.types.should.eql(['String']); tag.description.should.equal('a normal string'); + tag.string.should.equal('{String} a normal string'); }, 'test .parseTag() @augments': function(){ var tag = dox.parseTag('@augments otherClass'); tag.type.should.equal('augments'); tag.otherClass.should.equal('otherClass') + tag.string.should.equal('otherClass'); }, 'test .parseTag() @author': function(){ @@ -663,12 +672,14 @@ module.exports = { tag.type.should.equal('borrows'); tag.otherMemberName.should.equal('foo'); tag.thisMemberName.should.equal('bar'); + tag.string.should.equal('foo as bar'); }, 'test .parseTag() @memberOf': function(){ var tag = dox.parseTag('@memberOf Foo.bar') tag.type.should.equal('memberOf') tag.parent.should.equal('Foo.bar') + tag.string.should.equal('Foo.bar') }, 'test .parseTag() @example': function(){ @@ -708,6 +719,7 @@ module.exports = { all.tags.should.have.length(1); all.tags[0].type.should.equal('return'); all.tags[0].description.should.equal('

Digit

'); + all.tags[0].string.should.equal('{number} Digit'); all.description.full.should.equal(''); all.description.summary.should.equal(''); all.description.summary.should.equal(''); @@ -749,6 +761,7 @@ module.exports = { , types: [ 'Object' ] , typesDescription: 'Object' , description: '

description

' + , string: '{Object} description' , nullable: false , nonNullable: false , variable: false