test(components): [pagination/input] test case (#18080)

This commit is contained in:
btea 2024-08-29 20:20:58 +08:00 committed by GitHub
parent 044f0afc1e
commit 344c218d01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { useLocale } from '@element-plus/hooks'
import Chinese from '@element-plus/locale/lang/zh-cn'
import English from '@element-plus/locale/lang/en'
import { ElButton, ElMessage } from '@element-plus/components'
import { ElButton, ElMessage, ElPagination } from '@element-plus/components'
import { rAF } from '@element-plus/test-utils/tick'
import {
useGlobalComponentSettings,
@ -281,5 +281,25 @@ describe('config-provider', () => {
expect(vm.size).toBe('small')
})
// #18004
it('dynamically modify global size configuration', async () => {
const size = ref<ComponentSize>('small')
const wrapper = mount(() => (
<ConfigProvider size={size.value}>
<ElButton />
<ElPagination total={100} background={true} />
</ConfigProvider>
))
const button = wrapper.findComponent(ElButton)
const pagination = wrapper.findComponent(ElPagination)
expect(button.vm.$el.className.includes('small')).toBe(true)
expect(pagination.vm.$el.className.includes('small')).toBe(true)
size.value = 'large'
await nextTick()
expect(button.vm.$el.className.includes('large')).toBe(true)
expect(pagination.vm.$el.className.includes('large')).toBe(true)
})
})
})

View File

@ -48,10 +48,15 @@ describe('Input.vue', () => {
expect(inputElm.element.value).toBe('')
})
test('disabled', () => {
test('disabled', async () => {
const wrapper = mount(() => <Input disabled />)
const inputElm = wrapper.find('input')
expect(inputElm.element.disabled).not.toBeNull()
// trigger click should not focus #18012
inputElm.trigger('click')
await nextTick()
expect(inputElm.element.className.includes('is-focus')).toBe(false)
})
describe('test emoji', () => {