test(compiler): test v-slot transform

This commit is contained in:
Evan You
2019-09-28 14:05:10 -04:00
parent 96749e0178
commit 1c410205de
8 changed files with 613 additions and 30 deletions

View File

@@ -1234,6 +1234,50 @@ describe('compiler: parse', () => {
})
})
test('v-slot shorthand', () => {
const ast = parse('<Comp #a="{ b }" />')
const directive = (ast.children[0] as ElementNode).props[0]
expect(directive).toStrictEqual({
type: NodeTypes.DIRECTIVE,
name: 'slot',
arg: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: 'a',
isStatic: true,
loc: {
source: 'a',
start: {
column: 8,
line: 1,
offset: 7
},
end: {
column: 9,
line: 1,
offset: 8
}
}
},
modifiers: [],
exp: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: '{ b }',
isStatic: false,
loc: {
start: { offset: 10, line: 1, column: 11 },
end: { offset: 15, line: 1, column: 16 },
source: '{ b }'
}
},
loc: {
start: { offset: 6, line: 1, column: 7 },
end: { offset: 16, line: 1, column: 17 },
source: '#a="{ b }"'
}
})
})
test('end tags are case-insensitive.', () => {
const ast = parse('<div>hello</DIV>after')
const element = ast.children[0] as ElementNode