Skip to content

Commit bb762c5

Browse files
authored
test: simplify test-http-write-callbacks.js
PR-URL: #42628 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent b98386c commit bb762c5

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

test/parallel/test-http-write-callbacks.js

+13-18
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
require('../common');
23+
const common = require('../common');
2424
const assert = require('assert');
2525

2626
const http = require('http');
@@ -53,15 +53,13 @@ server.on('checkContinue', (req, res) => {
5353
res.writeContinue(() => {
5454
// Continue has been written
5555
req.on('end', () => {
56-
res.write('asdf', (er) => {
57-
assert.ifError(er);
58-
res.write('foo', 'ascii', (er) => {
59-
assert.ifError(er);
60-
res.end(Buffer.from('bar'), 'buffer', (er) => {
56+
res.write('asdf', common.mustSucceed(() => {
57+
res.write('foo', 'ascii', common.mustSucceed(() => {
58+
res.end(Buffer.from('bar'), 'buffer', common.mustSucceed(() => {
6159
serverEndCb = true;
62-
});
63-
});
64-
});
60+
}));
61+
}));
62+
}));
6563
});
6664
});
6765

@@ -79,16 +77,13 @@ server.listen(0, function() {
7977
});
8078
req.on('continue', () => {
8179
// ok, good to go.
82-
req.write('YmF6', 'base64', (er) => {
83-
assert.ifError(er);
84-
req.write(Buffer.from('quux'), (er) => {
85-
assert.ifError(er);
86-
req.end('626c657267', 'hex', (er) => {
87-
assert.ifError(er);
80+
req.write('YmF6', 'base64', common.mustSucceed(() => {
81+
req.write(Buffer.from('quux'), common.mustSucceed(() => {
82+
req.end('626c657267', 'hex', common.mustSucceed(() => {
8883
clientEndCb = true;
89-
});
90-
});
91-
});
84+
}));
85+
}));
86+
}));
9287
});
9388
req.on('response', (res) => {
9489
// This should not come until after the end is flushed out

0 commit comments

Comments
 (0)