-
-
Notifications
You must be signed in to change notification settings - Fork 729
Expand file tree
/
Copy pathbounds.spec.js
More file actions
37 lines (31 loc) · 1.13 KB
/
bounds.spec.js
File metadata and controls
37 lines (31 loc) · 1.13 KB
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
import { getBounds } from '../../../src/js/utils/bounds';
describe('Utils - bounds', () => {
describe('get bounds', () => {
let bodyElement;
beforeEach(() => {
bodyElement = document.createElement('div');
document.body.appendChild(bodyElement);
});
it('should get body offset', () => {
let bounds;
const element = document.createElement('div');
element.style.position = 'absolute';
element.style.top = '0';
element.style.left = '0';
bodyElement.appendChild(element);
bounds = getBounds(bodyElement, element);
expect(bounds.top).toEqual(0);
expect(bounds.left).toEqual(0);
bodyElement.style.position = 'absolute';
bodyElement.style.top = '30px';
bodyElement.style.left = '30px';
bounds = getBounds(bodyElement, element);
expect(bounds.top, 'correct top bounds with body offset').toEqual(0);
expect(bounds.left, 'correct left bounds with body offset').toEqual(0);
});
afterEach(() => {
document.body.removeChild(bodyElement);
bodyElement = null;
});
});
});