-
Notifications
You must be signed in to change notification settings - Fork 0
/
poor-mans-jasmine.js
41 lines (33 loc) · 1.1 KB
/
poor-mans-jasmine.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
function Assert( outcome, description ) {
var output = document.getElementById('output');
var te = document.createElement('div');
te.className = outcome ? 'pass' : 'fail';
te.innerHTML = description;
output.appendChild(te);
}
function Expect(actual_){
var self = this;
self.actual = actual_;
return {
toEqual: function(expected_){
return self.actual === expected_;
},
toNotEqual: function(expected_){
return self.actual !== expected_;
}
}
}
function RunTestFor(param_){
var testParam = param_.testParam;
var expected = param_.expected;
var actual = param_.functionToExecute(testParam); // getDisplayTime();
Assert(Expect(actual).toEqual(expected),
' <strong>' + param_.description + '</strong><br /><br />' +
'<code>' + param_.functionToExecute.name + '(' + testParam + ')</code> returns ' +
'<code>' + expected + '</code>.<br /><br />' +
'What we expected: <highlight>' +
expected +
'</highlight><br />What we got: <highlight>' +
actual +
'</highlight>');
}