Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Commit ce412ae

Browse files
authored
Merge pull request #66 from misha/master
test: Add a test for formatting using locale, ie. Japanese
2 parents 710dba1 + dcdf9f8 commit ce412ae

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/unit/logic.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,24 @@ describe('Logic connection', () => {
240240
const actionRow = menu.findComponent(ActionRow);
241241
expect(actionRow.text().includes(format(selected))).toBeTruthy();
242242
});
243+
244+
it('Should format with locale', async () => {
245+
const selected = new Date(0);
246+
// The day of the week (E) is locale-sensitive in Japanese.
247+
// Since epoch time zero (1970/1/1) was a Thursday, the 'Thu' must be localized to '木'.
248+
const dp = mount(Datepicker, { props: { modelValue: null, format: 'E', locale: 'ja-JP' } });
249+
250+
dp.vm.openMenu();
251+
252+
await dp.vm.$nextTick();
253+
254+
const menu: VueWrapper<any> = dp.findComponent(DatepickerMenu);
255+
const calendar = menu.findComponent(Calendar);
256+
calendar.vm.$emit('selectDate', { value: selected, current: true });
257+
await calendar.vm.$nextTick();
258+
dp.vm.selectDate();
259+
await dp.vm.$nextTick();
260+
261+
expect(dp.vm.inputValue).toEqual('木');
262+
});
243263
});

0 commit comments

Comments
 (0)