test: fix tests w/ nested CompoundExpressions

This commit is contained in:
Evan You 2020-02-05 14:30:34 -05:00
parent c952321fcf
commit 8f9e85afb1
4 changed files with 43 additions and 24 deletions

View File

@ -99,7 +99,7 @@ exports[`compiler: codegen compound expression 1`] = `
"
return function render() {
with (this) {
return _ctx.foo + _toDisplayString(bar)
return _ctx.foo + _toDisplayString(bar) + nested
}
}"
`;

View File

@ -207,12 +207,14 @@ describe('compiler: codegen', () => {
type: NodeTypes.INTERPOLATION,
loc: locStub,
content: createSimpleExpression(`bar`, false, locStub)
}
},
// nested compound
createCompoundExpression([` + `, `nested`])
])
})
)
expect(code).toMatch(
`return _ctx.foo + _${helperNameMap[TO_DISPLAY_STRING]}(bar)`
`return _ctx.foo + _${helperNameMap[TO_DISPLAY_STRING]}(bar) + nested`
)
expect(code).toMatchSnapshot()
})

View File

@ -190,6 +190,8 @@ describe('compiler: transform v-model', () => {
value: {
children: [
'$event => (',
{
children: [
{
content: '_ctx.model',
isStatic: false
@ -199,7 +201,9 @@ describe('compiler: transform v-model', () => {
content: '_ctx.index',
isStatic: false
},
']',
']'
]
},
' = $event)'
]
}

View File

@ -168,11 +168,16 @@ describe('compiler: transform v-on', () => {
type: NodeTypes.COMPOUND_EXPRESSION,
children: [
`$event => (`,
{
type: NodeTypes.COMPOUND_EXPRESSION,
children: [
{ content: `_ctx.foo` },
`(`,
// should NOT prefix $event
{ content: `$event` },
`)`,
`)`
]
},
`)`
]
}
@ -191,13 +196,17 @@ describe('compiler: transform v-on', () => {
type: NodeTypes.COMPOUND_EXPRESSION,
children: [
`$event => {`,
{
children: [
{ content: `_ctx.foo` },
`(`,
// should NOT prefix $event
{ content: `$event` },
`);`,
{ content: `_ctx.bar` },
`()`,
`()`
]
},
`}`
]
}
@ -363,7 +372,11 @@ describe('compiler: transform v-on', () => {
index: 1,
value: {
type: NodeTypes.COMPOUND_EXPRESSION,
children: [`$event => (`, { content: `_ctx.foo` }, `++`, `)`]
children: [
`$event => (`,
{ children: [{ content: `_ctx.foo` }, `++`] },
`)`
]
}
})
})