Skip to content

Jest: Can not test onTruncate method #142

@Kazimirkas

Description

@Kazimirkas

The following test fails with 0 value. Can you please help and mention, what am I doing wrong?

import React from "react";
import { mount } from "enzyme";
import Truncate from "react-truncate";

it("on Truncate", () => {
  const onTr = jest.fn();
  const layout = mount(<Truncate onTruncate={onTr}>Hello world</Truncate>);
  expect(onTr).toBeCalledTimes(1);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions