Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
feat(conditionalIntl): disable getLocalePack with env var
Browse files Browse the repository at this point in the history
  • Loading branch information
timBarton96 committed Feb 19, 2024
1 parent 43f9921 commit 5c0aab4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions __tests__/client/prerender.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ describe('loadPrerenderScripts', () => {
expect(getLocalePack).not.toHaveBeenCalled();
})
);

it('should still resolve if useNativeIntl is set to true but not call getLocalePack', async () => {
window.useNativeIntl = true;
const { getLocalePack } = require('@americanexpress/one-app-ducks');
const initialState = fromJS({ intl: { activeLocale: 'es-ES' } });
getLocalePack.mockClear();

await loadPrerenderScripts(initialState);

expect(getLocalePack).not.toHaveBeenCalled();
});
});

describe('moveHelmetScripts', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function initializeClientStore() {

export function loadPrerenderScripts(initialState) {
const locale = initialState && initialState.getIn(['intl', 'activeLocale']);
return locale ? getLocalePack(locale) : Promise.resolve();
return locale && !window?.useNativeIntl ? getLocalePack(locale) : Promise.resolve();
}

export function moveHelmetScripts() {
Expand Down

0 comments on commit 5c0aab4

Please sign in to comment.