This repository was archived by the owner on Nov 17, 2022. It is now read-only.
forked from mathquill/mathquill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit.html
89 lines (73 loc) · 2.88 KB
/
unit.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html>
<head>
<!-- allow fancy checkmarks to show up -->
<meta charset="UTF-8">
<!-- complain about uncaught errors -->
<script type="text/javascript">
window.onerror = function() {
document.documentElement.style.background = 'red';
};
</script>
<!-- better living through jQuery -->
<script type="text/javascript" src="support/jquery-1.5.2.js"></script>
<!-- mocha test framework -->
<script type="text/javascript" src="../node_modules/mocha/mocha.js"></script>
<link rel="stylesheet" type="text/css" href="../node_modules/mocha/mocha.css" />
<!-- home-grown assertions -->
<script src="support/assert.js" type="text/javascript"></script>
<!-- configure mocha and chai -->
<script type="text/javascript">
var post_xunit_to = Mocha.utils.parseQuery(location.search).post_xunit_to;
mocha.setup({
ui: 'tdd',
reporter: post_xunit_to ? 'xunit' : 'html'
});
var xunit = '';
Mocha.process.stdout.write = function(line) { xunit += line; };
</script>
<!-- include the library with the tests inlined -->
<script id="mathquill" type="text/javascript" src="../build/mathquill.test.js"
onerror="alert('couldn\'t find `build/mathquill.test.js`. Please run `make test` before opening this file.')">
</script>
<!-- include MathQuill-basic -->
<link rel="stylesheet" type="text/css" href="../build/mathquill.css" />
<script type="text/javascript" src="../build/mathquill-basic.js"></script>
<script type="text/javascript">
MQBasic = MathQuill.noConflict().getInterface(MathQuill.getInterface.MAX);
MQ = MathQuill.getInterface(MathQuill.getInterface.MAX);
</script>
</head>
<body>
<h1>Unit Tests</h1>
<div id="mocha"></div>
<div id="mock"></div>
<script type="text/javascript">
teardown(function() { $('#mock').empty(); });
var runner = mocha.run();
if (post_xunit_to) {
// the following is based on https://github.com/saucelabs-sample-scripts/JavaScript/blob/4946c5cf0ab7325dce5562881dba7c28e30989e5/reporting_mocha.js
var failedTests = [];
runner.on('fail', function(test, err) {
function flattenTitles(test) {
var titles = [];
while (test.parent.title) {
titles.push(test.parent.title);
test = test.parent;
}
return titles.reverse();
}
failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test) });
});
runner.on('end', function() {
setTimeout(function() {
$.post(post_xunit_to, xunit).complete(function() {
window.mochaResults = runner.stats;
window.mochaResults.reports = failedTests;
});
});
});
}
</script>
</body>
</html>