Skip to content

Commit

Permalink
test: add a failing test for #10852
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed May 9, 2024
1 parent fdd1dd5 commit 9061dc4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/compiler-sfc/__tests__/compileTemplate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type RawSourceMap, SourceMapConsumer } from 'source-map-js'
import { parse as babelParse } from '@babel/parser'
import {
type SFCTemplateCompileOptions,
compileTemplate,
Expand Down Expand Up @@ -452,6 +453,36 @@ test('prefixing edge case for reused AST ssr mode', () => {
).not.toThrowError()
})

// #10852
test('non-identifier expression in legacy filter syntax', () => {
const src = `
<template>
<div>
Today is
{{ new Date() | formatDate }}
</div>
</template>
`

const { descriptor } = parse(src)
const compilationResult = compileTemplate({
id: 'xxx',
filename: 'test.vue',
ast: descriptor.template!.ast,
source: descriptor.template!.content,
ssr: false,
compilerOptions: {
compatConfig: {
MODE: 2,
},
},
})

expect(() => {
babelParse(compilationResult.code, { sourceType: 'module' })
}).not.toThrow()

Check failure on line 483 in packages/compiler-sfc/__tests__/compileTemplate.spec.ts

View workflow job for this annotation

GitHub Actions / unit-test

packages/compiler-sfc/__tests__/compileTemplate.spec.ts > non-identifier expression in legacy filter syntax

AssertionError: expected [Function] to not throw an error but 'SyntaxError: Missing semicolon. (6:14…' was thrown - Expected: undefined + Received: "SyntaxError: Missing semicolon. (6:140)" ❯ packages/compiler-sfc/__tests__/compileTemplate.spec.ts:483:10

Check failure on line 483 in packages/compiler-sfc/__tests__/compileTemplate.spec.ts

View workflow job for this annotation

GitHub Actions / unit-test-windows

packages/compiler-sfc/__tests__/compileTemplate.spec.ts > non-identifier expression in legacy filter syntax

AssertionError: expected [Function] to not throw an error but 'SyntaxError: Missing semicolon. (6:14…' was thrown - Expected: undefined + Received: "SyntaxError: Missing semicolon. (6:140)" ❯ packages/compiler-sfc/__tests__/compileTemplate.spec.ts:483:10
})

interface Pos {
line: number
column: number
Expand Down

0 comments on commit 9061dc4

Please sign in to comment.