Skip to content

Commit

Permalink
fix(ui/testing): "plugin" generator should ensure the tested plugin g…
Browse files Browse the repository at this point in the history
…ets installed
  • Loading branch information
rstoenescu committed Apr 3, 2024
1 parent 99b3ee1 commit 915d83f
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions ui/testing/specs/generators/generator.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,15 @@ export default {
getJson: readAssociatedJsonFile,
getFileHeader: ({ ctx, json }) => {
const acc = [
'import { describe, test, expect } from \'vitest\''
'import { describe, test, expect } from \'vitest\'',
'import { mount } from \'@vue/test-utils\'',
'import { defineComponent } from \'vue\''
]

const vueImports = []
const quasarImports = []

if (json.injection !== void 0) {
quasarImports.push('useQuasar')
vueImports.push('defineComponent')
acc.push(
'import { mount } from \'@vue/test-utils\''
)
}

if (
Expand All @@ -153,15 +150,12 @@ export default {
)
}

if (vueImports.length !== 0) {
acc.push(
`import { ${ vueImports.join(', ') } } from 'vue'`
)
}

acc.push(
'',
`import ${ ctx.pascalName } from './${ ctx.localName }'`
`import ${ ctx.pascalName } from './${ ctx.localName }'`,
'',
'// ensure the Quasar plugin gets installed:',
'mount(defineComponent({ template: \'<div />\' }))'
)

return acc.join('\n')
Expand Down

0 comments on commit 915d83f

Please sign in to comment.