web.js
This file
Path
test/convert/web.js
105 lines · 3.1 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
TweaksSindre Sorhusbefore adoption698a1b8
line 1why, one step back1import assert from 'node:assert/strict';Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
line 2why, one step back2import {ReadableStream, WritableStream} from 'node:stream/web';TweaksSindre Sorhusbefore adoption698a1b8
line 3why, one step back3import test from 'node:test';Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 4–25why, one step back4import {execa} from '../../index.js';5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {7 assertStreamOutput,8 assertStreamReadError,9 assertSubprocessOutput,10 assertSubprocessError,11 assertPromiseError,12 getReadableSubprocess,13 getWritableSubprocess,14 getReadWriteSubprocess,15} from '../helpers/convert.js';16import {foobarString} from '../helpers/input.js';1718setFixtureDirectory();1920const writeToStream = async (stream, input = foobarString) => {21 const writer = stream.getWriter();22 await writer.write(new TextEncoder().encode(input));23 await writer.close();24};25TweaksSindre Sorhusbefore adoption698a1b8
line 26why, one step back26test('.readableStream() success', async () => {Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 27–29why, one step back27 const subprocess = getReadableSubprocess();28 const stream = subprocess.readableStream();29TweaksSindre Sorhusbefore adoption698a1b8
line 30why, one step back30 assert.ok(stream instanceof ReadableStream);Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
line 31why, one step back31TweaksSindre Sorhusbefore adoption698a1b8
lines 32–33why, one step back32 await assertStreamOutput(stream);33 await assertSubprocessOutput(subprocess);Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 34–35why, one step back34});35TweaksSindre Sorhusbefore adoption698a1b8
line 36why, one step back36test('.readableStream() can use from', async () => {Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 37–39why, one step back37 const subprocess = execa('noop-fd.js', ['2', foobarString]);38 const stream = subprocess.readableStream({from: 'stderr'});39TweaksSindre Sorhusbefore adoption698a1b8
line 40why, one step back40 await assertStreamOutput(stream);Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 41–42why, one step back41});42TweaksSindre Sorhusbefore adoption698a1b8
line 43why, one step back43test('.writableStream() success', async () => {Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 44–46why, one step back44 const subprocess = getWritableSubprocess();45 const stream = subprocess.writableStream();46TweaksSindre Sorhusbefore adoption698a1b8
line 47why, one step back47 assert.ok(stream instanceof WritableStream);Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 48–49why, one step back4849 await writeToStream(stream);TweaksSindre Sorhusbefore adoption698a1b8
line 50why, one step back50 await assertSubprocessOutput(subprocess, foobarString, 2);Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 51–52why, one step back51});52TweaksSindre Sorhusbefore adoption698a1b8
line 53why, one step back53test('.writableStream() can use to', async () => {Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 54–57why, one step back54 const subprocess = execa('stdin-fd.js', ['0']);55 const stream = subprocess.writableStream({to: 'stdin'});5657 await writeToStream(stream);TweaksSindre Sorhusbefore adoption698a1b8
line 58why, one step back58 await assertSubprocessOutput(subprocess);Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 59–60why, one step back59});60TweaksSindre Sorhusbefore adoption698a1b8
line 61why, one step back61test('.transformStream() success', async () => {Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 62–64why, one step back62 const subprocess = getReadWriteSubprocess();63 const {readable, writable} = subprocess.transformStream();64TweaksSindre Sorhusbefore adoption698a1b8
lines 65–66why, one step back65 assert.ok(readable instanceof ReadableStream);66 assert.ok(writable instanceof WritableStream);Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 67–68why, one step back6768 await writeToStream(writable);TweaksSindre Sorhusbefore adoption698a1b8
lines 69–70why, one step back69 await assertStreamOutput(readable);70 await assertSubprocessOutput(subprocess);Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 71–72why, one step back71});72TweaksSindre Sorhusbefore adoption698a1b8
line 73why, one step back73test('subprocess fail -> .readableStream() error', async () => {Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 74–79why, one step back74 const subprocess = getReadWriteSubprocess();75 const stream = subprocess.readableStream();7677 const cause = new Error(foobarString);78 subprocess.kill(cause);79TweaksSindre Sorhusbefore adoption698a1b8
lines 80–81why, one step back80 await assertStreamReadError(stream, {cause});81 await assertSubprocessError(subprocess, {cause});Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 82–83why, one step back82});83TweaksSindre Sorhusbefore adoption698a1b8
line 84why, one step back84test('subprocess fail -> .writableStream() error', async () => {Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 85–91why, one step back85 const subprocess = getReadWriteSubprocess();86 const stream = subprocess.writableStream();87 const writer = stream.getWriter();8889 const cause = new Error(foobarString);90 subprocess.kill(cause);91TweaksSindre Sorhusbefore adoption698a1b8
lines 92–93why, one step back92 await assertPromiseError(writer.closed, {cause});93 await assertSubprocessError(subprocess, {cause});Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 94–95why, one step back94});95TweaksSindre Sorhusbefore adoption698a1b8
line 96why, one step back96test('subprocess fail -> .transformStream() error', async () => {Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
lines 97–102why, one step back97 const subprocess = getReadWriteSubprocess();98 const {readable} = subprocess.transformStream();99100 const cause = new Error(foobarString);101 subprocess.kill(cause);102TweaksSindre Sorhusbefore adoption698a1b8
lines 103–104why, one step back103 await assertStreamReadError(readable, {cause});104 await assertSubprocessError(subprocess, {cause});Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc
line 105why, one step back105});