index.test.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. require('whatwg-fetch')
  2. const Core = require('@uppy/core')
  3. const AwsS3 = require('./')
  4. describe('AwsS3', () => {
  5. it('Registers AwsS3 upload plugin', () => {
  6. const core = new Core()
  7. core.use(AwsS3)
  8. const pluginNames = core.plugins.uploader.map((plugin) => plugin.constructor.name)
  9. expect(pluginNames).toContain('AwsS3')
  10. })
  11. describe('getUploadParameters', () => {
  12. it('Throws an error if configured without companionUrl', () => {
  13. const core = new Core()
  14. core.use(AwsS3)
  15. const awsS3 = core.getPlugin('AwsS3')
  16. expect(awsS3.opts.getUploadParameters).toThrow()
  17. })
  18. it('Does not throw an error with campanionUrl configured', () => {
  19. const core = new Core()
  20. core.use(AwsS3, { companionUrl: 'https://uppy-companion.myapp.com/' })
  21. const awsS3 = core.getPlugin('AwsS3')
  22. const file = {
  23. meta: {
  24. name: 'foo.jpg',
  25. type: 'image/jpg'
  26. }
  27. }
  28. expect(() => awsS3.opts.getUploadParameters(file)).not.toThrow()
  29. })
  30. })
  31. })