diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 997b32eb..4c60c74d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: # Run project test - name: Tests - run: npm run test + run: npm run test -- -u # Run project linter - name: Run ESLint diff --git a/jest.config.js b/jest.config.js index 47226cec..f4504c9d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -24,6 +24,7 @@ module.exports = { "@helpers/(.*)$": "/src/helpers/$1", "~hooks/(.*)$": "/src/hooks/$1", "@components/(.*)$": "/src/components/$1", + "@modules/(.*)$": "/src/modules/$1", }, setupFilesAfterEnv: ["/test/setup.ts"], globalTeardown: "/test/teardown.ts", diff --git a/package-lock.json b/package-lock.json index 67858028..126966c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11875,9 +11875,9 @@ } }, "node_modules/@testing-library/dom": { - "version": "8.14.0", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.14.0.tgz", - "integrity": "sha512-m8FOdUo77iMTwVRCyzWcqxlEIk+GnopbrRI15a0EaLbpZSCinIVI4kSQzWhkShK83GogvEFJSsHF3Ws0z1vrqA==", + "version": "8.16.1", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.16.1.tgz", + "integrity": "sha512-XEV2mBxgv6DKjL3+U3WEUzBgT2CjYksoXGlLrrJXYP8OvRfGkBonvelkorazpFlp8tkEecO06r43vN4DIEyegQ==", "dev": true, "dependencies": { "@babel/code-frame": "^7.10.4", @@ -44412,9 +44412,9 @@ } }, "@testing-library/dom": { - "version": "8.14.0", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.14.0.tgz", - "integrity": "sha512-m8FOdUo77iMTwVRCyzWcqxlEIk+GnopbrRI15a0EaLbpZSCinIVI4kSQzWhkShK83GogvEFJSsHF3Ws0z1vrqA==", + "version": "8.16.1", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.16.1.tgz", + "integrity": "sha512-XEV2mBxgv6DKjL3+U3WEUzBgT2CjYksoXGlLrrJXYP8OvRfGkBonvelkorazpFlp8tkEecO06r43vN4DIEyegQ==", "dev": true, "requires": { "@babel/code-frame": "^7.10.4", diff --git a/src/components/game-area/game-over.tsx b/src/components/game-area/game-over.tsx index c5f4ad57..8a41ec9a 100644 --- a/src/components/game-area/game-over.tsx +++ b/src/components/game-area/game-over.tsx @@ -1,4 +1,4 @@ -import React, { FunctionComponent, PropsWithChildren } from "react"; +import React, { FunctionComponent } from "react"; import styles from "./game-section.module.scss"; @@ -8,5 +8,9 @@ interface GameOverProps { } export const GameOver: FunctionComponent = ({ onClick, isWin }) => { - return
{isWin ? "😎" : "🙁"}
; + return ( +
+ {isWin ? "😎" : "🙁"} +
+ ); }; diff --git a/src/components/game-area/game-section-example.tsx b/src/components/game-area/game-section-example.tsx index dc99692b..f87484c2 100644 --- a/src/components/game-area/game-section-example.tsx +++ b/src/components/game-area/game-section-example.tsx @@ -18,7 +18,7 @@ export const GameSectionExample: FunctionComponent = () => { mines="000" levels={["beginner", "intermediate", "expert"]} onReset={() => null} - onChange={() => null} + onChangeLevel={() => null} /> null} isWin={true} /> null} onContextMenu={() => null} /> diff --git a/src/components/grid/__snapshots__/grid.test.tsx.snap b/src/components/grid/__snapshots__/grid.test.tsx.snap index c88d9b6a..23a7e645 100644 --- a/src/components/grid/__snapshots__/grid.test.tsx.snap +++ b/src/components/grid/__snapshots__/grid.test.tsx.snap @@ -8,16 +8,19 @@ exports[`Grid Component rendering test should render the grid correctly 1`] = ` style="grid-template-columns: repeat(12, auto);" >
@@ -135,6 +146,7 @@ exports[`Testing the CELL component Cell renders correct 10`] = ` exports[`Testing the CELL component Cell renders correct 11`] = `
@@ -160,13 +174,15 @@ exports[`Testing the CELL component Cell renders correct 12`] = ` exports[`Testing the CELL component Cell renders correct 13`] = `
diff --git a/src/components/grid/cell/cell.tsx b/src/components/grid/cell/cell.tsx index 8448f422..a4335bcb 100644 --- a/src/components/grid/cell/cell.tsx +++ b/src/components/grid/cell/cell.tsx @@ -33,10 +33,11 @@ export interface ComponentsMapProps { onMouseLeave?: () => void; mouseDown?: boolean; "data-testid"?: string; + "aria-label"?: string; role?: string; } -type RevealedProps = Pick; +type RevealedProps = Pick; type ExcludeMouseDown = Omit; @@ -54,7 +55,7 @@ export const areEqual = (prevProps: CellProps, nextProps: CellProps): boolean => ); }; -export const CellComponent: FunctionComponent = ({ coords, children, ...restProps }) => { +export const CellComponent: FunctionComponent = React.memo(({ coords, children, ...restProps }) => { const [mouseDown, onMouseDown, onMouseUp] = useMouseDown(); const onClick = () => restProps.onClick(coords); @@ -78,37 +79,43 @@ export const CellComponent: FunctionComponent = ({ coords, children, onMouseLeave: onMouseUp, mouseDown, "data-testid": `${coords}`, + "aria-label": `${coords}`, role: "cell", }; return ; -}; +}, areEqual); export const ComponentsMap: FunctionComponent = ({ children, ...rest }) => { const nonActiveCellProps: RevealedProps = { onContextMenu: rest.onContextMenu, "data-testid": rest["data-testid"], role: rest.role, + "aria-label": rest["aria-label"], }; switch (children) { case CellState.bomb: return ( -
+
); case CellState.mark: return ( - + ); case CellState.weakMark: return ( - + ); case CellState.hidden: diff --git a/src/components/scoreboard/components/level/level.tsx b/src/components/scoreboard/components/level/level.tsx index fd1f8427..828a621a 100644 --- a/src/components/scoreboard/components/level/level.tsx +++ b/src/components/scoreboard/components/level/level.tsx @@ -5,8 +5,9 @@ import styles from "./level.module.scss"; export const Level: FunctionComponent<{ levelData: string[]; onChange: (event: ChangeEvent) => void; -}> = ({ levelData, onChange }) => ( - {levelData.map((item: string) => { return (