Created
August 23, 2022 14:58
-
-
Save MaxMoskalenko/958fae22a8332d5431544bb3f26ead6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fireEvent, render, screen } from '@testing-library/react'; | |
import React from 'react'; | |
import { ReduxProvider } from '../../../providers/ReduxProvider'; | |
import { OTPModal } from './'; | |
const setIsOpen = jest.fn(); | |
const setStateMock = jest.fn(); | |
const useStateMock: any = (useState: any) => [useState, setStateMock]; | |
jest.spyOn(React, 'useState').mockImplementation(useStateMock); | |
const props = { | |
bounty: '', | |
isOpen: false, | |
setIsOpen: setIsOpen, | |
}; | |
const phoneApi = require('features/phone/phoneApi'); | |
jest.mock('features/phone/phoneApi'); | |
describe('OTPModal', () => { | |
it('renders a DuckiesPrizes', () => { | |
phoneApi.useVerifyPhoneMutation.mockImplementation(() => { | |
console.log('useVerifyPhoneMutation'); | |
return [jest.fn]; | |
}); | |
phoneApi.useSendPhoneVerificationMutation.mockImplementation(() => { | |
console.log('useSendPhoneVerificationMutation'); | |
return [jest.fn]; | |
}); | |
render( | |
<ReduxProvider> | |
<OTPModal {...props} /> | |
</ReduxProvider>, | |
); | |
const button = screen.getByText('Submit'); | |
fireEvent.click(button); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment