You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

101 lines
2.3 KiB

import { cleanup } from "@testing-library/react";
import { enableMapSet } from "immer";
import { afterEach, vi } from "vitest";
import "@testing-library/jest-dom";
import "@testing-library/user-event";
import channelsEN from "@public/i18n/locales/en/channels.json" with {
type: "json",
};
import commandPaletteEN from "@public/i18n/locales/en/commandPalette.json" with {
type: "json",
};
import commonEN from "@public/i18n/locales/en/common.json" with {
type: "json",
};
import dashboardEN from "@public/i18n/locales/en/dashboard.json" with {
type: "json",
};
import deviceConfigEN from "@public/i18n/locales/en/deviceConfig.json" with {
type: "json",
};
import dialogEN from "@public/i18n/locales/en/dialog.json" with {
type: "json",
};
import messagesEN from "@public/i18n/locales/en/messages.json" with {
type: "json",
};
import moduleConfigEN from "@public/i18n/locales/en/moduleConfig.json" with {
type: "json",
};
import nodesEN from "@public/i18n/locales/en/nodes.json" with { type: "json" };
import uiEN from "@public/i18n/locales/en/ui.json" with { type: "json" };
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
enableMapSet();
vi.mock("idb-keyval", () => ({
get: vi.fn(() => Promise.resolve(undefined)),
set: vi.fn(() => Promise.resolve()),
del: vi.fn(() => Promise.resolve()),
clear: vi.fn(() => Promise.resolve()),
keys: vi.fn(() => Promise.resolve([])),
createStore: vi.fn(() => ({})),
}));
globalThis.ResizeObserver = class {
observe() {}
unobserve() {}
disconnect() {}
};
const appNamespaces = [
"channels",
"commandPalette",
"common",
"deviceConfig",
"moduleConfig",
"dashboard",
"dialog",
"messages",
"nodes",
"ui",
];
const appFallbackNS = ["common", "ui", "dialog"];
const appDefaultNS = "common";
i18n.use(initReactI18next).init({
lng: "en",
ns: appNamespaces,
defaultNS: appDefaultNS,
fallbackNS: appFallbackNS,
resources: {
en: {
channels: channelsEN,
commandPalette: commandPaletteEN,
common: commonEN,
deviceConfig: deviceConfigEN,
moduleConfig: moduleConfigEN,
dashboard: dashboardEN,
dialog: dialogEN,
messages: messagesEN,
nodes: nodesEN,
ui: uiEN,
},
},
interpolation: {
escapeValue: false,
},
react: {
useSuspense: false,
},
debug: false,
});
afterEach(() => {
cleanup();
});