Skip to content

Instantly share code, notes, and snippets.

@MaxMoskalenko
Created August 23, 2022 14:58
Show Gist options
  • Save MaxMoskalenko/958fae22a8332d5431544bb3f26ead6a to your computer and use it in GitHub Desktop.
Save MaxMoskalenko/958fae22a8332d5431544bb3f26ead6a to your computer and use it in GitHub Desktop.
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