blob: 9a2da0e100167980ac5b9115ca459c803cb4bfcd (
plain)
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
|
var test = require('tape')
var ldj = require('./')
var os = require('os')
test('.parse', function(t) {
var parser = ldj.parse()
parser.on('data', function(obj) {
t.equal(obj.hello, 'world')
t.end()
})
parser.write('{"hello": "world"}\n')
})
test('.parse twice', function(t) {
var parser = ldj.parse()
parser.once('data', function(obj) {
t.equal(obj.hello, 'world')
parser.once('data', function(obj) {
t.equal(obj.hola, 'mundo')
t.end()
})
})
parser.write('{"hello": "world"}\n{"hola": "mundo"}\n')
})
test('.serialize', function(t) {
var serializer = ldj.serialize()
serializer.on('data', function(data) {
t.equal(data, '{"hello":"world"}' + os.EOL)
t.end()
})
serializer.write({hello: 'world'})
})
|