Skip to content
Myr

script-s.test-d.ts

This file

Path

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

65 lines · 3.6 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 SyncResult} from '../../index.js';
34const fileUrl = new URL('file:///test');5const stringArray = ['foo', 'bar'] as const;67expectError($.s());8expectError($.s(true));9expectError($.s(['unicorns', 'arg']));

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

lines 10–11why, one step back
10expectTypeOf($.s('unicorns')).toBe<SyncResult<{}>>();
11expectTypeOf($.s(fileUrl)).toBe<SyncResult<{}>>();

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($.s('unicorns', [])).toBe<SyncResult<{}>>();
14expectTypeOf($.s('unicorns', ['foo'])).toBe<SyncResult<{}>>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

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

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

100% test coverage (#1018)ehmickybefore adoption9f65b86

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

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

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

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 26why, one step back
26

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

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

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 32why, one step back
32

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

lines 33–52why, one step back
33expectTypeOf($.s('unicorns')).toBeAssignableTo<{stdout: string}>();
34expectTypeOf($.s('unicorns', {encoding: 'buffer'})).toBeAssignableTo<{stdout: Uint8Array}>();35expectTypeOf($.s('unicorns', ['foo'])).toBeAssignableTo<{stdout: string}>();36expectTypeOf($.s('unicorns', ['foo'], {encoding: 'buffer'})).toBeAssignableTo<{stdout: Uint8Array}>();37expectTypeOf($.s({})('unicorns')).toBeAssignableTo<{stdout: string}>();38expectTypeOf($({}).s('unicorns')).toBeAssignableTo<{stdout: string}>();39expectTypeOf($.s({encoding: 'buffer'})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();40expectTypeOf($({encoding: 'buffer'}).s('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();41expectTypeOf($.s({})({encoding: 'buffer'})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();42expectTypeOf($({})({encoding: 'buffer'}).s('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();43expectTypeOf($.s({encoding: 'buffer'})({})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();44expectTypeOf($({encoding: 'buffer'}).s({})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();45expectTypeOf($.s({})`unicorns`).toBeAssignableTo<{stdout: string}>();46expectTypeOf($({}).s`unicorns`).toBeAssignableTo<{stdout: string}>();47expectTypeOf($.s({encoding: 'buffer'})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();48expectTypeOf($({encoding: 'buffer'}).s`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();49expectTypeOf($.s({})({encoding: 'buffer'})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();50expectTypeOf($({})({encoding: 'buffer'}).s`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();51expectTypeOf($.s({encoding: 'buffer'})({})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();52expectTypeOf($({encoding: 'buffer'}).s({})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 53why, one step back
53

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

lines 54–60why, one step back
54expectTypeOf($.s`${'unicorns'}`).toBe<SyncResult<{}>>();
55expectTypeOf($.s`unicorns ${'foo'}`).toBe<SyncResult<{}>>();56expectTypeOf($.s`unicorns ${'foo'} ${'bar'}`).toBe<SyncResult<{}>>();57expectTypeOf($.s`unicorns ${1}`).toBe<SyncResult<{}>>();58expectTypeOf($.s`unicorns ${stringArray}`).toBe<SyncResult<{}>>();59expectTypeOf($.s`unicorns ${[1, 2]}`).toBe<SyncResult<{}>>();60expectTypeOf($.s`unicorns ${false.toString()}`).toBe<SyncResult<{}>>();

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 61–62why, one step back
61expectError($.s`unicorns ${false}`);
62

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

lines 63–65why, one step back
63expectTypeOf($.s`unicorns ${$.s`echo foo`}`).toBe<SyncResult<{}>>();
64expectTypeOf($.s`unicorns ${$.s({reject: false})`echo foo`}`).toBe<SyncResult<{}>>();65expectTypeOf($.s`unicorns ${[$.s`echo foo`, 'bar']}`).toBe<SyncResult<{}>>();