|
1 | 1 | import test from 'ava';
|
2 | 2 | import {execa, execaSync} from '../../index.js';
|
3 | 3 | import {getStdio} from '../helpers/stdio.js';
|
4 |
| -import {noopGenerator, uppercaseGenerator} from '../helpers/generator.js'; |
| 4 | +import {uppercaseGenerator} from '../helpers/generator.js'; |
5 | 5 | import {uppercaseBufferDuplex} from '../helpers/duplex.js';
|
6 | 6 | import {uppercaseBufferWebTransform} from '../helpers/web-transform.js';
|
7 | 7 | import {generatorsMap} from '../helpers/map.js';
|
8 | 8 | import {setFixtureDirectory} from '../helpers/fixtures-directory.js';
|
9 | 9 |
|
10 | 10 | setFixtureDirectory();
|
11 | 11 |
|
12 |
| -const testInvalidGenerator = (t, fdNumber, stdioOption, execaMethod) => { |
13 |
| - t.throws(() => { |
14 |
| - execaMethod('empty.js', getStdio(fdNumber, {...noopGenerator(), ...stdioOption})); |
15 |
| - }, {message: 'final' in stdioOption ? /must be a generator/ : /must be a generator, a Duplex stream or a web TransformStream/}); |
16 |
| -}; |
17 |
| - |
18 |
| -test('Cannot use invalid "transform" with stdin', testInvalidGenerator, 0, {transform: true}, execa); |
19 |
| -test('Cannot use invalid "transform" with stdout', testInvalidGenerator, 1, {transform: true}, execa); |
20 |
| -test('Cannot use invalid "transform" with stderr', testInvalidGenerator, 2, {transform: true}, execa); |
21 |
| -test('Cannot use invalid "transform" with stdio[*]', testInvalidGenerator, 3, {transform: true}, execa); |
22 |
| -test('Cannot use invalid "final" with stdin', testInvalidGenerator, 0, {final: true}, execa); |
23 |
| -test('Cannot use invalid "final" with stdout', testInvalidGenerator, 1, {final: true}, execa); |
24 |
| -test('Cannot use invalid "final" with stderr', testInvalidGenerator, 2, {final: true}, execa); |
25 |
| -test('Cannot use invalid "final" with stdio[*]', testInvalidGenerator, 3, {final: true}, execa); |
26 |
| -test('Cannot use invalid "transform" with stdin, sync', testInvalidGenerator, 0, {transform: true}, execaSync); |
27 |
| -test('Cannot use invalid "transform" with stdout, sync', testInvalidGenerator, 1, {transform: true}, execaSync); |
28 |
| -test('Cannot use invalid "transform" with stderr, sync', testInvalidGenerator, 2, {transform: true}, execaSync); |
29 |
| -test('Cannot use invalid "transform" with stdio[*], sync', testInvalidGenerator, 3, {transform: true}, execaSync); |
30 |
| -test('Cannot use invalid "final" with stdin, sync', testInvalidGenerator, 0, {final: true}, execaSync); |
31 |
| -test('Cannot use invalid "final" with stdout, sync', testInvalidGenerator, 1, {final: true}, execaSync); |
32 |
| -test('Cannot use invalid "final" with stderr, sync', testInvalidGenerator, 2, {final: true}, execaSync); |
33 |
| -test('Cannot use invalid "final" with stdio[*], sync', testInvalidGenerator, 3, {final: true}, execaSync); |
34 |
| - |
35 |
| -// eslint-disable-next-line max-params |
36 |
| -const testInvalidBinary = (t, fdNumber, optionName, type, execaMethod) => { |
37 |
| - t.throws(() => { |
38 |
| - execaMethod('empty.js', getStdio(fdNumber, {...generatorsMap[type].uppercase(), [optionName]: 'true'})); |
39 |
| - }, {message: /a boolean/}); |
40 |
| -}; |
41 |
| - |
42 |
| -test('Cannot use invalid "binary" with stdin', testInvalidBinary, 0, 'binary', 'generator', execa); |
43 |
| -test('Cannot use invalid "binary" with stdout', testInvalidBinary, 1, 'binary', 'generator', execa); |
44 |
| -test('Cannot use invalid "binary" with stderr', testInvalidBinary, 2, 'binary', 'generator', execa); |
45 |
| -test('Cannot use invalid "binary" with stdio[*]', testInvalidBinary, 3, 'binary', 'generator', execa); |
46 |
| -test('Cannot use invalid "objectMode" with stdin, generators', testInvalidBinary, 0, 'objectMode', 'generator', execa); |
47 |
| -test('Cannot use invalid "objectMode" with stdout, generators', testInvalidBinary, 1, 'objectMode', 'generator', execa); |
48 |
| -test('Cannot use invalid "objectMode" with stderr, generators', testInvalidBinary, 2, 'objectMode', 'generator', execa); |
49 |
| -test('Cannot use invalid "objectMode" with stdio[*], generators', testInvalidBinary, 3, 'objectMode', 'generator', execa); |
50 |
| -test('Cannot use invalid "binary" with stdin, sync', testInvalidBinary, 0, 'binary', 'generator', execaSync); |
51 |
| -test('Cannot use invalid "binary" with stdout, sync', testInvalidBinary, 1, 'binary', 'generator', execaSync); |
52 |
| -test('Cannot use invalid "binary" with stderr, sync', testInvalidBinary, 2, 'binary', 'generator', execaSync); |
53 |
| -test('Cannot use invalid "binary" with stdio[*], sync', testInvalidBinary, 3, 'binary', 'generator', execaSync); |
54 |
| -test('Cannot use invalid "objectMode" with stdin, generators, sync', testInvalidBinary, 0, 'objectMode', 'generator', execaSync); |
55 |
| -test('Cannot use invalid "objectMode" with stdout, generators, sync', testInvalidBinary, 1, 'objectMode', 'generator', execaSync); |
56 |
| -test('Cannot use invalid "objectMode" with stderr, generators, sync', testInvalidBinary, 2, 'objectMode', 'generator', execaSync); |
57 |
| -test('Cannot use invalid "objectMode" with stdio[*], generators, sync', testInvalidBinary, 3, 'objectMode', 'generator', execaSync); |
58 |
| -test('Cannot use invalid "objectMode" with stdin, duplexes', testInvalidBinary, 0, 'objectMode', 'duplex', execa); |
59 |
| -test('Cannot use invalid "objectMode" with stdout, duplexes', testInvalidBinary, 1, 'objectMode', 'duplex', execa); |
60 |
| -test('Cannot use invalid "objectMode" with stderr, duplexes', testInvalidBinary, 2, 'objectMode', 'duplex', execa); |
61 |
| -test('Cannot use invalid "objectMode" with stdio[*], duplexes', testInvalidBinary, 3, 'objectMode', 'duplex', execa); |
62 |
| -test('Cannot use invalid "objectMode" with stdin, webTransforms', testInvalidBinary, 0, 'objectMode', 'webTransform', execa); |
63 |
| -test('Cannot use invalid "objectMode" with stdout, webTransforms', testInvalidBinary, 1, 'objectMode', 'webTransform', execa); |
64 |
| -test('Cannot use invalid "objectMode" with stderr, webTransforms', testInvalidBinary, 2, 'objectMode', 'webTransform', execa); |
65 |
| -test('Cannot use invalid "objectMode" with stdio[*], webTransforms', testInvalidBinary, 3, 'objectMode', 'webTransform', execa); |
66 |
| - |
67 | 12 | // eslint-disable-next-line max-params
|
68 | 13 | const testUndefinedOption = (t, fdNumber, optionName, type, optionValue) => {
|
69 | 14 | t.throws(() => {
|
|
0 commit comments