chore(test): rewritten scheduled query section test using rtl (#5358)

This commit is contained in:
Tharun Rajendran 2022-04-25 22:36:42 +02:00 committed by GitHub
parent 0b120a612d
commit bd18bf3c7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,5 @@
import React from "react";
import { mount } from "enzyme";
import PATHS from "router/paths";
import { render, screen } from "@testing-library/react";
import ScheduledQueriesSection from "components/side_panels/PackDetailsSidePanel/ScheduledQueriesSection";
import { scheduledQueryStub } from "test/stubs";
@ -8,12 +7,9 @@ import { scheduledQueryStub } from "test/stubs";
describe("ScheduledQueriesSection - component", () => {
it("links the query name to the show query route", () => {
const scheduledQuery = { ...scheduledQueryStub, query_id: 55 };
const Component = mount(
<ScheduledQueriesSection scheduledQueries={[scheduledQuery]} />
);
const Link = Component.find("Link");
const path = `${PATHS.EDIT_QUERY({ id: scheduledQuery.query_id })}`;
render(<ScheduledQueriesSection scheduledQueries={[scheduledQuery]} />);
expect(Link.prop("to")).toEqual(path);
expect(screen.getByText("Get all users")).toBeInTheDocument();
expect(screen.getByText("Get all users").closest("a")).toBeInTheDocument();
});
});