core.spec.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import test from 'tape'
  2. import Uppy from '../../src/core/Core.js'
  3. import Acquirer1Plugin from './mocks/plugin-acquirer1.js'
  4. // import Acquirer2Plugin from './mocks/plugin-acquirer2.js'
  5. test('core', function (t) {
  6. t.equal(typeof new Uppy(), 'object', '`new Uppy()` should return an `object`')
  7. t.equal(typeof Uppy(), 'object', '`Uppy()` without `new` should also return an `object`')
  8. // t.ok(uppy instanceof Uppy, '`uppy` should be an instance of `Core` core')
  9. t.end()
  10. })
  11. test('use plugins', function (t) {
  12. const uppy = new Uppy()
  13. uppy
  14. .use(Acquirer1Plugin)
  15. t.equal(Object.keys(uppy.plugins).length, 1, 'should add a plugin to the plugins stack')
  16. t.end()
  17. })
  18. test('noDuplicates', function (t) {
  19. const uppyTwoAcquirers = new Uppy()
  20. uppyTwoAcquirers.use(Acquirer1Plugin)
  21. const fn = uppyTwoAcquirers.use.bind(uppyTwoAcquirers, Acquirer1Plugin)
  22. t.throws(fn, new RegExp('Uppy is currently limited to running one of every plugin'))
  23. t.end()
  24. })
  25. // test('autoProceed', function (t) {
  26. // const uppyOneAcquirer = new Core()
  27. // uppyOneAcquirer
  28. // .use(Acquirer1Plugin)
  29. // .run()
  30. //
  31. // const uppyTwoAcquirers = new Core()
  32. // uppyTwoAcquirers
  33. // .use(Acquirer1Plugin)
  34. // .use(Acquirer2Plugin)
  35. // .run()
  36. //
  37. // t.equal(uppyOneAcquirer.opts.autoProceed, true, 'should autoProceed if only one acquirer is used')
  38. // t.equal(uppyTwoAcquirers.opts.autoProceed, false, 'should not autoProceed if more than one acquirer is used')
  39. // t.end()
  40. // })