fleet/frontend/components/buttons/DropdownButton/DropdownButton.tests.jsx
Gabe Hernandez efb35b537a
add prettier and have it format all fleet application code (#625)
* add prettier and have it format all js code except website:
:

* trying running prettier check in CI

* fix runs on in CI

* change CI job name

* fix prettier erros and fix CI
2021-04-12 14:32:25 +01:00

28 lines
804 B
JavaScript

import React from "react";
import { mount } from "enzyme";
import { noop } from "lodash";
import { DropdownButton } from "./DropdownButton";
describe("DropdownButton - component", () => {
it("calls the clicked item's onClick attribute", () => {
const optionSpy = jest.fn();
const dropdownOptions = [
{ label: "btn1", onClick: noop },
{ label: "btn2", onClick: optionSpy },
];
const component = mount(
<DropdownButton options={dropdownOptions}>New Button</DropdownButton>
);
component.find("button.dropdown-button").simulate("click");
expect(component.state().isOpen).toEqual(true);
component
.find("li.dropdown-button__option")
.last()
.find("Button")
.simulate("click");
expect(optionSpy).toHaveBeenCalled();
});
});