Skip to content

Commit

Permalink
Add tests for adopt and free item hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed Aug 7, 2015
1 parent d262593 commit 4b9f37f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/unit/utils/linked-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ test('initial state', (assert) => {
assert.equal(item.next, null, 'item next is null');
assert.equal(item.prev, null, 'item prev is null');
});

test(`#${method} call adoptItem`, (assert) => {
let adoptedItem;
let list = new LinkedList({
adoptItem(item) {
adoptedItem = item;
}
});
let item = new LinkedItem();
list[method](item);
assert.equal(adoptedItem, item, 'item is adopted');
});
});

test(`#append second item`, (assert) => {
Expand Down Expand Up @@ -98,6 +110,19 @@ test(`#remove an only item`, (assert) => {
assert.equal(item.next, null, 'item next is null');
});

test(`#remove calls freeItem`, (assert) => {
let freedItem;
let list = new LinkedList({
freeItem(item) {
freedItem = item;
}
});
let item = new LinkedItem();
list.append(item);
list.remove(item);
assert.equal(freedItem, item, 'item is freed');
});

test(`#remove a first item`, (assert) => {
let list = new LinkedList();
let itemOne = new LinkedItem();
Expand Down

0 comments on commit 4b9f37f

Please sign in to comment.