-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestExample.html
More file actions
34 lines (30 loc) · 1.2 KB
/
testExample.html
File metadata and controls
34 lines (30 loc) · 1.2 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
<html>
<body>
<script src="jsTest.js"></script>
<div id="results"></div>
<script>
var suite = new jsTest.TestSuite();
suite.runTests(document.getElementById('results'));
suite = new jsTest.TestSuite();
suite.addTest('should fail', function(test) {
test.assertTrue('false should equal true', false == true);
test.assertEqual('5 should equal 6', 5, 6);
test.assertArraysEqual('Array [3, 2, 1] should equal [3, 2]',
[3, 2, 1], [3, 2]);
test.assertArraysEqual('Array [3, 2, 1] should equal [3, 1, 2]',
[3, 2, 1], [3, 1, 2]);
test.assertThrows('Addition should raise exception',
function() {1+2});
});
suite.addTest('should pass', function(test) {
test.assertTrue('true should equal true', true == true);
test.assertEqual('5 should equal 5', 5, 5);
test.assertArraysEqual('Array [3, 2, 1] should equal [3, 2, 1]',
[3, 2, 1], [3, 2, 1]);
test.assertThrows('Reference error should raise exception',
function() {x.y});
});
suite.runTests(document.getElementById('results'));
</script>
</body>
</html>