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() { return function render() {
with (this) { 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, type: NodeTypes.INTERPOLATION,
loc: locStub, loc: locStub,
content: createSimpleExpression(`bar`, false, locStub) content: createSimpleExpression(`bar`, false, locStub)
} },
// nested compound
createCompoundExpression([` + `, `nested`])
]) ])
}) })
) )
expect(code).toMatch( expect(code).toMatch(
`return _ctx.foo + _${helperNameMap[TO_DISPLAY_STRING]}(bar)` `return _ctx.foo + _${helperNameMap[TO_DISPLAY_STRING]}(bar) + nested`
) )
expect(code).toMatchSnapshot() expect(code).toMatchSnapshot()
}) })

View File

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

View File

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