Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomek Wiszniewski committed Mar 23, 2015
1 parent f072553 commit 4815da0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/dox.jsdoccomplex.test.js
Expand Up @@ -36,6 +36,8 @@ module.exports = {
]);
complexTypeParamAndReturn.tags[0].typesDescription.should
.equal('<code>number</code>|<code>string</code>|{ name: <code>string</code>, age: <code>number</code> }');
complexTypeParamAndReturn.tags[0].string.should
.equal('{number|string|{name:string,age:number}} a');

complexTypeParamAndReturn.tags[1].types.should.be.eql([
'number',
Expand All @@ -47,6 +49,8 @@ module.exports = {
]);
complexTypeParamAndReturn.tags[1].typesDescription.should
.equal('<code>number</code>|{ name: <code>string</code>, age: <code>number</code> }|<code>Array</code>');
complexTypeParamAndReturn.tags[1].string.should
.equal('{number|{name:string,age:number}|Array} a');

complexTypeParamAndReturn.tags[2].types.should.be.eql([
{
Expand All @@ -56,6 +60,8 @@ module.exports = {
]);
complexTypeParamAndReturn.tags[2].typesDescription.should
.equal('{ name: <code>string</code>, age: <code>number</code> }');
complexTypeParamAndReturn.tags[2].string.should
.equal('{{name:string,age:number}}');

/////////////////////////////////////
// nestedComplexTypeParam
Expand All @@ -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
Expand All @@ -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();
});
Expand Down
8 changes: 8 additions & 0 deletions test/dox.multilinetags.test.js
Expand Up @@ -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('<p>one<br />two<br />three</p>');
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('<p>one<br />two<br />three</p>');
firstParam.tags[0].string.should.equal('{String} foo\none\ntwo\nthree');
firstParam.tags[1].string.should.equal('last');
firstParam.tags[1].html.should.equal('<p>last</p>');
lastParam.tags.should.with.lengthOf(2);
Expand All @@ -68,24 +70,28 @@ module.exports = {
lastParam.tags[1].name.should.equal('foo');
lastParam.tags[1].types.should.eql(['String']);
lastParam.tags[1].description.should.equal('<p>one<br />two<br />three</p>');
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('<p>first</p>');
midParam.tags[1].type.should.equal('param');
midParam.tags[1].name.should.equal('foo');
midParam.tags[1].types.should.eql(['String']);
midParam.tags[1].description.should.equal('<p>one<br />two<br />three</p>');
midParam.tags[1].string.should.equal('{String} foo\none\ntwo\nthree');
midParam.tags[2].string.should.equal('last');
midParam.tags[2].html.should.equal('<p>last</p>');

onlyReturn.tags.should.with.lengthOf(1);
onlyReturn.tags[0].type.should.equal('return');
onlyReturn.tags[0].types.should.eql(['String']);
onlyReturn.tags[0].description.should.equal('<p>one<br />two<br />three</p>');
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('<p>one<br />two<br />three</p>');
firstReturn.tags[0].string.should.equal('{String}\none\ntwo\nthree');
firstReturn.tags[1].string.should.equal('last');
firstReturn.tags[1].html.should.equal('<p>last</p>');
lastReturn.tags.should.with.lengthOf(2);
Expand All @@ -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('<p>one<br />two<br />three</p>');
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('<p>first</p>');
midReturn.tags[1].type.should.equal('return');
midReturn.tags[1].types.should.eql(['String']);
midReturn.tags[1].description.should.equal('<p>one<br />two<br />three</p>');
midReturn.tags[1].string.should.equal('{String}\none\ntwo\nthree');
midReturn.tags[2].string.should.equal('last');
midReturn.tags[2].html.should.equal('<p>last</p>');

Expand Down
13 changes: 13 additions & 0 deletions test/dox.test.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
},

Expand All @@ -615,27 +618,31 @@ 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')
tag.type.should.equal('param');
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')
tag.type.should.equal('param');
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')
tag.type.should.equal('param');
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;
},

Expand All @@ -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(){
Expand All @@ -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(){
Expand Down Expand Up @@ -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('<p>Digit</p>');
all.tags[0].string.should.equal('{number} Digit');
all.description.full.should.equal('');
all.description.summary.should.equal('');
all.description.summary.should.equal('');
Expand Down Expand Up @@ -749,6 +761,7 @@ module.exports = {
, types: [ 'Object' ]
, typesDescription: '<code>Object</code>'
, description: '<p>description</p>'
, string: '{Object} description'
, nullable: false
, nonNullable: false
, variable: false
Expand Down

0 comments on commit 4815da0

Please sign in to comment.