-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
test.active_tasks.js
64 lines (56 loc) · 2.17 KB
/
test.active_tasks.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict';
describe('test.active_tasks.js', function () {
afterEach(function (done) {
PouchDB.activeTasks.tasks = []
return done();
});
it('Can add a task', function () {
const task1 = {name: 'lol', total_items: 12}
const id1 = PouchDB.activeTasks.add(task1)
id1.should.be.a('string')
});
it('Can get tasks by id', function () {
const task2 = {name: 'wat', total_items: 546}
const id2 = PouchDB.activeTasks.add(task2)
const got2 = PouchDB.activeTasks.get(id2)
got2['id'].should.equal(id2)
});
it('Can get all tasks', function () {
const task1 = {name: 'lol', total_items: 12}
const task2 = {name: 'wat', total_items: 546}
const id1 = PouchDB.activeTasks.add(task1)
const id2 = PouchDB.activeTasks.add(task2)
PouchDB.activeTasks.update(id1, {"completed_items": 2})
PouchDB.activeTasks.update(id2, {"completed_items": 213})
const list = PouchDB.activeTasks.list()
const got2 = PouchDB.activeTasks.get(id2)
list.length.should.equal(2)
list[0]['id'].should.equal(id1)
list[1]['id'].should.equal(id2)
});
it('Can update a task', function () {
const task1 = {name: 'lol', total_items: 12}
const task2 = {name: 'wat', total_items: 546}
const id1 = PouchDB.activeTasks.add(task1)
const id2 = PouchDB.activeTasks.add(task2)
PouchDB.activeTasks.update(id1, {"completed_items": 2})
PouchDB.activeTasks.update(id2, {"completed_items": 213})
const got1 = PouchDB.activeTasks.get(id1)
const got2 = PouchDB.activeTasks.get(id2)
got1['completed_items'].should.equal(2)
got2['completed_items'].should.equal(213)
got2['updatedAt'].should.be.a('string')
});
it('Can remove a task', function () {
const task1 = {name: 'lol', total_items: 12}
const task2 = {name: 'wat', total_items: 546}
const id1 = PouchDB.activeTasks.add(task1)
const id2 = PouchDB.activeTasks.add(task2)
PouchDB.activeTasks.update(id1, {"completed_items": 2})
PouchDB.activeTasks.update(id2, {"completed_items": 213})
PouchDB.activeTasks.remove(id1)
const got2 = PouchDB.activeTasks.get(id2)
PouchDB.activeTasks.tasks.length.should.equal(1)
got2['id'].should.equal(id2)
});
});