test: restructure v-if & v-for tests
This commit is contained in:
parent
4fc963bc5a
commit
65661b5ec0
@ -1,6 +1,6 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`compiler: transform v-if codegen basic v-if 1`] = `
|
exports[`compiler: v-if codegen basic v-if 1`] = `
|
||||||
"const _Vue = Vue
|
"const _Vue = Vue
|
||||||
|
|
||||||
return function render() {
|
return function render() {
|
||||||
@ -14,7 +14,7 @@ return function render() {
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: transform v-if codegen template v-if 1`] = `
|
exports[`compiler: v-if codegen template v-if 1`] = `
|
||||||
"const _Vue = Vue
|
"const _Vue = Vue
|
||||||
|
|
||||||
return function render() {
|
return function render() {
|
||||||
@ -32,7 +32,7 @@ return function render() {
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: transform v-if codegen v-if + v-else 1`] = `
|
exports[`compiler: v-if codegen v-if + v-else 1`] = `
|
||||||
"const _Vue = Vue
|
"const _Vue = Vue
|
||||||
|
|
||||||
return function render() {
|
return function render() {
|
||||||
@ -46,7 +46,7 @@ return function render() {
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: transform v-if codegen v-if + v-else-if + v-else 1`] = `
|
exports[`compiler: v-if codegen v-if + v-else-if + v-else 1`] = `
|
||||||
"const _Vue = Vue
|
"const _Vue = Vue
|
||||||
|
|
||||||
return function render() {
|
return function render() {
|
||||||
@ -62,7 +62,7 @@ return function render() {
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: transform v-if codegen v-if + v-else-if 1`] = `
|
exports[`compiler: v-if codegen v-if + v-else-if 1`] = `
|
||||||
"const _Vue = Vue
|
"const _Vue = Vue
|
||||||
|
|
||||||
return function render() {
|
return function render() {
|
||||||
|
@ -27,7 +27,8 @@ function parseWithForTransform(
|
|||||||
return node.children[0]
|
return node.children[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('compiler: transform v-for', () => {
|
describe('compiler: v-for', () => {
|
||||||
|
describe('transform', () => {
|
||||||
test('number expression', () => {
|
test('number expression', () => {
|
||||||
const forNode = parseWithForTransform(
|
const forNode = parseWithForTransform(
|
||||||
'<span v-for="index in 5" />'
|
'<span v-for="index in 5" />'
|
||||||
@ -183,7 +184,9 @@ describe('compiler: transform v-for', () => {
|
|||||||
expect(forNode.valueAlias).toBeUndefined()
|
expect(forNode.valueAlias).toBeUndefined()
|
||||||
expect((forNode.source as SimpleExpressionNode).content).toBe('items')
|
expect((forNode.source as SimpleExpressionNode).content).toBe('items')
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('errors', () => {
|
||||||
test('missing expression', () => {
|
test('missing expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = jest.fn()
|
||||||
parseWithForTransform('<span v-for />', { onError })
|
parseWithForTransform('<span v-for />', { onError })
|
||||||
@ -243,6 +246,7 @@ describe('compiler: transform v-for', () => {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('source location', () => {
|
describe('source location', () => {
|
||||||
test('value & source', () => {
|
test('value & source', () => {
|
||||||
@ -534,4 +538,10 @@ describe('compiler: transform v-for', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('codegen', () => {
|
||||||
|
test('basic v-for', () => {})
|
||||||
|
|
||||||
|
test('', () => {})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -45,7 +45,8 @@ function parseWithIfTransform(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('compiler: transform v-if', () => {
|
describe('compiler: v-if', () => {
|
||||||
|
describe('transform', () => {
|
||||||
test('basic v-if', () => {
|
test('basic v-if', () => {
|
||||||
const { node } = parseWithIfTransform(`<div v-if="ok"/>`)
|
const { node } = parseWithIfTransform(`<div v-if="ok"/>`)
|
||||||
expect(node.type).toBe(NodeTypes.IF)
|
expect(node.type).toBe(NodeTypes.IF)
|
||||||
@ -183,6 +184,7 @@ describe('compiler: transform v-if', () => {
|
|||||||
content: `_ctx.ok`
|
content: `_ctx.ok`
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('errors', () => {
|
describe('errors', () => {
|
||||||
test('error on v-else missing adjacent v-if', () => {
|
test('error on v-else missing adjacent v-if', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user