You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
582 B
22 lines
582 B
9 years ago
|
import test from 'ava';
|
||
|
import bufferEquals from 'buffer-equals';
|
||
|
import fn from './';
|
||
|
|
||
|
test.serial('get stdin', async t => {
|
||
|
t.plan(2);
|
||
|
process.stdin.isTTY = false;
|
||
|
|
||
|
const promise = fn.buffer();
|
||
|
process.stdin.push(new Buffer('uni'));
|
||
|
process.stdin.push(new Buffer('corns'));
|
||
|
process.stdin.emit('end');
|
||
|
const data = await promise;
|
||
|
t.true(bufferEquals(data, new Buffer('unicorns')));
|
||
|
t.is(data.toString(), 'unicorns');
|
||
|
});
|
||
|
|
||
|
test.serial('get empty buffer when no stdin', async t => {
|
||
|
process.stdin.isTTY = true;
|
||
|
t.true(bufferEquals(await fn.buffer(), new Buffer('')));
|
||
|
});
|