@@ -17,6 +17,11 @@ var sortOrder = function(a,b) {
17
17
return 0 ;
18
18
}
19
19
20
+ test ( 'Tape is up and running' , function ( t ) {
21
+ t . equal ( 1 , 1 , 'one should equal one' ) ;
22
+ t . end ( ) ;
23
+ } ) ;
24
+
20
25
test ( 'check that to do has been added' , function ( t ) {
21
26
var actual = logicFile . addTodo ( state , { description : 'fourth todo' , done : false } ) ;
22
27
var expected = [
@@ -29,52 +34,64 @@ test('check that to do has been added', function(t){
29
34
t . end ( ) ;
30
35
} ) ;
31
36
32
- test ( 'Tape is up and running' , function ( t ) {
33
- t . equal ( 1 , 1 , 'one should equal one' ) ;
34
- t . end ( ) ;
35
- } ) ;
36
37
37
38
test ( 'check that id is removed from returned array' , function ( t ) {
38
- t . deepEqual ( logicFile . deleteTodo ( state , - 3 ) , [ { id : - 2 , description : 'second todo' , done :false } , { id : - 1 , description : 'third todo' , done :false } ] , 'should return ids' ) ;
39
+ var actual = logicFile . deleteTodo ( state , - 3 ) ;
40
+ var expected = [ { id : - 2 , description : 'second todo' , done :false } , { id : - 1 , description : 'third todo' , done :false } ] ;
41
+ t . deepEqual ( actual , expected , 'should return ids' ) ;
39
42
t . end ( ) ;
40
43
} ) ;
41
44
42
45
test ( 'deleteTodo() check that passed array is not equal to the returned one' , function ( t ) {
43
- t . notEqual ( logicFile . deleteTodo ( state , - 3 ) , state , "The arrays should npt be the same" ) ;
46
+ var actual = logicFile . deleteTodo ( state , - 3 ) ;
47
+ var expected = state ;
48
+ t . notEqual ( actual , expected , "The arrays should npt be the same" ) ;
44
49
t . end ( ) ;
45
50
46
51
} ) ;
47
52
48
53
test ( 'Test if the done property is changed' , function ( t ) {
49
- t . deepEqual ( logicFile . markTodo ( state , - 3 ) , [ { id : - 3 , description : 'first todo' , done : true } ,
54
+ var actual = logicFile . markTodo ( state , - 3 ) ;
55
+ var expected = [ { id : - 3 , description : 'first todo' , done : true } ,
50
56
{ id : - 2 , description : 'second todo' , done : false } ,
51
- { id : - 1 , description : 'third todo' , done : false } ] , 'should toggle the property done for the element with id passed as argument' ) ;
57
+ { id : - 1 , description : 'third todo' , done : false } ] ;
58
+ t . deepEqual ( actual , expected , 'should toggle the property done for the element with id passed as argument' ) ;
52
59
t . end ( ) ;
53
60
} ) ;
54
61
55
62
test ( 'markTodo() check that passed array is not equal to the returned one' , function ( t ) {
56
- t . notEqual ( logicFile . markTodo ( state , - 2 ) , state , "The arrays should npt be the same" ) ;
63
+ var actual = logicFile . markTodo ( state , - 2 ) ;
64
+ var expected = state ;
65
+ t . notEqual ( actual , expected , "The arrays should npt be the same" ) ;
57
66
t . end ( ) ;
58
67
59
68
} ) ;
60
69
61
70
62
71
63
72
test ( 'check if items are sorted alphabetically by description' , function ( t ) {
64
- t . deepEqual ( logicFile . sortTodos ( state , sortOrder ) , [
73
+ var actual = logicFile . sortTodos ( state , sortOrder ) ;
74
+ var expected = [
65
75
{ id : - 3 , description : 'first todo' , done : false } ,
66
76
{ id : - 2 , description : 'second todo' , done : false } ,
67
77
{ id : - 1 , description : 'third todo' , done : false }
68
- ] , 'should have description in alphabetical order' ) ;
69
- t . deepEqual ( logicFile . sortTodos ( [
78
+ ] ;
79
+ t . deepEqual ( actual , expected , 'should have description in alphabetical order' ) ;
80
+ t . end ( ) ;
81
+ } ) ;
82
+
83
+ test ( 'check if items are sorted alphabetically by description' , function ( t ) {
84
+ var actual = logicFile . sortTodos ( [
70
85
{ id : - 2 , description : 'second todo' , done : false } ,
71
86
{ id : - 1 , description : 'third todo' , done : false } ,
72
87
{ id : - 3 , description : 'first todo' , done : false }
73
88
74
- ] , sortOrder ) , [
89
+ ] , sortOrder ) ;
90
+ var expected = [
75
91
{ id : - 3 , description : 'first todo' , done : false } ,
76
92
{ id : - 2 , description : 'second todo' , done : false } ,
77
93
{ id : - 1 , description : 'third todo' , done : false }
78
- ] , 'should have description in alphabetical order' ) ;
94
+ ] ;
95
+ t . deepEqual ( actual , expected , 'should have description in alphabetical order' ) ;
79
96
t . end ( ) ;
80
- } )
97
+ } ) ;
0 commit comments