-
Notifications
You must be signed in to change notification settings - Fork 2
/
todolist_test.js
38 lines (29 loc) · 1002 Bytes
/
todolist_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
var todolist = require('./todolist');
var assert = require('assert');
var observable = require('poochie/observable');
var pub = observable.publisher;
var eq = assert.deepEqual;
(function testTodoList(){
var oTodoData = pub([]);
var oFragment = pub('/');
var todoList = todolist.todoList(oTodoData, oFragment);
oTodoData.set([{text: pub('a'), completed: pub(false)}]);
// Test 1 item in all.
oFragment.set('/');
eq(todoList.contents.get().length, 1);
// Test 1 item is active.
oFragment.set('/active');
eq(todoList.contents.get().length, 1);
// Test 0 items are completed.
oFragment.set('/completed');
eq(todoList.contents.get().length, 0);
// Test that todoList updates if an item is marked completed.
oTodoData.get()[0].completed.set(true);
eq(todoList.contents.get().length, 1);
// Test removing an item.
var removeButton = todoList.contents.get()[0];
removeButton.handlers.remove();
eq(todoList.contents.get().length, 0);
})();
module.exports = 'passed!';