Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const emptyLocaleData = () => {
const emptyObject = (obj) => {
Object.keys(obj).forEach((prop) => delete obj[prop]);
};
emptyObject(IntlRelativeFormat.__localeData__);
};
const restoreLocaleData = () => {
emptyLocaleData();
Object.assign(IntlRelativeFormat.__localeData__, IRF_LOCALE_DATA);
};
describe('locale data registry', () => {
const IRF_LOCALE_DATA = {...IntlRelativeFormat.__localeData__};
const emptyLocaleData = () => {
const emptyObject = (obj) => {
Object.keys(obj).forEach((prop) => delete obj[prop]);
};
emptyObject(IntlRelativeFormat.__localeData__);
};
const restoreLocaleData = () => {
emptyLocaleData();
Object.assign(IntlRelativeFormat.__localeData__, IRF_LOCALE_DATA);
};
afterEach(() => {
restoreLocaleData();
function hasIMFAndIRFLocaleData(locale) {
let normalizedLocale = locale && locale.toLowerCase();
return !!IntlRelativeFormat.__localeData__[normalizedLocale];
}