From 2c123015fcde0d414e541c553287fe69fb682f39 Mon Sep 17 00:00:00 2001
From: AntoineGonzalez <45924026+AntoineGonzalez@users.noreply.github.com>
Date: Thu, 22 Sep 2022 13:46:27 +0200
Subject: [PATCH 1/3] feature: add clear game button
---
src/tests/components/App.test.tsx | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 src/tests/components/App.test.tsx
diff --git a/src/tests/components/App.test.tsx b/src/tests/components/App.test.tsx
new file mode 100644
index 0000000..b1bc945
--- /dev/null
+++ b/src/tests/components/App.test.tsx
@@ -0,0 +1,16 @@
+import { render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import App from '../../App'
+import wrapWithReduxProvider from '../utils/reduxProviderWrapper'
+
+describe('components/App.tsx', () => {
+ it('starts the game on start game button click and stops the game on stop game button click', async () => {
+ render(wrapWithReduxProvider())
+
+ const startGameBtn = screen.getByRole('button', { name: 'Start' })
+ await userEvent.click(startGameBtn)
+ expect(startGameBtn).toHaveTextContent('Stop')
+ await userEvent.click(startGameBtn)
+ expect(startGameBtn).toHaveTextContent('Start')
+ })
+})
From 6df7b6612b0caba8a82237fa9198bdb7b1eee556 Mon Sep 17 00:00:00 2001
From: AntoineGonzalez <45924026+AntoineGonzalez@users.noreply.github.com>
Date: Thu, 22 Sep 2022 13:46:45 +0200
Subject: [PATCH 2/3] feature: add clear game button
---
src/App.tsx | 9 +++++++
src/store/slices/gameSlice.ts | 12 +++++++--
src/tests/components/Grid.test.tsx | 11 --------
src/tests/components/PatternList.test.tsx | 2 +-
src/tests/unit/gameSlice.test.ts | 32 +++++++++++++++++++++++
5 files changed, 52 insertions(+), 14 deletions(-)
diff --git a/src/App.tsx b/src/App.tsx
index 62f6e52..71a657f 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -36,6 +36,10 @@ function App () {
dispatch(gameSlice.actions.startGame())
}
+ function handleClearGame () {
+ dispatch(gameSlice.actions.clearGame())
+ }
+
function handleStopGame () {
dispatch(gameSlice.actions.stopGame())
}
@@ -48,6 +52,11 @@ function App () {
Nombre d'itérations : {iterationCounter}
+
+
+