diff --git a/lib/__tests__/index.js b/lib/__tests__/index.js index 254dc0a..c5973a3 100644 --- a/lib/__tests__/index.js +++ b/lib/__tests__/index.js @@ -17,8 +17,9 @@ const { describe('index', () => { describe('withOptions', () => { it('should call the given function with options', done => { - const fn = (a, options) => { - expect(a).to.be.equal('abc'); + const fn = (layoutClass, regions = {}, options) => { + expect(layoutClass).to.be.equal('abc'); + expect(regions).to.deep.equal({}); expect(options).to.deep.equal({aa: 10}); done(); }; diff --git a/lib/index.js b/lib/index.js index debda0b..cc92fe7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -12,9 +12,13 @@ export function mount(layoutClass, regions, options = {}) { mounter(layoutClass, regions, options); } -export function withOptions(options, fn) { - return function (...args) { - const newArgs = [ ...args, options ]; +export function withOptions(defaultOptions, fn) { + return function (layoutClass, regions, options = {}) { + const newArgs = [ + layoutClass, + regions, + { ...defaultOptions, ...options } + ]; return fn(...newArgs); }; }