diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-02-02 19:05:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 12:05:46 +0100 |
commit | 6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch) | |
tree | fd94c013a19fcb38954844085821ec1601c20e18 /std/node/_stream/promises_test.ts | |
parent | a2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff) |
chore: remove std directory (#9361)
This removes the std folder from the tree.
Various parts of the tests are pretty tightly dependent
on std (47 direct imports and 75 indirect imports, not
counting the cli tests that use them as fixtures) so I've
added std as a submodule for now.
Diffstat (limited to 'std/node/_stream/promises_test.ts')
-rw-r--r-- | std/node/_stream/promises_test.ts | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/std/node/_stream/promises_test.ts b/std/node/_stream/promises_test.ts deleted file mode 100644 index 90803b4af..000000000 --- a/std/node/_stream/promises_test.ts +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright Node.js contributors. All rights reserved. MIT License. -import { Buffer } from "../buffer.ts"; -import Readable from "./readable.ts"; -import Writable from "./writable.ts"; -import { pipeline } from "./promises.ts"; -import { deferred } from "../../async/mod.ts"; -import { - assert, - assertEquals, - assertThrowsAsync, -} from "../../testing/asserts.ts"; - -Deno.test("Promise pipeline works correctly", async () => { - let pipelineExecuted = 0; - const pipelineExecutedExpected = 1; - const pipelineExpectedExecutions = deferred(); - - let finished = false; - // deno-lint-ignore no-explicit-any - const processed: any[] = []; - const expected = [ - Buffer.from("a"), - Buffer.from("b"), - Buffer.from("c"), - ]; - - const read = new Readable({ - read() {}, - }); - - const write = new Writable({ - write(data, _enc, cb) { - processed.push(data); - cb(); - }, - }); - - write.on("finish", () => { - finished = true; - }); - - for (let i = 0; i < expected.length; i++) { - read.push(expected[i]); - } - read.push(null); - - pipeline(read, write).then(() => { - pipelineExecuted++; - if (pipelineExecuted == pipelineExecutedExpected) { - pipelineExpectedExecutions.resolve(); - } - assert(finished); - assertEquals(processed, expected); - }); - - const pipelineTimeout = setTimeout( - () => pipelineExpectedExecutions.reject(), - 1000, - ); - await pipelineExpectedExecutions; - clearTimeout(pipelineTimeout); - assertEquals(pipelineExecuted, pipelineExecutedExpected); -}); - -Deno.test("Promise pipeline throws on readable destroyed", async () => { - const read = new Readable({ - read() {}, - }); - - const write = new Writable({ - write(_data, _enc, cb) { - cb(); - }, - }); - - read.push("data"); - read.destroy(); - - await assertThrowsAsync( - () => pipeline(read, write), - Error, - "Premature close", - ); -}); |