-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
47 lines (36 loc) · 1023 Bytes
/
test.js
File metadata and controls
47 lines (36 loc) · 1023 Bytes
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
require('jsdom-global')()
const assert = require('assert')
const { position } = require('./')
describe('Bianco pointer', function() {
it('can read the pointer position from a mousemove', function(done) {
const div = document.createElement('div')
div.addEventListener('mousemove', function(event) {
const { x, y } = position(event)
assert.equal(x, 1)
assert.equal(y, 1)
done()
})
div.dispatchEvent(new window.MouseEvent('mousemove', {
clientX: 1,
clientY: 1
}))
})
it('can read the pointer position from multiple touches', function(done) {
const div = document.createElement('div')
div.addEventListener('touchmove', function(event) {
const { x, y } = position(event)
assert.equal(x, 10)
assert.equal(y, 10)
done()
})
div.dispatchEvent(new window.TouchEvent('touchmove', {
targetTouches: [{
clientX: 10,
clientY: 10
}, {
clientX: 2,
clientY: 2
}]
}))
})
})