mirror of https://github.com/vuejs/core.git
fix(runtime-core): test cases for mixing composition/options api
This commit is contained in:
parent
7704d78a34
commit
3e21461ca0
|
@ -0,0 +1,86 @@
|
||||||
|
import { defineComponent, h, renderToString } from '@vue/runtime-test'
|
||||||
|
|
||||||
|
describe('api: options', () => {
|
||||||
|
test('mix api options: setup and data with created', () => {
|
||||||
|
const mixinA = defineComponent({
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
a: 'from setup',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
a: 'from data',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created(this: any) {
|
||||||
|
this.a = 'from created'
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return `${this.a}`
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(renderToString(h(mixinA))).toBe(`from created`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('mix api options: data and setup with created', () => {
|
||||||
|
const mixinA = defineComponent({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
a: 'from data',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
a: 'from setup',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created(this: any) {
|
||||||
|
this.a = 'from created'
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return `${this.a}`
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(renderToString(h(mixinA))).toBe(`from created`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('mix api options: data and setup', () => {
|
||||||
|
const mixinA = defineComponent({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
a: 'from data',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
a: 'from setup',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created(this: any) {},
|
||||||
|
render() {
|
||||||
|
return `${this.a}`
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(renderToString(h(mixinA))).toBe(`from setup`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('mix api options: setup and data', () => {
|
||||||
|
const mixinA = defineComponent({
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
a: 'from setup',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
a: 'from data',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return `${this.a}`
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(renderToString(h(mixinA))).toBe(`from setup`)
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue