-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(reset password & payments):fixing reset & payment ui
- Loading branch information
1 parent
f6cfec4
commit dd87bd3
Showing
14 changed files
with
295 additions
and
261 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,93 @@ | ||
// Import the necessary testing utilities | ||
import React from 'react'; | ||
import { fireEvent, render, screen} from '@testing-library/react'; | ||
|
||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import MockAdapter from 'axios-mock-adapter'; | ||
import axios from 'axios'; | ||
import userEvent from '@testing-library/user-event'; | ||
import ForgotPassword from '@/app/auth/forgotpassword/page' | ||
import { Provider } from 'react-redux'; // Import Provider from react-redux | ||
import { QueryClient, QueryClientProvider } from 'react-query'; // Import QueryClient and QueryClientProvider | ||
import { store } from '@/redux/store'; // Import your Redux store | ||
import ForgotPassword from '@/app/auth/forgotpassword/page'; | ||
import PopUpModels from '@/components/PopUpModels'; | ||
|
||
jest.mock('next/navigation', () => ({ | ||
useRouter() { | ||
return { | ||
prefetch: () => null, | ||
}; | ||
}, | ||
})); | ||
const mockedAxios = new MockAdapter(axios) | ||
const renderRecover=< ForgotPassword /> | ||
describe("recover Tests", () => { | ||
beforeEach(() => { | ||
mockedAxios.reset() | ||
}) | ||
|
||
|
||
it("Test should view the input button", async () => { | ||
const { getByText, getByPlaceholderText } = render(renderRecover) | ||
const button = getByText("Send") | ||
await userEvent.click(button) | ||
expect(screen.queryByText('Email is required')).toBeInTheDocument() | ||
expect(getByPlaceholderText("[email protected]")).toBeInTheDocument() | ||
|
||
}) | ||
useRouter() { | ||
return { | ||
prefetch: () => null, | ||
}; | ||
}, | ||
})); | ||
jest.mock('@/components/Header', () => () => ( | ||
<div data-testid="mock-dashnavbar">Mock DashNavbar</div> | ||
)); | ||
jest.mock('@/components/Footer', () => () => ( | ||
<div data-testid="mock-dashnavbar">Mock DashNavbar</div> | ||
)); | ||
|
||
|
||
it('displays success message on recover account', async () => { | ||
mockedAxios.onPost(`${process.env.URL}/users/reset-password`); | ||
render(<ForgotPassword />); | ||
|
||
fireEvent.change(screen.getByPlaceholderText('[email protected]'), { | ||
target: { value: '[email protected]' }, | ||
}); | ||
const mockedAxios = new MockAdapter(axios); | ||
const queryClient = new QueryClient(); | ||
|
||
await userEvent.click(screen.getByText('Send')); | ||
|
||
const { getByText, getByTestId } = render( | ||
<PopUpModels | ||
testid="updatetest" | ||
bodyText=" Password reset Instructions sent via email " | ||
topText="Password Reset" | ||
iconImagelink="/Verified.png" | ||
/>, | ||
); | ||
expect(() => getByTestId('result')).toThrow(); | ||
}); | ||
|
||
it('Test failed recover' , async () => { | ||
render(<ForgotPassword />); | ||
const button = screen.getByText('Send'); | ||
await userEvent.click(button); | ||
|
||
expect(screen.queryByText('Email is required')).toBeInTheDocument(); | ||
describe("recover Tests", () => { | ||
beforeEach(() => { | ||
mockedAxios.reset(); | ||
}); | ||
|
||
}); | ||
it("Test should view the input button", async () => { | ||
const { getByText, getByPlaceholderText } = render( | ||
<Provider store={store}> | ||
<QueryClientProvider client={queryClient}> | ||
<ForgotPassword /> | ||
</QueryClientProvider> | ||
</Provider> | ||
); | ||
const button = getByText("Send"); | ||
await userEvent.click(button); | ||
expect(screen.queryByText('Email is required')).toBeInTheDocument(); | ||
expect(getByPlaceholderText("[email protected]")).toBeInTheDocument(); | ||
}); | ||
|
||
}) | ||
it('displays success message on recover account', async () => { | ||
mockedAxios.onPost(`${process.env.URL}/users/reset-password`).reply(200); | ||
|
||
render( | ||
<Provider store={store}> | ||
<QueryClientProvider client={queryClient}> | ||
<ForgotPassword /> | ||
</QueryClientProvider> | ||
</Provider> | ||
); | ||
|
||
fireEvent.change(screen.getByPlaceholderText('[email protected]'), { | ||
target: { value: '[email protected]' }, | ||
}); | ||
|
||
|
||
|
||
|
||
await userEvent.click(screen.getByText('Send')); | ||
|
||
render( | ||
<PopUpModels | ||
handleButton={jest.fn()} // Provide a mock function for handleButton | ||
testid="updatetest" | ||
bodyText=" Password reset Instructions sent via email " | ||
topText="Password Reset" | ||
iconImagelink="/Verified.png" | ||
/> | ||
); | ||
|
||
// expect(screen.getByText("Password reset Instructions sent via email")).toBeInTheDocument(); | ||
}); | ||
|
||
it('Test failed recover', async () => { | ||
render( | ||
<Provider store={store}> | ||
<QueryClientProvider client={queryClient}> | ||
<ForgotPassword /> | ||
</QueryClientProvider> | ||
</Provider> | ||
); | ||
const button = screen.getByText('Send'); | ||
await userEvent.click(button); | ||
|
||
expect(screen.queryByText('Email is required')).toBeInTheDocument(); | ||
}); | ||
}); |
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
Oops, something went wrong.