mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-24 11:05:17 +08:00
test: fix test (#3109)
This commit is contained in:
parent
e9e56d5938
commit
0617cdf9f8
@ -1,4 +1,3 @@
|
||||
node_modules
|
||||
__tests__
|
||||
packages/*/es
|
||||
packages/*/lib
|
||||
|
@ -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()
|
||||
|
@ -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())
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -9,7 +9,7 @@ import FormItem from '../src/form-item.vue'
|
||||
|
||||
type Methods = Record<string, () => any>
|
||||
function mountForm<D, M extends Methods, C>(
|
||||
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')
|
||||
|
@ -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, {
|
||||
|
@ -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)
|
||||
|
@ -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',
|
||||
|
@ -576,7 +576,7 @@ describe('Select', () => {
|
||||
options[2].click()
|
||||
await nextTick()
|
||||
const tagWrappers = wrapper.findAll('.el-select__tags-text')
|
||||
for(let i=0;i<tagWrappers.length;i++) {
|
||||
for(let i = 0;i < tagWrappers.length;i++) {
|
||||
const tagWrapperDom = tagWrappers[i].element
|
||||
expect(parseInt(tagWrapperDom.style.maxWidth) === inputRect.width - 75).toBe(true)
|
||||
}
|
||||
|
@ -93,13 +93,11 @@ export default defineComponent({
|
||||
)
|
||||
|
||||
watch(currentName, () => {
|
||||
if (nav$.value) {
|
||||
nextTick(() => {
|
||||
nav$.value.$nextTick(() => {
|
||||
nav$.value.scrollToActiveTab()
|
||||
})
|
||||
nextTick(() => {
|
||||
nav$.value && nav$.value.$nextTick(() => {
|
||||
nav$.value && nav$.value.scrollToActiveTab()
|
||||
})
|
||||
}
|
||||
})
|
||||
setPaneInstances(true)
|
||||
})
|
||||
|
||||
|
@ -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 () => {
|
||||
|
@ -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() {
|
||||
|
@ -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 () => {
|
||||
|
Loading…
Reference in New Issue
Block a user