chore: prettier test files

This commit is contained in:
陈嘉涵 2020-01-19 16:16:54 +08:00
parent 82208c42b8
commit 2adcfd8b8b
15 changed files with 65 additions and 32 deletions

View File

@ -82,10 +82,7 @@ test('disable lazy-render', () => {
const wrapper = mount(ActionSheet, {
propsData: {
lazyRender: false,
actions: [
{ name: 'Option' },
{ name: 'Option' },
],
actions: [{ name: 'Option' }, { name: 'Option' }],
cancelText: 'Cancel',
},
});

View File

@ -70,11 +70,17 @@ test('change option', () => {
expect(wrapper).toMatchSnapshot();
triggerDrag(columns.at(0), 0, -100);
columns.at(0).find('ul').trigger('transitionend');
columns
.at(0)
.find('ul')
.trigger('transitionend');
expect(wrapper).toMatchSnapshot();
triggerDrag(columns.at(2), 0, -100);
columns.at(2).find('ul').trigger('transitionend');
columns
.at(2)
.find('ul')
.trigger('transitionend');
expect(wrapper).toMatchSnapshot();
expect(onChange.mock.calls[0][1]).toEqual(secondOption);

View File

@ -419,7 +419,9 @@ test('should scroll to current month when show', async done => {
});
Element.prototype.scrollIntoView = function() {
expect(this.parentNode).toEqual(wrapper.findAll('.van-calendar__month').at(3).element);
expect(this.parentNode).toEqual(
wrapper.findAll('.van-calendar__month').at(3).element
);
done();
};

View File

@ -83,7 +83,14 @@ test('render coupon list', async () => {
const wrapper = mount(CouponList, {
propsData: {
chosenCoupon: 1,
coupons: [emptyCoupon, coupon, coupon2, coupon3, discountCoupon, discountCoupon2],
coupons: [
emptyCoupon,
coupon,
coupon2,
coupon3,
discountCoupon,
discountCoupon2,
],
disabledCoupons: [disabledCoupon, disabledDiscountCoupon],
},
});
@ -98,7 +105,10 @@ test('render empty coupon list', () => {
disabledCoupons: [],
},
});
wrapper.findAll('.van-tab').at(1).trigger('click');
wrapper
.findAll('.van-tab')
.at(1)
.trigger('click');
expect(wrapper).toMatchSnapshot();
});

View File

@ -59,7 +59,10 @@ test('formatter prop', async () => {
wrapper.find('.van-picker-column ul').trigger('transitionend');
await later();
expect(wrapper.emitted('change')[0][0].getValues()).toEqual(['20 hour', '00 minute']);
expect(wrapper.emitted('change')[0][0].getValues()).toEqual([
'20 hour',
'00 minute',
]);
});
test('confirm event', () => {

View File

@ -120,7 +120,7 @@ test('autosize object', async () => {
const textarea = wrapper.find('.van-field__control');
await later();
expect(textarea.element.style.height).toEqual(('50px'));
expect(textarea.element.style.height).toEqual('50px');
});
test('blur method', () => {
@ -267,7 +267,7 @@ test('formatter prop', () => {
const wrapper = mount(Field, {
propsData: {
value: 'abc123',
formatter: (value) => value.replace(/\d/g, ''),
formatter: value => value.replace(/\d/g, ''),
},
});

View File

@ -105,7 +105,10 @@ test('onClose option', () => {
instance.close();
expect(onClose).toHaveBeenCalledTimes(1);
expect(onClose).toHaveBeenCalledWith({ index: 0, url: 'https://img.yzcdn.cn/1.png' });
expect(onClose).toHaveBeenCalledWith({
index: 0,
url: 'https://img.yzcdn.cn/1.png',
});
});
test('onChange option', async done => {

View File

@ -1,4 +1,3 @@
import { mount } from '../../../test';
import Image from '..';

View File

@ -68,7 +68,7 @@ test('touch and scroll to anchor', () => {
const sidebar = wrapper.find('.van-index-bar__sidebar');
const indexes = wrapper.findAll('.van-index-bar__index');
document.elementFromPoint = function (x, y) {
document.elementFromPoint = function(x, y) {
const index = y / 100;
if (index === 1 || index === 2) {
@ -99,7 +99,7 @@ test('touch and scroll to anchor', () => {
test('scroll and update active anchor', () => {
const nativeRect = Element.prototype.getBoundingClientRect;
Element.prototype.getBoundingClientRect = function () {
Element.prototype.getBoundingClientRect = function() {
const { index } = this.dataset;
return {
top: index ? index * 10 : 0,

View File

@ -168,7 +168,7 @@ test('simulation finger swipe again before transitionend', () => {
expect(wrapper.emitted('change')[0][1]).toEqual('1995');
});
test('click column\'s item', () => {
test('click column item', () => {
const columns = [
{ text: '杭州' },
{ text: '宁波' },
@ -181,7 +181,10 @@ test('click column\'s item', () => {
},
});
wrapper.findAll('.van-picker-column__item').at(3).trigger('click');
wrapper
.findAll('.van-picker-column__item')
.at(3)
.trigger('click');
expect(wrapper.emitted('change')[0][1]).toEqual(columns[1]);
});

View File

@ -37,7 +37,10 @@ test('v-model', () => {
},
});
wrapper.findAll('.van-sidebar-item').at(1).trigger('click');
wrapper
.findAll('.van-sidebar-item')
.at(1)
.trigger('click');
expect(wrapper.vm.active).toEqual(1);
});
@ -56,7 +59,10 @@ test('disabled prop', () => {
},
});
wrapper.findAll('.van-sidebar-item').at(1).trigger('click');
wrapper
.findAll('.van-sidebar-item')
.at(1)
.trigger('click');
expect(wrapper.vm.active).toEqual(0);
});

View File

@ -322,7 +322,6 @@ test('change min and max', async () => {
expect(wrapper.emitted('input')[1][0]).toEqual(8);
});
test('change decimal-length', async () => {
const wrapper = mount(Stepper, {
propsData: {

View File

@ -141,7 +141,6 @@ test('border props', async () => {
expect(wrapper).toMatchSnapshot();
});
test('click event', async () => {
const onClick = jest.fn();
const onDisabled = jest.fn();

View File

@ -369,7 +369,10 @@ it('click to preview image', () => {
wrapper.find('.van-image').trigger('click');
const imagePreviewNode2 = document.querySelector('.van-image-preview');
expect(imagePreviewNode2.querySelectorAll('.van-image-preview__image').length).toEqual(1);
const images = imagePreviewNode2.querySelectorAll(
'.van-image-preview__image'
);
expect(images.length).toEqual(1);
});
it('closeImagePreview method', () => {
@ -400,7 +403,10 @@ it('click-preview event', () => {
wrapper.find('.van-image').trigger('click');
expect(wrapper.emitted('click-preview')[0][0]).toEqual({ url: IMAGE });
expect(wrapper.emitted('click-preview')[0][1]).toEqual({ name: '', index: 0 });
expect(wrapper.emitted('click-preview')[0][1]).toEqual({
name: '',
index: 0,
});
});
it('close-preview event', async () => {

View File

@ -29,14 +29,14 @@ test('deepAssign', () => {
expect(deepAssign({}, { foo: undefined })).toEqual({});
expect(deepAssign({ fn: null }, { fn })).toEqual({ fn });
expect(deepAssign({ foo: 0 }, { bar: 1 })).toEqual({ foo: 0, bar: 1 });
expect(deepAssign({ foo: { bar: false } }, { foo: { bar: true, foo: false } })).toEqual(
{
foo: {
bar: true,
foo: false,
},
}
);
expect(
deepAssign({ foo: { bar: false } }, { foo: { bar: true, foo: false } })
).toEqual({
foo: {
bar: true,
foo: false,
},
});
});
test('isDef', () => {