test: change deprecated method to recommended · nodejs/node@34fc7a0 · GitHub
Skip to content

Commit 34fc7a0

Browse files
TrottMylesBorins
authored andcommitted
test: change deprecated method to recommended
In non-buffer tests, change usage of the Buffer constructor to one of the recommended alternatives. Backport-PR-URL: #14339 PR-URL: #13649 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Brian White <mscdex@mscdex.net>
1 parent 4ffe804 commit 34fc7a0

7 files changed

Lines changed: 12 additions & 12 deletions

test/parallel/test-stream-pipe-await-drain-push-while-write.js

Lines changed: 2 additions & 2 deletions

test/parallel/test-stream2-decode-partial.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const Readable = require('_stream_readable');
44
const assert = require('assert');
55

66
let buf = '';
7-
const euro = new Buffer([0xE2, 0x82, 0xAC]);
8-
const cent = new Buffer([0xC2, 0xA2]);
7+
const euro = Buffer.from([0xE2, 0x82, 0xAC]);
8+
const cent = Buffer.from([0xC2, 0xA2]);
99
const source = Buffer.concat([euro, cent]);
1010

1111
const readable = Readable({ encoding: 'utf8' });

test/parallel/test-stream3-cork-end.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ writeChunks(inputChunks, () => {
7979
// there was a chunk
8080
assert.ok(seen);
8181

82-
const expected = new Buffer(expectedChunks[i]);
82+
const expected = Buffer.from(expectedChunks[i]);
8383
// it was what we expected
8484
assert.ok(seen.equals(expected));
8585
}

test/parallel/test-stream3-cork-uncork.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ writeChunks(inputChunks, () => {
7474
// there was a chunk
7575
assert.ok(seen);
7676

77-
const expected = new Buffer(expectedChunks[i]);
77+
const expected = Buffer.from(expectedChunks[i]);
7878
// it was what we expected
7979
assert.ok(seen.equals(expected));
8080
}

test/parallel/test-tls-basic-validations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ assert.throws(() => tls.createServer({sessionTimeout: 'abcd'}),
2828
assert.throws(() => tls.createServer({ticketKeys: 'abcd'}),
2929
/TypeError: Ticket keys must be a buffer/);
3030

31-
assert.throws(() => tls.createServer({ticketKeys: new Buffer(0)}),
31+
assert.throws(() => tls.createServer({ticketKeys: Buffer.alloc(0)}),
3232
/TypeError: Ticket keys length must be 48 bytes/);
3333

3434
assert.throws(() => tls.createSecurePair({}),

test/parallel/test-zlib-from-gzip-with-trailing-garbage.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const zlib = require('zlib');
99
let data = Buffer.concat([
1010
zlib.gzipSync('abc'),
1111
zlib.gzipSync('def'),
12-
Buffer(10).fill(0)
12+
Buffer.alloc(10)
1313
]);
1414

1515
assert.strictEqual(zlib.gunzipSync(data).toString(), 'abcdef');
@@ -28,8 +28,8 @@ zlib.gunzip(data, common.mustCall((err, result) => {
2828
data = Buffer.concat([
2929
zlib.gzipSync('abc'),
3030
zlib.gzipSync('def'),
31-
Buffer([0x1f, 0x8b, 0xff, 0xff]),
32-
Buffer(10).fill(0)
31+
Buffer.from([0x1f, 0x8b, 0xff, 0xff]),
32+
Buffer.alloc(10)
3333
]);
3434

3535
assert.throws(
@@ -49,7 +49,7 @@ zlib.gunzip(data, common.mustCall((err, result) => {
4949
data = Buffer.concat([
5050
zlib.gzipSync('abc'),
5151
zlib.gzipSync('def'),
52-
Buffer([0x1f, 0x8b, 0xff, 0xff])
52+
Buffer.from([0x1f, 0x8b, 0xff, 0xff])
5353
]);
5454

5555
assert.throws(

test/parallel/test-zlib-sync-no-event.js

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)