Skip to content

Commit 1de9c7f

Browse files
vladfranguaduh95
andcommitted
chore: use forEach and assert based on error code
Co-authored-by: Antoine du Hamel <[email protected]>
1 parent f7015a0 commit 1de9c7f

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

test/pseudo-tty/test-os-guessFileDescriptorType.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@ strictEqual(guessFileDescriptorType(2), 'TTY', 'stderr reported to not be a tty,
1111
strictEqual(guessFileDescriptorType(55555), 'UNKNOWN', '55555 reported to be a handle, but it is not');
1212
strictEqual(guessFileDescriptorType(2 ** 31 - 1), 'UNKNOWN', '2^31-1 reported to be a handle, but it is not');
1313

14-
throws(() => guessFileDescriptorType(-1), /"fd" must be a positive integer/, '-1 reported to be a handle, but it is not');
15-
throws(() => guessFileDescriptorType(1.1), /"fd" must be a positive integer/, '1.1 reported to be a handle, but it is not');
16-
throws(() => guessFileDescriptorType('1'), /"fd" must be a positive integer/, '\'1\' reported to be a tty, but it is not');
17-
throws(() => guessFileDescriptorType({}), /"fd" must be a positive integer/, '{} reported to be a tty, but it is not');
18-
throws(() => guessFileDescriptorType(() => {}), /"fd" must be a positive integer/, '() => {} reported to be a tty, but it is not');
19-
throws(() => guessFileDescriptorType(2 ** 31), /"fd" must be a positive integer/, '2^31 reported to be a handle, but it is not (because the fd check rolls over the input to negative of it)');
14+
[
15+
-1,
16+
1.1,
17+
'1',
18+
[],
19+
{},
20+
() => {},
21+
2 ** 31,
22+
true,
23+
false,
24+
1n,
25+
Symbol(),
26+
undefined,
27+
null,
28+
].forEach((val) => throws(() => guessFileDescriptorType(val), { code: 'ERR_INVALID_FD' }));

0 commit comments

Comments
 (0)