/
dox.multilinetags.test.js
121 lines (113 loc) · 5.69 KB
/
dox.multilinetags.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/**
* Module dependencies.
*/
var dox = require('../')
, should = require('should')
, fs = require('fs');
function fixture(name, fn) {
fs.readFile(__dirname + '/fixtures/' + name, 'utf8', fn);
}
module.exports = {
'test .parseComments() multiline tags': function(done){
fixture('multilinetags.js', function(err, str){
var comments = dox.parseComments(str)
, only = comments.shift()
, first = comments.shift()
, last = comments.shift()
, mid = comments.shift()
, onlyParam = comments.shift()
, firstParam = comments.shift()
, lastParam = comments.shift()
, midParam = comments.shift()
, onlyReturn = comments.shift()
, firstReturn = comments.shift()
, lastReturn = comments.shift()
, midReturn = comments.shift()
, example = comments.shift();
only.tags.should.with.lengthOf(1);
only.tags[0].string.should.equal('one\ntwo\nthree');
only.tags[0].html.should.equal('<p>one<br />two<br />three</p>');
first.tags.should.with.lengthOf(2);
first.tags[0].string.should.equal('one\ntwo\nthree');
first.tags[0].html.should.equal('<p>one<br />two<br />three</p>');
first.tags[1].string.should.equal('last');
first.tags[1].html.should.equal('<p>last</p>');
last.tags.should.with.lengthOf(2);
last.tags[0].string.should.equal('first');
last.tags[0].html.should.equal('<p>first</p>');
last.tags[1].string.should.equal('one\ntwo\nthree');
last.tags[1].html.should.equal('<p>one<br />two<br />three</p>');
mid.tags.should.with.lengthOf(3);
mid.tags[0].string.should.equal('first');
mid.tags[0].html.should.equal('<p>first</p>');
mid.tags[1].string.should.equal('one\ntwo\nthree');
mid.tags[1].html.should.equal('<p>one<br />two<br />three</p>');
mid.tags[2].string.should.equal('last');
mid.tags[2].html.should.equal('<p>last</p>');
onlyParam.tags.should.with.lengthOf(1);
onlyParam.tags[0].type.should.equal('param');
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);
lastParam.tags[0].string.should.equal('first');
lastParam.tags[0].html.should.equal('<p>first</p>');
lastParam.tags[1].type.should.equal('param');
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);
lastReturn.tags[0].string.should.equal('first');
lastReturn.tags[0].html.should.equal('<p>first</p>');
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>');
example.tags.should.with.lengthOf(1);
example.tags[0].string.should.equal(' test(one);\n test(two);');
example.tags[0].html.should.equal('<pre><code>test(one);\ntest(two);\n</code></pre>');
done();
});
}
};