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 1
1
import { 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'
3
4
import ComponentWithComputed from '~resources/components/component-with-computed.vue'
4
5
import ComponentWithWatch from '~resources/components/component-with-watch.vue'
5
6
@@ -54,6 +55,34 @@ describe('setComputed', () => {
54
55
expect ( wrapper . vm . b ) . to . equal ( 3 )
55
56
} )
56
57
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
+
57
86
it ( 'throws an error if node is not a Vue instance' , ( ) => {
58
87
const message = 'wrapper.setComputed() can only be called on a Vue instance'
59
88
const compiled = compileToFunctions ( '<div><p></p></div>' )
You can’t perform that action at this time.
0 commit comments