From 0d6346c73a3fd91ac31294b48f3f7a94e9886fcd Mon Sep 17 00:00:00 2001 From: Manuel <30572287+manuel-rw@users.noreply.github.com> Date: Wed, 22 Mar 2023 13:29:00 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Pull=20request=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONTRIBUTING.md | 3 +++ next-i18next.config.js | 1 + next.config.js | 2 +- src/modules/Docker/ContainerActionBar.tsx | 8 ++++++++ src/tools/types.ts | 7 +++++++ setupVitest.ts => tests/setupVitest.ts | 0 vitest.config.ts | 8 ++++---- 7 files changed, 24 insertions(+), 5 deletions(-) rename setupVitest.ts => tests/setupVitest.ts (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 461f16f4a..b41812c26 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -105,6 +105,9 @@ Homarr uses [GitMoji](https://gitmoji.dev/). We would appreciate it if everyone keeps their commit messages withing these rulings. ### Tests + +> Components should be tested using unit tests. A unit is the smallest isolated part of the component. Unit tests must not have any dependencies and must be isolated. + - Place testfiles directly at the root of the unit - Only test a single unit of work inside a unit test - You may test multiple units inside one test file diff --git a/next-i18next.config.js b/next-i18next.config.js index 71af66b5d..d39ce661f 100644 --- a/next-i18next.config.js +++ b/next-i18next.config.js @@ -1,6 +1,7 @@ const path = require('path'); module.exports = { + // https://www.i18next.com/overview/configuration-options#logging i18n: { defaultLocale: 'en', locales: [ diff --git a/next.config.js b/next.config.js index 187db4b22..dde3ec977 100644 --- a/next.config.js +++ b/next.config.js @@ -10,5 +10,5 @@ module.exports = withBundleAnalyzer({ }, reactStrictMode: true, output: 'standalone', - i18n: i18n, + i18n, }); diff --git a/src/modules/Docker/ContainerActionBar.tsx b/src/modules/Docker/ContainerActionBar.tsx index 2c8a312ad..a3df3f6c1 100644 --- a/src/modules/Docker/ContainerActionBar.tsx +++ b/src/modules/Docker/ContainerActionBar.tsx @@ -207,6 +207,9 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction ); } +/** + * @deprecated legacy code + */ function tryMatchType(imageName: string): ServiceType { const match = MatchingImages.find(({ image }) => imageName.includes(image)); if (match) { @@ -216,6 +219,11 @@ function tryMatchType(imageName: string): ServiceType { return 'Other'; } +/** + * @deprecated + * @param container the container to match + * @returns a new service + */ const tryMatchService = (container: Dockerode.ContainerInfo | undefined) => { if (container === undefined) return {}; const name = container.Names[0].substring(1); diff --git a/src/tools/types.ts b/src/tools/types.ts index cb59c6f3a..71046a433 100644 --- a/src/tools/types.ts +++ b/src/tools/types.ts @@ -1,4 +1,5 @@ import { MantineTheme } from '@mantine/core'; + import { OptionValues } from '../modules/ModuleTypes'; export interface Settings { @@ -74,6 +75,12 @@ export type ServiceType = | 'Sabnzbd' | 'NZBGet'; +/** + * @deprecated + * @param name the name to match + * @param form the form + * @returns the port from the map + */ export function tryMatchPort(name: string | undefined, form?: any) { if (!name) { return undefined; diff --git a/setupVitest.ts b/tests/setupVitest.ts similarity index 100% rename from setupVitest.ts rename to tests/setupVitest.ts diff --git a/vitest.config.ts b/vitest.config.ts index 84963283d..df9cb8561 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -6,15 +6,15 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ plugins: [react()], test: { - environment: 'jsdom', + environment: 'happy-dom', coverage: { provider: 'c8', reporter: ['html'], all: true, - exclude: ['.next/', '.yarn/', 'data/'] + exclude: ['.next/', '.yarn/', 'data/'], }, setupFiles: [ - "./setupVitest.ts" - ] + './tests/setupVitest.ts', + ], }, });