Skip to content

Commit

Permalink
Added test to navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Mario committed Apr 28, 2024
1 parent 2cf567c commit b990279
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions webapp/src/components/fragments/NavBar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ Cookies.set('user', JSON.stringify({ username: 'dummy' }))

describe('NavBar fragment', () => {

it('shows the user name',async () => {
it('shows the user name and can log out',async () => {
render(<MemoryRouter><Navbar style={{ width: '100%' }} /></MemoryRouter>);
const text2 = await screen.findByText('dummy')
expect(text2).toBeInTheDocument();
// Wait for questions to load

fireEvent.click(screen.getByText('dummy'));
expect(screen.getByText('navBar.logout')).toBeInTheDocument();
fireEvent.click(screen.getByText('navBar.logout'));
expect(screen.queryByText('dummy')).not.toBeInTheDocument();
});

test('Navbar renders correctly', async () => {
Expand Down

0 comments on commit b990279

Please sign in to comment.