Skip to content

Commit 93c4107

Browse files
committed
fixup: test
1 parent 10283bb commit 93c4107

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

test/parallel/test-fs-write-stream.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ tmpdir.refresh();
5656
// Throws if data is not of type Buffer.
5757
{
5858
const stream = fs.createWriteStream(file);
59-
stream.on('error', common.expectsError({
59+
stream.on('error', common.mustNotCall());
60+
assert.throws(() => {
61+
stream.write(42);
62+
}, {
6063
code: 'ERR_INVALID_ARG_TYPE',
6164
name: 'TypeError'
62-
}));
63-
stream.write(42, null, common.expectsError({
64-
code: 'ERR_INVALID_ARG_TYPE',
65-
name: 'TypeError'
66-
}));
65+
});
6766
stream.destroy();
6867
}

test/parallel/test-net-socket-write-error.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
const common = require('../common');
44
const net = require('net');
5+
const assert = require('assert');
56

67
const server = net.createServer().listen(0, connectToServer);
78

89
function connectToServer() {
910
const client = net.createConnection(this.address().port, () => {
10-
client.write(1337, common.expectsError({
11+
client.on('error', common.mustNotCall());
12+
assert.throws(() => {
13+
client.write(1337);
14+
}, {
1115
code: 'ERR_INVALID_ARG_TYPE',
1216
name: 'TypeError'
13-
}));
14-
client.on('error', common.expectsError({
15-
code: 'ERR_INVALID_ARG_TYPE',
16-
name: 'TypeError'
17-
}));
17+
});
1818

1919
client.destroy();
2020
})
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
'use strict';
22
const common = require('../common');
33
const net = require('net');
4-
4+
const assert = require('assert');
55
const socket = net.Stream({ highWaterMark: 0 });
66

77
// Make sure that anything besides a buffer or a string throws.
8-
socket.write(null, common.expectsError({
8+
socket.on('error', common.mustNotCall());
9+
assert.throws(() => {
10+
socket.write(null);
11+
}, {
912
code: 'ERR_STREAM_NULL_VALUES',
1013
name: 'TypeError',
1114
message: 'May not write null values to stream'
12-
}));
13-
socket.on('error', common.expectsError({
14-
code: 'ERR_STREAM_NULL_VALUES',
15-
name: 'TypeError',
16-
message: 'May not write null values to stream'
17-
}));
15+
});
1816

1917
[
2018
true,
@@ -29,10 +27,12 @@ socket.on('error', common.expectsError({
2927
].forEach((value) => {
3028
// We need to check the callback since 'error' will only
3129
// be emitted once per instance.
32-
socket.write(value, common.expectsError({
30+
assert.throws(() => {
31+
socket.write(value);
32+
}, {
3333
code: 'ERR_INVALID_ARG_TYPE',
3434
name: 'TypeError',
3535
message: 'The "chunk" argument must be of type string or an instance of ' +
3636
`Buffer or Uint8Array.${common.invalidArgTypeHelper(value)}`
37-
}));
37+
});
3838
});

test/parallel/test-stream2-writable.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,12 @@ const helloWorldBuffer = Buffer.from('hello world');
422422
{
423423
// Verify that error is only emitted once when failing in write.
424424
const w = new W();
425-
w.on('error', common.mustCall((err) => {
426-
assert.strictEqual(w._writableState.errorEmitted, true);
427-
assert.strictEqual(err.code, 'ERR_STREAM_NULL_VALUES');
428-
}));
429-
w.write(null);
430-
w.destroy(new Error());
425+
w.on('error', common.mustNotCall());
426+
assert.throws(() => {
427+
w.write(null);
428+
}, {
429+
code: 'ERR_STREAM_NULL_VALUES'
430+
});
431431
}
432432

433433
{

test/parallel/test-zlib-invalid-input.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ const unzips = [
4343
];
4444

4545
nonStringInputs.forEach(common.mustCall((input) => {
46-
// zlib.gunzip should not throw an error when called with bad input.
47-
zlib.gunzip(input, (err, buffer) => {
48-
// zlib.gunzip should pass the error to the callback.
49-
assert.ok(err);
46+
assert.throws(() => {
47+
zlib.gunzip(input);
48+
}, {
49+
name: 'TypeError'
5050
});
5151
}, nonStringInputs.length));
5252

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
'use strict';
22

33
const common = require('../common');
4+
const assert = require('assert');
45
const { Gunzip } = require('zlib');
56

67
const gunzip = new Gunzip({ objectMode: true });
7-
gunzip.write({}, common.expectsError({
8+
gunzip.on('error', common.mustNotCall());
9+
assert.throws(() => {
10+
gunzip.write({});
11+
}, {
812
name: 'TypeError'
9-
}));
10-
gunzip.on('error', common.expectsError({
11-
name: 'TypeError'
12-
}));
13+
});

0 commit comments

Comments
 (0)