-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7564a0f
commit 4ae7c0d
Showing
6 changed files
with
257 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import '@testing-library/jest-dom'; | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import Board from './board'; | ||
import { DEFAULT_TURN_DURATION } from '../../../utils/constants'; | ||
import { DEFAULT_GAME_MODE } from '../../../utils/GameMode'; | ||
|
||
jest.mock('../model/model.jsx'); | ||
|
||
const G = { | ||
dealt: [], | ||
players: { | ||
0: ['T3', 'T4', 'T5'], | ||
}, | ||
order: [0, 1, 2], | ||
scores: [0, 0, 0], | ||
identifiedThreats: {}, | ||
selectedDiagram: 0, | ||
selectedComponent: '', | ||
threat: { | ||
modal: false, | ||
}, | ||
passed: [], | ||
suit: 'T', | ||
round: 1, | ||
startingCard: 'T3', | ||
gameMode: DEFAULT_GAME_MODE, | ||
turnDuration: DEFAULT_TURN_DURATION, | ||
turnFinishTargetTime: Date.now() + DEFAULT_TURN_DURATION * 1000, | ||
}; | ||
const ctx = { | ||
actionPlayers: [0, 1, 2], | ||
}; | ||
Board.prototype.componentDidMount = jest.fn(); | ||
|
||
|
||
describe('Board', () => { | ||
it('renders without crashing', async () => { | ||
|
||
// when | ||
render(<Board G={G} ctx={ctx} matchID="123" moves={{}} events={{}} playerID="0" />); | ||
|
||
// then | ||
await screen.getByRole(`button`, { | ||
name: `Download Threats` | ||
}); | ||
|
||
}); | ||
|
||
it('should render imprint link if env var is defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_IMPRINT = 'https://example.tld/imprint/' | ||
|
||
// when | ||
render(<Board G={G} ctx={ctx} matchID="123" moves={{}} events={{}} playerID="0" />); | ||
|
||
// when | ||
|
||
// then | ||
const links = await screen.queryAllByRole('link', { | ||
name: `Imprint` | ||
}); | ||
expect(links.length).toBe(1); | ||
}); | ||
|
||
it('should not render imprint link if env var is not defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_IMPRINT = ""; | ||
|
||
// when | ||
render(<Board G={G} ctx={ctx} matchID="123" moves={{}} events={{}} playerID="0" />); | ||
|
||
// then | ||
const links = await screen.queryAllByRole('link', { | ||
name: `Imprint` | ||
}); | ||
expect(links.length).toBe(0); | ||
}); | ||
|
||
it('should render privacy link if env var is defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_PRIVACY = 'https://example.tld/privacy/' | ||
|
||
// when | ||
render(<Board G={G} ctx={ctx} matchID="123" moves={{}} events={{}} playerID="0" />); | ||
|
||
// when | ||
|
||
// then | ||
const links = await screen.queryAllByRole('link', { | ||
name: `Privacy` | ||
}); | ||
expect(links.length).toBe(1); | ||
}); | ||
|
||
it('should not render privacy link if env var is not defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_PRIVACY = ""; | ||
|
||
// when | ||
render(<Board G={G} ctx={ctx} matchID="123" moves={{}} events={{}} playerID="0" />); | ||
|
||
// then | ||
const links = await screen.queryAllByRole('link', { | ||
name: `Privacy` | ||
}); | ||
expect(links.length).toBe(0); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import '@testing-library/jest-dom'; | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import Imprint from './imprint'; | ||
|
||
describe('Imprint', () => { | ||
it('should render link if env var is defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_IMPRINT = 'https://example.tld/imprint/' | ||
render(<Imprint />); | ||
|
||
// when | ||
const links = await screen.queryAllByRole('link'); | ||
|
||
// then | ||
expect(links.length).toBe(1); | ||
}); | ||
|
||
it('should not render link if env var is not defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_IMPRINT = ""; | ||
render(<Imprint />); | ||
|
||
// when | ||
const links = await screen.queryAllByRole('link'); | ||
|
||
// then | ||
expect(links.length).toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import '@testing-library/jest-dom'; | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import Privacy from './privacy'; | ||
|
||
describe('Privacy', () => { | ||
it('should render link if env var is defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_PRIVACY = 'https://example.tld/privacy/' | ||
render(<Privacy />); | ||
|
||
// when | ||
const links = await screen.queryAllByRole('link'); | ||
|
||
// then | ||
expect(links.length).toBe(1); | ||
}); | ||
|
||
it('should not render link if env var is not defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_PRIVACY = ""; | ||
render(<Privacy />); | ||
|
||
// when | ||
const links = await screen.queryAllByRole('link'); | ||
|
||
// then | ||
expect(links.length).toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,76 @@ | ||
import '@testing-library/jest-dom'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { render, screen } from '@testing-library/react'; | ||
import Create from '../create'; | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
|
||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render( | ||
<Router> | ||
<Create /> | ||
</Router>, | ||
div, | ||
); | ||
ReactDOM.unmountComponentAtNode(div); | ||
describe('<Create />', () => { | ||
it('renders without crashing', async () => { | ||
render(<Router><Create /></Router>); | ||
|
||
await screen.getAllByRole('button', { | ||
name: 'Proceed' | ||
}); | ||
}); | ||
|
||
it('should render imprint link if env var is defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_IMPRINT = 'https://example.tld/imprint/' | ||
|
||
// when | ||
render(<Router><Create /></Router>); | ||
|
||
// when | ||
|
||
// then | ||
const links = await screen.queryAllByRole('link', { | ||
name: `Imprint` | ||
}); | ||
expect(links.length).toBe(1); | ||
}); | ||
|
||
it('should not render imprint link if env var is not defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_IMPRINT = ""; | ||
|
||
// when | ||
render(<Router><Create /></Router>); | ||
|
||
// then | ||
const links = await screen.queryAllByRole('link', { | ||
name: `Imprint` | ||
}); | ||
expect(links.length).toBe(0); | ||
}); | ||
|
||
it('should render privacy link if env var is defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_PRIVACY = 'https://example.tld/privacy/' | ||
|
||
// when | ||
render(<Router><Create /></Router>); | ||
|
||
// when | ||
|
||
// then | ||
const links = await screen.queryAllByRole('link', { | ||
name: `Privacy` | ||
}); | ||
expect(links.length).toBe(1); | ||
}); | ||
|
||
it('should not render privacy link if env var is not defined', async () => { | ||
// given | ||
process.env.REACT_APP_EOP_PRIVACY = ""; | ||
|
||
// when | ||
render(<Router><Create /></Router>); | ||
|
||
// then | ||
const links = await screen.queryAllByRole('link', { | ||
name: `Privacy` | ||
}); | ||
expect(links.length).toBe(0); | ||
}); | ||
|
||
}); |