table-test-common.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { nextTick } from 'vue'
  2. import { mount as _mount } from '@vue/test-utils'
  3. import { vi } from 'vitest'
  4. vi.mock('lodash-unified', async () => {
  5. return {
  6. ...((await vi.importActual('lodash-unified')) as Record<string, any>),
  7. debounce: vi.fn((fn) => {
  8. fn.cancel = vi.fn()
  9. fn.flush = vi.fn()
  10. return fn
  11. }),
  12. }
  13. })
  14. export async function doubleWait() {
  15. await nextTick()
  16. await nextTick()
  17. }
  18. export const mount = (opt: any) =>
  19. _mount<any>(opt, {
  20. attachTo: 'body',
  21. })
  22. export function getTestData() {
  23. return [
  24. {
  25. id: 1,
  26. name: 'Toy Story',
  27. release: '1995-11-22',
  28. director: 'John Lasseter',
  29. runtime: 80,
  30. },
  31. {
  32. id: 2,
  33. name: "A Bug's Life",
  34. release: '1998-11-25',
  35. director: 'John Lasseter',
  36. runtime: 95,
  37. },
  38. {
  39. id: 3,
  40. name: 'Toy Story 2',
  41. release: '1999-11-24',
  42. director: 'John Lasseter',
  43. runtime: 92,
  44. },
  45. {
  46. id: 4,
  47. name: 'Monsters, Inc.',
  48. release: '2001-11-2',
  49. director: 'Peter Docter',
  50. runtime: 92,
  51. },
  52. {
  53. id: 5,
  54. name: 'Finding Nemo',
  55. release: '2003-5-30',
  56. director: 'Andrew Stanton',
  57. runtime: 100,
  58. },
  59. ]
  60. }