index.test.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { describe, expect, expectTypeOf, it } from 'vitest'
  2. import Core from '@uppy/core'
  3. import Tus, { type TusBody } from './index.ts'
  4. describe('Tus', () => {
  5. it('Throws errors if autoRetry option is true', () => {
  6. const uppy = new Core()
  7. expect(() => {
  8. // @ts-expect-error removed
  9. uppy.use(Tus, { autoRetry: true })
  10. }).toThrowError(
  11. /The `autoRetry` option was deprecated and has been removed/,
  12. )
  13. })
  14. it('Throws errors if autoRetry option is false', () => {
  15. const uppy = new Core()
  16. expect(() => {
  17. // @ts-expect-error removed
  18. uppy.use(Tus, { autoRetry: false })
  19. }).toThrowError(
  20. /The `autoRetry` option was deprecated and has been removed/,
  21. )
  22. })
  23. it('Throws errors if autoRetry option is `undefined`', () => {
  24. const uppy = new Core()
  25. expect(() => {
  26. // @ts-expect-error removed
  27. uppy.use(Tus, { autoRetry: undefined })
  28. }).toThrowError(
  29. /The `autoRetry` option was deprecated and has been removed/,
  30. )
  31. })
  32. it('propagates the TusBody type', () => {
  33. const uppy = new Core<any, TusBody>()
  34. const id = uppy.addFile({ name: 'test.jpg', data: { size: 1024 } })
  35. const file = uppy.getFile(id)
  36. expectTypeOf(file.response?.body).toEqualTypeOf<
  37. { xhr: XMLHttpRequest } | undefined
  38. >()
  39. })
  40. })