Skip to content

Listeners don't work with functional components #1025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
domoratskii opened this issue Nov 10, 2018 · 1 comment
Closed

Listeners don't work with functional components #1025

domoratskii opened this issue Nov 10, 2018 · 1 comment
Labels

Comments

@domoratskii
Copy link

Version

1.0.0-beta.25

Reproduction link

https://codesandbox.io/s/r7rn4q2qo

Steps to reproduce

  1. Run test
  2. Open sandbox console

What is expected?

Test passed

What is actually happening?

[Vue warn]: Invalid handler for event "click": got undefined.


How do I can pass them on?

@domoratskii
Copy link
Author

It works.

import { shallowMount } from "@vue/test-utils";
import BaseButton from "../BaseButton.vue";

describe("BaseButtonIcon", () => {
  it("calls item-click when button is clicked", () => {
    const stub = jest.fn();
    const wrapper = shallowMount(BaseButton, {
      context: {
        props: {
          text: "click"
        },
        on: {
          'item-click': stub,
        },
      },
    });
    const button = wrapper.find("button.base-button-inc");

    button.trigger("click");

    expect(stub).toHaveBeenCalled();
  });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants