fix(Calendar): should only scroll calendar body when inited (#6926)

This commit is contained in:
neverland
2020-08-02 16:49:57 +08:00
committed by GitHub
parent 81de225e69
commit 39c6637894
4 changed files with 15 additions and 30 deletions
-22
View File
@@ -457,28 +457,6 @@ test('color prop when type is range', async () => {
expect(wrapper).toMatchSnapshot();
});
test('should scroll to current month when show', async (done) => {
const wrapper = mount(Calendar, {
propsData: {
type: 'range',
minDate: new Date(2010, 0, 10),
maxDate: new Date(2010, 11, 10),
defaultDate: [new Date(2010, 3, 1), new Date(2010, 5, 1)],
},
});
Element.prototype.scrollIntoView = function () {
expect(this.parentNode).toEqual(
wrapper.findAll('.van-calendar__month').at(3).element
);
done();
};
wrapper.setProps({ value: true });
await later();
});
test('close event', () => {
const wrapper = mount(Calendar, {
propsData: {
+2 -1
View File
@@ -197,6 +197,7 @@ test('first day of week', async () => {
propsData: {
poppable: false,
defaultDate: new Date(2020, 7, 1),
minDate: new Date(2020, 7, 1),
maxDate: new Date(2020, 7, 30),
firstDayOfWeek: 2,
},
@@ -210,5 +211,5 @@ test('first day of week', async () => {
'.van-calendar__month:first-of-type .van-calendar__day'
);
expect(day.text()).toEqual('1');
expect(day.attributes('style')).toContain(`margin-left: ${100 / 7}%`);
expect(day.attributes('style')).toContain(`margin-left: ${(100 * 4) / 7}%`);
});