diff --git a/index.js b/index.js index b9d488b..3115b19 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ const merge = require('deepmerge'); const shvl = require('shvl'); module.exports = function(options, storage, key) { + options = options || {}; storage = options.storage || (window && window.localStorage); key = options.key || 'vuex'; diff --git a/test.js b/test.js index aa4f548..598174e 100644 --- a/test.js +++ b/test.js @@ -5,6 +5,11 @@ const createPersistedState = require('./index'); Vue.use(Vuex); +it('can be created with the default options', () => { + window.localStorage = new Storage(); + expect(() => createPersistedState()).not.toThrow(); +}); + it("replaces store's state and subscribes to changes when initializing", () => { const storage = new Storage(); storage.setItem('vuex', JSON.stringify({ persisted: 'json' }));