Skip to content

Commit 3681b9b

Browse files
TrottMyles Borins
authored and
Myles Borins
committed
test: refactor doctool tests
Adjust style in doctool tests to conform with predominant style of the rest of the project. The biggest changes are: * Replace string concatenation with `path.join()` * Remove unnecessary quotes from property names PR-URL: #6719 Reviewed-By: James M Snell <[email protected]>
1 parent 607173b commit 3681b9b

File tree

2 files changed

+91
-86
lines changed

2 files changed

+91
-86
lines changed

test/doctool/test-doctool-html.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const common = require('../common');
44
const assert = require('assert');
55
const fs = require('fs');
6+
const path = require('path');
67

78
const html = require('../../tools/doc/html.js');
89

@@ -13,13 +14,13 @@ const html = require('../../tools/doc/html.js');
1314
// have an html parser.
1415
const testData = [
1516
{
16-
'file': common.fixturesDir + '/sample_document.md',
17-
'html': '<ol><li>fish</li><li><p>fish</p></li><li><p>Redfish</p></li>' +
17+
file: path.join(common.fixturesDir, 'sample_document.md'),
18+
html: '<ol><li>fish</li><li><p>fish</p></li><li><p>Redfish</p></li>' +
1819
'<li>Bluefish</li></ol>'
1920
},
2021
{
21-
'file': common.fixturesDir + '/order_of_end_tags_5873.md',
22-
'html': '<h3>ClassMethod: Buffer.from(array) <span> ' +
22+
file: path.join(common.fixturesDir, 'order_of_end_tags_5873.md'),
23+
html: '<h3>ClassMethod: Buffer.from(array) <span> ' +
2324
'<a class="mark" href="#foo_class_method_buffer_from_array" ' +
2425
'id="foo_class_method_buffer_from_array">#</a> </span> </h3><div' +
2526
'class="signature"><ul><li><code>array</code><a ' +
@@ -28,8 +29,8 @@ const testData = [
2829
'</ul></div>'
2930
},
3031
{
31-
'file': common.fixturesDir + '/doc_with_yaml.md',
32-
'html': '<h1>Sample Markdown with YAML info' +
32+
file: path.join(common.fixturesDir, 'doc_with_yaml.md'),
33+
html: '<h1>Sample Markdown with YAML info' +
3334
'<span><a class="mark" href="#foo_sample_markdown_with_yaml_info" ' +
3435
' id="foo_sample_markdown_with_yaml_info">#</a></span></h1>' +
3536
'<h2>Foobar<span><a class="mark" href="#foo_foobar" ' +

test/doctool/test-doctool-json.js

+84-80
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const common = require('../common');
44
const assert = require('assert');
55
const fs = require('fs');
6+
const path = require('path');
67

78
const json = require('../../tools/doc/json.js');
89

@@ -12,113 +13,116 @@ const json = require('../../tools/doc/json.js');
1213
// The json property is some json which will be generated by the doctool.
1314
var testData = [
1415
{
15-
'file': common.fixturesDir + '/sample_document.md',
16-
'json': {
17-
'source': 'foo',
18-
'modules': [ { 'textRaw': 'Sample Markdown',
19-
'name': 'sample_markdown',
20-
'modules': [ { 'textRaw': 'Seussian Rhymes',
21-
'name': 'seussian_rhymes',
22-
'desc': '<ol>\n<li>fish</li>\n<li><p>fish</p>\n</li>\n<li>' +
16+
file: path.join(common.fixturesDir, 'sample_document.md'),
17+
json: {
18+
source: 'foo',
19+
modules: [{
20+
textRaw: 'Sample Markdown',
21+
name: 'sample_markdown',
22+
modules: [{
23+
textRaw: 'Seussian Rhymes',
24+
name: 'seussian_rhymes',
25+
desc: '<ol>\n<li>fish</li>\n<li><p>fish</p>\n</li>\n<li>' +
2326
'<p>Red fish</p>\n</li>\n<li>Blue fish</li>\n</ol>\n',
24-
'type': 'module',
25-
'displayName': 'Seussian Rhymes'
26-
} ],
27-
'type': 'module',
28-
'displayName': 'Sample Markdown'
29-
} ]
27+
type: 'module',
28+
displayName: 'Seussian Rhymes'
29+
}],
30+
type: 'module',
31+
displayName: 'Sample Markdown'
32+
}]
3033
}
3134
},
3235
{
33-
'file': common.fixturesDir + '/order_of_end_tags_5873.md',
34-
'json': {
35-
'source': 'foo',
36-
'modules': [ {
37-
'textRaw': 'Title',
38-
'name': 'title',
39-
'modules': [ {
40-
'textRaw': 'Subsection',
41-
'name': 'subsection',
42-
'classMethods': [ {
43-
'textRaw': 'Class Method: Buffer.from(array)',
44-
'type': 'classMethod',
45-
'name': 'from',
46-
'signatures': [ {
47-
'params': [ {
48-
'textRaw': '`array` {Array} ',
49-
'name': 'array',
50-
'type': 'Array'
51-
} ]
52-
},
36+
file: path.join(common.fixturesDir, 'order_of_end_tags_5873.md'),
37+
json: {
38+
source: 'foo',
39+
modules: [{
40+
textRaw: 'Title',
41+
name: 'title',
42+
modules: [{
43+
textRaw: 'Subsection',
44+
name: 'subsection',
45+
classMethods: [{
46+
textRaw: 'Class Method: Buffer.from(array)',
47+
type: 'classMethod',
48+
name: 'from',
49+
signatures: [
50+
{
51+
params: [{
52+
textRaw: '`array` {Array} ',
53+
name: 'array',
54+
type: 'Array'
55+
}]
56+
},
5357
{
54-
'params': [ {
55-
'name': 'array'
56-
} ]
58+
params: [{
59+
name: 'array'
60+
}]
5761
}
5862
]
59-
} ],
60-
'type': 'module',
61-
'displayName': 'Subsection'
62-
} ],
63-
'type': 'module',
64-
'displayName': 'Title'
65-
} ]
63+
}],
64+
type: 'module',
65+
displayName: 'Subsection'
66+
}],
67+
type: 'module',
68+
displayName: 'Title'
69+
}]
6670
}
6771
},
6872
{
69-
'file': common.fixturesDir + '/doc_with_yaml.md',
70-
'json': {
71-
'source': 'foo',
72-
'modules': [
73+
file: path.join(common.fixturesDir, 'doc_with_yaml.md'),
74+
json: {
75+
source: 'foo',
76+
modules: [
7377
{
74-
'textRaw': 'Sample Markdown with YAML info',
75-
'name': 'sample_markdown_with_yaml_info',
76-
'modules': [
78+
textRaw: 'Sample Markdown with YAML info',
79+
name: 'sample_markdown_with_yaml_info',
80+
modules: [
7781
{
78-
'textRaw': 'Foobar',
79-
'name': 'foobar',
80-
'meta': {
81-
'added': ['v1.0.0']
82+
textRaw: 'Foobar',
83+
name: 'foobar',
84+
meta: {
85+
added: ['v1.0.0']
8286
},
83-
'desc': '<p>Describe <code>Foobar</code> in more detail ' +
87+
desc: '<p>Describe <code>Foobar</code> in more detail ' +
8488
'here.</p>\n',
85-
'type': 'module',
86-
'displayName': 'Foobar'
89+
type: 'module',
90+
displayName: 'Foobar'
8791
},
8892
{
89-
'textRaw': 'Foobar II',
90-
'name': 'foobar_ii',
91-
'meta': {
92-
'added': ['v5.3.0', 'v4.2.0']
93+
textRaw: 'Foobar II',
94+
name: 'foobar_ii',
95+
meta: {
96+
added: ['v5.3.0', 'v4.2.0']
9397
},
94-
'desc': '<p>Describe <code>Foobar II</code> in more detail ' +
98+
desc: '<p>Describe <code>Foobar II</code> in more detail ' +
9599
'here.</p>\n',
96-
'type': 'module',
97-
'displayName': 'Foobar II'
100+
type: 'module',
101+
displayName: 'Foobar II'
98102
},
99103
{
100-
'textRaw': 'Deprecated thingy',
101-
'name': 'deprecated_thingy',
102-
'meta': {
103-
'added': ['v1.0.0'],
104-
'deprecated': ['v2.0.0']
104+
textRaw: 'Deprecated thingy',
105+
name: 'deprecated_thingy',
106+
meta: {
107+
added: ['v1.0.0'],
108+
deprecated: ['v2.0.0']
105109
},
106-
'desc': '<p>Describe <code>Deprecated thingy</code> in more ' +
110+
desc: '<p>Describe <code>Deprecated thingy</code> in more ' +
107111
'detail here.</p>\n',
108-
'type': 'module',
109-
'displayName': 'Deprecated thingy'
112+
type: 'module',
113+
displayName: 'Deprecated thingy'
110114
},
111115
{
112-
'textRaw': 'Something',
113-
'name': 'something',
114-
'desc': '<!-- This is not a metadata comment -->\n<p>' +
116+
textRaw: 'Something',
117+
name: 'something',
118+
desc: '<!-- This is not a metadata comment -->\n<p>' +
115119
'Describe <code>Something</code> in more detail here.</p>\n',
116-
'type': 'module',
117-
'displayName': 'Something'
120+
type: 'module',
121+
displayName: 'Something'
118122
}
119123
],
120-
'type': 'module',
121-
'displayName': 'Sample Markdown with YAML info'
124+
type: 'module',
125+
displayName: 'Sample Markdown with YAML info'
122126
}
123127
]
124128
}

0 commit comments

Comments
 (0)