-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.js
More file actions
131 lines (108 loc) · 2.28 KB
/
temp.js
File metadata and controls
131 lines (108 loc) · 2.28 KB
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
var chalk = require('chalk');
var test = {};
var results = [];
function describe(testName, testFunction) {
startTest(testName);
testFunction();
endTest(testName);
}
function it(testName, callback) {
if(callback() === true) {
processPass(testName, callback);
} else {
processFail(testName, callback);
}
}
function assert(variable) {
test = {};
test.firstVariable = variable;
}
function to(matcher) {
test.isPositive = true;
return matcher();
}
function toNot(matcher) {
test.isPositive = false;
return matcher();
}
function be(variable) {
test.firstVariable = variable;
test.matcher = 'be';
return runTest();
}
function runTest() {
if(test.isPositive) {
return(runPositive());
} else {
return(runNegative());
}
}
function runNegative() {
if(test.matcher === 'be') {
return(test.firstVariable !== test.secondVariable);
}
}
function runPositive() {
if(test.matcher === 'be') {
return(test.firstVariable === test.secondVariable);
}
}
function processPass(testName) {
results.push({
name: testName,
firstVariable: test.firstVariable,
secondVariable: test.secondVariable,
isPassed: true
});
}
function processFail(testName) {
results.push({
name: testName,
firstVariable: test.firstVariable,
secondVariable: test.secondVariable,
isPassed: false
});
}
function startTest (testName) {
logFunction(testName);
}
function endTest (testName) {
logTests(testName);
}
function logFunction (testName) {
console.log(chalk.green(testName));
}
function logTests (testName) {
}
// variables/ functions for tests
function multiplyByFive (varToMultiply) {
return varToMultiply * 5;
}
function returnsTrue () {
return true;
}
// Example tests:
describe("#multiplyByFive", function () {
it("returns param multiplied by 5", function () {
assert(multiplyByFive(2)); to(function () {
be(10);
});
});
it("works with negative numbers", function () {
assert(multiplyByFive(-2)); to(function () {
be(-10);
});
});
});
describe("#returnsTrue", function () {
it("returns true", function () {
assert(returnsTrue()); to(function () {
be(true);
});
});
it("does not return false", function () {
assert(returnsTrue()); toNot(function () {
be(true);
});
});
});