Giter Club home page Giter Club logo

mock-vuex's People

Contributors

jackmellis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

rhelling

mock-vuex's Issues

Dont throw dispatch errors

Previously store.assert would not throw an error. Now, when.reject will throw an error instead of rejecting. I think the best thing to do is to do the fijdMatchingReponse call synchronously, then call the call back asynchronously

Which are the practical advantages over creating a normal store?

First of all thank you for doing this - we definitely need something like arnaudbenard.com/redux-mock-store/ for Vue/Vuex.

Question: What is the practical difference with using a normal Vuex store?

store = new Vuex.Store({
  state,
  actions,
  getters,
});

Speed & the helper methods I guess? But isn't re-creating your actions / mutations / state in tests a bit of an overhead - cheating? (I understand you're arguing that sometimes you wanna test pure component functionality without bothering with the store which is probably a legit argument but just to see if there's something else)

again thank you!

Tries to create modules for null and array state values

If you create a store with a null or array property i.e.

mockStore({
  list : [],
  thing : null
});

it tries to create a module from these properties, resulting in cannot access property of null etc.

Change create.js line 9 to:

if (Object.prototype.toString.call(v) === '[object Object]'){

Blocking Vuenit 0.5

non-namespaced modules

mock-vuex automatically namespaces modules, but vuex allows you to create modules without their own namespace.

mock-vuex should namespace modules by default, but if namespace is false, do not namespace the module.

Mutation not firing — lost as to why it isn't working

I don't understand why this simple mutation fails to run in my Vuecli environment; but works perfectly from the example
Does Vuenit not work outside of ava?

import { mockStore } from 'vuenit'

// my test 
const $store = mockStore({
  common: {
    state: {
      loaded: true
    },
    mutations: {
      why (state, payload) {
        state.loaded = payload
        console.log('called') // this never fires...
      }
    }
  }
})
// straight from the example
const $store2 = mockStore({
  things: {
    state: {
      things: []
    },
    getters: {},
    mutations: {
      ADD_THING(state, payload){
        console.log('called!', state, payload) // neither does this
        state.things.push(payload)
      }
    },
    actions: {
      addThing({state, commit}, payload){
        commit('ADD_THING', payload)
        return payload
      }
    }
  }
})

describe('Http Service/Interceptors', () => {
  it('on a request, should trigger a loading state', () => {
    // interceptor.request($store)({})
    $store.commit('why', false)
    $store2.commit('ADD_THING', {})
    console.log($store.state.common.loaded) // true — should be false
    console.log($store2.state.things.length) // undefined
  })
})

Using standard Vuecli webpack setup. Only added vuenit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.