UNPKG

1.34 kBHTMLView Raw
1<!DOCTYPE html>
2<head>
3 <title>store.js test</title>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5 <style type="text/css">
6 body { margin: 50px; font-family: helvetica; color: #333; }
7 div { color: green; }
8 #errorOutput div { color: red; }
9 </style>
10 <script src="./json.js"></script>
11 <script src="./store.js"></script>
12 <script src="./tests.js"></script>
13</head>
14<body>
15 tests for <a href="http://github.com/marcuswestin/store.js">store.js</a>
16 <div id="errorOutput"></div>
17
18 <script>
19 (function() {
20 var doc = document,
21 errorOutput = doc.getElementById('errorOutput'),
22 isSecondPass = (doc.location.hash == '#secondPass')
23
24 tests.outputError = function outputError(msg) {
25 var prefix = (isSecondPass ? 'second' : 'first') + ' pass '
26 errorOutput.appendChild(doc.createElement('div')).innerHTML = prefix+msg
27 }
28
29 try {
30 if (isSecondPass) { tests.runSecondPass() }
31 else { tests.runFirstPass() }
32 } catch(e) {
33 tests.assert(false, 'Tests should not throw: "' + JSON.stringify(e) + '"')
34 }
35
36 if (!tests.failed) {
37 if (!isSecondPass) {
38 doc.location.hash = '#secondPass'
39 doc.location.reload()
40 } else {
41 doc.location.hash = '#'
42 doc.body.appendChild(doc.createElement('div')).innerHTML = 'Tests passed'
43 }
44 }
45 })()
46 </script>
47</body>
48</html>