-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
134 lines (117 loc) · 3.38 KB
/
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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
var test = require('tape');
var logic = require('./logic');
var todos = [];
test('Example test', function(t) {
t.pass();
t.end();
});
test('Testing if input argument is unchanged', function(t) {
var actual = (logic.deleteTodo([{id: 3},{id: 5}], 3));
var expected = ([{id: 3},{id: 5}]);
t.equal(actual, expected, 'Should return todos when given todos');
t.end();
});
test('Testing if input argument is unchanged', function(t) {
var actual = (logic.deleteTodo(["a", "b"]).join());
var expected = (["a", "b"]).join();
t.equal(actual, expected, 'Should return todos when given todos');
t.end();
});
test('Testing new array does not contain idTODelete', function(t) {
var actual = ((logic.deleteTodo([{id: 3},{id: 5}], 3))).join();
var expected = ([{id: 5}]).join();
t.equal(actual, expected, 'testing new array does notcontain idtodelete');
t.end();
});
var toDoInput = [
{
id: 5,
description: 'smash avocados',
done: true,
},
{
id: 3,
description: 'make coffee',
done: false,
},
];
var toDoOutput = [
{
id: 5,
description: 'smash avocados',
done: true,
}
];
test('Testing input argument todos is unchanged', function(t) {
var actual = toDoInput;
var callFunction = logic.deleteTodo(toDoInput, 3);
var expected = toDoInput;
t.deepEqual(actual, expected, 'testing input argument todos are unchanged');
t.end();
});
test('Testing new array does not contain idTODelete', function(t) {
var actual = logic.deleteTodo(toDoInput, 3);
var expected = toDoOutput;
t.deepEqual(actual, expected, 'testing new array does notcontain idtodelete');
t.end();
});
test('Testing input argument todos is unchanged', function(t) {
var actual = toDoInput;
var callFunction = logic.markTodo(toDoInput, 3);
var expected = toDoInput;
t.deepEqual(actual, expected, 'testing input argument todos are unchanged');
t.end();
});
var markToDoOutput = [
{
id: 5,
description: 'smash avocados',
done: false,
},
{
id: 3,
description: 'make coffee',
done: false,
},
];
test('test done property has been changed', function(t) {
var x = toDoInput.map(function(e) {return e.id}).indexOf(5);
var actual = toDoInput[x].done;
var expected = markToDoOutput[x].done;
t.notEqual(actual, expected, 'test done property has been changed');
t.end();
});
test('test done property has been changed', function(t) {
var actual = toDoInput[0].done;
var expected = markToDoOutput[0].done;
t.notEqual(actual, expected, 'test done property has been changed');
t.end();
});
test('Returns new array', function(t) {
var actual = typeof logic.addTodo([]);
var expected = typeof [];
t.equal(actual, expected, 'addTodo should return a new array');
t.end();
})
test('Should leave input argument unchanged', function(t) {
var actual = logic.addTodo([1,2,3]);
var expected = [1,2,3];
t.deepEqual(actual, expected, 'Should leave the input argument todos unchanged');
t.end();
})
test('Should add an id to newObject', function(t) {
var actual = logic.addTodo(todos, 'make coffee');
var expected = [{
id: 1,
description: 'make coffee',
done: false
}]
t.deepEqual(actual, expected, 'Should add an id to newObject');
t.end();
})
test('Should add an id to newObject', function(t) {
var actual = logic.addTodo();
var expected =
t.equal(actual, expected, 'Should add an id to the newObject');
t.end();
})