feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
51
apps/web/tests/locale-switcher.test.tsx
Normal file
51
apps/web/tests/locale-switcher.test.tsx
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { I18nProvider as BaseI18nProvider, LOCALE_META } from '@d3ro/i18n'
|
||||
import { LocaleSwitcher } from '@/components/layout/locale-switcher'
|
||||
import {
|
||||
WEB_LOCALE_STORAGE_KEY,
|
||||
createWebLocaleStorage,
|
||||
resolveInitialBrowserLocale,
|
||||
} from '@/components/providers/i18n-provider'
|
||||
|
||||
describe('웹 12개 로케일 전환 및 영속화 (GAP-I18N-03)', () => {
|
||||
it('resolveInitialBrowserLocale_브라우저언어태그별_지원되는12개로케일로정규화한다', () => {
|
||||
expect(resolveInitialBrowserLocale('ja-JP')).toBe('ja')
|
||||
expect(resolveInitialBrowserLocale('zh-TW')).toBe('zh-TW')
|
||||
expect(resolveInitialBrowserLocale('zh-Hant-HK')).toBe('zh-TW')
|
||||
expect(resolveInitialBrowserLocale('zh-CN')).toBe('zh')
|
||||
expect(resolveInitialBrowserLocale('fr-FR')).toBe('fr')
|
||||
expect(resolveInitialBrowserLocale('unsupported-XX')).toBe('ko')
|
||||
})
|
||||
|
||||
it('createWebLocaleStorage_저장된유효로케일을우선로드하고변경시저장한다', () => {
|
||||
const store = new Map<string, string>()
|
||||
const adapter = createWebLocaleStorage(
|
||||
() => ({
|
||||
getItem: (key) => store.get(key) ?? null,
|
||||
setItem: (key, val) => {
|
||||
store.set(key, val)
|
||||
},
|
||||
}),
|
||||
() => 'en-US',
|
||||
)
|
||||
|
||||
expect(adapter.load()).toBe('en')
|
||||
adapter.save('de')
|
||||
expect(store.get(WEB_LOCALE_STORAGE_KEY)).toBe('de')
|
||||
expect(adapter.load()).toBe('de')
|
||||
})
|
||||
|
||||
it('LocaleSwitcher_초기로케일렌더시_언어선택컨트롤과현재언어를표시한다', () => {
|
||||
expect(LOCALE_META).toHaveLength(12)
|
||||
const html = renderToStaticMarkup(
|
||||
<BaseI18nProvider initialLocale="en">
|
||||
<LocaleSwitcher />
|
||||
</BaseI18nProvider>,
|
||||
)
|
||||
|
||||
expect(html).toContain('data-testid="web-locale-select"')
|
||||
expect(html).toContain('Language')
|
||||
expect(html).toContain('English')
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue