Skip to content

Commit

Permalink
fix(compiler-core): add test case for v-for source with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
hchlq committed Apr 29, 2022
1 parent b1180b6 commit c31788b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/compiler-core/__tests__/transforms/vFor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ describe('compiler: v-for', () => {
expect(forNode.valueAlias).toBeUndefined()
expect((forNode.source as SimpleExpressionNode).content).toBe('items')
})

test('source containing string expression with spaces', () => {
const { node: forNode } = parseWithForTransform(
`<span v-for="item in state ['my items']" />`
)
expect(forNode.keyAlias).toBeUndefined()
expect(forNode.objectIndexAlias).toBeUndefined()
expect((forNode.valueAlias as SimpleExpressionNode).content).toBe('item')
expect((forNode.source as SimpleExpressionNode).content).toBe("state ['my items']")
})
})

describe('errors', () => {
Expand Down Expand Up @@ -265,16 +275,6 @@ describe('compiler: v-for', () => {
)
})

test('source containing string expression with spaces', () => {
const { node: forNode } = parseWithForTransform(
`<span v-for="item in state ['my items']" />`
)
expect(forNode.keyAlias).toBeUndefined()
expect(forNode.objectIndexAlias).toBeUndefined()
expect((forNode.valueAlias as SimpleExpressionNode).content).toBe('item')
expect((forNode.source as SimpleExpressionNode).content).toBe("state ['my items']")
})

test('missing value', () => {
const onError = jest.fn()
parseWithForTransform('<span v-for="in items" />', { onError })
Expand Down

0 comments on commit c31788b

Please sign in to comment.