Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NicBG committed Apr 3, 2024
1 parent 99143fa commit 0e6ada2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lvlgg_frontend/src/Components/__tests__/SignIn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import SignIn from '../../Components/Pages/SignIn';
import axios from 'axios';
import { AuthContext, AuthProvider } from '../../Contexts/AuthContext.js';

const backendUrl = process.env.REACT_APP_BACKEND_URL;

jest.mock('axios');

test('renders SignIn component', () => {
Expand Down Expand Up @@ -46,7 +48,7 @@ test('allows user to sign in', async () => {
fireEvent.click(button);

await waitFor(() => {
expect(axios.post).toHaveBeenCalledWith('http://localhost:8000/account/signin/', {
expect(axios.post).toHaveBeenCalledWith(`${backendUrl}/account/signin/`, {
username: 'testuser',
password: 'testpassword',
});
Expand Down
12 changes: 7 additions & 5 deletions lvlgg_frontend/src/Components/__tests__/SignUp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import '@testing-library/jest-dom/extend-expect';
import SignUp from '../../Components/Pages/SignUp.js';
import axios from 'axios';

const backendUrl = process.env.REACT_APP_BACKEND_URL;

jest.mock('axios');

test('renders SignUp component', () => {
render(<SignUp />);
const usernameInput = screen.getByLabelText('Username:');
const emailInput = screen.getByLabelText('Email:');
const passwordInput = screen.getByLabelText('Password:');
const firstNameInput = screen.getByLabelText('First:');
const lastNameInput = screen.getByLabelText('Last:');
const firstNameInput = screen.getByLabelText('FirstName:');
const lastNameInput = screen.getByLabelText('LastName:');
const button = screen.getByText('Create Account');

expect(usernameInput).toBeInTheDocument();
Expand All @@ -28,8 +30,8 @@ test('allows user to sign up', async () => {
const usernameInput = screen.getByLabelText('Username:');
const emailInput = screen.getByLabelText('Email:');
const passwordInput = screen.getByLabelText('Password:');
const firstNameInput = screen.getByLabelText('First:');
const lastNameInput = screen.getByLabelText('Last:');
const firstNameInput = screen.getByLabelText('FirstName:');
const lastNameInput = screen.getByLabelText('LastName:');
const button = screen.getByText('Create Account');

fireEvent.change(usernameInput, { target: { value: 'testuser' } });
Expand All @@ -43,7 +45,7 @@ test('allows user to sign up', async () => {
fireEvent.click(button);

await waitFor(() => {
expect(axios.post).toHaveBeenCalledWith('http://localhost:8000/account/signup/', {
expect(axios.post).toHaveBeenCalledWith(`${backendUrl}/account/signup/`, {
username: 'testuser',
email: 'test@example.com',
password: 'testpassword',
Expand Down

0 comments on commit 0e6ada2

Please sign in to comment.