Skip to content

Commit e76a2a3

Browse files
author
Jakub Freisler
committed
test: template string within the HTML template
add proposed config API for templateCompiler
1 parent 4afea00 commit e76a2a3

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<div
3+
:data-sth="
4+
gql`
5+
query {
6+
id
7+
}
8+
`
9+
"
10+
/>
11+
</template>
12+
13+
<script lang="ts">
14+
export default {
15+
methods: {
16+
gql([str]) {
17+
return str
18+
}
19+
}
20+
}
21+
</script>

e2e/__projects__/basic/package.json

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
"vue-jest": {
3939
"pug": {
4040
"basedir": "./"
41+
},
42+
"templateCompiler": {
43+
"transpileOptions": {
44+
"transforms": {
45+
"dangerousTaggedTemplateString": true
46+
}
47+
}
4148
}
4249
}
4350
}

e2e/__projects__/basic/test.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { mount } from '@vue/test-utils'
22
import TypeScript from './components/TypeScript.vue'
3+
import TemplateString from './components/TemplateString.vue'
34
import { resolve } from 'path'
45
import { readFileSync } from 'fs'
56
import jestVue from 'vue-jest'
@@ -81,6 +82,11 @@ test('processes .vue files with lang set to typescript', () => {
8182
expect(wrapper.element.tagName).toBe('DIV')
8283
})
8384

85+
test('processes .vue files with template strings in the template', () => {
86+
const wrapper = mount(TemplateString)
87+
expect(wrapper.attributes('data-sth')).toBe('query { id }')
88+
})
89+
8490
test('processes functional components', () => {
8591
const clickSpy = jest.fn()
8692
const wrapper = mount(FunctionalSFC, {

0 commit comments

Comments
 (0)