Skip to content

Commit 5bf0d3a

Browse files
yangyonglunJuniorTour
authored andcommitted
test: add test case for computed OptionalMemberExpression
1 parent f53d618 commit 5bf0d3a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/compileRender.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,24 @@ test('should work for optional chaining', () => {
140140
expect(vm.$el.innerHTML).toMatch(`<h1>optional chaining worked</h1>`)
141141
})
142142

143+
test('should work for computed property accessing in optional chaining', () => {
144+
const vm = new Vue({
145+
...compileAsFunctions(`
146+
<div>
147+
<h1 v-if="optional?.[key]">optional chaining worked</h1>
148+
</div>
149+
`),
150+
data: {
151+
optional: {
152+
chaining: true
153+
},
154+
key: 'chaining'
155+
}
156+
}).$mount()
157+
158+
expect(vm.$el.innerHTML).toMatch(`<h1>optional chaining worked</h1>`)
159+
})
160+
143161
test('should work for __staticRenderFns__', () => {
144162
const transpileResult = transpileWithOption(`
145163
var __render__ = function () {with (this) {return _m(0)}}

0 commit comments

Comments
 (0)