Skip to content

Commit

Permalink
test: trigger camelCase handler
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Jul 24, 2022
1 parent bb121d2 commit 2a05579
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/runtime-core/__tests__/componentEmits.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe("component: emits", () => {
test("trigger handlers", () => {
const Foo = {
render() {
return h("foo")
return h("foo");
},
setup(props, { emit }) {
// the `emit` function is bound on component instances
Expand All @@ -26,4 +26,25 @@ describe("component: emits", () => {
// only capitalized or special chars are considered event listeners
expect(onBar).toHaveBeenCalled();
});

test("trigger camelCase handler", () => {
const Foo = {
render() {
return h("foo");
},
setup(props, { emit }) {
emit("test-event");
},
};

const fooSpy = jest.fn();
const Comp = {
render() {
return h(Foo, { onTestEvent: fooSpy });
},
};
render(h(Comp), nodeOps.createElement("div"));

expect(fooSpy).toHaveBeenCalledTimes(1);
});
});

0 comments on commit 2a05579

Please sign in to comment.