0
Q:

how to test timeout in component did mount

it('button shoould start glowing', () => {
        let clock = sinon.useFakeTimers();
        const wrapper = mount(<PlayButton media={{ currentTime: 0, duration: 1 }}/>);
        wrapper.update()
        clock.tick(3000)
        expect(wrapper.state('glow')).toBe(true);
    });
0
it('button shoould start glowing', () => {
        const wrapper = mount(<PlayButton media={{ currentTime: 0, duration: 1 }}/>);
        wrapper.update()
        jest.runAllTimers();
        expect(wrapper.state('glow')).toBe(true);
    });
0

New to Communities?

Join the community