-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-runner.html
64 lines (54 loc) · 1.94 KB
/
test-runner.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
<!DOCTYPE html>
<html>
<head>
<title>Proctoring frontend library test suite</title>
<link rel="stylesheet" href="node_modules/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="node_modules/mocha/mocha.js"></script>
<script src="node_modules/chai/chai.js"></script>
<script>mocha.setup('bdd')</script>
<script src="public/proctor.js"></script>
<script>
/**
* Testing suite for the frontend library
* */
const proctor = new Proctor();
const {strictEqual, equal} = chai.assert;
describe('Tests for logging', () => {
it('should add a correct status to the log', () => {
// adding status
proctor.logFocus(true);
// adding status
proctor.logFocus(false);
// adding status
proctor.logFocus(true);
const currentLog = proctor.getFocusLog();
// log should have 3 objects
strictEqual(currentLog.length, 3);
// the second object in the log should have an inFocus value of false
strictEqual(currentLog[1].inFocus, false);
});
});
describe('Tests for log formatting', () => {
it('should return a properly formatted log', () => {
const log = [
{inFocus: true, ts: '2020-09-07 09:00:00'},
{inFocus: true, ts: '2020-09-07 09:05:00'},
{inFocus: false, ts: '2020-09-07 09:10:00'}
];
const expected = '{"focuslog":[{"inFocus":true,"ts":"2020-09-07 09:00:00"},{"inFocus":true,"ts":"2020-09-07 09:05:00"},{"inFocus":false,"ts":"2020-09-07 09:10:00"}]}';
const result = proctor.prepareLog(log);
// result should be the same as expected value
equal(result, expected);
// result should have a type of string
equal(typeof result, 'string');
});
});
</script>
<script>
mocha.run();
</script>
</body>
</html>