feat: calendar support firstDayOfWeek (#6468)

This commit is contained in:
yeliex
2020-07-14 11:51:27 +08:00
committed by GitHub
parent 63aa6baa86
commit 5febb845d0
8 changed files with 89 additions and 2 deletions
@@ -51,6 +51,10 @@ exports[`renders demo correctly 1`] = `
<div class="van-cell__title"><span>日期区间最大范围</span></div><i class="van-icon van-icon-arrow van-cell__right-icon">
<!----></i>
</div>
<div role="button" tabindex="0" class="van-cell van-cell--clickable">
<div class="van-cell__title"><span>自定义周起始日</span></div><i class="van-icon van-icon-arrow van-cell__right-icon">
<!----></i>
</div>
</div>
<div>
<div class="van-calendar" style="height: 500px;">
+21
View File
@@ -191,3 +191,24 @@ test('month-show event', async () => {
expect(wrapper.emitted('month-show')).toBeTruthy();
});
test.only('first day of week', async () => {
const wrapper = mount(Calendar, {
propsData: {
poppable: false,
defaultDate: new Date(2020, 7, 1),
maxDate: new Date(2020, 7, 30),
firstDayOfWeek: 2,
},
});
await later();
expect(wrapper.find('.van-calendar__weekdays').text()[0]).toEqual('二');
const day = wrapper.find(
'.van-calendar__month:first-of-type .van-calendar__day'
);
expect(day.text()).toEqual('1');
expect(day.attributes('style')).toContain(`margin-left: ${100 / 7}%`);
});