Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Plugin can be created without passing empty object (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinvdvleuten authored Nov 6, 2017
1 parent 821fd0b commit 3e0582e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
5 changes: 5 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }));
Expand Down

0 comments on commit 3e0582e

Please sign in to comment.