diff --git a/src/__tests__/CountUp.test.js b/src/__tests__/CountUp.test.js index e2c7a60b..5d5eb236 100644 --- a/src/__tests__/CountUp.test.js +++ b/src/__tests__/CountUp.test.js @@ -60,6 +60,18 @@ it('renders with delay as a render prop component correctly', () => { expect(container).toMatchSnapshot(); }); +it('renders with delay as a render prop component correctly', () => { + console.error = jest.fn(); + + const { container } = render( + + {({ countUpRef }) => } + , + ); + + expect(console.error).toHaveBeenCalled(); +}); + it('renders as a render prop component correctly', () => { const { container } = render( {({ countUpRef }) =>
}, diff --git a/src/__tests__/useCountUp.test.js b/src/__tests__/useCountUp.test.js index 370e4bce..1f409c3a 100644 --- a/src/__tests__/useCountUp.test.js +++ b/src/__tests__/useCountUp.test.js @@ -76,10 +76,10 @@ it('calls update correctly with hook', () => { const spy = {}; const Hook = () => { - const { countUp, update } = useCountUp({ end: 10 }); - spy.update = update; - spyOn(spy, 'update'); - return {countUp}; + const onUpdate = jest.fn(); + const { countUp, update } = useCountUp({ end: 10, onUpdate }); + spy.onUpdate = onUpdate; + return {countUp}; }; const { container } = render(); @@ -87,17 +87,17 @@ it('calls update correctly with hook', () => { jest.runAllTimers(); fireEvent.click(container.firstChild); jest.runAllTimers(); - expect(spy.update).toHaveBeenCalled(); + expect(spy.onUpdate).toHaveBeenCalled(); }); it('calls pauseResume correctly with hook', () => { const spy = {}; const Hook = () => { - const { countUp, pauseResume } = useCountUp({ end: 10 }); - spy.pauseResume = pauseResume; - spyOn(spy, 'pauseResume'); - return {countUp}; + const onPauseResume = jest.fn(); + const { countUp, pauseResume } = useCountUp({ end: 10, onPauseResume }); + spy.onPauseResume = onPauseResume; + return {countUp}; }; const { container } = render(); @@ -105,5 +105,5 @@ it('calls pauseResume correctly with hook', () => { jest.runAllTimers(); fireEvent.click(container.firstChild); jest.runAllTimers(); - expect(spy.pauseResume).toHaveBeenCalled(); + expect(spy.onPauseResume).toHaveBeenCalled(); });