Skip to content

Commit f256971

Browse files
committed
test: add vuex vue 3 test
1 parent b19cb44 commit f256971

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

packages/@vue/cli-plugin-vuex/__tests__/vuexGenerator.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,26 @@ test('base', async () => {
1212

1313
expect(pkg.dependencies).toHaveProperty('vuex')
1414
})
15+
16+
test('use with Vue 3', async () => {
17+
const { files, pkg } = await generateWithPlugin([
18+
{
19+
id: '@vue/cli-service',
20+
apply: require('@vue/cli-service/generator'),
21+
options: {
22+
vueVersion: '3'
23+
}
24+
},
25+
{
26+
id: 'vuex',
27+
apply: require('../generator'),
28+
options: {}
29+
}
30+
])
31+
32+
expect(files['src/store/index.js']).toBeTruthy()
33+
expect(files['src/store/index.js']).toMatch('import { createStore }')
34+
35+
expect(pkg.dependencies).toHaveProperty('vuex')
36+
expect(pkg.dependencies.vuex).toMatch('^4')
37+
})

packages/@vue/cli-plugin-vuex/generator/inject-use-store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = (file, api) => {
2121
appRoots.replaceWith(({ node: createAppCall }) => {
2222
return j.callExpression(
2323
j.memberExpression(createAppCall, j.identifier('use')),
24-
['store']
24+
[j.identifier('store')]
2525
)
2626
})
2727
}

0 commit comments

Comments
 (0)