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.
 
 
 
 
 
 

57 lines
1.2 KiB

var BlockStream = require("../")
var tap = require("tap")
tap.test("don't pad, small writes", function (t) {
var f = new BlockStream(16, { nopad: true })
t.plan(1)
f.on("data", function (c) {
t.equal(c.toString(), "abc", "should get 'abc'")
})
f.on("end", function () { t.end() })
f.write(new Buffer("a"))
f.write(new Buffer("b"))
f.write(new Buffer("c"))
f.end()
})
tap.test("don't pad, exact write", function (t) {
var f = new BlockStream(16, { nopad: true })
t.plan(1)
var first = true
f.on("data", function (c) {
if (first) {
first = false
t.equal(c.toString(), "abcdefghijklmnop", "first chunk")
} else {
t.fail("should only get one")
}
})
f.on("end", function () { t.end() })
f.end(new Buffer("abcdefghijklmnop"))
})
tap.test("don't pad, big write", function (t) {
var f = new BlockStream(16, { nopad: true })
t.plan(2)
var first = true
f.on("data", function (c) {
if (first) {
first = false
t.equal(c.toString(), "abcdefghijklmnop", "first chunk")
} else {
t.equal(c.toString(), "q")
}
})
f.on("end", function () { t.end() })
f.end(new Buffer("abcdefghijklmnopq"))
})