forked from vojtajina/ng-todo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
todoSpec.js
59 lines (42 loc) · 1.38 KB
/
todoSpec.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
beforeEach(module('todo'));
describe('App', function() {
var scope;
beforeEach(module('mocks.Item'));
beforeEach(inject(function($controller, $rootScope) {
// store reference to scope, so that we can access it from the specs
scope = $rootScope.$new();
// instantiate the controller
$controller('App', {$scope: scope});
}));
describe('add', function() {
it('should add new task', function() {
scope.items = [];
scope.newText = 'FAKE TASK';
scope.add();
expect(scope.items.length).toBe(1);
expect(scope.items[0].text).toBe('FAKE TASK');
});
it('should reset newText', function() {
scope.newText = 'SOME TEXT';
scope.add();
expect(scope.newText).toBe('');
});
});
describe('remaining', function() {
it('should return number of tasks that are not done', function() {
scope.items = [{done: false}, {done: false}, {done: false}, {done: false}];
expect(scope.remaining()).toBe(4);
scope.items[0].done = true;
expect(scope.remaining()).toBe(3);
});
});
describe('archive', function() {
it('should remove tasks that are done', function() {
scope.items = [new MockItem({done: false}), new MockItem({done: true}), new MockItem({done: false})];
// scope.items = [{done: false}, {done: true}, {done: false}];
expect(scope.items.length).toBe(3);
scope.archive();
expect(scope.items.length).toBe(2);
});
});
});