diff --git a/.eslintignore b/.eslintignore index 01a3180fa9..9442ad986c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,3 @@ node_modules -__tests__ packages/*/es packages/*/lib diff --git a/packages/components/color-picker/__tests__/color-picker.spec.ts b/packages/components/color-picker/__tests__/color-picker.spec.ts index 86e1b4b186..0899f84f1a 100644 --- a/packages/components/color-picker/__tests__/color-picker.spec.ts +++ b/packages/components/color-picker/__tests__/color-picker.spec.ts @@ -4,7 +4,7 @@ import ColorPicker from '../src/index.vue' import type { Nullable } from '@element-plus/utils/types' -const _mount = (template: string, data: () => ({[key:string]: any;})) => { +const _mount = (template: string, data: () => ({ [key: string]: any; })) => { const Component = defineComponent({ components: { ElColorPicker: ColorPicker, @@ -89,7 +89,7 @@ describe('Color-picker', () => { const mockThumbDom = jest.spyOn(thumbDom, 'offsetHeight', 'get').mockImplementation(() => 4) await wrapper.find('.el-color-picker__trigger').trigger('click') await nextTick() - expect((hueSlideWrapper.vm as ComponentPublicInstance<{thumbTop: number;}>).thumbTop > 10).toBeTruthy() + expect((hueSlideWrapper.vm as ComponentPublicInstance<{ thumbTop: number; }>).thumbTop > 10).toBeTruthy() mockHueSlideHeight.mockRestore() mockThumbDom.mockRestore() wrapper.unmount() diff --git a/packages/components/date-picker/__tests__/date-picker.spec.ts b/packages/components/date-picker/__tests__/date-picker.spec.ts index f1e316f402..e1163aa032 100644 --- a/packages/components/date-picker/__tests__/date-picker.spec.ts +++ b/packages/components/date-picker/__tests__/date-picker.spec.ts @@ -743,7 +743,7 @@ describe('DateRangePicker', () => { await nextTick(); (panels[1].querySelector('td.available') as HTMLElement).click() await nextTick() - expect((wrapper.vm as any).value.toString()).toBe([ '01/05 2021', '01/06 2021' ].toString()) + expect((wrapper.vm as any).value.toString()).toBe(['01/05 2021', '01/06 2021'].toString()) }) }) diff --git a/packages/components/form/__tests__/form.spec.ts b/packages/components/form/__tests__/form.spec.ts index a73cd7005c..379b87a438 100644 --- a/packages/components/form/__tests__/form.spec.ts +++ b/packages/components/form/__tests__/form.spec.ts @@ -9,7 +9,7 @@ import FormItem from '../src/form-item.vue' type Methods = Record any> function mountForm( - config: C & {data?(): D; methods?: M;}, + config: C & { data?(): D; methods?: M; }, ) { return mount({ components: { @@ -350,7 +350,7 @@ describe('Form', () => { const form: any = wrapper.findComponent({ ref: 'form' }).vm const nameField: any = wrapper.findComponent({ ref: 'name' }).vm const addressField: any = wrapper.findComponent({ ref: 'address' }).vm - form.validate() + await form.validate().catch(() => undefined) await nextTick() expect(nameField.validateMessage).toBe('Please input name') expect(addressField.validateMessage).toBe('Please input address') diff --git a/packages/components/message/__tests__/message.spec.ts b/packages/components/message/__tests__/message.spec.ts index c1a0548b11..81c0df0993 100644 --- a/packages/components/message/__tests__/message.spec.ts +++ b/packages/components/message/__tests__/message.spec.ts @@ -11,7 +11,7 @@ const AXIOM = 'Rem is the best girl' jest.useFakeTimers() -type MessageInstance = ComponentPublicInstance<{visible: boolean; typeClass: string; customStyle: CSSProperties;}> +type MessageInstance = ComponentPublicInstance<{ visible: boolean; typeClass: string; customStyle: CSSProperties; }> const onClose = jest.fn() const _mount = makeMount(Message, { diff --git a/packages/components/popover/__tests__/directive.spec.ts b/packages/components/popover/__tests__/directive.spec.ts index f4ff1d2e04..7d1f804e2d 100644 --- a/packages/components/popover/__tests__/directive.spec.ts +++ b/packages/components/popover/__tests__/directive.spec.ts @@ -52,7 +52,7 @@ describe('v-popover', () => { const refNode = '#reference-node' expect(wrapper.find(refNode).exists()).toBe(false); - (wrapper.vm as ComponentPublicInstance<{visible: boolean;}>).visible = true + (wrapper.vm as ComponentPublicInstance<{ visible: boolean; }>).visible = true await nextTick() expect(wrapper.find(refNode).exists()).toBe(true) diff --git a/packages/components/popover/__tests__/popover.spec.ts b/packages/components/popover/__tests__/popover.spec.ts index 34499f8915..18eb858aae 100644 --- a/packages/components/popover/__tests__/popover.spec.ts +++ b/packages/components/popover/__tests__/popover.spec.ts @@ -86,7 +86,7 @@ describe('Popover.vue', () => { const Comp = { render() { - const slot = () => [ h('button', { ref: 'btn' }, 'click 激活') ] + const slot = () => [h('button', { ref: 'btn' }, 'click 激活')] return h(Popover, { placement: 'bottom', diff --git a/packages/components/select/__tests__/select.spec.ts b/packages/components/select/__tests__/select.spec.ts index 01d21a3665..b33135b723 100644 --- a/packages/components/select/__tests__/select.spec.ts +++ b/packages/components/select/__tests__/select.spec.ts @@ -576,7 +576,7 @@ describe('Select', () => { options[2].click() await nextTick() const tagWrappers = wrapper.findAll('.el-select__tags-text') - for(let i=0;i { - if (nav$.value) { - nextTick(() => { - nav$.value.$nextTick(() => { - nav$.value.scrollToActiveTab() - }) + nextTick(() => { + nav$.value && nav$.value.$nextTick(() => { + nav$.value && nav$.value.scrollToActiveTab() }) - } + }) setPaneInstances(true) }) diff --git a/packages/components/time-picker/__tests__/time-picker.spec.ts b/packages/components/time-picker/__tests__/time-picker.spec.ts index 5c5e34efe9..f5a947d22e 100644 --- a/packages/components/time-picker/__tests__/time-picker.spec.ts +++ b/packages/components/time-picker/__tests__/time-picker.spec.ts @@ -445,14 +445,14 @@ describe('TimePicker(range)', () => { const list = document.querySelectorAll('.el-time-spinner__list') const leftHoursEl = list[0] const leftEndbledHours = getSpinnerTextAsArray(leftHoursEl, ':not(.disabled)') - expect(leftEndbledHours).toEqual([ 8, 9, 10, 11, 12 ]) + expect(leftEndbledHours).toEqual([8, 9, 10, 11, 12]) const rightHoursEl = list[3] const rightEndbledHours = getSpinnerTextAsArray(rightHoursEl, ':not(.disabled)') - expect(rightEndbledHours).toEqual([ 11, 12, 13, 14, 15, 16 ]); + expect(rightEndbledHours).toEqual([11, 12, 13, 14, 15, 16]); (leftHoursEl.querySelectorAll('.el-time-spinner__item')[12] as any).click() await nextTick() const NextRightEndbledHours = getSpinnerTextAsArray(rightHoursEl, ':not(.disabled)') - expect(NextRightEndbledHours).toEqual([ 12, 13, 14, 15, 16 ]) + expect(NextRightEndbledHours).toEqual([12, 13, 14, 15, 16]) }) it('arrow key', async () => { diff --git a/packages/components/upload/__tests__/upload.spec.ts b/packages/components/upload/__tests__/upload.spec.ts index 2a167378c7..be8e3c53e7 100644 --- a/packages/components/upload/__tests__/upload.spec.ts +++ b/packages/components/upload/__tests__/upload.spec.ts @@ -8,12 +8,6 @@ import Upload from '../src/upload.vue' const AXIOM = 'Rem is the best girl' const action = 'test-action' -interface MockFile { - name: string - body: string - mimeType: string -} - const mockGetFile = (element: HTMLInputElement, files: File[]) => { Object.defineProperty(element, 'files', { get() { diff --git a/packages/components/virtual-list/__tests__/scrollbar.spec.ts b/packages/components/virtual-list/__tests__/scrollbar.spec.ts index 55f1958472..9c9c5d3d7f 100644 --- a/packages/components/virtual-list/__tests__/scrollbar.spec.ts +++ b/packages/components/virtual-list/__tests__/scrollbar.spec.ts @@ -12,19 +12,20 @@ describe('virtual scrollbar', () => { Scrollbar, }, }) - await nextTick + await nextTick() const scrollbar = wrapper.findComponent(Scrollbar) const styles = getComputedStyle(scrollbar.vm.$el) - expect(styles).toMatchObject({ + + Object.entries({ display: 'block', position: 'absolute', width: 'vertical' !== layout ? '100%' : '6px', - height: 'vertical' !== layout ? '6px' : '100%', + height: 'vertical' !== layout ? '6px' : 'auto', [ScrollbarDirKey[layout]]: '2px', right: '2px', bottom: '2px', 'border-radius': '4px', - }) + }).forEach(([key, value]) => expect(`${key}: ${styles.getPropertyValue(key)}`).toBe(`${key}: ${value}`)) } it('vertical inline style', async () => {