Skip to content

Commit

Permalink
test(node_compat): enable more stream-writable tests (denoland#24328)
Browse files Browse the repository at this point in the history
  • Loading branch information
satyarohith authored and zebreus committed Jul 8, 2024
1 parent 16622ac commit 7737755
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 4 deletions.
4 changes: 4 additions & 0 deletions tests/node_compat/config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@
"test-stream-unpipe-event.js",
"test-stream-unshift-empty-chunk.js",
"test-stream-unshift-read-race.js",
"test-stream-writable-aborted.js",
"test-stream-writable-change-default-encoding.js",
"test-stream-writable-clear-buffer.js",
"test-stream-writable-constructor-set-methods.js",
Expand All @@ -583,6 +584,9 @@
"test-stream-writable-end-cb-error.js",
"test-stream-writable-end-multiple.js",
"test-stream-writable-ended-state.js",
"test-stream-writable-final-async.js",
"test-stream-writable-final-destroy.js",
"test-stream-writable-final-throw.js",
"test-stream-writable-finish-destroyed.js",
"test-stream-writable-finished-state.js",
"test-stream-writable-finished.js",
Expand Down
4 changes: 0 additions & 4 deletions tests/node_compat/runner/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2298,11 +2298,7 @@ NOTE: This file should not be manually edited. Please edit `tests/node_compat/co
- [parallel/test-stream-wrap-drain.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-wrap-drain.js)
- [parallel/test-stream-wrap-encoding.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-wrap-encoding.js)
- [parallel/test-stream-wrap.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-wrap.js)
- [parallel/test-stream-writable-aborted.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-aborted.js)
- [parallel/test-stream-writable-end-cb-uncaught.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-end-cb-uncaught.js)
- [parallel/test-stream-writable-final-async.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-final-async.js)
- [parallel/test-stream-writable-final-destroy.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-final-destroy.js)
- [parallel/test-stream-writable-final-throw.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-final-throw.js)
- [parallel/test-stream-writable-samecb-singletick.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-samecb-singletick.js)
- [parallel/test-stream2-finish-pipe-error.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream2-finish-pipe-error.js)
- [parallel/test-stream2-httpclient-response-end.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream2-httpclient-response-end.js)
Expand Down
33 changes: 33 additions & 0 deletions tests/node_compat/test/parallel/test-stream-writable-aborted.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// deno-fmt-ignore-file
// deno-lint-ignore-file

// Copyright Joyent and Node contributors. All rights reserved. MIT license.
// Taken from Node 18.12.1
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.

'use strict';

require('../common');
const assert = require('assert');
const { Writable } = require('stream');

{
const writable = new Writable({
write() {
}
});
assert.strictEqual(writable.writableAborted, false);
writable.destroy();
assert.strictEqual(writable.writableAborted, true);
}

{
const writable = new Writable({
write() {
}
});
assert.strictEqual(writable.writableAborted, false);
writable.end();
writable.destroy();
assert.strictEqual(writable.writableAborted, true);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// deno-fmt-ignore-file
// deno-lint-ignore-file

// Copyright Joyent and Node contributors. All rights reserved. MIT license.
// Taken from Node 18.12.1
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.

'use strict';

const common = require('../common');
const {
Duplex,
} = require('stream');
const { setTimeout } = require('timers/promises');

{
class Foo extends Duplex {
async _final(callback) {
await setTimeout(common.platformTimeout(1));
callback();
}

_read() {}
}

const foo = new Foo();
foo._write = common.mustCall((chunk, encoding, cb) => {
cb();
});
foo.end('test', common.mustCall());
foo.on('error', common.mustNotCall());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// deno-fmt-ignore-file
// deno-lint-ignore-file

// Copyright Joyent and Node contributors. All rights reserved. MIT license.
// Taken from Node 18.12.1
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.

'use strict';
const common = require('../common');

const { Writable } = require('stream');

{
const w = new Writable({
write(chunk, encoding, callback) {
callback(null);
},
final(callback) {
queueMicrotask(callback);
}
});
w.end();
w.destroy();

w.on('prefinish', common.mustNotCall());
w.on('finish', common.mustNotCall());
w.on('close', common.mustCall());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// deno-fmt-ignore-file
// deno-lint-ignore-file

// Copyright Joyent and Node contributors. All rights reserved. MIT license.
// Taken from Node 18.12.1
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.

'use strict';

const common = require('../common');
const {
Duplex,
} = require('stream');

{
class Foo extends Duplex {
_final(callback) {
throw new Error('fhqwhgads');
}

_read() {}
}

const foo = new Foo();
foo._write = common.mustCall((chunk, encoding, cb) => {
cb();
});
foo.end('test', common.expectsError({ message: 'fhqwhgads' }));
foo.on('error', common.mustCall());
}

0 comments on commit 7737755

Please sign in to comment.