result-main.test-d.ts
This file
Path
test-d/return/result-main.test-d.ts
104 lines · 5.1 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.
Avoid using NodeJS global type (#1032)ehmickybefore adoption398d090
line 1why, one step back1import type {SignalConstants} from 'node:os';Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
line 2why, one step back2import {expectTypeOf} from 'nz';100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 3–12why, one step back3import {4 execa,5 execaSync,6 ExecaError,7 ExecaSyncError,8 type Result,9 type SyncResult,10} from '../../index.js';1112type AnyChunk = string | Uint8Array | string[] | unknown[] | undefined;Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 13–20why, one step back13expectTypeOf<Result['stdout']>().toBe<AnyChunk>();14expectTypeOf<Result['stderr']>().toBe<AnyChunk>();15expectTypeOf<Result['all']>().toBe<AnyChunk>();16expectTypeOf<Result['stdio']>().toBeAssignableTo<[undefined, AnyChunk, AnyChunk, ...AnyChunk[]]>();17expectTypeOf<SyncResult['stdout']>().toBe<AnyChunk>();18expectTypeOf<SyncResult['stderr']>().toBe<AnyChunk>();19expectTypeOf<SyncResult['all']>().toBe<AnyChunk>();20expectTypeOf<SyncResult['stdio']>().toBeAssignableTo<[undefined, AnyChunk, AnyChunk, ...AnyChunk[]]>();100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 21–22why, one step back2122const unicornsResult = await execa('unicorns', {all: true});Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 23–38why, one step back23expectTypeOf(unicornsResult).toBeAssignableTo<Result>();24expectTypeOf(unicornsResult.command).toBe<string>();25expectTypeOf(unicornsResult.escapedCommand).toBe<string>();26expectTypeOf(unicornsResult.exitCode).toBe<number | undefined>();27expectTypeOf(unicornsResult.failed).toBe<boolean>();28expectTypeOf(unicornsResult.timedOut).toBe<boolean>();29expectTypeOf(unicornsResult.isCanceled).toBe<boolean>();30expectTypeOf(unicornsResult.isGracefullyCanceled).toBe<boolean>();31expectTypeOf(unicornsResult.isTerminated).toBe<boolean>();32expectTypeOf(unicornsResult.isMaxBuffer).toBe<boolean>();33expectTypeOf(unicornsResult.isForcefullyTerminated).toBe<boolean>();34expectTypeOf(unicornsResult.signal).toBe<keyof SignalConstants | undefined>();35expectTypeOf(unicornsResult.signalDescription).toBe<string | undefined>();36expectTypeOf(unicornsResult.cwd).toBe<string>();37expectTypeOf(unicornsResult.durationMs).toBe<number>();38expectTypeOf(unicornsResult.pipedFrom).toBe<Array<Result | ExecaError>>();100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 39–40why, one step back3940const unicornsResultSync = execaSync('unicorns', {all: true});Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 41–56why, one step back41expectTypeOf(unicornsResultSync).toBeAssignableTo<SyncResult>();42expectTypeOf(unicornsResultSync.command).toBe<string>();43expectTypeOf(unicornsResultSync.escapedCommand).toBe<string>();44expectTypeOf(unicornsResultSync.exitCode).toBe<number | undefined>();45expectTypeOf(unicornsResultSync.failed).toBe<boolean>();46expectTypeOf(unicornsResultSync.timedOut).toBe<boolean>();47expectTypeOf(unicornsResultSync.isCanceled).toBe<boolean>();48expectTypeOf(unicornsResultSync.isGracefullyCanceled).toBe<boolean>();49expectTypeOf(unicornsResultSync.isTerminated).toBe<boolean>();50expectTypeOf(unicornsResultSync.isMaxBuffer).toBe<boolean>();51expectTypeOf(unicornsResultSync.isForcefullyTerminated).toBe<boolean>();52expectTypeOf(unicornsResultSync.signal).toBe<keyof SignalConstants | undefined>();53expectTypeOf(unicornsResultSync.signalDescription).toBe<string | undefined>();54expectTypeOf(unicornsResultSync.cwd).toBe<string>();55expectTypeOf(unicornsResultSync.durationMs).toBe<number>();56expectTypeOf(unicornsResultSync.pipedFrom).toBe<[]>();100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 57–59why, one step back5758const error = new Error('.');59if (error instanceof ExecaError) {Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 60–79why, one step back60 expectTypeOf(error).toBe<ExecaError<any>>();61 expectTypeOf(error.name).toBe<'ExecaError'>();62 expectTypeOf(error.message).toBe<string>();63 expectTypeOf(error.exitCode).toBe<number | undefined>();64 expectTypeOf(error.failed).toBe<boolean>();65 expectTypeOf(error.timedOut).toBe<boolean>();66 expectTypeOf(error.isCanceled).toBe<boolean>();67 expectTypeOf(error.isGracefullyCanceled).toBe<boolean>();68 expectTypeOf(error.isTerminated).toBe<boolean>();69 expectTypeOf(error.isMaxBuffer).toBe<boolean>();70 expectTypeOf(error.isForcefullyTerminated).toBe<boolean>();71 expectTypeOf(error.signal).toBe<keyof SignalConstants | undefined>();72 expectTypeOf(error.signalDescription).toBe<string | undefined>();73 expectTypeOf(error.cwd).toBe<string>();74 expectTypeOf(error.durationMs).toBe<number>();75 expectTypeOf(error.shortMessage).toBe<string>();76 expectTypeOf(error.originalMessage).toBe<string>();77 expectTypeOf(error.code).toBe<string | undefined>();78 expectTypeOf(error.cause).toBe<unknown>();79 expectTypeOf(error.pipedFrom).toBe<Array<Result | ExecaError>>();100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 80–83why, one step back80}8182const errorSync = new Error('.');83if (errorSync instanceof ExecaSyncError) {Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
lines 84–103why, one step back84 expectTypeOf(errorSync).toBe<ExecaSyncError<any>>();85 expectTypeOf(errorSync.name).toBe<'ExecaSyncError'>();86 expectTypeOf(errorSync.message).toBe<string>();87 expectTypeOf(errorSync.exitCode).toBe<number | undefined>();88 expectTypeOf(errorSync.failed).toBe<boolean>();89 expectTypeOf(errorSync.timedOut).toBe<boolean>();90 expectTypeOf(errorSync.isCanceled).toBe<boolean>();91 expectTypeOf(errorSync.isGracefullyCanceled).toBe<boolean>();92 expectTypeOf(errorSync.isTerminated).toBe<boolean>();93 expectTypeOf(errorSync.isMaxBuffer).toBe<boolean>();94 expectTypeOf(errorSync.isForcefullyTerminated).toBe<boolean>();95 expectTypeOf(errorSync.signal).toBe<keyof SignalConstants | undefined>();96 expectTypeOf(errorSync.signalDescription).toBe<string | undefined>();97 expectTypeOf(errorSync.cwd).toBe<string>();98 expectTypeOf(errorSync.durationMs).toBe<number>();99 expectTypeOf(errorSync.shortMessage).toBe<string>();100 expectTypeOf(errorSync.originalMessage).toBe<string>();101 expectTypeOf(errorSync.code).toBe<string | undefined>();102 expectTypeOf(errorSync.cause).toBe<unknown>();103 expectTypeOf(errorSync.pipedFrom).toBe<[]>();100% test coverage (#1018)ehmickybefore adoption9f65b86
line 104why, one step back104}