this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix date-time-format test

+25 -10
+19 -9
src/utils/date-time-format.js
··· 1 - import localeMatch from './locale-match'; 2 - import mem from './mem'; 1 + import localeMatch from './locale-match.js'; 2 + import mem from './mem.js'; 3 3 4 - const locales = [...navigator.languages]; 5 - try { 6 - const dtfLocale = new Intl.DateTimeFormat().resolvedOptions().locale; 7 - if (!locales.includes(dtfLocale)) { 8 - locales.push(dtfLocale); 9 - } 10 - } catch {} 4 + function initLocales() { 5 + const newLocales = [...navigator.languages]; 6 + try { 7 + const dtfLocale = new Intl.DateTimeFormat().resolvedOptions().locale; 8 + if (!newLocales.includes(dtfLocale)) { 9 + newLocales.push(dtfLocale); 10 + } 11 + } catch {} 12 + return newLocales; 13 + } 14 + 15 + let locales = initLocales(); 16 + 17 + // For testing: refresh locales from current navigator state 18 + export function refreshLocales() { 19 + locales = initLocales(); 20 + } 11 21 12 22 const createLocale = mem((language, options = {}) => { 13 23 try {
+6 -1
tests/date-time-format.spec.js
··· 1 1 // @ts-check 2 2 import { test, expect } from '@playwright/test'; 3 - import DateTimeFormat from '../src/utils/date-time-format.js'; 3 + import DateTimeFormat, { 4 + refreshLocales, 5 + } from '../src/utils/date-time-format.js'; 4 6 5 7 // Store original navigator properties for cleanup 6 8 let originalLanguage; ··· 22 24 get: () => languages || [language], 23 25 configurable: true, 24 26 }); 27 + 28 + // Automatically refresh locales after mocking 29 + refreshLocales(); 25 30 }; 26 31 27 32 // Reset navigator to original state