2022-02-21 14:20:44 +08:00
|
|
|
import { nextTick } from 'vue'
|
2021-06-12 19:38:39 +08:00
|
|
|
import { mount as _mount } from '@vue/test-utils'
|
2022-04-19 12:46:57 +08:00
|
|
|
import { vi } from 'vitest'
|
2021-06-12 19:38:39 +08:00
|
|
|
|
2022-04-19 12:46:57 +08:00
|
|
|
vi.mock('lodash-unified', async () => {
|
2022-02-10 16:35:44 +08:00
|
|
|
return {
|
2022-04-19 12:46:57 +08:00
|
|
|
...((await vi.importActual('lodash-unified')) as Record<string, any>),
|
|
|
|
debounce: vi.fn((fn) => {
|
|
|
|
fn.cancel = vi.fn()
|
|
|
|
fn.flush = vi.fn()
|
2022-02-10 16:35:44 +08:00
|
|
|
return fn
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-02-21 14:20:44 +08:00
|
|
|
export async function doubleWait() {
|
|
|
|
await nextTick()
|
|
|
|
await nextTick()
|
|
|
|
}
|
|
|
|
|
2021-06-12 19:38:39 +08:00
|
|
|
export const mount = (opt: any) =>
|
|
|
|
_mount<any>(opt, {
|
|
|
|
attachTo: 'body',
|
|
|
|
})
|
|
|
|
|
|
|
|
export function getTestData() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
name: 'Toy Story',
|
|
|
|
release: '1995-11-22',
|
|
|
|
director: 'John Lasseter',
|
|
|
|
runtime: 80,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
name: "A Bug's Life",
|
|
|
|
release: '1998-11-25',
|
|
|
|
director: 'John Lasseter',
|
|
|
|
runtime: 95,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 3,
|
|
|
|
name: 'Toy Story 2',
|
|
|
|
release: '1999-11-24',
|
|
|
|
director: 'John Lasseter',
|
|
|
|
runtime: 92,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 4,
|
|
|
|
name: 'Monsters, Inc.',
|
|
|
|
release: '2001-11-2',
|
|
|
|
director: 'Peter Docter',
|
|
|
|
runtime: 92,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 5,
|
|
|
|
name: 'Finding Nemo',
|
|
|
|
release: '2003-5-30',
|
|
|
|
director: 'Andrew Stanton',
|
|
|
|
runtime: 100,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|