Skip to content

Commit

Permalink
Register test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CANCI0 committed Mar 10, 2024
1 parent 96080d0 commit 1a26749
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions webapp/src/components/Register/Register.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const AddUser = () => {
margin="normal"
fullWidth
label="Username"
placeholder="Username"
value={username}
onChange={(e) => setUsername(e.target.value)}
/>
Expand All @@ -43,6 +44,7 @@ const AddUser = () => {
fullWidth
label="Password"
type="password"
placeholder="Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
Expand Down
16 changes: 8 additions & 8 deletions webapp/src/components/Register/Register.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import React from 'react';
import { render, fireEvent, screen, waitFor } from '@testing-library/react';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import AddUser from './AddUser';
import Register from './Register';

const mockAxios = new MockAdapter(axios);

describe('AddUser component', () => {
describe('Register component', () => {
beforeEach(() => {
mockAxios.reset();
});

it('should add user successfully', async () => {
render(<AddUser />);
render(<Register />);

const usernameInput = screen.getByLabelText(/Username/i);
const passwordInput = screen.getByLabelText(/Password/i);
const usernameInput = screen.getByPlaceholderText(/Username/i);
const passwordInput = screen.getByPlaceholderText(/Password/i);
const addUserButton = screen.getByRole('button', { name: /Add User/i });

// Mock the axios.post request to simulate a successful response
Expand All @@ -35,10 +35,10 @@ describe('AddUser component', () => {
});

it('should handle error when adding user', async () => {
render(<AddUser />);
render(<Register />);

const usernameInput = screen.getByLabelText(/Username/i);
const passwordInput = screen.getByLabelText(/Password/i);
const usernameInput = screen.getByPlaceholderText(/Username/i);
const passwordInput = screen.getByPlaceholderText(/Password/i);
const addUserButton = screen.getByRole('button', { name: /Add User/i });

// Mock the axios.post request to simulate an error response
Expand Down

0 comments on commit 1a26749

Please sign in to comment.