diff --git a/package.json b/package.json index ce53aa998..4e9383379 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "node": ">=8.x" }, "devDependencies": { + "@testing-library/react": "^12", "@types/classnames": "^2.2.9", "@types/enzyme": "^3.10.3", "@types/jest": "^26.0.0", diff --git a/src/locale/eu_ES.ts b/src/locale/eu_ES.ts new file mode 100644 index 000000000..b76056e61 --- /dev/null +++ b/src/locale/eu_ES.ts @@ -0,0 +1,33 @@ +import type { Locale } from '../interface'; + +const locale: Locale = { + locale: 'eu_ES', + today: 'Gaur', + now: 'Orain', + backToToday: 'Gaur itzuli', + ok: 'OK', + clear: 'Garbitu', + month: 'Hilabete', + year: 'Urte', + timeSelect: 'Ordua aukeratu', + dateSelect: 'Eguna aukeratu', + weekSelect: 'Astea aukeratu', + monthSelect: 'Hilabetea aukeratu', + yearSelect: 'Urtea aukeratu', + decadeSelect: 'Hamarkada aukeratu', + yearFormat: 'YYYY', + dateFormat: 'YYYY/M/D', + dayFormat: 'D', + dateTimeFormat: 'YYYY/M/D HH:mm:ss', + monthBeforeYear: false, + previousMonth: 'Aurreko hilabetea (RePag)', + nextMonth: 'Urrengo hilabetea (AvPag)', + previousYear: 'Aurreko urtea (Control + ezkerra)', + nextYear: 'Urrento urtea (Control + eskuina)', + previousDecade: 'Aurreko hamarkada', + nextDecade: 'Urrengo hamarkada', + previousCentury: 'Aurreko mendea', + nextCentury: 'Urrengo mendea', +}; + +export default locale; \ No newline at end of file diff --git a/src/locale/uz_UZ.ts b/src/locale/uz_UZ.ts new file mode 100644 index 000000000..8c105568d --- /dev/null +++ b/src/locale/uz_UZ.ts @@ -0,0 +1,33 @@ +import type { Locale } from '../interface'; + +const locale: Locale = { + locale: 'uz_UZ', + today: 'Bugun', + now: 'Hozir', + backToToday: 'Bugunga qaytish', + ok: 'OK', + clear: 'Toza', + month: 'Oy', + year: 'Yil', + timeSelect: 'vaqtni tanlang', + dateSelect: 'sanani tanlang', + weekSelect: 'Haftani tanlang', + monthSelect: 'Oyni tanlang', + yearSelect: 'Yilni tanlang', + decadeSelect: 'O\'n yilni tanlang', + yearFormat: 'YYYY', + dateFormat: 'M/D/YYYY', + dayFormat: 'D', + dateTimeFormat: 'M/D/YYYY HH:mm:ss', + monthBeforeYear: true, + previousMonth: 'Oldingi oy (PageUp)', + nextMonth: 'Keyingi oy (PageDown)', + previousYear: 'O\'tgan yili (Control + left)', + nextYear: 'Keyingi yil (Control + right)', + previousDecade: 'Oxirgi o\'n yil', + nextDecade: 'Keyingi o\'n yil', + previousCentury: 'O\'tgan asr', + nextCentury: 'Keyingi asr', +}; + +export default locale; diff --git a/tests/picker.spec.tsx b/tests/picker.spec.tsx index c4d82ddaf..a42c197b1 100644 --- a/tests/picker.spec.tsx +++ b/tests/picker.spec.tsx @@ -8,6 +8,7 @@ import moment from 'moment'; import type { Moment } from 'moment'; import type { PanelMode, PickerMode } from '../src/interface'; import { mount, getMoment, isSame, MomentPicker } from './util/commonUtil'; +import { fireEvent, render } from '@testing-library/react'; describe('Picker.Basic', () => { beforeAll(() => { @@ -125,17 +126,14 @@ describe('Picker.Basic', () => { it('fixed open need repeat trigger onOpenChange', () => { jest.useFakeTimers(); const onOpenChange = jest.fn(); - mount(); + render(); + expect(onOpenChange).toHaveBeenCalledTimes(0); for (let i = 0; i < 10; i += 1) { - const clickEvent = new Event('mousedown'); - Object.defineProperty(clickEvent, 'target', { - get: () => document.body, - }); act(() => { - window.dispatchEvent(clickEvent); + fireEvent.mouseDown(document.body); }); - expect(onOpenChange).toHaveBeenCalledTimes(i + 1); + expect(onOpenChange).toHaveBeenCalledTimes(1); } act(() => { jest.runAllTimers(); diff --git a/tests/range.spec.tsx b/tests/range.spec.tsx index 2bca8ec8f..2b69841e0 100644 --- a/tests/range.spec.tsx +++ b/tests/range.spec.tsx @@ -9,6 +9,7 @@ import type { Wrapper } from './util/commonUtil'; import { mount, getMoment, isSame, MomentRangePicker } from './util/commonUtil'; import zhCN from '../src/locale/zh_CN'; import type { PickerMode } from '../src/interface'; +import { fireEvent, render } from '@testing-library/react'; describe('Picker.Range', () => { function matchValues(wrapper: Wrapper, value1: string, value2: string) { @@ -693,23 +694,15 @@ describe('Picker.Range', () => { it('fixed open need repeat trigger onOpenChange', () => { jest.useFakeTimers(); const onOpenChange = jest.fn(); - const wrapper = mount(); + render(); - for (let i = 0; i < 10; i += 1) { - const clickEvent = new Event('mousedown'); - Object.defineProperty(clickEvent, 'target', { - get: () => document.body, - }); + expect(onOpenChange).toHaveBeenCalledTimes(0); - const current = onOpenChange.mock.calls.length; + for (let i = 0; i < 10; i += 1) { act(() => { - window.dispatchEvent(clickEvent); - wrapper.find('input').first().simulate('blur'); + fireEvent.mouseDown(document.body); }); - const next = onOpenChange.mock.calls.length; - - // Maybe not good since onOpenChange trigger twice - expect(current < next).toBeTruthy(); + expect(onOpenChange).toHaveBeenCalledTimes(1); } act(() => { jest.runAllTimers();