Skip to content

Commit

Permalink
Button and Nav tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krovostcora committed Mar 14, 2024
1 parent 9e624a0 commit 0193ccd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions webapp/src/components/Button/Button.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { render, fireEvent, screen, waitFor } from '@testing-library/react';
import Button from './Button';
import '@testing-library/jest-dom'

describe('Button component', () => {
it ('renders without crashing', () => {
render(<Button>Hello!</Button>)

expect(screen.getByText(/Hello!/i)).toBeInTheDocument();
})
})
19 changes: 19 additions & 0 deletions webapp/src/components/Nav/Nav.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { render, fireEvent, screen, waitFor } from '@testing-library/react';
import Nav from './Nav';
import '@testing-library/jest-dom'
import { Routes, BrowserRouter, Route } from 'react-router-dom'

describe('Nav component', () => {
it ('renders Nap without crashing', () => {

render (<BrowserRouter>
<Routes>
<Route path="/" element={< Nav openNav={true} onToggleNav={() => {}} />}></Route>
</Routes>
</BrowserRouter>)
expect(screen.getByText(/Leaderboard/i)).toBeInTheDocument();
expect(screen.getByText(/Settings/i)).toBeInTheDocument();
expect(screen.getByText(/Play/i)).toBeInTheDocument();
})
})

0 comments on commit 0193ccd

Please sign in to comment.