-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPositionAnchor.test.js
54 lines (43 loc) · 1.07 KB
/
PositionAnchor.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
import PositionAnchor from './PositionAnchor'
import assert from 'assert'
global.window = {
requestAnimationFrame(callback) {
callback()
return 0
}
}
it("tests PositionAnchor", function (done) {
let ca = new PositionAnchor()
ca.props = {
element: () => ({
x: () => 0,
y: () => 0,
getClientRect: () => ({
x: 0,
y: 0,
width: 20,
height: 20
})
}),
elementOrigin: { x: 0.5, y: 0.5 },
elementDesiredOrigin: { x: 0.5, y: 0.5 },
reference: () => ({
x: () => 0,
y: () => 0,
getClientRect: () => ({
x: 0,
y: 0,
width: 200,
height: 50
})
}),
referenceOrigin: { x: 0, y: 0 },
referenceDesiredOrigin: { x: 1, y: 0 },
shift: { x: -25, y: 0 },
change: (x, y) => {
assert.equal(x, 175)
assert.equal(y, 0)
done()
}
}
})