2019-01-12 03:33:27 +00:00
|
|
|
|
import { mount } from '@vue/test-utils';
|
2021-09-25 08:51:32 +00:00
|
|
|
|
import { asyncExpect } from '../../../tests/utils';
|
|
|
|
|
import dayjs from 'dayjs';
|
2019-01-12 03:33:27 +00:00
|
|
|
|
import MockDate from 'mockdate';
|
|
|
|
|
import DatePicker from '..';
|
|
|
|
|
import focusTest from '../../../tests/shared/focusTest';
|
2018-06-09 05:14:14 +00:00
|
|
|
|
|
|
|
|
|
describe('DatePicker', () => {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
focusTest(DatePicker);
|
2018-06-09 05:14:14 +00:00
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
document.body.outerHTML = '';
|
2021-09-25 08:51:32 +00:00
|
|
|
|
MockDate.set(dayjs('2016-11-22'));
|
2019-01-12 03:33:27 +00:00
|
|
|
|
});
|
2018-06-09 05:14:14 +00:00
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
MockDate.reset();
|
|
|
|
|
});
|
2018-06-09 05:14:14 +00:00
|
|
|
|
|
|
|
|
|
it('prop locale should works', async () => {
|
|
|
|
|
const locale = {
|
|
|
|
|
lang: {
|
2021-09-25 08:51:32 +00:00
|
|
|
|
locale: 'mk',
|
2018-06-09 05:14:14 +00:00
|
|
|
|
placeholder: 'Избери дата',
|
2019-01-12 03:33:27 +00:00
|
|
|
|
rangePlaceholder: ['Начална дата', 'Крайна дата'],
|
2018-06-09 05:14:14 +00:00
|
|
|
|
today: 'Днес',
|
|
|
|
|
now: 'Сега',
|
|
|
|
|
backToToday: 'Към днес',
|
|
|
|
|
ok: 'Добре',
|
|
|
|
|
clear: 'Изчистване',
|
|
|
|
|
month: 'Месец',
|
|
|
|
|
year: 'Година',
|
|
|
|
|
timeSelect: 'Избор на час',
|
|
|
|
|
dateSelect: 'Избор на дата',
|
|
|
|
|
monthSelect: 'Избор на месец',
|
|
|
|
|
yearSelect: 'Избор на година',
|
|
|
|
|
decadeSelect: 'Десетилетие',
|
|
|
|
|
previousMonth: 'Предишен месец (PageUp)',
|
|
|
|
|
nextMonth: 'Следващ месец (PageDown)',
|
|
|
|
|
previousYear: 'Последна година (Control + left)',
|
|
|
|
|
nextYear: 'Следваща година (Control + right)',
|
|
|
|
|
previousDecade: 'Предишно десетилетие',
|
|
|
|
|
nextDecade: 'Следващо десетилетие',
|
|
|
|
|
previousCentury: 'Последен век',
|
|
|
|
|
nextCentury: 'Следващ век',
|
|
|
|
|
yearFormat: 'YYYY',
|
|
|
|
|
dateFormat: 'D M YYYY',
|
|
|
|
|
dayFormat: 'D',
|
|
|
|
|
dateTimeFormat: 'D M YYYY HH:mm:ss',
|
|
|
|
|
monthBeforeYear: true,
|
|
|
|
|
},
|
|
|
|
|
timePickerLocale: {
|
|
|
|
|
placeholder: 'Избор на час',
|
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
};
|
2021-09-25 08:51:32 +00:00
|
|
|
|
const birthday = dayjs('2000-01-01', 'YYYY-MM-DD');
|
2018-06-09 05:14:14 +00:00
|
|
|
|
const wrapper = mount({
|
2019-01-12 03:33:27 +00:00
|
|
|
|
render() {
|
|
|
|
|
return <DatePicker open locale={locale} value={birthday} />;
|
2018-06-09 05:14:14 +00:00
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
|
});
|
2018-06-09 05:14:14 +00:00
|
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|