Skip to content
Myr

iterable.test-d.ts

This file

Path

test-d/convert/iterable.test-d.ts

85 lines · 3.2 KiB · TypeScript

Last changed by

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 1why, one step back
1import {expectTypeOf, expectError} from 'nz';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 2–9why, one step back
2import {execa} from '../../index.js';
34const subprocess = execa('unicorns');5const bufferSubprocess = execa('unicorns', {encoding: 'buffer', all: true});6const hexSubprocess = execa('unicorns', {encoding: 'hex', all: true});78const asyncIteration = async () => {9 for await (const line of subprocess) {

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 10why, one step back
10 expectTypeOf(line).toBe<string>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 11–13why, one step back
11 }
1213 for await (const line of subprocess.iterable()) {

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 14why, one step back
14 expectTypeOf(line).toBe<string>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 15–17why, one step back
15 }
1617 for await (const line of subprocess.iterable({binary: false})) {

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 18why, one step back
18 expectTypeOf(line).toBe<string>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 19–21why, one step back
19 }
2021 for await (const line of subprocess.iterable({binary: true})) {

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 22why, one step back
22 expectTypeOf(line).toBe<Uint8Array>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 23–25why, one step back
23 }
2425 for await (const line of subprocess.iterable({} as {binary: boolean})) {

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 26why, one step back
26 expectTypeOf(line).toBe<string | Uint8Array>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 27–29why, one step back
27 }
2829 for await (const line of bufferSubprocess) {

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 30why, one step back
30 expectTypeOf(line).toBe<Uint8Array>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 31–33why, one step back
31 }
3233 for await (const line of bufferSubprocess.iterable()) {

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 34why, one step back
34 expectTypeOf(line).toBe<Uint8Array>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 35–37why, one step back
35 }
3637 for await (const line of bufferSubprocess.iterable({binary: false})) {

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 38why, one step back
38 expectTypeOf(line).toBe<Uint8Array>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 39–41why, one step back
39 }
4041 for await (const line of bufferSubprocess.iterable({binary: true})) {

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 42why, one step back
42 expectTypeOf(line).toBe<Uint8Array>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 43–45why, one step back
43 }
4445 for await (const line of bufferSubprocess.iterable({} as {binary: boolean})) {

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

line 46why, one step back
46 expectTypeOf(line).toBe<Uint8Array>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 47–51why, one step back
47 }
48};4950await asyncIteration();51

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

lines 52–55why, one step back
52expectTypeOf(subprocess.iterable()).toBe<AsyncIterableIterator<string>>();
53expectTypeOf(subprocess.iterable({binary: false})).toBe<AsyncIterableIterator<string>>();54expectTypeOf(subprocess.iterable({binary: true})).toBe<AsyncIterableIterator<Uint8Array>>();55expectTypeOf(subprocess.iterable({} as {binary: boolean})).toBe<AsyncIterableIterator<string | Uint8Array>>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 56why, one step back
56

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

lines 57–60why, one step back
57expectTypeOf(bufferSubprocess.iterable()).toBe<AsyncIterableIterator<Uint8Array>>();
58expectTypeOf(bufferSubprocess.iterable({binary: false})).toBe<AsyncIterableIterator<Uint8Array>>();59expectTypeOf(bufferSubprocess.iterable({binary: true})).toBe<AsyncIterableIterator<Uint8Array>>();60expectTypeOf(bufferSubprocess.iterable({} as {binary: boolean})).toBe<AsyncIterableIterator<Uint8Array>>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 61why, one step back
61

Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147

lines 62–65why, one step back
62expectTypeOf(hexSubprocess.iterable()).toBe<AsyncIterableIterator<Uint8Array>>();
63expectTypeOf(hexSubprocess.iterable({binary: false})).toBe<AsyncIterableIterator<Uint8Array>>();64expectTypeOf(hexSubprocess.iterable({binary: true})).toBe<AsyncIterableIterator<Uint8Array>>();65expectTypeOf(hexSubprocess.iterable({} as {binary: boolean})).toBe<AsyncIterableIterator<Uint8Array>>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 66–71why, one step back
66
67subprocess.iterable({});68subprocess.iterable({from: 'stdout'});69subprocess.iterable({from: 'stderr'});70subprocess.iterable({from: 'all'});71subprocess.iterable({from: 'fd3'});

Add more type tests (#1117)ehmickybefore adoption077749d

line 72why, one step back
72expectError(subprocess.iterable({from: 'fd3' as string}));

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 73–85why, one step back
73expectError(subprocess.iterable({from: 'stdin'}));
74expectError(subprocess.iterable({from: 'fd'}));75expectError(subprocess.iterable({from: 'fdNotANumber'}));76expectError(subprocess.iterable({to: 'stdin'}));7778subprocess.iterable({binary: false});79expectError(subprocess.iterable({binary: 'false'}));8081subprocess.iterable({preserveNewlines: false});82expectError(subprocess.iterable({preserveNewlines: 'false'}));8384expectError(subprocess.iterable('stdout'));85expectError(subprocess.iterable({other: 'stdout'}));