Skip to content

Commit 9b5af54

Browse files
committedNov 3, 2017
Imporoved readability to the test
1 parent 5ff57fc commit 9b5af54

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed
 

‎test.js

+32-15
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ var sortOrder = function(a,b) {
1717
return 0;
1818
}
1919

20+
test('Tape is up and running', function(t) {
21+
t.equal(1, 1, 'one should equal one');
22+
t.end();
23+
});
24+
2025
test('check that to do has been added', function(t){
2126
var actual = logicFile.addTodo(state, {description: 'fourth todo', done: false});
2227
var expected = [
@@ -29,52 +34,64 @@ test('check that to do has been added', function(t){
2934
t.end();
3035
});
3136

32-
test('Tape is up and running', function(t) {
33-
t.equal(1, 1, 'one should equal one');
34-
t.end();
35-
});
3637

3738
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');
3942
t.end();
4043
});
4144

4245
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");
4449
t.end();
4550

4651
});
4752

4853
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 },
5056
{ 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');
5259
t.end();
5360
});
5461

5562
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");
5766
t.end();
5867

5968
});
6069

6170

6271

6372
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 = [
6575
{ id: -3, description: 'first todo', done: false },
6676
{ id: -2, description: 'second todo', done: false},
6777
{ 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([
7085
{ id: -2, description: 'second todo', done: false},
7186
{ id: -1, description: 'third todo', done: false },
7287
{ id: -3, description: 'first todo', done: false }
7388

74-
], sortOrder), [
89+
], sortOrder);
90+
var expected = [
7591
{ id: -3, description: 'first todo', done: false },
7692
{ id: -2, description: 'second todo', done: false},
7793
{ 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');
7996
t.end();
80-
})
97+
});

0 commit comments

Comments
 (0)
Please sign in to comment.