diff --git a/.gitignore b/.gitignore index 04c01ba7..25768809 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -dist/ \ No newline at end of file +dist/ +.idea/ \ No newline at end of file diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..a9db3daf --- /dev/null +++ b/jest.config.js @@ -0,0 +1,32 @@ +const path = require("path"); + +module.exports = { + clearMocks: true, + restoreMocks: true, + collectCoverage: true, + collectCoverageFrom: [path.resolve(__dirname, "src/**/*.{js,jsx,ts,tsx}")], + coverageDirectory: "coverage", + coverageReporters: ["text-summary", "lcov"], + coverageThreshold: { + global: { + branches: 95, + functions: 99, + lines: 99, + statements: 95, + }, + }, + errorOnDeprecated: true, + moduleNameMapper: { + "\\.(jpg|jpeg|png|gif|webp|svg|bmp|woff|woff2|ttf)$": "/test/mocks/fileMock.js", + "\\.(css|less|scss|sass)$": "identity-obj-proxy", + "test/(.*)$": "/test/$1", + "~/(.*)$": "/src/$1", + }, + setupFilesAfterEnv: ["/test/setup.ts"], + globalTeardown: "/test/teardown.ts", + fakeTimers: { + enableGlobally: true, + }, + verbose: true, + testEnvironment: "jsdom", +}; diff --git a/package.json b/package.json index 5482fbee..013d81a8 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch --mode=development", "serve": "webpack serve --mode=development", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "jest" }, "directories": { "example": "examples" diff --git a/src/helpers/Field.ts b/src/helpers/Field.ts index e69de29b..f04eca48 100644 --- a/src/helpers/Field.ts +++ b/src/helpers/Field.ts @@ -0,0 +1,11 @@ +export type Cell = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; +export type Field = Cell[][]; +export type Coordinates = [number, number]; + +export const CellState: Record = { + empty: 0, + bomb: 9, + hidden: 10, + mark: 11, + weakMark: 12, +};