From b9ce0ccf0bfe2f4a104f5899c67b6eff8d3b392c Mon Sep 17 00:00:00 2001 From: Adrien Di Mascio Date: Sat, 27 Jul 2019 12:53:37 +0200 Subject: [PATCH] [tests] use jest mocks instead of sinon ones for timers Instead of using jest faketimers that don't seem to work directly, (maybe because https://github.com/facebook/jest/issues/3465) just mock `_.throttle` to make it return the throttled function directly. --- tests/unit/popover.spec.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/unit/popover.spec.ts b/tests/unit/popover.spec.ts index ff2c14f61c..31627c9646 100644 --- a/tests/unit/popover.spec.ts +++ b/tests/unit/popover.spec.ts @@ -1,5 +1,4 @@ import _ from 'lodash'; -import sinon from 'sinon'; import { mount, Wrapper } from '@vue/test-utils'; import Vue from 'vue'; @@ -149,9 +148,9 @@ describe('DOM Position Tests', () => { }); describe('Popover', function() { - var wrapper: Wrapper; - var popoverWrapper: Wrapper; - var clock = sinon.useFakeTimers(); + let wrapper: Wrapper; + let popoverWrapper: Wrapper; + let throttleSpy: jest.SpyInstance; const createWrapper = (...args: any) => { const val = args[0], @@ -200,17 +199,15 @@ describe('Popover', function() { }, ); popoverWrapper = wrapper.find({ ref: 'popover' }); - // Force throttle end - clock.tick(16); }; beforeEach(function() { - clock = sinon.useFakeTimers(); + throttleSpy = jest.spyOn(_, 'throttle').mockImplementation((fn: any) => fn); }); afterEach(function() { wrapper.destroy(); - clock.restore(); + throttleSpy.mockRestore(); }); it('should instanciate a popover', function() {