-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlocale-lookup.test.ts
More file actions
34 lines (28 loc) · 1.33 KB
/
locale-lookup.test.ts
File metadata and controls
34 lines (28 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { describe, expect, it } from 'vitest'
import { getCommonLanguagesForRegion, getCommonRegionsForLanguage } from './locale-lookup.ts'
describe('getCommonRegionsForLanguage', () => {
it('returns regions for a language present in standard locales', () => {
expect(getCommonRegionsForLanguage('zh')).toMatchObject(['CN', 'HK', 'MO', 'SG', 'TW'])
expect(getCommonRegionsForLanguage('en')).toContain('US')
expect(getCommonRegionsForLanguage('en')).toContain('GB')
})
it('returns empty array for a language not present in standard locales', () => {
expect(getCommonRegionsForLanguage('ace')).toEqual([])
})
it('returns empty array for an unknown language', () => {
expect(getCommonRegionsForLanguage('abc')).toEqual([])
})
})
describe('getCommonLanguagesForRegion', () => {
it('returns languages for a region present in standard locales', () => {
expect(getCommonLanguagesForRegion('CA')).toMatchObject(['en', 'fr', 'iu'])
expect(getCommonLanguagesForRegion('CH')).toContain('de')
expect(getCommonLanguagesForRegion('CH')).toContain('fr')
})
it('returns empty array for a region not present in standard locales', () => {
expect(getCommonLanguagesForRegion('AC')).toEqual([])
})
it('returns empty array for an unknown region', () => {
expect(getCommonLanguagesForRegion('AB')).toEqual([])
})
})