/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { render } from "@testing-library/react";
import React from "react";
import { UpdateButton } from "..";
import "@testing-library/jest-dom/extend-expect";
const update = jest.fn();
describe("", () => {
beforeEach(() => {
update.mockClear();
});
it("should not render if no warning level prop passed", () => {
const { queryByTestId } = render();
expect(queryByTestId("update-button")).not.toBeInTheDocument();
});
it("should render if warning level prop passed", () => {
const { getByTestId } = render();
expect(getByTestId("update-button")).toMatchSnapshot();
});
it("should open menu when clicked", () => {
const { getByTestId } = render();
const button = getByTestId("update-button");
button.click();
expect(getByTestId("update-lens-menu-item")).toBeInTheDocument();
});
it("should call update function when menu item clicked", () => {
const { getByTestId } = render();
const button = getByTestId("update-button");
button.click();
const menuItem = getByTestId("update-lens-menu-item");
menuItem.click();
expect(update).toHaveBeenCalled();
});
it("should have class name with medium warning level", () => {
const { getByTestId } = render();
const button = getByTestId("update-button");
expect(button.className.toLowerCase().includes("medium")).toBeTruthy();
});
it("should have class name with high warning level", () => {
const { getByTestId } = render();
const button = getByTestId("update-button");
expect(button.className.toLowerCase().includes("high")).toBeTruthy();
});
});