diff --git a/lib/registry.ts b/lib/registry.ts index 328752f1..a53443ec 100644 --- a/lib/registry.ts +++ b/lib/registry.ts @@ -103,12 +103,6 @@ export function unregisterAppTranslations(appId: string) { * @return {object} */ export function getAppTranslations(appId: string): AppTranslations { - if ( - typeof window._oc_l10n_registry_translations?.[appId] === 'undefined' - || typeof window._oc_l10n_registry_plural_functions?.[appId] === 'undefined' - ) { - console.warn(`No translation for appId "${appId}" have been registered`) - } return { translations: window._oc_l10n_registry_translations?.[appId] ?? {}, pluralFunction: window._oc_l10n_registry_plural_functions?.[appId] ?? ((number: number) => number), diff --git a/tests/gettext.test.js b/tests/gettext.test.js index e4d076c5..45cb1f24 100644 --- a/tests/gettext.test.js +++ b/tests/gettext.test.js @@ -3,9 +3,9 @@ import { po } from 'gettext-parser' import { getGettextBuilder } from '../lib/gettext.ts' describe('gettext', () => { - beforeEach(() => { jest.spyOn(console, 'warn') + console.warn.mockImplementation(() => {}) }) afterEach(() => { diff --git a/tests/registry.test.ts b/tests/registry.test.ts index 455c2072..7d983655 100644 --- a/tests/registry.test.ts +++ b/tests/registry.test.ts @@ -49,13 +49,7 @@ describe('registry', () => { }) describe('getAppTranslations', () => { - const orginalWarn = console.warn - - afterAll(() => { - console.warn = orginalWarn - }) beforeEach(() => { - console.warn = jest.fn() clearWindow() }) @@ -64,7 +58,6 @@ describe('registry', () => { expect(bundle.translations).toMatchObject({}) expect(typeof bundle.pluralFunction === 'function').toBe(true) expect(typeof bundle.pluralFunction(0)).toBe('number') - expect(console.warn).toBeCalled() }) it('with translations', () => { @@ -73,17 +66,10 @@ describe('registry', () => { let bundle = getAppTranslations('core') expect(Object.keys(bundle.translations).length > 0).toBe(true) expect(bundle.pluralFunction).toBe(pluralFunction) - expect(console.warn).toBeCalledTimes(0) bundle = getAppTranslations('doesnotexist') expect(bundle.translations).toMatchObject({}) expect(typeof bundle.pluralFunction === 'function').toBe(true) - expect(console.warn).toBeCalledTimes(1) - - // Expect a warning if some registration is broken - delete window._oc_l10n_registry_plural_functions - bundle = getAppTranslations('core') - expect(console.warn).toBeCalledTimes(2) }) })