import AddCredentialsModal from '@screens/add-credentials';
import React from 'react';
import {shallow} from 'enzyme';
import renderer, {act} from 'react-test-renderer';
import {digiLockerAffinidiServiceInstance} from '@services/Axios';
describe('Should test AddCredentials screen', () => {
afterEach(() => {
jest.clearAllMocks();
});
afterAll(done => {
done();
});
test('renders correctly AddCredentialsModal', async () => {
const tree = renderer.create().toJSON();
expect(tree).toMatchSnapshot();
});
test('check if Add Button render properly', async () => {
const wrapper = shallow();
expect(wrapper.find({testID: 'AddBtn'})).toBeDefined();
});
test('check if onPress works properly', async () => {
const wrapper = shallow();
let value = wrapper.find({testID: 'AddBtn'});
value.simulate('press');
expect(value.simulate('press')).toBeTruthy();
});
it('should show updated ui when verifyUser is called', async () => {
jest.useFakeTimers();
const axiosGetSpy = jest
.spyOn(digiLockerAffinidiServiceInstance, 'post')
.mockResolvedValueOnce({verified: true});
await act(async () => {
renderer.create();
});
expect(axiosGetSpy).toBeCalled();
// expect(component?.toJSON()).toMatchSnapshot();
axiosGetSpy.mockRestore();
jest.runAllTimers();
});
});