Explorar o código

Merge pull request #677 from richmeij/master

Added merge of restrictions
Artur Paikin %!s(int64=7) %!d(string=hai) anos
pai
achega
b63a2d3213
Modificáronse 2 ficheiros con 14 adicións e 0 borrados
  1. 1 0
      src/core/Core.js
  2. 13 0
      src/core/Core.test.js

+ 1 - 0
src/core/Core.js

@@ -52,6 +52,7 @@ class Uppy {
 
     // Merge default options with the ones set by user
     this.opts = Object.assign({}, defaultOptions, opts)
+    this.opts.restrictions = Object.assign({}, defaultOptions.restrictions, this.opts.restrictions)
 
     this.locale = Object.assign({}, defaultLocale, this.opts.locale)
     this.locale.strings = Object.assign({}, defaultLocale.strings, this.opts.locale.strings)

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

@@ -1213,4 +1213,17 @@ describe('src/Core', () => {
       expect(core.i18n('test')).toBe('beep boop')
     })
   })
+
+  describe('default restrictions', () => {
+    it.only('should be merged with supplied restrictions', () => {
+      const core = new Core({
+        restrictions: {
+          maxNumberOfFiles: 3
+        }
+      })
+
+      expect(core.opts.restrictions.maxNumberOfFiles).toBe(3)
+      expect(core.opts.restrictions.minNumberOfFiles).toBe(false)
+    })
+  })
 })