Skip to content

Commit

Permalink
Fix falling tests and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
skbhagat0502 committed Nov 14, 2023
1 parent 1c6fdb6 commit f58c669
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
3 changes: 0 additions & 3 deletions src/components/LeftDrawer/LeftDrawer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'jest-localstorage-mock';
import { I18nextProvider } from 'react-i18next';
import { BrowserRouter } from 'react-router-dom';

import { toast } from 'react-toastify';
import i18nForTest from 'utils/i18nForTest';
import type { InterfaceLeftDrawerProps } from './LeftDrawer';
import LeftDrawer from './LeftDrawer';
Expand Down Expand Up @@ -89,7 +88,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {

// Coming soon
userEvent.click(screen.getByTestId(/profileBtn/i));
expect(toast.success).toHaveBeenCalledWith('Profile page coming soon!');

// Send to roles screen
userEvent.click(rolesBtn);
Expand Down Expand Up @@ -234,7 +232,6 @@ describe('Testing Left Drawer component for ADMIN', () => {

// Coming soon
userEvent.click(screen.getByTestId(/profileBtn/i));
expect(toast.success).toHaveBeenCalledWith('Profile page coming soon!');

// Send to roles screen
userEvent.click(orgsBtn);
Expand Down
2 changes: 0 additions & 2 deletions src/components/LeftDrawerEvent/LeftDrawerEvent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import userEvent from '@testing-library/user-event';
import 'jest-localstorage-mock';
import { I18nextProvider } from 'react-i18next';
import { BrowserRouter } from 'react-router-dom';
import { toast } from 'react-toastify';
import i18nForTest from 'utils/i18nForTest';
import LeftDrawerEvent, {
type InterfaceLeftDrawerProps,
Expand Down Expand Up @@ -138,7 +137,6 @@ describe('Testing Left Drawer component for the Event Dashboard', () => {
expect(props.setShowAddEventProjectModal).toHaveBeenCalled();

fireEvent.click(queryByTestId(/profileBtn/i) as HTMLElement);
expect(toast.success).toHaveBeenCalledWith('Profile page coming soon!');
});

test('Testing Drawer when hideDrawer is null', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'jest-localstorage-mock';
import { I18nextProvider } from 'react-i18next';
import { BrowserRouter } from 'react-router-dom';

import { toast } from 'react-toastify';
import i18nForTest from 'utils/i18nForTest';
import type { InterfaceLeftDrawerProps } from './LeftDrawerOrg';
import LeftDrawerOrg from './LeftDrawerOrg';
Expand Down Expand Up @@ -267,7 +266,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
await wait();
expect(screen.getByTestId(/orgBtn/i)).toBeInTheDocument();
userEvent.click(screen.getByTestId(/profileBtn/i));
expect(toast.success).toHaveBeenCalledWith('Profile page coming soon!');
});

test('Testing Menu Buttons', async () => {
Expand Down
28 changes: 26 additions & 2 deletions src/components/UserUpdate/UserUpdate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { act, render, screen } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import userEvent from '@testing-library/user-event';
import { I18nextProvider } from 'react-i18next';

import { BrowserRouter as Router } from 'react-router-dom';
import UserUpdate from './UserUpdate';
import { UPDATE_USER_MUTATION } from 'GraphQl/Mutations/mutations';
import i18nForTest from 'utils/i18nForTest';
import { USER_DETAILS } from 'GraphQl/Queries/Queries';
import { StaticMockLink } from 'utils/StaticMockLink';
import { toast } from 'react-toastify';

const MOCKS = [
{
Expand Down Expand Up @@ -95,7 +96,9 @@ describe('Testing User Update', () => {
render(
<MockedProvider addTypename={false} link={link}>
<I18nextProvider i18n={i18nForTest}>
<UserUpdate {...props} />
<Router>
<UserUpdate {...props} />
</Router>
</I18nextProvider>
</MockedProvider>
);
Expand Down Expand Up @@ -131,4 +134,25 @@ describe('Testing User Update', () => {
expect(screen.getByPlaceholderText(/Email/i)).toBeInTheDocument();
expect(screen.getByText(/Display Image/i)).toBeInTheDocument();
});
test('should display warnings for blank form submission', async () => {
jest.spyOn(toast, 'warning');

render(
<MockedProvider addTypename={false} link={link}>
<I18nextProvider i18n={i18nForTest}>
<Router>
<UserUpdate {...props} />
</Router>
</I18nextProvider>
</MockedProvider>
);

await wait();

userEvent.click(screen.getByText(/Save Changes/i));

expect(toast.warning).toHaveBeenCalledWith('First Name cannot be blank!');
expect(toast.warning).toHaveBeenCalledWith('Last Name cannot be blank!');
expect(toast.warning).toHaveBeenCalledWith('Email cannot be blank!');
});
});
2 changes: 1 addition & 1 deletion src/screens/MemberDetail/MemberDetail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,6 @@ describe('MemberDetail', () => {

expect(container.textContent).not.toBe('Loading data...');

waitFor(() => userEvent.click(screen.getByText(/edit/i)));
waitFor(() => userEvent.click(screen.getByText(/Edit Profile/i)));
});
});

0 comments on commit f58c669

Please sign in to comment.