1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Remove tests that are covered by behaviour

Co-authored-by: Alex Andreev <alex.andreev.email@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-06-28 12:14:56 +03:00
parent 66bd8d3a17
commit 05a6916d9f
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
2 changed files with 0 additions and 126 deletions

View File

@ -1,22 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<UpdateButton/> should render if warning level prop passed 1`] = `
<button
class="updateButton"
data-testid="update-button"
data-warning-level="light"
id="update-lens-button"
>
Update
<i
class="Icon icon material focusable"
>
<span
class="icon"
data-icon-name="arrow_drop_down"
>
arrow_drop_down
</span>
</i>
</button>
`;

View File

@ -1,104 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { act } from "@testing-library/react";
import React from "react";
import { UpdateButton } from "../update-button";
import "@testing-library/jest-dom/extend-expect";
import type { DiContainer } from "@ogre-tools/injectable";
import appUpdateWarningLevelInjectable from "../../../app-update-warning/app-update-warning-level.injectable";
import { computed } from "mobx";
import type { DiRender } from "../../test-utils/renderFor";
import { renderFor } from "../../test-utils/renderFor";
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
import quitAndInstallUpdateInjectable from "../../../../main/electron-app/features/quit-and-install-update.injectable";
describe("<UpdateButton/>", () => {
let di: DiContainer;
let render: DiRender;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di.override(appUpdateWarningLevelInjectable, () => computed(() => ""));
render = renderFor(di);
});
it("should not render if no warning level prop passed", () => {
const { queryByTestId } = render(<UpdateButton />);
expect(queryByTestId("update-button")).not.toBeInTheDocument();
});
it("should render if warning level prop passed", () => {
di.override(appUpdateWarningLevelInjectable, () => computed(() => "light"));
const { getByTestId } = render(<UpdateButton />);
expect(getByTestId("update-button")).toMatchSnapshot();
});
it("should open menu when clicked", async () => {
di.override(appUpdateWarningLevelInjectable, () => computed(() => "light"));
const { getByTestId } = render(<UpdateButton />);
const button = getByTestId("update-button");
act(() => button.click());
expect(getByTestId("update-lens-menu-item")).toBeInTheDocument();
});
it("should call update function when menu item clicked", () => {
const update = jest.fn();
di.override(appUpdateWarningLevelInjectable, () => computed(() => "light"));
di.override(quitAndInstallUpdateInjectable, update);
const { getByTestId } = render(<UpdateButton />);
const button = getByTestId("update-button");
act(() => button.click());
const menuItem = getByTestId("update-lens-menu-item");
menuItem.click();
expect(update).toHaveBeenCalled();
});
it("should have light warning level", () => {
di.override(appUpdateWarningLevelInjectable, () => computed(() => "light"));
const { getByTestId } = render(<UpdateButton />);
const button = getByTestId("update-button");
expect(button.dataset.warningLevel).toBe("light");
});
it("should have medium warning level", () => {
di.override(appUpdateWarningLevelInjectable, () => computed(() => "medium"));
const { getByTestId } = render(<UpdateButton />);
const button = getByTestId("update-button");
expect(button.dataset.warningLevel).toBe("medium");
});
it("should have high warning level", () => {
di.override(appUpdateWarningLevelInjectable, () => computed(() => "high"));
const { getByTestId } = render(<UpdateButton />);
const button = getByTestId("update-button");
expect(button.dataset.warningLevel).toBe("high");
});
});