fix: fix console errors on running test (#930)
This commit is contained in:
@@ -4,6 +4,7 @@ import React from 'react';
|
||||
|
||||
import { fetchAuthenticatedUser, getAuthenticatedUser } from '@edx/frontend-platform/auth';
|
||||
import { mount } from 'enzyme';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
|
||||
import { UnAuthOnlyRoute } from '..';
|
||||
import { LOGIN_PAGE } from '../../data/constants';
|
||||
@@ -42,7 +43,7 @@ describe('UnAuthOnlyRoute', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should have called with forceRefresh true', () => {
|
||||
it('should have called with forceRefresh true', async () => {
|
||||
const user = {
|
||||
username: 'gonzo',
|
||||
other: 'data',
|
||||
@@ -51,16 +52,20 @@ describe('UnAuthOnlyRoute', () => {
|
||||
getAuthenticatedUser.mockReturnValue(user);
|
||||
fetchAuthenticatedUser.mockReturnValueOnce(Promise.resolve(user));
|
||||
|
||||
mount(routerWrapper());
|
||||
await act(async () => {
|
||||
await mount(routerWrapper());
|
||||
});
|
||||
|
||||
expect(fetchAuthenticatedUser).toBeCalledWith({ forceRefresh: true });
|
||||
});
|
||||
|
||||
it('should have called with forceRefresh false', () => {
|
||||
it('should have called with forceRefresh false', async () => {
|
||||
getAuthenticatedUser.mockReturnValue(null);
|
||||
fetchAuthenticatedUser.mockReturnValueOnce(Promise.resolve(null));
|
||||
|
||||
mount(routerWrapper());
|
||||
await act(async () => {
|
||||
await mount(routerWrapper());
|
||||
});
|
||||
|
||||
expect(fetchAuthenticatedUser).toBeCalledWith({ forceRefresh: false });
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('FieldRendererTests', () => {
|
||||
type: 'select',
|
||||
label: 'Year of Birth',
|
||||
name: 'yob-field',
|
||||
options: [['1997', 1997], ['1998', 1998]],
|
||||
options: [['1997', '1997'], ['1998', '1998']],
|
||||
};
|
||||
|
||||
const fieldRenderer = mount(<FieldRenderer value={value} fieldData={fieldData} onChangeHandler={changeHandler} />);
|
||||
|
||||
@@ -166,11 +166,14 @@ describe('ResetPasswordPage', () => {
|
||||
resetPasswordPage.find('input#newPassword').simulate('blur', { target: { value: 'aziz156', name: 'newPassword' } });
|
||||
expect(resetPasswordPage.find('div[feedback-for="newPassword"]').text()).toEqual(expectedText);
|
||||
});
|
||||
it('should not call validation when typing and click on show icon button', () => {
|
||||
it('should not call validation when typing and click on show icon button', async () => {
|
||||
const resetPasswordPage = mount(reduxWrapper(<IntlResetPasswordPage {...props} />));
|
||||
resetPasswordPage.find('input#newPassword').simulate('change', { target: { value: 'aziz156@', name: 'newPassword' } });
|
||||
resetPasswordPage.find('button[aria-label="Show password"]').at(0).simulate('click');
|
||||
resetPasswordPage.find('button[aria-label="Hide password"]').at(0).simulate('blur');
|
||||
await act(async () => {
|
||||
await resetPasswordPage.find('input#newPassword').simulate('change', { target: { value: 'aziz156@', name: 'newPassword' } });
|
||||
await resetPasswordPage.find('button[aria-label="Show password"]').at(0).simulate('click');
|
||||
await resetPasswordPage.find('button[aria-label="Hide password"]').at(0).simulate('blur');
|
||||
});
|
||||
|
||||
expect(resetPasswordPage.find('div[feedback-for="newPassword"]').exists()).toBe(false);
|
||||
});
|
||||
it('should call validation click on show icon button and then focus out', () => {
|
||||
|
||||
Reference in New Issue
Block a user