mirror of https://github.com/lukechilds/node.git
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.
29 lines
755 B
29 lines
755 B
var concat = require('../')
|
|
var test = require('tape')
|
|
|
|
test('writing objects', function (t) {
|
|
var stream = concat({encoding: "objects"}, concatted)
|
|
function concatted(objs) {
|
|
t.equal(objs.length, 2)
|
|
t.deepEqual(objs[0], {"foo": "bar"})
|
|
t.deepEqual(objs[1], {"baz": "taco"})
|
|
}
|
|
stream.write({"foo": "bar"})
|
|
stream.write({"baz": "taco"})
|
|
stream.end()
|
|
t.end()
|
|
})
|
|
|
|
|
|
test('switch to objects encoding if no encoding specified and objects are written', function (t) {
|
|
var stream = concat(concatted)
|
|
function concatted(objs) {
|
|
t.equal(objs.length, 2)
|
|
t.deepEqual(objs[0], {"foo": "bar"})
|
|
t.deepEqual(objs[1], {"baz": "taco"})
|
|
}
|
|
stream.write({"foo": "bar"})
|
|
stream.write({"baz": "taco"})
|
|
stream.end()
|
|
t.end()
|
|
})
|
|
|