rafa
Version:
Rafa.js is a Javascript framework for building concurrent applications.
53 lines (47 loc) • 1.38 kB
JavaScript
module.exports = (assert, Rafa) => {
suite("detach", () => {
test("root node", () => {
Rafa.stream().detach();
});
test("remove single head node", () => {
var root = Rafa.stream();
var stream = root.each(Rafa.noop);
stream.detach();
assert.isNull(root.child);
});
test("remove head node", () => {
var root = Rafa.stream();
var tail = root.each(Rafa.noop);
var head = root.each(Rafa.noop);
head.detach();
assert.equal(tail.prev, null);
assert.equal(tail.next, null);
assert.equal(root.child, tail);
});
test("remove tail node", () => {
var root = Rafa.stream();
var tail = root.each(Rafa.noop);
var head = root.each(Rafa.noop);
tail.detach();
assert.equal(head.next, null);
assert.equal(root.child, head);
});
test("remove mid node", () => {
var root = Rafa.stream();
var tail = root.each(Rafa.noop);
var mid = root.each(Rafa.noop);
var head = root.each(Rafa.noop);
mid.detach();
assert.equal(head.next, tail);
assert.equal(tail.prev, head);
assert.equal(root.child, head);
});
test("call destroy", () => {
var stream = Rafa.stream();
var called;
stream.destroy = () => called = true;
stream.detach();
assert.ok(called);
});
});
};