fix(runtime-core): fix warning for absent props (#3363)

fix #3362
This commit is contained in:
HcySunYang
2021-03-26 04:22:43 +08:00
committed by GitHub
parent e4a5712a33
commit 86ceef4352
2 changed files with 27 additions and 6 deletions

View File

@@ -301,6 +301,23 @@ describe('component props', () => {
}).not.toThrow(TypeError)
})
test('warn absent required props', () => {
const Comp = {
props: {
bool: { type: Boolean, required: true },
str: { type: String, required: true },
num: { type: Number, required: true }
},
setup() {
return () => null
}
}
render(h(Comp), nodeOps.createElement('div'))
expect(`Missing required prop: "bool"`).toHaveBeenWarned()
expect(`Missing required prop: "str"`).toHaveBeenWarned()
expect(`Missing required prop: "num"`).toHaveBeenWarned()
})
test('merging props from mixins and extends', () => {
let setupProps: any
let renderProxy: any