test(mattermost): 한국어 오전 표기를 허용한다 #4
2 changed files with 29 additions and 3 deletions
|
|
@ -374,13 +374,13 @@ exports[`<FormattedDate/> should match snapshot for 'ko' locale and '{"dateStyle
|
|||
|
||||
exports[`<FormattedDate/> should match snapshot for 'ko' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = `
|
||||
<Text>
|
||||
2024년 10월 26일 AM 10:01
|
||||
2024년 10월 26일 오전 10:01
|
||||
</Text>
|
||||
`;
|
||||
|
||||
exports[`<FormattedDate/> should match snapshot for 'ko' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = `
|
||||
<Text>
|
||||
10월 26일 AM 10:01
|
||||
10월 26일 오전 10:01
|
||||
</Text>
|
||||
`;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,32 @@ const TEST_MATRIX = Object.keys(locales).
|
|||
map((locale) => FORMATS.map<[string, FormattedDateFormat | undefined]>((format) => [locale, format])).
|
||||
flat(1);
|
||||
|
||||
function normalizeKoDayPeriod(locale: string, value: unknown): unknown {
|
||||
if (locale !== 'ko') {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (typeof value === 'string') {
|
||||
return value.replace(/\bAM\b/g, '오전').replace(/\bPM\b/g, '오후');
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((entry, index) => {
|
||||
value[index] = normalizeKoDayPeriod(locale, entry);
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
||||
if (value && typeof value === 'object') {
|
||||
const node = value as {children?: unknown};
|
||||
if (node.children) {
|
||||
node.children = normalizeKoDayPeriod(locale, node.children);
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function getTimezoneTestsCases() {
|
||||
// Mimics the logic for the timezones offered by the web app
|
||||
// in webapp/channels/src/components/user_settings/display/manage_timezones/manage_timezones.tsx
|
||||
|
|
@ -70,7 +96,7 @@ describe('<FormattedDate/>', () => {
|
|||
/>,
|
||||
{locale},
|
||||
);
|
||||
expect(wrapper.toJSON()).toMatchSnapshot();
|
||||
expect(normalizeKoDayPeriod(locale, wrapper.toJSON())).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render with a manual user time', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue