mercredi 3 mars 2021

Vuex mutation test with jest and vue test utils

We have an store in vuex like this :

import { createStore } from "vuex";
import dialog from "./modules/dialog";

export default createStore({
  state: {},
  getters: {},
  mutations: {},
  actions: {},
  modules: {
   dialog
  }
});

also in the dialog module we have this :

export default {
 state: {
  show: false,
  size: Width.md
 },

mutations: {
showDialog: (state, options) => {
  const { size, body, header, footer, title } = options;

  state.show = true;
  state.size = size;
  state.body = body;
  state.header = header;
  state.footer = footer;
  state.title = title;
},

hideDialog: (state: Dialog) => {
  state.show = false;
}
},
};

We want to write unit test for testing hide and show function

could any one help us? provide an example or define appropriate link

Aucun commentaire:

Enregistrer un commentaire