2022-03-31 14:35:01 +00:00
|
|
|
import { render, screen } from "test/testUtils";
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { DisconnectService } from "./DisconnectService";
|
|
|
|
|
import {
|
|
|
|
|
createMessage,
|
|
|
|
|
DISCONNECT_AUTH_METHOD,
|
|
|
|
|
DISCONNECT_CONFIRMATION,
|
2024-08-06 14:52:22 +00:00
|
|
|
} from "ee/constants/messages";
|
2022-03-31 14:35:01 +00:00
|
|
|
|
2024-07-31 15:41:28 +00:00
|
|
|
// TODO: Fix this the next time the file is edited
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2022-03-31 14:35:01 +00:00
|
|
|
let container: any = null;
|
|
|
|
|
const buttonClickHandler = jest.fn();
|
|
|
|
|
|
|
|
|
|
const useSelector = jest.fn();
|
|
|
|
|
const values = {
|
|
|
|
|
subHeader: "some subheader value",
|
|
|
|
|
warning: "some warning",
|
|
|
|
|
};
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2022-03-31 14:35:01 +00:00
|
|
|
useSelector.mockReturnValue(values);
|
|
|
|
|
|
|
|
|
|
function renderComponent() {
|
|
|
|
|
render(
|
|
|
|
|
<DisconnectService
|
|
|
|
|
disconnect={() => buttonClickHandler()}
|
|
|
|
|
subHeader={values.subHeader}
|
|
|
|
|
warning={values.warning}
|
|
|
|
|
/>,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe("Disconnect Service", () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
container = document.createElement("div");
|
|
|
|
|
document.body.appendChild(container);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("is rendered", () => {
|
|
|
|
|
renderComponent();
|
|
|
|
|
const disconnectBtn = screen.queryAllByTestId("disconnect-service-button");
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2022-03-31 14:35:01 +00:00
|
|
|
expect(disconnectBtn).toHaveLength(1);
|
|
|
|
|
expect(disconnectBtn[0].textContent).toEqual(
|
|
|
|
|
createMessage(DISCONNECT_AUTH_METHOD),
|
|
|
|
|
);
|
|
|
|
|
disconnectBtn[0].click();
|
|
|
|
|
expect(disconnectBtn[0].textContent).toEqual(
|
|
|
|
|
createMessage(DISCONNECT_CONFIRMATION),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|