diff --git a/src/renderer/components/update-button/__tests__/update-button.test.tsx b/src/renderer/components/update-button/__tests__/update-button.test.tsx
index ff52035a48..fbb91adf36 100644
--- a/src/renderer/components/update-button/__tests__/update-button.test.tsx
+++ b/src/renderer/components/update-button/__tests__/update-button.test.tsx
@@ -3,32 +3,48 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
-import { render, act } from "@testing-library/react";
+import { act } from "@testing-library/react";
import React from "react";
import { UpdateButton } from "../update-button";
import "@testing-library/jest-dom/extend-expect";
-
-const update = jest.fn();
+import type { DiContainer } from "@ogre-tools/injectable";
+import appUpdateWarningLevelInjectable from "../../../app-update-warning/app-update-warning-level.injectable";
+import { computed } from "mobx";
+import { DiRender, renderFor } from "../../test-utils/renderFor";
+import updateAppInjectable from "../update-app.injectable";
+import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
describe("", () => {
+ let di: DiContainer;
+ let render: DiRender;
+
beforeEach(() => {
- update.mockClear();
+ di = getDiForUnitTesting({ doGeneralOverrides: true });
+
+ di.override(updateAppInjectable, jest.fn);
+ di.override(appUpdateWarningLevelInjectable, () => computed(() => ""));
+
+ render = renderFor(di);
});
it("should not render if no warning level prop passed", () => {
- const { queryByTestId } = render();
+ const { queryByTestId } = render();
expect(queryByTestId("update-button")).not.toBeInTheDocument();
});
it("should render if warning level prop passed", () => {
- const { getByTestId } = render();
+ di.override(appUpdateWarningLevelInjectable, () => computed(() => "light"));
+
+ const { getByTestId } = render();
expect(getByTestId("update-button")).toMatchSnapshot();
});
it("should open menu when clicked", async () => {
- const { getByTestId } = render();
+ di.override(appUpdateWarningLevelInjectable, () => computed(() => "light"));
+
+ const { getByTestId } = render();
const button = getByTestId("update-button");
@@ -38,7 +54,11 @@ describe("", () => {
});
it("should call update function when menu item clicked", () => {
- const { getByTestId } = render();
+ const update = jest.fn();
+ di.override(appUpdateWarningLevelInjectable, () => computed(() => "light"));
+ di.override(updateAppInjectable, update);
+
+ const { getByTestId } = render();
const button = getByTestId("update-button");
@@ -52,7 +72,9 @@ describe("", () => {
});
it("should have light warning level", () => {
- const { getByTestId } = render();
+ di.override(appUpdateWarningLevelInjectable, () => computed(() => "light"));
+
+ const { getByTestId } = render();
const button = getByTestId("update-button");
@@ -60,7 +82,9 @@ describe("", () => {
});
it("should have medium warning level", () => {
- const { getByTestId } = render();
+ di.override(appUpdateWarningLevelInjectable, () => computed(() => "medium"));
+
+ const { getByTestId } = render();
const button = getByTestId("update-button");
@@ -68,7 +92,9 @@ describe("", () => {
});
it("should have high warning level", () => {
- const { getByTestId } = render();
+ di.override(appUpdateWarningLevelInjectable, () => computed(() => "high"));
+
+ const { getByTestId } = render();
const button = getByTestId("update-button");