Skip to content

Commit

Permalink
Merge pull request #165 from Arquisoft/150-increase-code-coverage
Browse files Browse the repository at this point in the history
Added test to navbar
  • Loading branch information
UO289845 authored Apr 28, 2024
2 parents 2bda0de + 08796c1 commit 52ef5aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ jobs:
- run: npm --prefix gatewayservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
- run: npm --prefix webapp run test:e2e
- run: npm --prefix webapp run test:e2e
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
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 52ef5aa

Please sign in to comment.