-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
42 lines (36 loc) · 796 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import test from 'ava';
import m from '.';
const getStream = require('get-stream');
const objects = [
{
name: 'Foo',
value: 1
},
{
name: 'Bar',
value: 2
},
{
name: 'Foobar',
value: 3
}
];
test('should fail due to invalid arguments', t => {
const someFunction = item => console.log(item);
const badArray1 = ['bla', 1];
const badArray2 = [{name: 'Smart Object', do: someFunction}];
t.throws(() => m(badArray1), Error);
t.throws(() => m(badArray2), Error);
});
test('should return a readstream of ndjson qualified objects', async t => {
const arrayStream = m(objects);
const result = await getStream.array(arrayStream);
t.deepEqual(result, [
'{"name":"Foo","value":1}',
'\n',
'{"name":"Bar","value":2}',
'\n',
'{"name":"Foobar","value":3}',
'\n'
]);
});