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

tray - when no new update is discovered showMessagePopupMock toHaveBeenCalled & toHaveBeenCalledWith

Signed-off-by: Gabriel <gaccettola@mirantis.com>
This commit is contained in:
Gabriel 2023-04-03 19:12:29 +02:00
parent cd265e5fd1
commit 922e97225d

View File

@ -15,11 +15,14 @@ import type { DownloadPlatformUpdate } from "../../main/download-update/download
import downloadPlatformUpdateInjectable from "../../main/download-update/download-platform-update/download-platform-update.injectable"; import downloadPlatformUpdateInjectable from "../../main/download-update/download-platform-update/download-platform-update.injectable";
import type { LensWindow } from "../../../../main/start-main-application/lens-window/application-window/create-lens-window.injectable"; import type { LensWindow } from "../../../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
import getCurrentApplicationWindowInjectable from "../../../../main/start-main-application/lens-window/application-window/get-current-application-window.injectable"; import getCurrentApplicationWindowInjectable from "../../../../main/start-main-application/lens-window/application-window/get-current-application-window.injectable";
import showMessagePopupInjectable from "../../../../main/electron-app/features/show-message-popup.injectable";
import type { ShowMessagePopup } from "../../../../main/electron-app/features/show-message-popup.injectable";
describe("installing update using tray", () => { describe("installing update using tray", () => {
let builder: ApplicationBuilder; let builder: ApplicationBuilder;
let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>; let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>;
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>; let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
let showMessagePopupMock: AsyncFnMock<ShowMessagePopup>;
beforeEach(() => { beforeEach(() => {
builder = getApplicationBuilder(); builder = getApplicationBuilder();
@ -27,6 +30,7 @@ describe("installing update using tray", () => {
builder.beforeApplicationStart(({ mainDi }) => { builder.beforeApplicationStart(({ mainDi }) => {
checkForPlatformUpdatesMock = asyncFn(); checkForPlatformUpdatesMock = asyncFn();
downloadPlatformUpdateMock = asyncFn(); downloadPlatformUpdateMock = asyncFn();
showMessagePopupMock = asyncFn();
mainDi.override( mainDi.override(
checkForPlatformUpdatesInjectable, checkForPlatformUpdatesInjectable,
@ -40,6 +44,12 @@ describe("installing update using tray", () => {
mainDi.override(electronUpdaterIsActiveInjectable, () => true); mainDi.override(electronUpdaterIsActiveInjectable, () => true);
mainDi.override(publishIsConfiguredInjectable, () => true); mainDi.override(publishIsConfiguredInjectable, () => true);
mainDi.override(
showMessagePopupInjectable,
() => showMessagePopupMock,
);
}); });
}); });
@ -164,15 +174,15 @@ describe("installing update using tray", () => {
}); });
}); });
// it displays a popup it("it displays a popup", () => {
// showMessagePopup( expect(showMessagePopupMock).toHaveBeenCalled();
// "No Updates Available", expect(showMessagePopupMock).toHaveBeenCalledWith(
// "You're all good", "No Updates Available",
// "You've got the latest version of Lens,\nthanks for staying on the ball.", "You're all good",
// { "You've got the latest version of Lens,\nthanks for staying on the ball.",
// textWidth: 300, { "textWidth": 300 }
// }, );
// ); });
it("user cannot install update", () => { it("user cannot install update", () => {
expect(builder.tray.get("install-update")).toBeNull(); expect(builder.tray.get("install-update")).toBeNull();