|
4 | 4 | getPrimaryLanguageSubtag, |
5 | 5 | getLocale, |
6 | 6 | getMessages, |
7 | | - getSupportedLocales, |
| 7 | + getSupportedLocaleList, |
8 | 8 | isRtl, |
9 | 9 | handleRtl, |
10 | 10 | getCookies, |
@@ -186,36 +186,28 @@ describe('lib', () => { |
186 | 186 | }); |
187 | 187 |
|
188 | 188 | describe('getSupportedLocales', () => { |
189 | | - beforeEach(() => { |
190 | | - configure({ |
191 | | - loggingService: { logError: jest.fn() }, |
192 | | - config: { |
193 | | - ENVIRONMENT: 'production', |
194 | | - LANGUAGE_PREFERENCE_COOKIE_NAME: 'yum', |
195 | | - }, |
196 | | - messages: { |
197 | | - 'es-419': { message: 'es-hah' }, |
198 | | - de: { message: 'de-hah' }, |
199 | | - 'en-us': { message: 'en-us-hah' }, |
200 | | - fr: { message: 'fr-hah' }, |
201 | | - }, |
| 189 | + describe('when configured', () => { |
| 190 | + beforeEach(() => { |
| 191 | + configure({ |
| 192 | + loggingService: { logError: jest.fn() }, |
| 193 | + config: { |
| 194 | + ENVIRONMENT: 'production', |
| 195 | + LANGUAGE_PREFERENCE_COOKIE_NAME: 'yum', |
| 196 | + }, |
| 197 | + messages: { |
| 198 | + 'es-419': { message: 'es-hah' }, |
| 199 | + de: { message: 'de-hah' }, |
| 200 | + 'en-us': { message: 'en-us-hah' }, |
| 201 | + fr: { message: 'fr-hah' }, |
| 202 | + }, |
| 203 | + }); |
202 | 204 | }); |
203 | | - }); |
204 | | - |
205 | | - it('should return an array of supported locale codes', () => { |
206 | | - const supportedLocales = getSupportedLocales(); |
207 | | - expect(Array.isArray(supportedLocales)).toBe(true); |
208 | | - expect(supportedLocales).toEqual(['es-419', 'de', 'en-us', 'fr']); |
209 | | - }); |
210 | 205 |
|
211 | | - it('should throw an error if i18n is not configured', () => { |
212 | | - // Reset the configuration to null |
213 | | - jest.resetModules(); |
214 | | - const { getSupportedLocales: freshGetSupportedLocales } = require('./lib'); |
215 | | - |
216 | | - expect(() => freshGetSupportedLocales()).toThrow( |
217 | | - 'getSupportedLocales called before configuring i18n. Call configure with messages first.' |
218 | | - ); |
| 206 | + it('should return an array of supported locale codes', () => { |
| 207 | + const supportedLocales = getSupportedLocaleList(); |
| 208 | + expect(Array.isArray(supportedLocales)).toBe(true); |
| 209 | + expect(supportedLocales).toEqual(['es-419', 'de', 'en-us', 'fr', 'en']); |
| 210 | + }); |
219 | 211 | }); |
220 | 212 | }); |
221 | 213 |
|
|
0 commit comments