-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
58 lines (49 loc) · 1.94 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
const { Keyboard, Mouse, Touch } = require('./')
const { Context } = require('axis3d')
const test = require('tape')
const ctx = new Context()
test("Keyboard", ({test, end}) => {
test("Keyboard() throws TypeError for bad inputs", ({throws, end}) => {
throws(() => { Keyboard(null) }, TypeError, "for null argument")
throws(() => { Keyboard(undefined) }, TypeError, "for undefined argument")
throws(() => { Keyboard(0) }, TypeError, "for number argument")
throws(() => { Keyboard(true) }, TypeError, "for boolean argument")
throws(() => { Keyboard([]) }, TypeError, "for array argument")
end()
})
test("Keyboard() returns a function for correct input", ({pass, end}) => {
pass('function' == typeof Keyboard(ctx))
end()
})
end()
})
test('Mouse', ({test, end}) => {
test("Mouse() throws TypeError for bad inputs", ({throws, end}) => {
throws(() => { Mouse(null) }, TypeError, "for null argument")
throws(() => { Mouse(undefined) }, TypeError, "for undefined argument")
throws(() => { Mouse(0) }, TypeError, "for number argument")
throws(() => { Mouse(true) }, TypeError, "for boolean argument")
throws(() => { Mouse([]) }, TypeError, "for array argument")
end()
})
test("Mouse() returns a function for correct input", ({pass, end}) => {
pass('function' == typeof Mouse(ctx))
end()
})
end()
})
test('Touch', ({test, end}) => {
test("Keyboard() throws TypeError for bad inputs", ({throws, end}) => {
throws(() => { Touch(null) }, TypeError, "for null argument")
throws(() => { Touch(undefined) }, TypeError, "for undefined argument")
throws(() => { Touch(0) }, TypeError, "for number argument")
throws(() => { Touch(true) }, TypeError, "for boolean argument")
throws(() => { Touch([]) }, TypeError, "for array argument")
end()
})
test("Touch() returns a function for correct input", ({pass, end}) => {
pass('function' == typeof Touch(ctx))
end()
})
end()
})