Skip to content

Commit

Permalink
Update tests for new mapInstanceState functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Mar 3, 2022
1 parent 5d3eb38 commit b65317a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions spec/vuex-helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe('Vuex Store Utils', () => {
namespaced: true,
state: () => ({
value: 1,
value2: 2,
value3: 3,
}),
};

Expand All @@ -32,7 +34,10 @@ describe('Vuex Store Utils', () => {
computed: {
...mapInstanceState(getModuleName, ['value']),
...mapInstanceState(getModuleName, {
value2: state => state.value,
value2: state => state.value2,
}),
...mapInstanceState(getModuleName, {
value3: 'value3',
}),
},
render(h) {
Expand Down Expand Up @@ -60,8 +65,10 @@ describe('Vuex Store Utils', () => {

expect(wrapper.vm.value).toBe(store.state.myNamespace.value);
expect(wrapper.vm.value).toBe(1);
expect(wrapper.vm.value2).toBe(store.state.myNamespace.value);
expect(wrapper.vm.value2).toBe(1);
expect(wrapper.vm.value2).toBe(store.state.myNamespace.value2);
expect(wrapper.vm.value2).toBe(2);
expect(wrapper.vm.value3).toBe(store.state.myNamespace.value3);
expect(wrapper.vm.value3).toBe(3);
});

it('should work for nested modules', () => {
Expand Down Expand Up @@ -93,8 +100,10 @@ describe('Vuex Store Utils', () => {

expect(wrapper.vm.value).toBe(store.state.parent.child.grandchild.value);
expect(wrapper.vm.value).toBe(1);
expect(wrapper.vm.value2).toBe(store.state.parent.child.grandchild.value);
expect(wrapper.vm.value2).toBe(1);
expect(wrapper.vm.value2).toBe(store.state.parent.child.grandchild.value2);
expect(wrapper.vm.value2).toBe(2);
expect(wrapper.vm.value3).toBe(store.state.parent.child.grandchild.value3);
expect(wrapper.vm.value3).toBe(3);
});

});
Expand Down

0 comments on commit b65317a

Please sign in to comment.