UNPKG

@stolostron/multicluster-sdk

Version:

Provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management.

106 lines 3.71 kB
"use strict"; /* Copyright Contributors to the Open Cluster Management project */ /* istanbul ignore file */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var _a; var _b; var _c; Object.defineProperty(exports, "__esModule", { value: true }); /* eslint-disable @typescript-eslint/no-explicit-any */ const dom_1 = require("@testing-library/dom"); require("@testing-library/jest-dom"); require("jest-axe/extend-expect"); const jest_fetch_mock_1 = __importDefault(require("jest-fetch-mock")); const util_1 = require("util"); const i18next_1 = __importDefault(require("i18next")); // eslint-disable-next-line @typescript-eslint/no-restricted-imports const react_i18next_1 = require("react-i18next"); process.env.NODE_ENV = 'test'; process.env.JEST_DEFAULT_HOST = 'http://localhost'; process.env.REACT_APP_BACKEND_PATH = ''; process.env.MODE = 'plugin'; (_a = (_b = process.env).DEBUG_PRINT_LIMIT) !== null && _a !== void 0 ? _a : (_b.DEBUG_PRINT_LIMIT = '0'); window.SERVER_FLAGS = { basePath: '/' }; jest_fetch_mock_1.default.enableMocks(); fetchMock.dontMock(); global.fetch = jest.fn((input, reqInit) => { const newInput = typeof input === 'string' || input instanceof URL ? new URL(input.toString(), process.env.JEST_DEFAULT_HOST).toString() : input; return fetchMock(newInput, reqInit); }); global.EventSource = (_c = class EventSource { constructor(url, eventSourceInitDict) { this.CONNECTING = 0; this.OPEN = 1; this.CLOSED = 2; this.readyState = 0; this.withCredentials = false; this.addEventListener = () => { }; this.close = () => { }; this.dispatchEvent = () => false; this.onerror = () => { }; this.onmessage = () => { }; this.onopen = () => { }; this.removeEventListener = () => { }; this.url = url.toString(); this.withCredentials = !!(eventSourceInitDict === null || eventSourceInitDict === void 0 ? void 0 : eventSourceInitDict.withCredentials); } }, _c.CONNECTING = 0, _c.OPEN = 1, _c.CLOSED = 2, _c); global.TextEncoder = util_1.TextEncoder; (0, dom_1.configure)({ testIdAttribute: 'id' }); jest.setTimeout((process.env.LAUNCH ? 3000 : 180) * 1000); let consoleWarnings = []; let consoleErrors = []; // eslint-disable-next-line @typescript-eslint/no-unused-vars console.warn = (message, ..._optionalParams) => { if (typeof message === 'string') { if (message.startsWith('You are using a beta component feature (isAriaDisabled).')) return; } consoleWarnings.push(message); }; // eslint-disable-next-line @typescript-eslint/no-unused-vars console.error = (message, ..._optionalParams) => { consoleErrors.push(message); }; function setupBeforeEach() { consoleErrors = []; consoleWarnings = []; } beforeEach(setupBeforeEach); i18next_1.default.use(react_i18next_1.initReactI18next).init({ keySeparator: false, interpolation: { escapeValue: false, }, compatibilityJSON: 'v3', defaultNS: 'translation', nsSeparator: '~', supportedLngs: ['en'], simplifyPluralSuffix: true, lng: 'en', fallbackLng: 'en', ns: 'translation', resources: { en: { translation: {}, }, }, }); window.matchMedia = window.matchMedia || function () { return { matches: false, addListener: function () { }, removeListener: function () { }, }; }; //# sourceMappingURL=setupTests.js.map