Skip to content

Commit

Permalink
Merge branch 'master' into fix/panel-flick
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc committed Aug 1, 2022
2 parents 8f34fb2 + 7d937d2 commit 325f8fe
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 20 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
33 changes: 33 additions & 0 deletions src/locale/eu_ES.ts
Original file line number Diff line number Diff line change
@@ -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;
33 changes: 33 additions & 0 deletions src/locale/uz_UZ.ts
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 5 additions & 7 deletions tests/picker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -125,17 +126,14 @@ describe('Picker.Basic', () => {
it('fixed open need repeat trigger onOpenChange', () => {
jest.useFakeTimers();
const onOpenChange = jest.fn();
mount(<MomentPicker onOpenChange={onOpenChange} open />);
render(<MomentPicker onOpenChange={onOpenChange} open />);
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();
Expand Down
19 changes: 6 additions & 13 deletions tests/range.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -693,23 +694,15 @@ describe('Picker.Range', () => {
it('fixed open need repeat trigger onOpenChange', () => {
jest.useFakeTimers();
const onOpenChange = jest.fn();
const wrapper = mount(<MomentRangePicker onOpenChange={onOpenChange} open />);
render(<MomentRangePicker onOpenChange={onOpenChange} open />);

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();
Expand Down

0 comments on commit 325f8fe

Please sign in to comment.