From 34169dd294abd2981c029079ae4452c9360a45f8 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Sun, 22 Dec 2019 19:31:44 +0100 Subject: [PATCH] Add timeout to async tests --- js/test/chartviewmodel.test.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/js/test/chartviewmodel.test.js b/js/test/chartviewmodel.test.js index e2a245b..07f84e8 100644 --- a/js/test/chartviewmodel.test.js +++ b/js/test/chartviewmodel.test.js @@ -369,7 +369,7 @@ describe('ChartViewModel tests', () => { expect(point.classList.contains('ct-point-selected')).toBe(false); }); - it('should show chart on button click', () => { + it('should show chart on button click', (done) => { // given spyOn(vm, 'renderContainer'); vm.model.chartVisible = false; @@ -378,10 +378,13 @@ describe('ChartViewModel tests', () => { vm.setObservers(); buttonEl.click(); // then - expect(vm.model.chartVisible).toBe(true); + setTimeout(() => { + expect(vm.model.chartVisible).toBe(true); + done(); + }, 100); }); - it('should hide chart on button click', () => { + it('should hide chart on button click', (done) => { // given spyOn(vm, 'renderContainer'); vm.model.chartVisible = true; @@ -390,10 +393,13 @@ describe('ChartViewModel tests', () => { vm.setObservers(); buttonEl.click(); // then - expect(vm.model.chartVisible).toBe(false); + setTimeout(() => { + expect(vm.model.chartVisible).toBe(false); + done(); + }, 100); }); - it('should hide chart on close click', () => { + it('should hide chart on close click', (done) => { // given spyOn(vm, 'renderContainer'); vm.model.chartVisible = true; @@ -402,7 +408,10 @@ describe('ChartViewModel tests', () => { vm.setObservers(); closeEl.click(); // then - expect(vm.model.chartVisible).toBe(false); + setTimeout(() => { + expect(vm.model.chartVisible).toBe(false); + done(); + }, 100); }); });