script-sync.test-d.ts
This file
Path
test-d/methods/script-sync.test-d.ts
65 lines · 3.8 KiB · TypeScript
Last changed by
Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
History of this fileTake 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 back1import {expectTypeOf, expectError} from 'nz';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 2–9why, one step back2import {$, type SyncResult} from '../../index.js';34const fileUrl = new URL('file:///test');5const stringArray = ['foo', 'bar'] as const;67expectError($.sync());8expectError($.sync(true));9expectError($.sync(['unicorns', 'arg']));Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 10–11why, one step back10expectTypeOf($.sync('unicorns')).toBe<SyncResult<{}>>();11expectTypeOf($.sync(fileUrl)).toBe<SyncResult<{}>>();100% test coverage (#1018)ehmickybefore adoption9f65b86
line 12why, one step back12Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 13–14why, one step back13expectTypeOf($.sync('unicorns', [])).toBe<SyncResult<{}>>();14expectTypeOf($.sync('unicorns', ['foo'])).toBe<SyncResult<{}>>();100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 15–17why, one step back15expectError($.sync('unicorns', 'foo'));16expectError($.sync('unicorns', [true]));17Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 18–19why, one step back18expectTypeOf($.sync('unicorns', {})).toBe<SyncResult<{}>>();19expectTypeOf($.sync('unicorns', [], {})).toBe<SyncResult<{}>>();100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 20–22why, one step back20expectError($.sync('unicorns', [], []));21expectError($.sync('unicorns', {other: true}));22Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 23–25why, one step back23expectTypeOf($.sync`unicorns`).toBe<SyncResult<{}>>();24expectTypeOf($.sync('unicorns')).toBe<SyncResult<{}>>();25expectTypeOf($.sync`unicorns`).toBe<SyncResult<{}>>();100% test coverage (#1018)ehmickybefore adoption9f65b86
line 26why, one step back26Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 27–31why, one step back27expectTypeOf($.sync({})).toBeAssignableTo<typeof $.sync>();28expectTypeOf($.sync({})('unicorns')).toBe<SyncResult<{}>>();29expectTypeOf($({}).sync('unicorns')).toBe<SyncResult<{}>>();30expectTypeOf($.sync({})`unicorns`).toBe<SyncResult<{}>>();31expectTypeOf($({}).sync`unicorns`).toBe<SyncResult<{}>>();100% test coverage (#1018)ehmickybefore adoption9f65b86
line 32why, one step back32Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 33–52why, one step back33expectTypeOf($.sync('unicorns')).toBeAssignableTo<{stdout: string}>();34expectTypeOf($.sync('unicorns', {encoding: 'buffer'})).toBeAssignableTo<{stdout: Uint8Array}>();35expectTypeOf($.sync('unicorns', ['foo'])).toBeAssignableTo<{stdout: string}>();36expectTypeOf($.sync('unicorns', ['foo'], {encoding: 'buffer'})).toBeAssignableTo<{stdout: Uint8Array}>();37expectTypeOf($.sync({})('unicorns')).toBeAssignableTo<{stdout: string}>();38expectTypeOf($({}).sync('unicorns')).toBeAssignableTo<{stdout: string}>();39expectTypeOf($.sync({encoding: 'buffer'})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();40expectTypeOf($({encoding: 'buffer'}).sync('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();41expectTypeOf($.sync({})({encoding: 'buffer'})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();42expectTypeOf($({})({encoding: 'buffer'}).sync('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();43expectTypeOf($.sync({encoding: 'buffer'})({})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();44expectTypeOf($({encoding: 'buffer'}).sync({})('unicorns')).toBeAssignableTo<{stdout: Uint8Array}>();45expectTypeOf($.sync({})`unicorns`).toBeAssignableTo<{stdout: string}>();46expectTypeOf($({}).sync`unicorns`).toBeAssignableTo<{stdout: string}>();47expectTypeOf($.sync({encoding: 'buffer'})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();48expectTypeOf($({encoding: 'buffer'}).sync`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();49expectTypeOf($.sync({})({encoding: 'buffer'})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();50expectTypeOf($({})({encoding: 'buffer'}).sync`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();51expectTypeOf($.sync({encoding: 'buffer'})({})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();52expectTypeOf($({encoding: 'buffer'}).sync({})`unicorns`).toBeAssignableTo<{stdout: Uint8Array}>();100% test coverage (#1018)ehmickybefore adoption9f65b86
line 53why, one step back53Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 54–60why, one step back54expectTypeOf($.sync`${'unicorns'}`).toBe<SyncResult<{}>>();55expectTypeOf($.sync`unicorns ${'foo'}`).toBe<SyncResult<{}>>();56expectTypeOf($.sync`unicorns ${'foo'} ${'bar'}`).toBe<SyncResult<{}>>();57expectTypeOf($.sync`unicorns ${1}`).toBe<SyncResult<{}>>();58expectTypeOf($.sync`unicorns ${stringArray}`).toBe<SyncResult<{}>>();59expectTypeOf($.sync`unicorns ${[1, 2]}`).toBe<SyncResult<{}>>();60expectTypeOf($.sync`unicorns ${false.toString()}`).toBe<SyncResult<{}>>();100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 61–62why, one step back61expectError($.sync`unicorns ${false}`);62Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 63–65why, one step back63expectTypeOf($.sync`unicorns ${$.sync`echo foo`}`).toBe<SyncResult<{}>>();64expectTypeOf($.sync`unicorns ${$.sync({reject: false})`echo foo`}`).toBe<SyncResult<{}>>();65expectTypeOf($.sync`unicorns ${[$.sync`echo foo`, 'bar']}`).toBe<SyncResult<{}>>();