Skip to content
Myr

script.test-d.ts

This file

Path

test-d/methods/script.test-d.ts

64 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 {$, type Result, type ResultPromise} from '../../index.js';
34const fileUrl = new URL('file:///test');5const stringArray = ['foo', 'bar'] as const;67expectError($());8expectError($(true));9expectError($(['unicorns', 'arg']));

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

lines 10–11why, one step back
10expectTypeOf($('unicorns')).toBeAssignableTo<ResultPromise>();
11expectTypeOf($(fileUrl)).toBeAssignableTo<ResultPromise>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 12why, one step back
12

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

lines 13–14why, one step back
13expectTypeOf($('unicorns', [])).toBeAssignableTo<ResultPromise>();
14expectTypeOf($('unicorns', ['foo'])).toBeAssignableTo<ResultPromise>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 15–17why, one step back
15expectError($('unicorns', 'foo'));
16expectError($('unicorns', [true]));17

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

lines 18–19why, one step back
18expectTypeOf($('unicorns', {})).toBeAssignableTo<ResultPromise>();
19expectTypeOf($('unicorns', [], {})).toBeAssignableTo<ResultPromise>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 20–22why, one step back
20expectError($('unicorns', [], []));
21expectError($('unicorns', {other: true}));22

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

lines 23–25why, one step back
23expectTypeOf($`unicorns`).toBeAssignableTo<ResultPromise>();
24expectTypeOf(await $('unicorns')).toBe<Result<{}>>();25expectTypeOf(await $`unicorns`).toBe<Result<{}>>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 26why, one step back
26

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

lines 27–29why, one step back
27expectTypeOf($({})).toBeAssignableTo<typeof $>();
28expectTypeOf($({})('unicorns')).toBeAssignableTo<ResultPromise>();29expectTypeOf($({})`unicorns`).toBeAssignableTo<ResultPromise>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 30why, one step back
30

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

lines 31–42why, one step back
31expectTypeOf(await $('unicorns')).toBeAssignableTo<{stdout: string}>();
32expectTypeOf(await $('unicorns', {encoding: 'buffer'})).toBeAssignableTo<{stdout: Uint8Array}>();33expectTypeOf(await $('unicorns', ['foo'])).toBeAssignableTo<{stdout: string}>();34expectTypeOf(await $('unicorns', ['foo'], {encoding: 'buffer'})).toBeAssignableTo<{stdout: Uint8Array}>();35expectTypeOf(await $({})('unicorns')).toBeAssignableTo<{stdout: string}>();36expectTypeOf(await $({encoding: 'buffer'})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();37expectTypeOf(await $({})({encoding: 'buffer'})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();38expectTypeOf(await $({encoding: 'buffer'})({})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();39expectTypeOf(await $({})`unicorns`).toBeAssignableTo<{stdout: string}>();40expectTypeOf(await $({encoding: 'buffer'})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();41expectTypeOf(await $({})({encoding: 'buffer'})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();42expectTypeOf(await $({encoding: 'buffer'})({})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 43why, one step back
43

Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8

lines 44–50why, one step back
44const uint8ArrayGenerator = function * (chunk: Uint8Array) {
45 yield chunk;46};4748expectError($({encoding: 'utf8', stdout: uint8ArrayGenerator}));49$({encoding: 'buffer', stdout: uint8ArrayGenerator});50

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

lines 51–57why, one step back
51expectTypeOf(await $`${'unicorns'}`).toBe<Result<{}>>();
52expectTypeOf(await $`unicorns ${'foo'}`).toBe<Result<{}>>();53expectTypeOf(await $`unicorns ${'foo'} ${'bar'}`).toBe<Result<{}>>();54expectTypeOf(await $`unicorns ${1}`).toBe<Result<{}>>();55expectTypeOf(await $`unicorns ${stringArray}`).toBe<Result<{}>>();56expectTypeOf(await $`unicorns ${[1, 2]}`).toBe<Result<{}>>();57expectTypeOf(await $`unicorns ${false.toString()}`).toBe<Result<{}>>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 58–59why, one step back
58expectError(await $`unicorns ${false}`);
59

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

lines 60–61why, one step back
60expectTypeOf(await $`unicorns ${await $`echo foo`}`).toBe<Result<{}>>();
61expectTypeOf(await $`unicorns ${await $({reject: false})`echo foo`}`).toBe<Result<{}>>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 62why, one step back
62expectError(await $`unicorns ${$`echo foo`}`);

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

line 63why, one step back
63expectTypeOf(await $`unicorns ${[await $`echo foo`, 'bar']}`).toBe<Result<{}>>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 64why, one step back
64expectError(await $`unicorns ${[$`echo foo`, 'bar']}`);