Skip to content

Commit bb19c9b

Browse files
committed
fix test after readable-stream upgrade
1 parent 8c74b08 commit bb19c9b

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed

test/index.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
const {
2+
PassThrough,
3+
Transform,
4+
finished,
5+
pipeline,
6+
} = require('readable-stream');
17
const test = require('tape');
2-
const { PassThrough, Transform, finished, pipeline } = require('readable-stream');
38
// eslint-disable-next-line import/no-unresolved
49
const ObjMultiplex = require('../dist');
510

@@ -18,7 +23,7 @@ test('basic - string', (t) => {
1823
inStream.write('wuurl');
1924

2025
// simulate disconnect
21-
setTimeout(() => inTransport.destroy());
26+
setImmediate(() => inTransport.end(null, () => undefined));
2227
});
2328

2429
test('basic - obj', (t) => {
@@ -39,7 +44,7 @@ test('basic - obj', (t) => {
3944
inStream.write({ message: 'wuurl' });
4045

4146
// simulate disconnect
42-
setTimeout(() => inTransport.destroy());
47+
setImmediate(() => inTransport.end(null, () => undefined));
4348
});
4449

4550
test('roundtrip', (t) => {
@@ -54,7 +59,7 @@ test('roundtrip', (t) => {
5459
},
5560
});
5661

57-
pipeline(outStream, doubler, outStream);
62+
pipeline(outStream, doubler, outStream, () => undefined);
5863

5964
bufferToEnd(inStream, (err, results) => {
6065
t.error(err, 'should not error');
@@ -66,7 +71,7 @@ test('roundtrip', (t) => {
6671
inStream.write(12);
6772

6873
// simulate disconnect
69-
setTimeout(() => outTransport.destroy(), 100);
74+
setTimeout(() => outTransport.end(), 100);
7075
});
7176

7277
test('error on createStream if destroyed', (t) => {
@@ -104,7 +109,7 @@ function basicTestSetup() {
104109
const inStream = inMux.createStream('hello');
105110
const outStream = outMux.createStream('hello');
106111

107-
pipeline(inMux, inTransport, outMux, outTransport, inMux);
112+
pipeline(inMux, inTransport, outMux, outTransport, inMux, () => undefined);
108113

109114
return {
110115
inTransport,
@@ -118,6 +123,17 @@ function basicTestSetup() {
118123

119124
function bufferToEnd(stream, callback) {
120125
const results = [];
121-
finished(stream, (err) => callback(err, results));
122-
stream.on('data', (chunk) => results.push(chunk));
126+
let flushed = false;
127+
function onFinish(err) {
128+
if (flushed) {
129+
return;
130+
}
131+
flushed = true;
132+
callback(err, results);
133+
}
134+
stream.prependListener('close', onFinish);
135+
finished(stream, onFinish);
136+
stream.on('data', (chunk) => {
137+
results.push(chunk);
138+
});
123139
}

yarn.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ abbrev@1:
245245
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
246246
integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==
247247

248-
acorn-jsx@^5.2.0, acorn-jsx@^5.3.1:
248+
acorn-jsx@^5.3.1:
249249
version "5.3.1"
250250
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b"
251251
integrity sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==
@@ -1039,7 +1039,7 @@ get-caller-file@^2.0.5:
10391039
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
10401040
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
10411041

1042-
get-intrinsic@^1.0.0, get-intrinsic@^1.0.2, get-intrinsic@^1.1.1:
1042+
get-intrinsic@^1.0.2, get-intrinsic@^1.1.1:
10431043
version "1.1.1"
10441044
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6"
10451045
integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==
@@ -1227,12 +1227,12 @@ is-boolean-object@^1.1.0:
12271227
dependencies:
12281228
call-bind "^1.0.2"
12291229

1230-
is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.2, is-callable@^1.2.3:
1230+
is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.3:
12311231
version "1.2.3"
12321232
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.3.tgz#8b1e0500b73a1d76c70487636f368e519de8db8e"
12331233
integrity sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ==
12341234

1235-
is-core-module@^2.1.0, is-core-module@^2.2.0, is-core-module@^2.4.0:
1235+
is-core-module@^2.2.0, is-core-module@^2.4.0:
12361236
version "2.4.0"
12371237
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.4.0.tgz#8e9fc8e15027b011418026e98f0e6f4d86305cc1"
12381238
integrity sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==
@@ -1273,7 +1273,7 @@ is-glob@^4.0.0, is-glob@^4.0.1:
12731273
dependencies:
12741274
is-extglob "^2.1.1"
12751275

1276-
is-negative-zero@^2.0.0, is-negative-zero@^2.0.1:
1276+
is-negative-zero@^2.0.1:
12771277
version "2.0.1"
12781278
resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.1.tgz#3de746c18dda2319241a53675908d8f766f11c24"
12791279
integrity sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w==
@@ -1288,7 +1288,7 @@ is-number@^7.0.0:
12881288
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
12891289
integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==
12901290

1291-
is-regex@^1.0.4, is-regex@^1.1.1, is-regex@^1.1.3:
1291+
is-regex@^1.0.4, is-regex@^1.1.3:
12921292
version "1.1.3"
12931293
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.3.tgz#d029f9aff6448b93ebbe3f33dac71511fdcbef9f"
12941294
integrity sha512-qSVXFz28HM7y+IWX6vLCsexdlvzT1PJNFSBuaQLQ5o0IEw8UDYW6/2+eCMVyIsbM8CNLX2a/QWmSpyxYEHY7CQ==
@@ -1603,7 +1603,7 @@ object-assign@^4.1.0:
16031603
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
16041604
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
16051605

1606-
object-inspect@^1.10.3, object-inspect@^1.8.0:
1606+
object-inspect@^1.10.3:
16071607
version "1.10.3"
16081608
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.10.3.tgz#c2aa7d2d09f50c99375704f7a0adf24c5782d369"
16091609
integrity sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw==
@@ -1626,7 +1626,7 @@ object-keys@^1.0.12, object-keys@^1.1.1:
16261626
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e"
16271627
integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==
16281628

1629-
object.assign@^4.1.1, object.assign@^4.1.2:
1629+
object.assign@^4.1.2:
16301630
version "4.1.2"
16311631
resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940"
16321632
integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==
@@ -2090,15 +2090,15 @@ string.prototype.trim@~1.2.1:
20902090
define-properties "^1.1.3"
20912091
es-abstract "^1.18.0-next.1"
20922092

2093-
string.prototype.trimend@^1.0.1, string.prototype.trimend@^1.0.4:
2093+
string.prototype.trimend@^1.0.4:
20942094
version "1.0.4"
20952095
resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz#e75ae90c2942c63504686c18b287b4a0b1a45f80"
20962096
integrity sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==
20972097
dependencies:
20982098
call-bind "^1.0.2"
20992099
define-properties "^1.1.3"
21002100

2101-
string.prototype.trimstart@^1.0.1, string.prototype.trimstart@^1.0.4:
2101+
string.prototype.trimstart@^1.0.4:
21022102
version "1.0.4"
21032103
resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz#b36399af4ab2999b4c9c648bd7a3fb2bb26feeed"
21042104
integrity sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==

0 commit comments

Comments
 (0)