-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReadable.test.js
More file actions
30 lines (24 loc) · 788 Bytes
/
Copy pathReadable.test.js
File metadata and controls
30 lines (24 loc) · 788 Bytes
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
const Test = require('thunk-test')
const assert = require('assert')
const stream = require('stream')
const Readable = require('./Readable')
const test1 =
new Test('Readable', Readable.Buffer)
.case(stream.Readable.from([Buffer.from('abc')]), Buffer.from('abc'))
.case(stream.Readable.from(['abc']), Buffer.from('abc'))
const test2 =
new Test('Readable', Readable.Text)
.case(stream.Readable.from(['abc']), 'abc')
const test3 =
new Test('Readable', Readable.JSON)
.case(stream.Readable.from([JSON.stringify({ a: 1 })]), { a: 1 })
.throws(stream.Readable.from(['s']), new SyntaxError('Unexpected token \'s\', "s" is not valid JSON'))
const test = Test.all([
test1,
test2,
test3,
])
if (process.argv[1] == __filename) {
test()
}
module.exports = test