Skip to content

Commit 7b5e965

Browse files
committed
fixup: add tests
1 parent 3d97be2 commit 7b5e965

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const { spawnSync } = require('child_process');
5+
6+
// --warnings is on by default.
7+
assertHasWarning(spawnWithFlags([]));
8+
9+
// --warnings can be passed alone.
10+
assertHasWarning(spawnWithFlags(['--warnings']));
11+
12+
// --no-warnings can be passed alone.
13+
assertHasNoWarning(spawnWithFlags(['--no-warnings']));
14+
15+
// Last flag takes precedence.
16+
assertHasWarning(spawnWithFlags(['--no-warnings', '--warnings']));
17+
18+
// Non-boolean flags cannot be negated.
19+
assert(spawnWithFlags(['--no-max-http-header-size']).stderr.toString().includes(
20+
'--no-max-http-header-size is an invalid negation because it is not ' +
21+
'a boolean option',
22+
));
23+
24+
// Inexistant flags cannot be negated.
25+
assert(spawnWithFlags(['--no-i-dont-exist']).stderr.toString().includes(
26+
'bad option: --no-i-dont-exist',
27+
));
28+
29+
function spawnWithFlags(flags) {
30+
return spawnSync(process.execPath, [...flags, '-e', 'new Buffer(0)']);
31+
}
32+
33+
function assertHasWarning(proc) {
34+
assert(proc.stderr.toString().includes('Buffer() is deprecated'));
35+
}
36+
37+
function assertHasNoWarning(proc) {
38+
assert(!proc.stderr.toString().includes('Buffer() is deprecated'));
39+
}

0 commit comments

Comments
 (0)