Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vuex-mock-store

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuex-mock-store - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

25

package.json
{
"name": "vuex-mock-store",
"version": "0.0.5",
"version": "0.0.6",
"description": "Simple and straightforward mock for Vuex v3.x Store",

@@ -12,3 +12,3 @@ "main": "src/index.js",

"scripts": {
"lint": "eslint --color --ext=js,html src test",
"lint": "eslint --color --ext=js,html src tests",
"unit": "jest",

@@ -38,10 +38,10 @@ "dev": "npm run unit -- --watchAll",

"devDependencies": {
"@types/jest": "^23.3.2",
"@vue/test-utils": "^1.0.0-beta.25",
"@types/jest": "^23.3.10",
"@vue/test-utils": "^1.0.0-beta.26",
"codecov": "^3.1.0",
"eslint": "^5.6.0",
"eslint-config-posva": "^2.0.1",
"eslint": "^5.10.0",
"eslint-config-posva": "^2.0.3",
"jest": "^23.6.0",
"vue": "^2.5.17",
"vue-template-compiler": "^2.5.17",
"vue": "^2.5.18",
"vue-template-compiler": "^2.5.18",
"vuex": "^3.0.1"

@@ -63,9 +63,6 @@ },

],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest"
},
"coveragePathIgnorePatterns": [
"<rootDir>/test/*.js",
"<rootDir>/test/.*.js",
"<rootDir>/test/*/*.js"
"<rootDir>/tests/*.js",
"<rootDir>/tests/.*.js",
"<rootDir>/tests/*/*.js"
]

@@ -72,0 +69,0 @@ },

@@ -14,2 +14,18 @@ // @ts-check

function getNestedState ({ state, modules, key }) {
let _state = state
for (let module of modules) {
if (_state[module]) _state = _state[module]
else {
throw new Error(
`[vuex-mock-store] module "${key.slice(
0,
-1
)}" not defined in state:\n${JSON.stringify(state, null, 2)}`
)
}
}
return _state
}
exports.Store = class Store {

@@ -34,32 +50,25 @@ constructor ({ getters = {}, state = {}, spy = defaultSpy } = {}) {

// modules always have a trailing /
if (modules.length > 1) {
// remove trailing empty module
modules.pop()
// get the nested state corresponding to the module
let state = this.state
for (let module of modules) {
if (state[module]) state = state[module]
else {
throw new Error(
`[vuex-mock-store] module "${key.slice(
0,
-1
)}" not defined in state:\n${JSON.stringify(this.state, null, 2)}`
)
}
}
return {
context: {
// make sure we reuse this proxy
_modulesNamespaceMap: this._modulesNamespaceMap,
// pass the right state
state,
// getters are not nested
getters: this.getters,
},
}
} else {
if (modules.length <= 1) {
return Reflect.get(target, key)
}
// remove trailing empty module
modules.pop()
const state = getNestedState({ state: this.state, modules, key })
return {
context: {
dispatch: (name, ...args) =>
this.dispatch(key + name, ...args),
commit: (name, ...args) =>
this.commit(key + name, ...args),
// make sure we reuse this proxy
_modulesNamespaceMap: this._modulesNamespaceMap,
// pass the right state
state,
// getters are not nested
getters: this.getters,
},
}
},

@@ -66,0 +75,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc