generator-object.test-d.ts
This file
Path
test-d/stdio/option/generator-object.test-d.ts
46 lines · 1.8 KiB · TypeScript
Last changed by
Move type tests from `tsd` to `nz`Sindre Sorhusbefore adoption2141147
History of this fileTake it
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import {expectTypeOf, expectError} from 'nz';import { execa, execaSync, type StdinOption, type StdinSyncOption, type StdoutStderrOption, type StdoutStderrSyncOption,} from '../../../index.js';
const objectGenerator = function * (line: unknown) { yield JSON.parse(line as string) as object;};
await execa('unicorns', {stdin: objectGenerator});execaSync('unicorns', {stdin: objectGenerator});await execa('unicorns', {stdin: [objectGenerator]});execaSync('unicorns', {stdin: [objectGenerator]});
await execa('unicorns', {stdout: objectGenerator});execaSync('unicorns', {stdout: objectGenerator});await execa('unicorns', {stdout: [objectGenerator]});execaSync('unicorns', {stdout: [objectGenerator]});
await execa('unicorns', {stderr: objectGenerator});execaSync('unicorns', {stderr: objectGenerator});await execa('unicorns', {stderr: [objectGenerator]});execaSync('unicorns', {stderr: [objectGenerator]});
expectError(await execa('unicorns', {stdio: objectGenerator}));expectError(execaSync('unicorns', {stdio: objectGenerator}));
await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGenerator]});execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGenerator]});await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGenerator]]});execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGenerator]]});
expectTypeOf(objectGenerator).toBeAssignableTo<StdinOption>();expectTypeOf(objectGenerator).toBeAssignableTo<StdinSyncOption>();[objectGenerator] satisfies StdinOption;[objectGenerator] satisfies StdinSyncOption;
expectTypeOf(objectGenerator).toBeAssignableTo<StdoutStderrOption>();expectTypeOf(objectGenerator).toBeAssignableTo<StdoutStderrSyncOption>();[objectGenerator] satisfies StdoutStderrOption;[objectGenerator] satisfies StdoutStderrSyncOption;