Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhe141 committed Sep 24, 2024
1 parent 59db93e commit 3edffcb
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion packages/compiler-core/__tests__/transforms/vMemo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { baseCompile } from '../../src'
import { NodeTypes, baseCompile } from '../../src'
import { parseWithForTransform } from './vFor.spec'

describe('compiler: v-memo transform', () => {
function compile(content: string) {
Expand Down Expand Up @@ -53,4 +54,27 @@ describe('compiler: v-memo transform', () => {
),
).toMatchSnapshot()
})

test('element v-for key expression prefixing + v-memo', () => {
const {
node: { codegenNode },
} = parseWithForTransform(
'<span v-for="data of tableData" :key="getId(data)" v-memo="getLetter(data)"></span>',
{ prefixIdentifiers: true },
)
const keyExp =
// @ts-expect-error
codegenNode.children.arguments[1].body.body[1].children[2]
expect(keyExp).toMatchObject({
type: NodeTypes.COMPOUND_EXPRESSION,
children: [
// should prefix outer scope references
{ content: `_ctx.getId` },
`(`,
// should NOT prefix in scope variables
{ content: `data` },
`)`,
],
})
})
})

0 comments on commit 3edffcb

Please sign in to comment.