Prechádzať zdrojové kódy

Test aws s3 plugin (#1934)

* begin testing aws-s3 uploader

* test getUplaodParameters

* getUploadParameters configured campanionUrl

* warn user when configured without campanionUrl

* warn if missconfigured

Co-Authored-By: Renée Kooi <renee@kooi.me>

* remove warning in constructor
Alexis Hope 5 rokov pred
rodič
commit
ad74af8b96
1 zmenil súbory, kde vykonal 36 pridanie a 0 odobranie
  1. 36 0
      packages/@uppy/aws-s3/src/index.test.js

+ 36 - 0
packages/@uppy/aws-s3/src/index.test.js

@@ -0,0 +1,36 @@
+const Core = require('@uppy/core')
+const AwsS3 = require('./')
+
+describe('AwsS3', () => {
+  it('Registers AwsS3 upload plugin', () => {
+    const core = new Core()
+    core.use(AwsS3)
+
+    const pluginNames = core.plugins.uploader.map((plugin) => plugin.constructor.name)
+    expect(pluginNames).toContain('AwsS3')
+  })
+
+  describe('getUploadParameters', () => {
+    it('Throws an error if configured without companionUrl', () => {
+      const core = new Core()
+      core.use(AwsS3)
+      const awsS3 = core.getPlugin('AwsS3')
+
+      expect(awsS3.opts.getUploadParameters).toThrow()
+    })
+
+    it('Does not throw an error with campanionUrl configured', () => {
+      const core = new Core()
+      core.use(AwsS3, { companionUrl: 'https://uppy-companion.myapp.com/' })
+      const awsS3 = core.getPlugin('AwsS3')
+      const file = {
+        meta: {
+          name: 'foo.jpg',
+          type: 'image/jpg'
+        }
+      }
+
+      expect(() => awsS3.opts.getUploadParameters(file)).not.toThrow()
+    })
+  })
+})