From 2adcfd8b8b2a98dd853e8018a643accd89e32cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Sun, 19 Jan 2020 16:16:54 +0800 Subject: [PATCH] chore: prettier test files --- src/action-sheet/test/index.spec.js | 5 +---- src/area/test/index.spec.js | 10 ++++++++-- src/calendar/test/index.spec.js | 4 +++- src/coupon-list/test/index.spec.js | 14 ++++++++++++-- src/datetime-picker/test/time-picker.spec.js | 5 ++++- src/field/test/index.spec.js | 4 ++-- src/image-preview/test/index.spec.js | 5 ++++- src/image/test/index.spec.js | 1 - src/index-bar/test/index.spec.js | 4 ++-- src/picker/test/index.spec.js | 7 +++++-- src/sidebar/test/index.spec.js | 10 ++++++++-- src/stepper/test/index.spec.js | 1 - src/tab/test/index.spec.js | 1 - src/uploader/test/index.spec.js | 10 ++++++++-- src/utils/test/index.spec.js | 16 ++++++++-------- 15 files changed, 65 insertions(+), 32 deletions(-) diff --git a/src/action-sheet/test/index.spec.js b/src/action-sheet/test/index.spec.js index d4aba0675..e07eeca18 100644 --- a/src/action-sheet/test/index.spec.js +++ b/src/action-sheet/test/index.spec.js @@ -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', }, }); diff --git a/src/area/test/index.spec.js b/src/area/test/index.spec.js index fbe0087f6..5a4f3e037 100644 --- a/src/area/test/index.spec.js +++ b/src/area/test/index.spec.js @@ -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); diff --git a/src/calendar/test/index.spec.js b/src/calendar/test/index.spec.js index a2e691faa..e3669fbad 100644 --- a/src/calendar/test/index.spec.js +++ b/src/calendar/test/index.spec.js @@ -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(); }; diff --git a/src/coupon-list/test/index.spec.js b/src/coupon-list/test/index.spec.js index b0f20afc2..30f69eee4 100644 --- a/src/coupon-list/test/index.spec.js +++ b/src/coupon-list/test/index.spec.js @@ -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(); }); diff --git a/src/datetime-picker/test/time-picker.spec.js b/src/datetime-picker/test/time-picker.spec.js index f1ba196ca..7e88cf868 100644 --- a/src/datetime-picker/test/time-picker.spec.js +++ b/src/datetime-picker/test/time-picker.spec.js @@ -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', () => { diff --git a/src/field/test/index.spec.js b/src/field/test/index.spec.js index 977e8ba97..8100c5103 100644 --- a/src/field/test/index.spec.js +++ b/src/field/test/index.spec.js @@ -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, ''), }, }); diff --git a/src/image-preview/test/index.spec.js b/src/image-preview/test/index.spec.js index 4f4632607..98001a10a 100644 --- a/src/image-preview/test/index.spec.js +++ b/src/image-preview/test/index.spec.js @@ -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 => { diff --git a/src/image/test/index.spec.js b/src/image/test/index.spec.js index 543642dd7..9e30dcdf3 100644 --- a/src/image/test/index.spec.js +++ b/src/image/test/index.spec.js @@ -1,4 +1,3 @@ - import { mount } from '../../../test'; import Image from '..'; diff --git a/src/index-bar/test/index.spec.js b/src/index-bar/test/index.spec.js index e65ebb4c6..67767edba 100644 --- a/src/index-bar/test/index.spec.js +++ b/src/index-bar/test/index.spec.js @@ -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, diff --git a/src/picker/test/index.spec.js b/src/picker/test/index.spec.js index 049dd68d4..c7b52e4e7 100644 --- a/src/picker/test/index.spec.js +++ b/src/picker/test/index.spec.js @@ -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]); }); diff --git a/src/sidebar/test/index.spec.js b/src/sidebar/test/index.spec.js index 508eba73f..faed2a42d 100644 --- a/src/sidebar/test/index.spec.js +++ b/src/sidebar/test/index.spec.js @@ -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); }); diff --git a/src/stepper/test/index.spec.js b/src/stepper/test/index.spec.js index 157470f8c..83a6d007b 100644 --- a/src/stepper/test/index.spec.js +++ b/src/stepper/test/index.spec.js @@ -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: { diff --git a/src/tab/test/index.spec.js b/src/tab/test/index.spec.js index dbe07dd1d..9c9d326c4 100644 --- a/src/tab/test/index.spec.js +++ b/src/tab/test/index.spec.js @@ -141,7 +141,6 @@ test('border props', async () => { expect(wrapper).toMatchSnapshot(); }); - test('click event', async () => { const onClick = jest.fn(); const onDisabled = jest.fn(); diff --git a/src/uploader/test/index.spec.js b/src/uploader/test/index.spec.js index 634a0949d..d91a47a3d 100644 --- a/src/uploader/test/index.spec.js +++ b/src/uploader/test/index.spec.js @@ -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 () => { diff --git a/src/utils/test/index.spec.js b/src/utils/test/index.spec.js index e5bd49a58..fc6aaa44a 100644 --- a/src/utils/test/index.spec.js +++ b/src/utils/test/index.spec.js @@ -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', () => {