Skip to content

Commit

Permalink
test: add test cases for input option
Browse files Browse the repository at this point in the history
  • Loading branch information
younggglcy committed Dec 16, 2023
1 parent edb75a0 commit b5fb652
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ test('input option can be a String', async t => {
t.is(stdout, 'foobar');
});

test('input option can be a Uint8Array', async t => {
const {stdout} = await execa('stdin.js', {input: Uint8Array.from('foo', c => c.codePointAt(0))});
t.is(stdout, 'foo');
});

test('input option can be a Buffer', async t => {
const {stdout} = await execa('stdin.js', {input: Buffer.from('testing12')});
t.is(stdout, 'testing12');
Expand Down Expand Up @@ -226,6 +231,11 @@ test('input option can be used with $.sync', t => {
t.is(stdout, 'foobar');
});

test('input option can be a Uint8Array - sync', t => {
const {stdout} = execaSync('stdin.js', {input: Uint8Array.from('foo', c => c.codePointAt(0))});
t.is(stdout, 'foo');
});

test('input option can be a Buffer - sync', t => {
const {stdout} = execaSync('stdin.js', {input: Buffer.from('testing12', 'utf8')});
t.is(stdout, 'testing12');
Expand Down

0 comments on commit b5fb652

Please sign in to comment.