|
@@ -155,12 +155,12 @@ describe('component: emit', () => {
|
|
|
render() {},
|
|
render() {},
|
|
|
created() {
|
|
created() {
|
|
|
// @ts-expect-error
|
|
// @ts-expect-error
|
|
|
- this.$emit('bar')
|
|
|
|
|
|
|
+ this.$emit('bar-baz')
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
render(h(Foo), nodeOps.createElement('div'))
|
|
render(h(Foo), nodeOps.createElement('div'))
|
|
|
expect(
|
|
expect(
|
|
|
- `Component emitted event "bar" but it is neither declared`,
|
|
|
|
|
|
|
+ `Component emitted event "bar-baz" but it is neither declared in the emits option nor as an "onBarBaz" prop`,
|
|
|
).toHaveBeenWarned()
|
|
).toHaveBeenWarned()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -172,12 +172,12 @@ describe('component: emit', () => {
|
|
|
render() {},
|
|
render() {},
|
|
|
created() {
|
|
created() {
|
|
|
// @ts-expect-error
|
|
// @ts-expect-error
|
|
|
- this.$emit('bar')
|
|
|
|
|
|
|
+ this.$emit('bar-baz')
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
render(h(Foo), nodeOps.createElement('div'))
|
|
render(h(Foo), nodeOps.createElement('div'))
|
|
|
expect(
|
|
expect(
|
|
|
- `Component emitted event "bar" but it is neither declared`,
|
|
|
|
|
|
|
+ `Component emitted event "bar-baz" but it is neither declared in the emits option nor as an "onBarBaz" prop`,
|
|
|
).toHaveBeenWarned()
|
|
).toHaveBeenWarned()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -197,6 +197,22 @@ describe('component: emit', () => {
|
|
|
).not.toHaveBeenWarned()
|
|
).not.toHaveBeenWarned()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ test('should not warn if has equivalent onXXX prop with kebab-cased event', () => {
|
|
|
|
|
+ const Foo = defineComponent({
|
|
|
|
|
+ props: ['onFooBar'],
|
|
|
|
|
+ emits: [],
|
|
|
|
|
+ render() {},
|
|
|
|
|
+ created() {
|
|
|
|
|
+ // @ts-expect-error
|
|
|
|
|
+ this.$emit('foo-bar')
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ render(h(Foo), nodeOps.createElement('div'))
|
|
|
|
|
+ expect(
|
|
|
|
|
+ `Component emitted event "foo-bar" but it is neither declared`,
|
|
|
|
|
+ ).not.toHaveBeenWarned()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
test('validator warning', () => {
|
|
test('validator warning', () => {
|
|
|
const Foo = defineComponent({
|
|
const Foo = defineComponent({
|
|
|
emits: {
|
|
emits: {
|