35 lines
849 B
TypeScript
35 lines
849 B
TypeScript
import '@testing-library/jest-dom';
|
|
import { TextEncoder, TextDecoder } from 'util';
|
|
|
|
// لازم برای بعضی از پکیجها در محیط jsdom
|
|
(global as any).TextEncoder = TextEncoder;
|
|
(global as any).TextDecoder = TextDecoder;
|
|
|
|
// فیک کردن matchMedia چون در jsdom نیست
|
|
if (!window.matchMedia) {
|
|
window.matchMedia = function () {
|
|
return {
|
|
matches: false,
|
|
media: '',
|
|
onchange: null,
|
|
addListener() {},
|
|
removeListener() {},
|
|
addEventListener() {},
|
|
removeEventListener() {},
|
|
dispatchEvent() {
|
|
return false;
|
|
},
|
|
};
|
|
} as any;
|
|
}
|
|
|
|
// فیک کردن IntersectionObserver
|
|
if (!('IntersectionObserver' in global)) {
|
|
class FakeObserver {
|
|
observe() {}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
}
|
|
(global as any).IntersectionObserver = FakeObserver;
|
|
}
|