Skip to content

Commit 9d28943

Browse files
committed
Add test for functional component using render function
1 parent f0d025e commit 9d28943

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script>
2+
export default {
3+
name: 'FunctionalSFCRender',
4+
functional: true,
5+
render(createElement, { $style }) {
6+
return createElement('div', {
7+
class: [$style.ModuleClass]
8+
})
9+
}
10+
}
11+
</script>
12+
13+
<style lang="scss" module>
14+
.ModuleClass {
15+
width: auto;
16+
}
17+
</style>

e2e/__projects__/basic/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import jestVue from 'vue-jest'
66
import RenderFunction from './components/RenderFunction.vue'
77
import Jade from './components/Jade.vue'
88
import FunctionalSFC from './components/FunctionalSFC.vue'
9+
import FunctionalSFCRender from './components/FunctionalSFCRender.vue'
910
import Basic from './components/Basic.vue'
1011
import BasicSrc from './components/BasicSrc.vue'
1112
import { randomExport } from './components/NamedExport.vue'
@@ -92,6 +93,12 @@ test('processes functional components', () => {
9293
expect(clickSpy).toHaveBeenCalledWith(1)
9394
})
9495

96+
test('processes functional components using render function', () => {
97+
const wrapper = mount(FunctionalSFCRender)
98+
const CSS_CLASSES = ['ModuleClass']
99+
expect(wrapper.classes().toString()).toBe(CSS_CLASSES.toString())
100+
})
101+
95102
test('processes SFC with functional template from parent', () => {
96103
const wrapper = mount(FunctionalSFCParent)
97104
expect(wrapper.text().trim()).toBe('foo')

0 commit comments

Comments
 (0)