summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/frontend/vue_shared/components/resizable_chart_container_spec.js26
1 files changed, 12 insertions, 14 deletions
diff --git a/spec/frontend/vue_shared/components/resizable_chart_container_spec.js b/spec/frontend/vue_shared/components/resizable_chart_container_spec.js
index dd18ce9dcb7..8f533e8ab24 100644
--- a/spec/frontend/vue_shared/components/resizable_chart_container_spec.js
+++ b/spec/frontend/vue_shared/components/resizable_chart_container_spec.js
@@ -4,8 +4,8 @@ import ResizableChartContainer from '~/vue_shared/components/resizable_chart/res
import $ from 'jquery';
jest.mock('~/lib/utils/common_utils', () => ({
- debounceByAnimationFrame(onResize) {
- return jest.spyOn({ onResize }, 'onResize');
+ debounceByAnimationFrame(callback) {
+ return jest.spyOn({ callback }, 'callback');
},
}));
@@ -34,24 +34,22 @@ describe('Resizable Chart Container', () => {
expect(wrapper.element).toMatchSnapshot();
});
- it('updates the slot width and height props', done => {
- const width = Math.floor(Math.random() * 1000);
- const height = Math.floor(Math.random() * 1000);
+ it('updates the slot width and height props', () => {
+ const width = 1920;
+ const height = 1080;
+ // JSDOM mocks and sets clientWidth/clientHeight to 0 so we set manually
wrapper.vm.$refs.chartWrapper = { clientWidth: width, clientHeight: height };
$(document).trigger('content.resize');
- Vue.nextTick()
- .then(() => {
- const widthNode = wrapper.find('.slot > .width');
- const heightNode = wrapper.find('.slot > .height');
+ return Vue.nextTick().then(() => {
+ const widthNode = wrapper.find('.slot > .width');
+ const heightNode = wrapper.find('.slot > .height');
- expect(parseInt(widthNode.text(), 10)).toEqual(width);
- expect(parseInt(heightNode.text(), 10)).toEqual(height);
- done();
- })
- .catch(done.fail);
+ expect(parseInt(widthNode.text(), 10)).toEqual(width);
+ expect(parseInt(heightNode.text(), 10)).toEqual(height);
+ });
});
it('calls onResize on manual resize', () => {