Skip to content

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

Merged
merged 2 commits into from
Jun 10, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions docs/guides/using-with-vuex.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Member

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


const localVue = createLocalVue()

Expand All @@ -230,9 +230,7 @@ describe('MyComponent.vue', () => {

beforeEach(() => {
state = {
module: {
clicks: 2
}
clicks: 2
}

actions = {
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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
}
}
})
Expand All @@ -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())
Expand Down