Skip to content

Commit

Permalink
isEmpty for linked list
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed Aug 11, 2015
1 parent 462d9a7 commit 3dceea4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/js/models/markup-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default class Section extends LinkedItem {
this.markers.remove(m);
}
});
if (this.markers.empty()) {
if (this.markers.isEmpty) {
this.markers.append(this.builder.createBlankMarker());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/utils/linked-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class LinkedList {
this.freeItem = freeItem;
}
}
empty() {
get isEmpty() {
return this.length === 0;
}
prepend(item) {
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/utils/linked-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test('initial state', (assert) => {
assert.equal(list.head, null, 'head is null');
assert.equal(list.tail, null ,'tail is null');
assert.equal(list.length, 0, 'length is one');
assert.equal(list.isEmpty, true, 'isEmpty is true');
});

['append', 'prepend', 'insertBefore', 'insertAfter'].forEach(method => {
Expand All @@ -18,6 +19,7 @@ test('initial state', (assert) => {
let item = new LinkedItem();
list[method](item);
assert.equal(list.length, 1, 'length is one');
assert.equal(list.isEmpty, false, 'isEmpty is false');
assert.equal(list.head, item, 'head is item');
assert.equal(list.tail, item, 'tail is item');
assert.equal(item.next, null, 'item next is null');
Expand Down Expand Up @@ -132,6 +134,7 @@ test(`#remove an only item`, (assert) => {
list.append(item);
list.remove(item);
assert.equal(list.length, 0, 'length is zero');
assert.equal(list.isEmpty, true, 'isEmpty is true');
assert.equal(list.head, null, 'head is null');
assert.equal(list.tail, null, 'tail is null');
assert.equal(item.prev, null, 'item prev is null');
Expand Down

0 comments on commit 3dceea4

Please sign in to comment.