forked from marcuswestin/store.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
48 lines (44 loc) · 1.31 KB
/
test.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
<!DOCTYPE html>
<head>
<title>store.js test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
body { margin: 50px; font-family: helvetica; color: #333; }
div { color: green; }
#errorOutput div { color: red; }
</style>
<script src="./json.js"></script>
<script src="./store.js"></script>
<script src="./tests.js"></script>
</head>
<body>
tests for <a href="http://github.com/marcuswestin/store.js">store.js</a>
<div id="errorOutput"></div>
<script>
(function() {
var doc = document,
errorOutput = doc.getElementById('errorOutput'),
isSecondPass = (doc.location.hash == '#secondPass')
tests.outputError = function outputError(msg) {
var prefix = (isSecondPass ? 'second' : 'first') + ' pass '
errorOutput.appendChild(doc.createElement('div')).innerHTML = prefix+msg
}
try {
if (isSecondPass) { tests.runSecondPass() }
else { tests.runFirstPass() }
} catch(e) {
tests.assert(false, 'Tests should not throw: "' + JSON.stringify(e) + '"')
}
if (!tests.failed) {
if (!isSecondPass) {
doc.location.hash = '#secondPass'
doc.location.reload()
} else {
doc.location.hash = '#'
doc.body.appendChild(doc.createElement('div')).innerHTML = 'Tests passed'
}
}
})()
</script>
</body>
</html>