diff --git a/.eslintrc.json b/.eslintrc.json index 208f455dc..5ee1474b4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,7 @@ { "root": true, "parserOptions": { - "tsconfigRootDir": "", + "tsconfigRootDir": ".", "project": [ "./tsconfig.json" ] @@ -16,11 +16,21 @@ "prefer": "type-imports", "disallowTypeAnnotations": false } - ] + ], + "jest/no-disabled-tests": "warn", + "jest/no-focused-tests": "error", + "jest/no-identical-title": "error", + "jest/prefer-to-have-length": "warn", + "jest/valid-expect": "error" + }, + "env": { + "jest": true, + "jest/globals": true }, "plugins": [ "@typescript-eslint", - "testing-library" + "testing-library", + "jest" ], "extends": [ "next/core-web-vitals", diff --git a/package.json b/package.json index 85bc364de..c6460dc5c 100644 --- a/package.json +++ b/package.json @@ -144,6 +144,7 @@ "eslint-config-prettier": "8.5.0", "eslint-plugin-chai-friendly": "0.7.2", "eslint-plugin-cypress": "2.12.1", + "eslint-plugin-jest": "26.4.6", "eslint-plugin-node": "11.1.0", "eslint-plugin-promise": "6.0.0", "eslint-plugin-testing-library": "5.5.1", diff --git a/src/components/markdown-renderer/utils/node-to-react-transformer.test.tsx b/src/components/markdown-renderer/utils/node-to-react-transformer.test.tsx index f8dd28c78..48f25e18a 100644 --- a/src/components/markdown-renderer/utils/node-to-react-transformer.test.tsx +++ b/src/components/markdown-renderer/utils/node-to-react-transformer.test.tsx @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -8,7 +8,7 @@ import { NodeToReactTransformer } from './node-to-react-transformer' import { Element } from 'domhandler' import type { ReactElement, ReactHTMLElement } from 'react' import type { NodeReplacement } from '../replace-components/component-replacer' -import { DO_NOT_REPLACE, REPLACE_WITH_NOTHING } from '../replace-components/component-replacer' +import { ComponentReplacer, DO_NOT_REPLACE, REPLACE_WITH_NOTHING } from '../replace-components/component-replacer' describe('node to react transformer', () => { let nodeToReactTransformer: NodeToReactTransformer @@ -28,11 +28,11 @@ describe('node to react transformer', () => { it('can replace an element nothing', () => { nodeToReactTransformer.setReplacers([ - { + new (class extends ComponentReplacer { replace(): NodeReplacement { return REPLACE_WITH_NOTHING } - } + })() ]) const translation = nodeToReactTransformer.translateNodeToReactElement(defaultTestSpanElement, 1) as ReactElement expect(translation).toEqual(null) @@ -40,11 +40,11 @@ describe('node to react transformer', () => { it('can translate an element with no matching replacer', () => { nodeToReactTransformer.setReplacers([ - { + new (class extends ComponentReplacer { replace(): NodeReplacement { return DO_NOT_REPLACE } - } + })() ]) const translation = nodeToReactTransformer.translateNodeToReactElement(defaultTestSpanElement, 1) as ReactElement @@ -54,11 +54,11 @@ describe('node to react transformer', () => { it('can replace an element', () => { nodeToReactTransformer.setReplacers([ - { + new (class extends ComponentReplacer { replace(): NodeReplacement { return
} - } + })() ]) const translation = nodeToReactTransformer.translateNodeToReactElement(defaultTestSpanElement, 1) as ReactElement diff --git a/src/redux/note-details/format-selection/apply-format-type-to-markdown-lines.test.ts b/src/redux/note-details/format-selection/apply-format-type-to-markdown-lines.test.ts index 925dfa03e..1b9dd9e5e 100644 --- a/src/redux/note-details/format-selection/apply-format-type-to-markdown-lines.test.ts +++ b/src/redux/note-details/format-selection/apply-format-type-to-markdown-lines.test.ts @@ -117,7 +117,7 @@ describe('apply format type to markdown lines', () => { expect(prependLinesOfSelectionMock).toBeCalledWith(markdownContentMock, cursorSelectionMock, expect.anything()) }) - it('can process the format type unordered list', () => { + it('can process the format type ordered list', () => { const result = applyFormatTypeToMarkdownLines(markdownContentMock, cursorSelectionMock, FormatType.ORDERED_LIST) expect(result).toEqual(['1. input', cursorSelectionMock]) expect(prependLinesOfSelectionMock).toBeCalledWith(markdownContentMock, cursorSelectionMock, expect.anything()) diff --git a/yarn.lock b/yarn.lock index 506ea24bf..ca6c5f2fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2050,6 +2050,7 @@ __metadata: eslint-config-prettier: 8.5.0 eslint-plugin-chai-friendly: 0.7.2 eslint-plugin-cypress: 2.12.1 + eslint-plugin-jest: 26.4.6 eslint-plugin-node: 11.1.0 eslint-plugin-promise: 6.0.0 eslint-plugin-testing-library: 5.5.1 @@ -5127,7 +5128,7 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/utils@npm:5.27.0, @typescript-eslint/utils@npm:^5.13.0": +"@typescript-eslint/utils@npm:5.27.0, @typescript-eslint/utils@npm:^5.10.0, @typescript-eslint/utils@npm:^5.13.0": version: 5.27.0 resolution: "@typescript-eslint/utils@npm:5.27.0" dependencies: @@ -9899,6 +9900,23 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-jest@npm:26.4.6": + version: 26.4.6 + resolution: "eslint-plugin-jest@npm:26.4.6" + dependencies: + "@typescript-eslint/utils": ^5.10.0 + peerDependencies: + "@typescript-eslint/eslint-plugin": ^5.0.0 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + "@typescript-eslint/eslint-plugin": + optional: true + jest: + optional: true + checksum: 1d4c35282abecbc3656f9a355c3e63df0b4134fae208ceb9ee75421ed95f6a108753ac86b54d9302f4ae192227c41b45a50034854e75fad3691868eaab8394a2 + languageName: node + linkType: hard + "eslint-plugin-jsx-a11y@npm:^6.5.1": version: 6.5.1 resolution: "eslint-plugin-jsx-a11y@npm:6.5.1"