Skip to content

Commit

Permalink
test(frontend): navigation works correctly
Browse files Browse the repository at this point in the history
Signed-off-by: Márk Kővári <kovarimarkofficial@gmail.com>
  • Loading branch information
markkovari committed Jul 16, 2024
1 parent 0db2977 commit 3b4fd60
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions frontend/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { render } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { App } from './App';
import { act } from 'react';


describe('App', () => {
it('should render successfully', () => {
render(<App />);
expect(true).toBe(true);
});

it('should render the main page', () => {
const { getByRole } = render(<App />);
expect(getByRole('heading', { name: /Home/i })).toBeInTheDocument();
});

it('should render the login page after clicked on the login link', () => {
const { getByRole } = render(<App />);

act(() => {
getByRole('link', { name: /login/i }).click();
});
expect(getByRole('heading', { name: /login/i })).toBeInTheDocument();
});

it('should render the main page after visited the register page and clicked on the home link', () => {
const { getByRole } = render(<App />);

act(() => {
getByRole('link', { name: /main/i }).click();
});
expect(getByRole('heading', { name: /home/i })).toBeInTheDocument();
});


it('should render the register page after clicked on the register link', () => {
const { getByRole } = render(<App />);

act(() => {
getByRole('link', { name: /register/i }).click();
});
expect(getByRole('heading', { name: /register/i })).toBeInTheDocument();
});

});

0 comments on commit 3b4fd60

Please sign in to comment.