index.test.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { describe, expect, it } from '@jest/globals'
  2. import resizeObserverPolyfill from 'resize-observer-polyfill'
  3. import Core from '@uppy/core'
  4. import Dashboard from '@uppy/dashboard'
  5. import RemoteSources from './index.js'
  6. describe('RemoteSources', () => {
  7. beforeAll(() => {
  8. globalThis.ResizeObserver = resizeObserverPolyfill.default || resizeObserverPolyfill
  9. })
  10. afterAll(() => {
  11. delete globalThis.ResizeObserver
  12. })
  13. it('should install RemoteSources with default options', () => {
  14. expect(() => {
  15. const core = new Core()
  16. core.use(Dashboard)
  17. core.use(RemoteSources, { companionUrl: 'https://example.com' })
  18. }).not.toThrow()
  19. })
  20. it('should throw when a companionUrl is not specified', () => {
  21. expect(() => {
  22. const core = new Core()
  23. core.use(Dashboard)
  24. core.use(RemoteSources, { sources: ['Webcam'] })
  25. }).toThrow(new Error('Please specify companionUrl for RemoteSources to work, see https://uppy.io/docs/remote-sources#companionUrl'))
  26. })
  27. it('should throw when trying to use a plugin which is not included in RemoteSources', () => {
  28. expect(() => {
  29. const core = new Core()
  30. core.use(Dashboard)
  31. core.use(RemoteSources, {
  32. companionUrl: 'https://example.com',
  33. sources: ['Webcam'],
  34. })
  35. }).toThrow('Invalid plugin: "Webcam" is not one of: Box, Dropbox, Facebook, GoogleDrive, Instagram, OneDrive, Unsplash, Url, or Zoom.')
  36. })
  37. })