import { jest } from '@jest/globals' if (process.env.NODE_ENV === 'test') { require('jest-preset-angular/setup-jest') } import '@angular/localize/init' import { TextEncoder, TextDecoder } from 'util' global.TextEncoder = TextEncoder global.TextDecoder = TextDecoder import { registerLocaleData } from '@angular/common' import localeAr from '@angular/common/locales/ar' import localeBe from '@angular/common/locales/be' import localeCa from '@angular/common/locales/ca' import localeCs from '@angular/common/locales/cs' import localeDa from '@angular/common/locales/da' import localeDe from '@angular/common/locales/de' import localeEnGb from '@angular/common/locales/en-GB' import localeEs from '@angular/common/locales/es' import localeFi from '@angular/common/locales/fi' import localeFr from '@angular/common/locales/fr' import localeIt from '@angular/common/locales/it' import localeLb from '@angular/common/locales/lb' import localeNl from '@angular/common/locales/nl' import localePl from '@angular/common/locales/pl' import localePt from '@angular/common/locales/pt' import localeRo from '@angular/common/locales/ro' import localeRu from '@angular/common/locales/ru' import localeSl from '@angular/common/locales/sl' import localeSr from '@angular/common/locales/sr' import localeSv from '@angular/common/locales/sv' import localeTr from '@angular/common/locales/tr' import localeZh from '@angular/common/locales/zh' registerLocaleData(localeAr) registerLocaleData(localeBe) registerLocaleData(localeCa) registerLocaleData(localeCs) registerLocaleData(localeDa) registerLocaleData(localeDe) registerLocaleData(localeEnGb) registerLocaleData(localeEs) registerLocaleData(localeFi) registerLocaleData(localeFr) registerLocaleData(localeIt) registerLocaleData(localeLb) registerLocaleData(localeNl) registerLocaleData(localePl) registerLocaleData(localePt, 'pt-BR') registerLocaleData(localePt, 'pt-PT') registerLocaleData(localeRo) registerLocaleData(localeRu) registerLocaleData(localeSl) registerLocaleData(localeSr) registerLocaleData(localeSv) registerLocaleData(localeTr) registerLocaleData(localeZh) /* global mocks for jsdom */ const mock = () => { let storage: { [key: string]: string } = {} return { getItem: (key: string) => (key in storage ? storage[key] : null), setItem: (key: string, value: string) => (storage[key] = value || ''), removeItem: (key: string) => delete storage[key], clear: () => (storage = {}), } } Object.defineProperty(window, 'localStorage', { value: mock() }) Object.defineProperty(window, 'sessionStorage', { value: mock() }) Object.defineProperty(window, 'getComputedStyle', { value: () => ['-webkit-appearance'], }) Object.defineProperty(window, 'ResizeObserver', { value: mock() }) HTMLCanvasElement.prototype.getContext = < typeof HTMLCanvasElement.prototype.getContext >jest.fn()