Skip to content

Commit b283fc9

Browse files
committed
JS: Add tests with missing flow.
1 parent f2b49a4 commit b283fc9

1 file changed

Lines changed: 47 additions & 2 deletions

File tree

‎javascript/ql/test/library-tests/frameworks/NodeJSLib/stream-pipe.js‎

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,12 @@ class HookTransform extends Transform {
171171
}
172172
}
173173

174-
Readable.from([source("transform-hook")]).pipe(new HookTransform());
174+
Readable.from([source("transform-hook")]).pipe(new HookTransform()).pipe({
175+
write(chunk) {
176+
consumeChunk(chunk); // $ MISSING: flow=transform-hook
177+
return true;
178+
}
179+
});
175180

176181
class OverriddenWriteDestination extends Writable {
177182
write(chunk) {
@@ -261,7 +266,12 @@ const transformOptions = {
261266
const transformOptionsAlias = transformOptions;
262267
const { Transform: ImportedTransform } = require("node:stream");
263268
const optionsTransform = new ImportedTransform(transformOptionsAlias);
264-
Readable.from([source("options-transform")]).pipe(optionsTransform);
269+
Readable.from([source("options-transform")]).pipe(optionsTransform).pipe({
270+
write(chunk) {
271+
consumeChunk(chunk); // $ MISSING: flow=options-transform
272+
return true;
273+
}
274+
});
265275

266276
const optionsDuplex = new Duplex({
267277
read() {},
@@ -297,3 +307,38 @@ overriddenOptionsDestination.write = function(chunk) {
297307
return true;
298308
};
299309
Readable.from([source("options-public-write")]).pipe(overriddenOptionsDestination);
310+
311+
class PushingTransform extends Transform {
312+
_transform(chunk, encoding, callback) {
313+
this.push(chunk);
314+
callback();
315+
}
316+
}
317+
Readable.from([source("transform-push")]).pipe(new PushingTransform()).pipe({
318+
write(chunk) {
319+
consumeChunk(chunk); // $ MISSING: flow=transform-push
320+
return true;
321+
}
322+
});
323+
324+
Readable.from([source("dropped-transform-input")]).pipe(new Transform({
325+
transform(chunk, encoding, callback) {
326+
callback();
327+
}
328+
})).pipe({
329+
write(chunk) {
330+
consumeChunk(chunk);
331+
return true;
332+
}
333+
});
334+
335+
Readable.from([source("replaced-transform-input")]).pipe(new Transform({
336+
transform(chunk, encoding, callback) {
337+
callback(null, source("replacement-output"));
338+
}
339+
})).pipe({
340+
write(chunk) {
341+
consumeChunk(chunk); // $ MISSING: flow=replacement-output
342+
return true;
343+
}
344+
});

0 commit comments

Comments
 (0)