|
@@ -1,8 +1,13 @@
|
|
|
import { mount } from '@vue/test-utils'
|
|
|
import { describe, it, expect } from 'vitest'
|
|
|
-import { nextTick } from 'vue'
|
|
|
|
|
|
-import { ButtonAnimation, CollapseTransition, EmptyPlaceholder } from '../index'
|
|
|
+import { ButtonAnimation } from '../index'
|
|
|
+
|
|
|
+async function sleep(delay: number): Promise<void> {
|
|
|
+ await new Promise((resolve) => {
|
|
|
+ setTimeout(resolve, delay)
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
describe('ButtonAnimation Component', () => {
|
|
|
it('render component', () => {
|
|
@@ -33,7 +38,7 @@ describe('ButtonAnimation Component', () => {
|
|
|
|
|
|
expect(wrapper.find('.animate-beat').exists()).toBe(true)
|
|
|
|
|
|
- await new Promise((resolve) => setTimeout(resolve, 150))
|
|
|
+ await sleep(150)
|
|
|
|
|
|
expect(wrapper.find('.animate-beat').exists()).toBe(false)
|
|
|
})
|
|
@@ -51,35 +56,3 @@ describe('ButtonAnimation Component', () => {
|
|
|
expect(wrapper.find('.animate-pulse').exists()).toBe(false)
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
-describe('EmptyPlaceholder Component', () => {
|
|
|
- it('render component', () => {
|
|
|
- const wrapper = mount(EmptyPlaceholder, {
|
|
|
- props: {
|
|
|
- show: true,
|
|
|
- },
|
|
|
- })
|
|
|
-
|
|
|
- expect(wrapper.exists()).toBe(true)
|
|
|
- expect(wrapper.find('.n-empty').exists()).toBe(true)
|
|
|
- })
|
|
|
-})
|
|
|
-
|
|
|
-describe('CollapseTransition Component', () => {
|
|
|
- it('toggle by v-if when display=false', async () => {
|
|
|
- const wrapper = mount(CollapseTransition, {
|
|
|
- props: {
|
|
|
- display: true,
|
|
|
- direction: 'vertical',
|
|
|
- },
|
|
|
- slots: { default: '<div class="context">context</div>' },
|
|
|
- })
|
|
|
-
|
|
|
- expect(wrapper.find('.context').exists()).toBe(true)
|
|
|
-
|
|
|
- await wrapper.setProps({ display: false })
|
|
|
- await nextTick()
|
|
|
-
|
|
|
- expect(wrapper.find('.context').exists()).toBe(false)
|
|
|
- })
|
|
|
-})
|