Skip to content

Commit 68956fb

Browse files
committed
[INTERNAL] Tests: Replace deprecated Buffer constructor calls
The Buffer constructor used in some of our recently added tests (#56 is deprecated. One should use Buffer.from(string) instead. Details: https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/
1 parent 1807fcc commit 68956fb

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

test/lib/DuplexCollection.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test("DuplexCollection: _byGlob", (t) => {
6161

6262
const resource = new Resource({
6363
path: "my/path",
64-
buffer: new Buffer("content")
64+
buffer: Buffer.from("content")
6565
});
6666
const abstractReader = {
6767
_byGlob: sinon.stub().returns(Promise.resolve([resource]))
@@ -115,7 +115,7 @@ test("DuplexCollection: _byGlobSource with default options and a reader finding
115115

116116
const resource = new Resource({
117117
path: "my/path",
118-
buffer: new Buffer("content")
118+
buffer: Buffer.from("content")
119119
});
120120
const abstractReader = {
121121
byGlob: sinon.stub().returns(Promise.resolve([resource]))
@@ -144,7 +144,7 @@ test("DuplexCollection: _byPath with reader finding a resource", (t) => {
144144

145145
const resource = new Resource({
146146
path: "path",
147-
buffer: new Buffer("content")
147+
buffer: Buffer.from("content")
148148
});
149149
const pushCollectionSpy = sinon.spy(resource, "pushCollection");
150150
const abstractReader = {
@@ -205,7 +205,7 @@ test("DuplexCollection: _write successful", (t) => {
205205

206206
const resource = new Resource({
207207
path: "my/path",
208-
buffer: new Buffer("content")
208+
buffer: Buffer.from("content")
209209
});
210210
const duplexCollection = new DuplexCollection({
211211
name: "myCollection",

test/lib/ReaderCollection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test("ReaderCollection: _byGlob with finding a resource", (t) => {
4242

4343
const resource = new Resource({
4444
path: "my/path",
45-
buffer: new Buffer("content")
45+
buffer: Buffer.from("content")
4646
});
4747
const abstractReader = {
4848
_byGlob: sinon.stub().returns(Promise.resolve([resource]))
@@ -74,7 +74,7 @@ test("ReaderCollection: _byPath with reader finding a resource", (t) => {
7474

7575
const resource = new Resource({
7676
path: "my/path",
77-
buffer: new Buffer("content")
77+
buffer: Buffer.from("content")
7878
});
7979
const pushCollectionSpy = sinon.spy(resource, "pushCollection");
8080
const abstractReader = {

test/lib/Resource.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test("Resource: constructor with duplicated content parameter", (t) => {
1414
const error = t.throws(() => {
1515
new Resource({
1616
path: "my/path",
17-
buffer: new Buffer("Content"),
17+
buffer: Buffer.from("Content"),
1818
string: "Content"
1919
});
2020
}, Error);
@@ -41,7 +41,7 @@ test("Resource: getStream", async (t) => {
4141

4242
const resource = new Resource({
4343
path: "my/path/to/resource",
44-
buffer: new Buffer("Content")
44+
buffer: Buffer.from("Content")
4545
});
4646

4747
return new Promise(function(resolve, reject) {
@@ -109,7 +109,7 @@ test("Resource: clone resource with buffer", (t) => {
109109

110110
const resource = new Resource({
111111
path: "my/path/to/resource",
112-
buffer: new Buffer("Content")
112+
buffer: Buffer.from("Content")
113113
});
114114

115115
return resource.clone().then(function(clonedResource) {

0 commit comments

Comments
 (0)