-
Notifications
You must be signed in to change notification settings - Fork 3
/
tests.js
47 lines (39 loc) · 817 Bytes
/
tests.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
import {createRequire} from 'module'
import {readdirSync} from 'fs'
import {parseHTML} from 'linkedom'
const require = createRequire(import.meta.url)
const dom = parseHTML(`
<!doctype html>
<html lang="en">
<head>
<title>Mithril Machine Tools</title>
</head>
<body>
</body>
</html>
`)
Object.assign(global, {
window : dom.window,
document : dom.window.document,
requestAnimationFrame: dom.window.requestAnimationFrame,
})
Object.assign(global, {
o: require('ospec'),
m: require('mithril'),
})
o.afterEach(() => {
document.body.innerHTML = ''
delete document.body.vnodes
})
Promise.all(
readdirSync('./tests')
.filter(file =>
file.endsWith('.js')
)
.map(file =>
import('./tests/' + file)
)
)
.then(() => {
o.run()
})