-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
46 lines (38 loc) · 1.53 KB
/
example.html
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
<html>
<head>
<title>JS Unit Testing</title>
<script type="text/javascript" src="./app/testEnv.js"></script>
<script>
var testEnv = testEnv || {};
var tests = testEnv.init()
.addTest(function checkIfPythagoreWasRight(){
this.assert.areEqual(5 * 5, 3 * 3 + 4 * 4);
})
.addTest(function simpleMath(){
this.assert.isTrue(1 + 1 == 2);
})
.addTest(function chackIfFunction(){
this.assert.isFunction(function(){});
})
.addTest(function longExecution(){
for(var i = 0;i < 1000;i++)
for(var j = i + 1;j < 5000;j++)
this.assert.isFalse(i == j);
})
.addErrorTest(function errorTestFail(){
this.assert.areEqual(1, 1);
})
.addErrorTest(function errorTestSuccess(){
throw new Error('Something went wrong, and this is what we wanted');
})
.addTest(function anotherFailingTest(){
throw new Error('This is not supposed to happen');
})
.runTests()
.printResults();
</script>
</head>
<body>
Check the console
</body>
</html>