vue-loading-hook.spec.ts 897 B

1234567891011121314151617181920212223242526272829
  1. import { nextTick, ref } from 'vue'
  2. import { describe, expect, it } from 'vitest'
  3. import { useLoading } from '../packages/components/vue3/src/package/components/FileViewer/hooks/useLoading'
  4. describe('Vue FileViewer loading hook', () => {
  5. it('syncs extension theme changes through the core loading controller', async () => {
  6. const extension = ref('pdf')
  7. const loading = useLoading(extension)
  8. expect(loading.theme.value).toMatchObject({
  9. badge: 'PDF',
  10. label: 'PDF 文档'
  11. })
  12. loading.startLoading('读取中')
  13. expect(loading.loading.value).toBe(true)
  14. expect(loading.message.value).toBe('读取中')
  15. extension.value = 'dwg'
  16. await nextTick()
  17. expect(loading.theme.value).toMatchObject({
  18. badge: 'CAD',
  19. label: 'CAD 图纸'
  20. })
  21. expect(loading.loading.value).toBe(true)
  22. expect(loading.message.value).toBe('读取中')
  23. })
  24. })