Skip to content

Commit 50a3d72

Browse files
committed
Split test file
1 parent 802b4c5 commit 50a3d72

File tree

2 files changed

+64
-56
lines changed

2 files changed

+64
-56
lines changed

test/stdio/type-invalid.js

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

test/stdio/type.js renamed to test/stdio/type-undefined.js

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,14 @@
11
import test from 'ava';
22
import {execa, execaSync} from '../../index.js';
33
import {getStdio} from '../helpers/stdio.js';
4-
import {noopGenerator, uppercaseGenerator} from '../helpers/generator.js';
4+
import {uppercaseGenerator} from '../helpers/generator.js';
55
import {uppercaseBufferDuplex} from '../helpers/duplex.js';
66
import {uppercaseBufferWebTransform} from '../helpers/web-transform.js';
77
import {generatorsMap} from '../helpers/map.js';
88
import {setFixtureDirectory} from '../helpers/fixtures-directory.js';
99

1010
setFixtureDirectory();
1111

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-
6712
// eslint-disable-next-line max-params
6813
const testUndefinedOption = (t, fdNumber, optionName, type, optionValue) => {
6914
t.throws(() => {

0 commit comments

Comments
 (0)