diff --git a/test/useStateMachine.test.tsx b/test/useStateMachine.test.tsx index 74c9398..37fd7bd 100644 --- a/test/useStateMachine.test.tsx +++ b/test/useStateMachine.test.tsx @@ -1,4 +1,3 @@ -import { mocked } from 'jest-mock'; import { renderHook } from '@testing-library/react'; import useStateMachineInput from '../src/hooks/useStateMachineInput'; @@ -35,6 +34,7 @@ function getRiveMock({ const riveMock = new Rive({ canvas: undefined as unknown as HTMLCanvasElement, }); + if (smiInputs) { riveMock.stateMachineInputs = jest.fn().mockReturnValue(smiInputs); } @@ -51,8 +51,6 @@ describe('useStateMachineInput', () => { it('returns null if there is no state machine name', () => { const riveMock = getRiveMock(); - mocked(Rive).mockImplementation(() => riveMock); - const { result } = renderHook(() => useStateMachineInput(riveMock, '', 'testInput') ); @@ -71,10 +69,8 @@ describe('useStateMachineInput', () => { it('returns null if there are no inputs for the state machine', () => { const riveMock = getRiveMock({ smiInputs: [] }); - mocked(Rive).mockImplementation(() => riveMock); - const { result } = renderHook(() => - useStateMachineInput(riveMock as Rive, 'smName', '') + useStateMachineInput(riveMock, 'smName', '') ); expect(result.current).toBeNull(); }); @@ -85,8 +81,6 @@ describe('useStateMachineInput', () => { } as StateMachineInput; const riveMock = getRiveMock({ smiInputs: [smInput] }); - mocked(Rive).mockImplementation(() => riveMock); - const { result } = renderHook(() => useStateMachineInput(riveMock, 'smName', 'numInput') ); @@ -99,8 +93,6 @@ describe('useStateMachineInput', () => { } as StateMachineInput; const riveMock = getRiveMock({ smiInputs: [smInput] }); - mocked(Rive).mockImplementation(() => riveMock); - const { result } = renderHook(() => useStateMachineInput(riveMock, 'smName', 'boolInput') ); @@ -113,7 +105,6 @@ describe('useStateMachineInput', () => { value: false, } as StateMachineInput; const riveMock = getRiveMock({ smiInputs: [smInput] }); - mocked(Rive).mockImplementation(() => riveMock); const { result } = renderHook(() => useStateMachineInput(riveMock, 'smName', 'boolInput', true)