Browse Source

core: Add test for returning data from upload hooks

Renée Kooi 7 years ago
parent
commit
8092230c6c
1 changed files with 15 additions and 0 deletions
  1. 15 0
      src/core/Core.test.js

+ 15 - 0
src/core/Core.test.js

@@ -270,6 +270,21 @@ describe('src/Core', () => {
     )
   })
 
+  describe('upload hooks', () => {
+    it('should add data returned from upload hooks to the .upload() result', () => {
+      const core = new Core()
+      core.addPreProcessor(() => Promise.resolve({ pre: 'ok' }))
+      core.addPostProcessor(() => Promise.resolve({ post: 'ok' }))
+      core.addUploader(() => Promise.resolve({ upload: 'ok' }))
+      core.run()
+      return core.upload().then((result) => {
+        expect(result.pre).toBe('ok')
+        expect(result.upload).toBe('ok')
+        expect(result.post).toBe('ok')
+      })
+    })
+  })
+
   describe('preprocessors', () => {
     it('should add a preprocessor', () => {
       const core = new Core()