Skip to content

Commit e65c24d

Browse files
authored
Options should be the second argment to tap.test. Refs #492 (#493)
1 parent bec5d7b commit e65c24d

File tree

2 files changed

+49
-49
lines changed

2 files changed

+49
-49
lines changed

test/bin-watch-serve.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ function normalize(result) {
3434

3535
var options = { timeout: 1000 * 120 };
3636

37-
test('harness', function (t) {
37+
test('harness', options, function (t) {
3838
var docProcess = documentation(['fixture/simple.input.js', '--serve']);
3939
t.ok(docProcess, 'creates a subprocess object');
4040
docProcess.kill();
4141
t.end();
42-
}, options);
42+
});
4343

44-
test('provides index.html', function (t) {
44+
test('provides index.html', options, function (t) {
4545
var docProcess = documentation(['serve', 'fixture/simple.input.js']);
4646
docProcess.stdout.on('data', function (data) {
4747
t.equal(data.toString().trim(), 'documentation.js serving on port 4001', 'shows listening message');
@@ -51,9 +51,9 @@ test('provides index.html', function (t) {
5151
t.end();
5252
});
5353
});
54-
}, options);
54+
});
5555

56-
test('accepts port argument', function (t) {
56+
test('accepts port argument', options, function (t) {
5757
var docProcess = documentation(['serve', 'fixture/simple.input.js', '--port=4004']);
5858
docProcess.stdout.on('data', function (data) {
5959
t.equal(data.toString().trim(), 'documentation.js serving on port 4004', 'shows listening message');
@@ -63,9 +63,9 @@ test('accepts port argument', function (t) {
6363
t.end();
6464
});
6565
});
66-
}, options);
66+
});
6767

68-
test('--watch', function (t) {
68+
test('--watch', options, function (t) {
6969
var tmpFile = path.join(os.tmpdir(), '/simple.js');
7070
fs.writeFileSync(tmpFile, '/** a function */function apples() {}');
7171
var docProcess = documentation(['serve', tmpFile, '--watch']);
@@ -82,9 +82,9 @@ test('--watch', function (t) {
8282
}, 1000);
8383
});
8484
});
85-
}, options);
85+
});
8686

87-
test('--watch', function (t) {
87+
test('--watch', options, function (t) {
8888
var tmpDir = os.tmpdir();
8989
var a = path.join(tmpDir, '/simple.js');
9090
var b = path.join(tmpDir, '/required.js');
@@ -104,9 +104,9 @@ test('--watch', function (t) {
104104
}, 1000);
105105
});
106106
});
107-
}, options);
107+
});
108108

109-
test('error page', function (t) {
109+
test('error page', options, function (t) {
110110
var tmpDir = os.tmpdir();
111111
var a = path.join(tmpDir, '/simple.js');
112112
fs.writeFileSync(a, '**');
@@ -118,4 +118,4 @@ test('error page', function (t) {
118118
t.end();
119119
});
120120
});
121-
}, options);
121+
});

test/bin.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ function normalize(result) {
4242

4343
var options = { timeout: 1000 * 120 };
4444

45-
test('documentation binary', function (t) {
45+
test('documentation binary', options, function (t) {
4646
documentation(['build fixture/simple.input.js'], function (err, data) {
4747
t.error(err);
4848
t.equal(data.length, 1, 'simple has no dependencies');
4949
t.end();
5050
});
51-
}, options);
51+
});
5252

53-
test('defaults to parsing package.json main', function (t) {
53+
test('defaults to parsing package.json main', options, function (t) {
5454
documentation(['build'], { cwd: path.join(__dirname, '..') }, function (err, data) {
5555
t.error(err);
5656
t.ok(data.length, 'we document ourself');
5757
t.end();
5858
});
59-
}, options);
59+
});
6060

61-
test('polyglot mode', function (t) {
61+
test('polyglot mode', options, function (t) {
6262
documentation(['build fixture/polyglot/blend.cpp --polyglot'],
6363
function (err, data) {
6464
t.ifError(err);
@@ -78,9 +78,9 @@ test('polyglot mode', function (t) {
7878
'parsed C++ file');
7979
t.end();
8080
});
81-
}, options);
81+
});
8282

83-
test('accepts config file', function (t) {
83+
test('accepts config file', options, function (t) {
8484
documentation(['build fixture/sorting/input.js -c fixture/config.json'],
8585
function (err, data) {
8686
t.error(err);
@@ -100,9 +100,9 @@ test('accepts config file', function (t) {
100100
'respected sort order from config file');
101101
t.end();
102102
});
103-
}, options);
103+
});
104104

105-
test('accepts config file - reports failures', function (t) {
105+
test('accepts config file - reports failures', options, function (t) {
106106
documentation(['build fixture/sorting/input.js -c fixture/config-bad.yml'], {},
107107
function (err, data, stderr) {
108108
t.error(err);
@@ -119,15 +119,15 @@ test('accepts config file - reports failures', function (t) {
119119
t.equal(stderr, expected, 'reported a missing toc entry');
120120
t.end();
121121
}, false);
122-
}, options);
122+
});
123123

124124
test('--shallow option', function (t) {
125125
documentation(['build --shallow fixture/internal.input.js'], function (err, data) {
126126
t.error(err);
127127
t.equal(data.length, 0, 'should not check dependencies');
128128
t.end();
129129
});
130-
}, options);
130+
});
131131

132132
test('external modules option', function (t) {
133133
documentation(['build fixture/external.input.js ' +
@@ -155,21 +155,21 @@ test('extension option', function (t) {
155155
});
156156

157157
test('invalid arguments', function (group) {
158-
group.test('bad -f option', function (t) {
158+
group.test('bad -f option', options, function (t) {
159159
documentation(['build -f DOES-NOT-EXIST fixture/internal.input.js'], function (err) {
160160
t.ok(err, 'returns error');
161161
t.end();
162162
});
163-
}, options);
163+
});
164164

165-
group.test('html with no destination', function (t) {
165+
group.test('html with no destination', options, function (t) {
166166
documentation(['build -f html fixture/internal.input.js'], function (err) {
167167
t.ok(err.toString()
168168
.match(/The HTML output mode requires a destination directory set with -o/),
169169
'needs dest for html');
170170
t.end();
171171
});
172-
}, options);
172+
});
173173

174174
group.test('bad command', function (t) {
175175
documentation(['-f html fixture/internal.input.js'], function (err, stdout, stderr) {
@@ -182,16 +182,16 @@ test('invalid arguments', function (group) {
182182
group.end();
183183
});
184184

185-
test('--version', function (t) {
185+
test('--version', options, function (t) {
186186
documentation(['--version'], {}, function (err, output) {
187187
t.ok(output, 'outputs version');
188188
t.end();
189189
}, false);
190-
}, options);
190+
});
191191

192192
test('lint command', function (group) {
193193

194-
group.test('generates lint output', function (t) {
194+
group.test('generates lint output', options, function (t) {
195195
documentation(['lint fixture/lint/lint.input.js'], function (err, data) {
196196
var output = path.join(__dirname, 'fixture/lint/lint.output.js');
197197
data = data.toString().split('\n').slice(2).join('\n');
@@ -202,41 +202,41 @@ test('lint command', function (group) {
202202
t.equal(data, fs.readFileSync(output, 'utf8'), 'outputs lint');
203203
t.end();
204204
});
205-
}, options);
205+
});
206206

207-
group.test('generates no output on a good file', function (t) {
207+
group.test('generates no output on a good file', options, function (t) {
208208
documentation(['lint fixture/simple.input.js'], {}, function (err, data) {
209209
t.equal(err, null);
210210
t.equal(data, '', 'no output');
211211
t.end();
212212
}, false);
213-
}, options);
213+
});
214214

215-
group.test('exposes syntax error on a bad file', function (t) {
215+
group.test('exposes syntax error on a bad file', options, function (t) {
216216
documentation(['lint fixture/bad/syntax.input.js'], {}, function (err, data) {
217217
t.ok(err.code > 0, 'exits with a > 0 exit code');
218218
t.end();
219219
}, false);
220-
}, options);
220+
});
221221

222222
group.end();
223223
});
224224

225-
test('given no files', function (t) {
225+
test('given no files', options, function (t) {
226226
documentation(['build'], function (err) {
227227
t.ok(err.toString()
228228
.match(/documentation was given no files and was not run in a module directory/),
229229
'no files given');
230230
t.end();
231231
});
232-
}, options);
232+
});
233233

234-
test('with an invalid command', function (t) {
234+
test('with an invalid command', options, function (t) {
235235
documentation(['invalid'], function (err) {
236236
t.ok(err, 'returns error');
237237
t.end();
238238
});
239-
}, options);
239+
});
240240

241241
test('--access flag', function (t) {
242242
documentation(['build --shallow fixture/internal.input.js -a public'], {}, function (err, data) {
@@ -271,7 +271,7 @@ test('--infer-private flag', function (t) {
271271
}, false);
272272
});
273273

274-
test('write to file', function (t) {
274+
test('write to file', options, function (t) {
275275

276276
var dst = path.join(os.tmpdir(), (Date.now() + Math.random()).toString());
277277

@@ -281,9 +281,9 @@ test('write to file', function (t) {
281281
t.ok(fs.existsSync(dst), 'created file');
282282
t.end();
283283
}, false);
284-
}, options);
284+
});
285285

286-
test('write to html', function (t) {
286+
test('write to html', options, function (t) {
287287

288288
var dstDir = path.join(os.tmpdir(), (Date.now() + Math.random()).toString());
289289
fs.mkdirSync(dstDir);
@@ -295,9 +295,9 @@ test('write to html', function (t) {
295295
t.ok(fs.existsSync(path.join(dstDir, 'index.html')), 'created index.html');
296296
t.end();
297297
}, false);
298-
}, options);
298+
});
299299

300-
test('write to html with custom theme', function (t) {
300+
test('write to html with custom theme', options, function (t) {
301301

302302
var dstDir = path.join(os.tmpdir(), (Date.now() + Math.random()).toString());
303303
fs.mkdirSync(dstDir);
@@ -309,9 +309,9 @@ test('write to html with custom theme', function (t) {
309309
t.ok(fs.readFileSync(path.join(dstDir, 'index.html'), 'utf8'), 'Hello world');
310310
t.end();
311311
}, false);
312-
}, options);
312+
});
313313

314-
test('write to html, highlightAuto', function (t) {
314+
test('write to html, highlightAuto', options, function (t) {
315315

316316
var fixture = 'fixture/auto_lang_hljs/multilanguage.input.js',
317317
config = 'fixture/auto_lang_hljs/config.yml',
@@ -331,13 +331,13 @@ test('write to html, highlightAuto', function (t) {
331331
'html is recognized by highlightjs');
332332
t.end();
333333
}, false);
334-
}, options);
334+
});
335335

336-
test('fatal error', function (t) {
336+
test('fatal error', options, function (t) {
337337

338338
documentation(['build --shallow fixture/bad/syntax.input.js'], {},
339339
function (err) {
340340
t.ok(err.toString().match(/Unexpected token/), 'reports syntax error');
341341
t.end();
342342
}, false);
343-
}, options);
343+
});

0 commit comments

Comments
 (0)