-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollision.test.ts
45 lines (39 loc) · 1.17 KB
/
collision.test.ts
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
import { CollisionHandler, position } from '../src/index';
import { allData, Helper, SizeData } from './Helpers';
const windowSize: SizeData = {
height: 1000,
width: 1000,
},
anchorSize: SizeData = {
height: 100,
width: 100,
},
targetSize: SizeData = {
height: 100,
width: 200,
},
helper = new Helper(CollisionHandler.bestFit, anchorSize, targetSize),
leftCollision: (input: number) => number = () => 800;
helper.setupEnvironment(windowSize);
test('Collision changes the output', () => {
const tP = 'center right',
myA = 'top center',
atA = 'bottom center';
helper.setupTest(tP);
const pData = position({
...{ debug: true },
...{
my: myA,
at: atA,
target: document.querySelector<HTMLDivElement>('.target')!,
anchor: document.querySelector<HTMLElement>('.anchor')!,
},
}) as allData;
expect({
left: parseInt(pData.left, 10),
top: parseInt(pData.top, 10),
}).toStrictEqual({
left: helper.getLeft(tP, myA, atA, leftCollision),
top: helper.getTop(tP, myA, atA),
});
});