test(components): [el-config-provider] use useFakeTimers (#5228)

* fix(components): modify config-provider sleep time

* test: use useFakeTimers
This commit is contained in:
btea 2022-01-09 19:45:01 -06:00 committed by GitHub
parent f41f3f8dd5
commit e3417babe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,10 +4,12 @@ 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 { sleep } from '@element-plus/test-utils'
import { rAF } from '@element-plus/test-utils/tick'
import ConfigProvider from '../src/config-provider'
import type { Language } from '@element-plus/locale'
jest.useFakeTimers()
const TestComp = {
setup() {
const { t } = useLocale()
@ -195,8 +197,8 @@ describe('config-provider', () => {
</el-config-provider>
`,
})
ElMessage.closeAll()
await sleep(40)
jest.runAllTimers()
await rAF()
wrapper.find('.el-button').trigger('click')
wrapper.find('.el-button').trigger('click')
wrapper.find('.el-button').trigger('click')