@stolostron/multicluster-sdk
Version:
Provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management.
101 lines • 3.25 kB
JavaScript
;
/* 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 };
};
Object.defineProperty(exports, "__esModule", { value: true });
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"));
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';
process.env.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 = class EventSource {
static CONNECTING = 0;
static OPEN = 1;
static CLOSED = 2;
constructor(url, eventSourceInitDict) {
this.url = url.toString();
this.withCredentials = !!eventSourceInitDict?.withCredentials;
}
CONNECTING = 0;
OPEN = 1;
CLOSED = 2;
url;
readyState = 0;
withCredentials = false;
addEventListener = () => { };
close = () => { };
dispatchEvent = () => false;
onerror = () => { };
onmessage = () => { };
onopen = () => { };
removeEventListener = () => { };
};
globalThis.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