Skip to content

Commit

Permalink
Merge pull request #158 from Arquisoft/150-increase-code-coverage
Browse files Browse the repository at this point in the history
Added tests
  • Loading branch information
uo289267 authored Apr 28, 2024
2 parents ddd55b8 + 613f9ff commit 523acf4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
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

0 comments on commit 523acf4

Please sign in to comment.