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
|
import { GlDrawer } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import { getDrawerBodyHeight } from '~/whats_new/utils/get_drawer_body_height';
describe('~/whats_new/utils/get_drawer_body_height', () => {
let drawerWrapper;
beforeEach(() => {
drawerWrapper = mount(GlDrawer, {
propsData: { open: true },
});
});
const setClientHeight = (el, height) => {
Object.defineProperty(el, 'clientHeight', {
get() {
return height;
},
});
};
const setDrawerDimensions = ({ height, top, headerHeight }) => {
const drawer = drawerWrapper.element;
setClientHeight(drawer, height);
jest.spyOn(drawer, 'getBoundingClientRect').mockReturnValue({ top });
setClientHeight(drawer.querySelector('.gl-drawer-header'), headerHeight);
};
it('calculates height of drawer body', () => {
setDrawerDimensions({ height: 100, top: 5, headerHeight: 40 });
expect(getDrawerBodyHeight(drawerWrapper.element)).toBe(55);
});
});
|