File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
test/unit/specs/mount/Wrapper Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 11import { compileToFunctions } from 'vue-template-compiler'
2- import { mount } from '~vue-test-utils'
2+ import { mount , createLocalVue } from '~vue-test-utils'
3+ import Vuex , { mapGetters } from 'vuex'
34import ComponentWithComputed from '~resources/components/component-with-computed.vue'
45import ComponentWithWatch from '~resources/components/component-with-watch.vue'
56
@@ -54,6 +55,34 @@ describe('setComputed', () => {
5455 expect ( wrapper . vm . b ) . to . equal ( 3 )
5556 } )
5657
58+ it ( 'works correctly with mapGetters' , ( ) => {
59+ const localVue = createLocalVue ( )
60+ localVue . use ( Vuex )
61+ const store = new Vuex . Store ( {
62+ getters : {
63+ someGetter : ( ) => false
64+ }
65+ } )
66+ const TestComponent = {
67+ computed : {
68+ ...mapGetters ( [
69+ 'someGetter'
70+ ] ) ,
71+ placeholder ( ) {
72+ return this . someGetter
73+ ? 'someGetter is true'
74+ : 'someGetter is false'
75+ }
76+ }
77+ }
78+ const wrapper = mount ( TestComponent , {
79+ localVue,
80+ store
81+ } )
82+ wrapper . setComputed ( { someGetter : true } )
83+ expect ( wrapper . vm . placeholder ) . to . equal ( 'someGetter is true' )
84+ } )
85+
5786 it ( 'throws an error if node is not a Vue instance' , ( ) => {
5887 const message = 'wrapper.setComputed() can only be called on a Vue instance'
5988 const compiled = compileToFunctions ( '<div><p></p></div>' )
You can’t perform that action at this time.
0 commit comments