mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-14 03:13:08 +00:00
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
import { MainMenu } from "./mainMenu.js";
|
|
import { mockUiService } from "../__mocks__/service.mocks.js";
|
|
import { mockInstallMenu, mockConfigMenu } from "../__mocks__/ui.mocks.js";
|
|
import { mockMenuLoop } from "../__mocks__/utils.mocks.js";
|
|
|
|
describe("mainmenu", () => {
|
|
let mainmenu;
|
|
|
|
beforeEach(() => {
|
|
vi.resetAllMocks();
|
|
|
|
mainmenu = new MainMenu(
|
|
mockUiService,
|
|
mockMenuLoop,
|
|
mockInstallMenu,
|
|
mockConfigMenu,
|
|
);
|
|
});
|
|
|
|
it("initializes the menu loop with the promptMainMenu function", () => {
|
|
expect(mockMenuLoop.initialize).toHaveBeenCalledWith(
|
|
mainmenu.promptMainMenu,
|
|
);
|
|
});
|
|
|
|
it("shows the logo", async () => {
|
|
await mainmenu.show();
|
|
|
|
expect(mockUiService.showLogo).toHaveBeenCalled();
|
|
});
|
|
|
|
it("starts the menu loop", async () => {
|
|
await mainmenu.show();
|
|
|
|
expect(mockMenuLoop.showLoop).toHaveBeenCalled();
|
|
});
|
|
|
|
it("shows the exit message after the menu loop", async () => {
|
|
await mainmenu.show();
|
|
|
|
expect(mockUiService.showInfoMessage).toHaveBeenCalledWith("K-THX-BYE");
|
|
});
|
|
|
|
it("prompts the main menu with multiple choices", async () => {
|
|
await mainmenu.promptMainMenu();
|
|
expect(mockUiService.askMultipleChoice).toHaveBeenCalledWith(
|
|
"Select an option",
|
|
[
|
|
{ label: "Install Codex", action: mockInstallMenu.show },
|
|
{ label: "Configure Codex", action: mockConfigMenu.show },
|
|
{ label: "Exit", action: mockMenuLoop.stopLoop },
|
|
],
|
|
);
|
|
});
|
|
});
|