-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
83 lines (81 loc) · 2.37 KB
/
test.js
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
/* global describe it */
const expect = require('chai').expect
const Mocha = require('mocha')
describe('table tests', function () {
var stats
beforeEach(function () {
stats = {}
})
function reporter (runner) {
['pass', 'fail', 'pending'].forEach(function (what) {
stats[what] = []
runner.on(what, function (test) {
stats[what].push(test.title)
})
})
}
it('runs the main table tests', function (done) {
var mocha = new Mocha()
mocha.addFile('table-tests.js')
mocha.reporter(reporter)
mocha.run(function () {
expect(stats).to.eql({
pass: [
'is 3 prime? (should be true)',
'is 4 prime? (should be false)',
'is 1847 prime? (should be true)',
'is 1848 prime? (should be false)',
'testing 1 10',
'testing 1 20',
'testing 2 10',
'testing 2 20',
'testing 4 30',
'testing 4 40',
'is 3 (asynchronously) prime? (should be true)',
'is 4 (asynchronously) prime? (should be false)',
'is 1847 (asynchronously) prime? (should be true)',
'is 1848 (asynchronously) prime? (should be false)',
'this object should be the right one',
'this object should be the right one in async',
'should end up with first',
'should also end up with second',
'make sure the promise is accepted'
],
fail: [
'is 685242563 prime? (should be false)',
'is 685242563 (asynchronously) prime? (should be false)',
'should continue to time out',
'make sure the promise is rejected',
'make sure the promise is timed out'
],
pending: [
'is 15 prime? (should be false)',
'is 21 prime? (should be false)',
'testing 3 30',
'testing 3 40',
'is 15 (asynchronously) prime? (should be false)',
'is 21 (asynchronously) prime? (should be false)'
]
})
done()
})
})
it('runs the onlying table tests', function (done) {
var mocha = new Mocha()
mocha.addFile('table-onlys.js')
mocha.reporter(reporter)
mocha.run(function () {
expect(stats).to.eql({
pass: [
'first table',
'second table'
],
fail: [
],
pending: [
]
})
done()
})
})
})