Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests #158

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions webapp/src/components/ForgetPassword/ForgetPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export default function ForgotPassword() {
setErrors([error.message])
}
}
else{
setErrors("Fill the code")
}

}

Expand Down
15 changes: 9 additions & 6 deletions webapp/src/components/ForgetPassword/ForgetPassword.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,15 @@ describe('ForgetPassword Component', () => {

act(async ()=>{
await waitFor(async () => expect(screen.getByText(i18en.t("forgotPassword.enter_code")).toBeInTheDocument()));

insertCode(['1', '1', '1', '1' ,'1' ,'1' ,'1'])
expect(screen.getByText("Netwok Error")).toBeInTheDocument()

mockAxios.onGet('http://localhost:8000/tokenFromCode/' + code).reply(200,
{token: token});
insertCode(['1', '1', '1', '1' ,'1' ,'1'])
expect(screen.getByText("Fill the code")).toBeInTheDocument()

insertCode(['1', '1', '1', '1' ,'1' ,'1' ,'1'])

//llegamos al replace
Expand Down Expand Up @@ -142,12 +149,8 @@ async function insertEmail(email, username) {
async function insertCode(code){
const inputs = screen.getAllByPlaceholderText('X');
// Introducir el mismo carácter en todos los inputs
userEvent.type(inputs[0], code[0]);
userEvent.type(inputs[1], code[1]);
userEvent.type(inputs[2], code[2]);
userEvent.type(inputs[3], code[3]);
userEvent.type(inputs[4], code[4]);
userEvent.type(inputs[5], code[5]);
for(let i = 0; i < code.length; i++)
userEvent.type(inputs[i], code[i]);
// Simula un clic en el botón de submit
fireEvent.click(screen.getByText(/"forgotPassword.send_code"/));
}
Expand Down