Skip to content
Snippets Groups Projects
Unverified Commit 9c229a01 authored by Kyle Doherty's avatar Kyle Doherty
Browse files

use built in jest timers

parent 360e6337
No related branches found
No related tags found
No related merge requests found
import React from 'react'
import { shallow, mount } from 'enzyme'
import sinon from 'sinon'
import LoadingAndErrorWrapper from 'metabase/components/LoadingAndErrorWrapper'
......@@ -43,16 +42,8 @@ describe('LoadingAndErrorWrapper', () => {
})
describe('cycling', () => {
let clock
beforeEach(() => {
clock = sinon.useFakeTimers()
})
afterEach(() => {
clock.restore()
})
it('should cycle through loading messages if provided', () => {
jest.useFakeTimers()
const interval = 6000
......@@ -72,20 +63,20 @@ describe('LoadingAndErrorWrapper', () => {
)
const instance = wrapper.instance()
const spy = sinon.spy(instance, 'cycleLoadingMessage')
const spy = jest.spyOn(instance, 'cycleLoadingMessage')
expect(wrapper.text()).toMatch(/One/)
clock.tick(interval)
expect(spy.called).toEqual(true)
jest.runTimersToTime(interval)
expect(spy).toHaveBeenCalled()
expect(wrapper.text()).toMatch(/Two/)
clock.tick(interval)
expect(spy.called).toEqual(true)
jest.runTimersToTime(interval)
expect(spy).toHaveBeenCalled()
expect(wrapper.text()).toMatch(/Three/)
clock.tick(interval)
expect(spy.called).toEqual(true)
jest.runTimersToTime(interval)
expect(spy).toHaveBeenCalled()
expect(wrapper.text()).toMatch(/One/)
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment