-
Notifications
You must be signed in to change notification settings - Fork 668
docs: update Vuex guide for namespaced option #691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,10 +214,10 @@ Simple component that includes one action and one getter. | |
And the test: | ||
|
||
``` js | ||
import { shallowMount, createLocalVue } from '@vue/test-utils' | ||
import { createLocalVue, shallowMount } from '@vue/test-utils' | ||
import Vuex from 'vuex' | ||
import MyComponent from '../../../src/components/MyComponent' | ||
import mymodule from '../../../src/store/mymodule' | ||
import myModule from '../../../src/store/myModule' | ||
|
||
const localVue = createLocalVue() | ||
|
||
|
@@ -230,9 +230,7 @@ describe('MyComponent.vue', () => { | |
|
||
beforeEach(() => { | ||
state = { | ||
module: { | ||
clicks: 2 | ||
} | ||
clicks: 2 | ||
} | ||
|
||
actions = { | ||
|
@@ -241,10 +239,11 @@ describe('MyComponent.vue', () => { | |
|
||
store = new Vuex.Store({ | ||
modules: { | ||
mymodule: { | ||
myModule: { | ||
namespaced: true, // If store/myModule is namespaced https://vuex.vuejs.org/guide/modules.html#namespacing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is necessary. I think the examples should have as little noise as possible. Since the user is testing their modules, we can assume they know if they namespaced it or not. Since the focus of this guide and repo is the test setup/assertions, not Vuex and the Vuex API, I don't think this should be included. |
||
state, | ||
actions, | ||
getters: module.getters | ||
getters: myModule.getters | ||
} | ||
} | ||
}) | ||
|
@@ -257,7 +256,7 @@ describe('MyComponent.vue', () => { | |
expect(actions.moduleActionClick).toHaveBeenCalled() | ||
}) | ||
|
||
it('Renders "state.inputValue" in first p tag', () => { | ||
it('renders "state.inputValue" in first p tag', () => { | ||
const wrapper = shallowMount(MyComponent, { store, localVue }) | ||
const p = wrapper.find('p') | ||
expect(p.text()).toBe(state.clicks.toString()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, fits the common convention of camel casing modules