Transloadit.spec.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import test from 'tape'
  2. import Core from '../../src/core/Core'
  3. import Transloadit from '../../src/plugins/Transloadit'
  4. test('Transloadit: Throws errors if options are missing', (t) => {
  5. const uppy = new Core()
  6. t.throws(() => {
  7. uppy.use(Transloadit, {})
  8. }, /The `params` option is required/)
  9. t.throws(() => {
  10. uppy.use(Transloadit, { params: {} })
  11. }, /The `params\.auth\.key` option is required/)
  12. t.end()
  13. })
  14. test('Transloadit: Accepts a JSON string as `params` for signature authentication', (t) => {
  15. const uppy = new Core()
  16. t.throws(() => {
  17. uppy.use(Transloadit, {
  18. params: 'not json'
  19. })
  20. }, /The `params` option is a malformed JSON string/)
  21. t.throws(() => {
  22. uppy.use(Transloadit, {
  23. params: '{"template_id":"some template id string"}'
  24. })
  25. }, /The `params\.auth\.key` option is required/)
  26. t.doesNotThrow(() => {
  27. uppy.use(Transloadit, {
  28. params: '{"auth":{"key":"some auth key string"},"template_id":"some template id string"}'
  29. })
  30. }, /The `params\.auth\.key` option is required/)
  31. t.end()
  32. })