1.0.1 • Published 5 years ago

mock-vuex v1.0.1

Weekly downloads
52
License
MIT
Repository
github
Last release
5 years ago

mock-vuex

A Mock version of Vuex to make unit testing easier

Install

npm install mock-vuex --save-dev

Create with state

import mock from 'mock-vuex';
const store = mock({
  users : {
    user : { id : 1, name : 'user1' }
  }
});

Create with getters/actions/mutations/modules

import mock from 'mock-vuex';
const store = mock({
  modules : {
    users : {
      state : {
        user : { id : 1, name : 'user1' }
      },
      actions : {
        setUserName({state, commit}, payload){
          /* ... */
        }
      },
      mutations : {
        SET_USER_NAME(state, payload){
          /* ... */
        }
      }
    }
  }
});

Intercept commit/dispatch calls

store.when('dispatch', 'setUserName').return('success'); // calling store.dispatch('setUserName') will resolve with 'success'
store.expect('commit', 'SET_USER_NAME'); // adds a check to ensure a commit has been called

store.assert(); // throws if SET_USER_NAME has not been called

Full Documentation:
https://jackmellis.gitbooks.io/vuenit/content/store/introduction.html

1.0.1

5 years ago

1.0.0

5 years ago

0.2.1

6 years ago

0.2.0

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago