mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Switch to using testing library queries from screen export
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
c57473c875
commit
fbabb32dab
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { render } from "@testing-library/react";
|
import { render, screen } from "@testing-library/react";
|
||||||
import "@testing-library/jest-dom/extend-expect";
|
import "@testing-library/jest-dom/extend-expect";
|
||||||
import { KubeObjectMenu, KubeObjectMenuDependencies } from "./kube-object-menu";
|
import { KubeObjectMenu, KubeObjectMenuDependencies } from "./kube-object-menu";
|
||||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||||
@ -117,8 +117,6 @@ describe("kube-object-menu", () => {
|
|||||||
describe("given kube object", () => {
|
describe("given kube object", () => {
|
||||||
let baseElement: Element;
|
let baseElement: Element;
|
||||||
let removeActionMock: any;
|
let removeActionMock: any;
|
||||||
let getByTestId: (arg0: string) => any;
|
|
||||||
let queryByTestId: (arg0: string) => any;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
objectStub = KubeObject.create({
|
objectStub = KubeObject.create({
|
||||||
@ -134,7 +132,7 @@ describe("kube-object-menu", () => {
|
|||||||
|
|
||||||
removeActionMock = asyncFn();
|
removeActionMock = asyncFn();
|
||||||
|
|
||||||
({ baseElement, getByTestId, queryByTestId } = render(
|
({ baseElement } = render(
|
||||||
<div>
|
<div>
|
||||||
<ConfirmDialog />
|
<ConfirmDialog />
|
||||||
|
|
||||||
@ -153,12 +151,12 @@ describe("kube-object-menu", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not open a confirmation dialog yet", () => {
|
it("does not open a confirmation dialog yet", () => {
|
||||||
expect(queryByTestId("confirmation-dialog")).toBeNull();
|
expect(screen.queryByTestId("confirmation-dialog")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when removing kube object", () => {
|
describe("when removing kube object", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const menuItem = getByTestId("menu-action-remove");
|
const menuItem = screen.getByTestId("menu-action-remove");
|
||||||
|
|
||||||
userEvent.click(menuItem);
|
userEvent.click(menuItem);
|
||||||
});
|
});
|
||||||
@ -168,12 +166,12 @@ describe("kube-object-menu", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("opens a confirmation dialog", () => {
|
it("opens a confirmation dialog", () => {
|
||||||
getByTestId("confirmation-dialog");
|
screen.getByTestId("confirmation-dialog");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when remove is confirmed", () => {
|
describe("when remove is confirmed", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const confirmRemovalButton = getByTestId("confirm");
|
const confirmRemovalButton = screen.getByTestId("confirm");
|
||||||
|
|
||||||
userEvent.click(confirmRemovalButton);
|
userEvent.click(confirmRemovalButton);
|
||||||
});
|
});
|
||||||
@ -183,13 +181,13 @@ describe("kube-object-menu", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not close the confirmation dialog yet", () => {
|
it("does not close the confirmation dialog yet", () => {
|
||||||
getByTestId("confirmation-dialog");
|
screen.getByTestId("confirmation-dialog");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when removal resolves, closes the confirmation dialog", async () => {
|
it("when removal resolves, closes the confirmation dialog", async () => {
|
||||||
await removeActionMock.resolve();
|
await removeActionMock.resolve();
|
||||||
|
|
||||||
expect(queryByTestId("confirmation-dialog")).toBeNull();
|
expect(screen.queryByTestId("confirmation-dialog")).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user