Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-mng committed Feb 5, 2025
1 parent acf4160 commit e79c9eb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/gmp/locale/__tests__/detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,24 @@ describe('LanguageDetector tests', () => {

test('should return language from navigator', () => {
const storage = {};
global.navigator = {language: 'en-US'};

const languageUtils = {
formatLanguageCode: testing.fn().mockImplementation(l => l),
isSupportedCode: testing.fn().mockReturnValue(true),
};

const detector = new LanguageDetector();
Object.defineProperty(global, 'navigator', {
value: {language: 'en-US'},
configurable: true,
});

const detector = new LanguageDetector();
detector.init({languageUtils}, {storage}, {fallbackLng: 'bar'});

expect(detector.detect()).toEqual('en-US');
expect(languageUtils.formatLanguageCode).toHaveBeenCalledTimes(1);
expect(languageUtils.formatLanguageCode).toHaveBeenCalledWith('en-US');
expect(languageUtils.isSupportedCode).toHaveBeenCalledTimes(1);
expect(languageUtils.isSupportedCode).toHaveBeenCalledWith('en-US');

global.navigator = undefined;
});

test('should return languages from fake navigator', () => {
Expand Down

0 comments on commit e79c9eb

Please sign in to comment.