SWE574-Fall2023-Group1 / SWE574-Fall2023-G1

Project for SWE 574 - Group 1
MIT License
7 stars 1 forks source link

Add unit test for login #80 #253

Closed aykutkantas closed 9 months ago

aykutkantas commented 9 months ago

Login unit test added. Cases are below. Register unit test will also be added.

  1. renders Login component: This test checks whether the Login component renders correctly when it's wrapped in a MemoryRouter. It expects that the text 'Welcome' should be present in the rendered component.

  2. calls axios.post with correct credentials on form submission: This test simulates a form submission by changing the values of the username and password fields and clicking the 'Login' button. It then asserts that the axios.post method is called with the correct parameters (username, password, and request configuration) when the form is submitted.

  3. handles successful login: This test checks the handling of a successful login scenario. It mocks the axios.post method to resolve with a status of 201 (simulating a successful login). The test then clicks the 'Login' button and waits for the asynchronous actions to complete. It expects that the onLoginSuccess callback is called, the text 'Login successful!' is present in the component, and the 'Username' input field is not present in the DOM.