mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
chore(test): rewritten icon components test using rtl (#4764)
This commit is contained in:
parent
ae85d9d069
commit
a9747128d0
3 changed files with 21 additions and 12 deletions
|
|
@ -1,10 +1,13 @@
|
|||
import React from "react";
|
||||
import { mount } from "enzyme";
|
||||
import { render } from "@testing-library/react";
|
||||
|
||||
import FleetIcon from "./FleetIcon";
|
||||
|
||||
describe("FleetIcon - component", () => {
|
||||
it("renders", () => {
|
||||
expect(mount(<FleetIcon name="success-check" />)).toBeTruthy();
|
||||
const { container } = render(<FleetIcon name="success-check" />);
|
||||
expect(
|
||||
container.querySelector(".fleeticon-success-check")
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
import React from "react";
|
||||
import { mount } from "enzyme";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
|
||||
import fleetAvatar from "../../../../assets/images/fleet-avatar-24x24@2x.png";
|
||||
import OrgLogoIcon from "./OrgLogoIcon";
|
||||
|
||||
describe("OrgLogoIcon - component", () => {
|
||||
it("renders the Fleet Logo by default", () => {
|
||||
const component = mount(<OrgLogoIcon />);
|
||||
render(<OrgLogoIcon />);
|
||||
|
||||
expect(component.state("imageSrc")).toEqual(fleetAvatar);
|
||||
// expect(component.state("imageSrc")).toEqual(fleetAvatar);
|
||||
expect(screen.getByRole("img")).toHaveAttribute("src", fleetAvatar);
|
||||
});
|
||||
|
||||
it("renders the image source when it is valid", () => {
|
||||
const component = mount(<OrgLogoIcon src="/assets/images/avatar.svg" />);
|
||||
render(<OrgLogoIcon src="/assets/images/avatar.svg" />);
|
||||
|
||||
expect(component.state("imageSrc")).toEqual("/assets/images/avatar.svg");
|
||||
expect(screen.getByRole("img")).toHaveAttribute(
|
||||
"src",
|
||||
"/assets/images/avatar.svg"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
import React from "react";
|
||||
import { mount } from "enzyme";
|
||||
import { render } from "@testing-library/react";
|
||||
|
||||
import PlatformIcon from "./PlatformIcon";
|
||||
|
||||
describe("PlatformIcon - component", () => {
|
||||
it("renders", () => {
|
||||
expect(mount(<PlatformIcon name="linux" />).length).toEqual(1);
|
||||
const { container } = render(<PlatformIcon name="linux" />);
|
||||
expect(container.querySelector(".platform-icon")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders text if no icon", () => {
|
||||
const component = mount(<PlatformIcon name="All" />);
|
||||
|
||||
expect(component.find(".fleeticon-single-host").length).toEqual(1);
|
||||
const { container } = render(<PlatformIcon name="All" />);
|
||||
expect(
|
||||
container.querySelector(".fleeticon-single-host")
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue