-
Notifications
You must be signed in to change notification settings - Fork 0
/
passing.html
63 lines (53 loc) · 2.09 KB
/
passing.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
<head>
<title>QUnit Test Suite</title>
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="../node_modules/qunitjs/qunit/qunit.js"></script>
<!-- Your project file goes here -->
<!-- <script type="text/javascript" src="myProject.js"></script> -->
<!-- Your tests file goes here -->
<!-- <script type="text/javascript" src="myTests.js"></script> -->
<!-- Adapted from https://github.com/jonkemp/qunit-phantomjs-runner -->
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script>
function run(n) {
// Let's test this function
function isEven(val) {
return val % 2 === 0;
}
test(n + ' isEven()', function () {
ok(isEven(0), 'Zero is an even number');
ok(isEven(2), 'So is two');
ok(isEven(-4), 'So is negative four');
ok(!isEven(1), 'One is not an even number');
ok(!isEven(-7), 'Neither is negative seven');
});
// Let's test this function
function multiply(a, b) {
return a * b;
}
test(n + ' multiply()', function () {
ok(multiply(0, 1) === 0, 'Zero times one is zero');
ok(multiply(2, 2) === 4, 'Two times two is four');
ok(multiply(1, 3) === 3, 'One times three is three');
ok(multiply(10, 5) === 50, 'Five times ten is fifty');
ok(multiply(10, 10) === 100, 'Ten times ten is one hundred');
});
test(n + ' querySelector', function () {
equal(document.querySelectorAll('div').length, 3);
equal(document.querySelectorAll('script').length, 2);
equal(document.querySelectorAll('input.foo').length, 0);
equal(document.querySelectorAll('span.bar').length, 0);
equal(document.querySelectorAll('a.baz').length, 0);
});
}
for (var n = 0; ++n <= 10;) {
run(n);
}
</script>
</body>
</html>