Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export function getInitialStepValues(opts = {}) {
}

export async function runSetup({ defaults = false } = {}) {
p.intro(getWelcomeMessage());
p.note(getWelcomeMessage(), "Welcome");

if (!isZshShell()) {
p.log.error("Suitup setup must be run from zsh.");
Expand Down
54 changes: 54 additions & 0 deletions tests/setup-ui.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { describe, test, expect, vi, beforeEach } from "vitest";

const { mockNote, mockIntro, mockOutro, mockError, mockInfo } = vi.hoisted(() => ({
mockNote: vi.fn(),
mockIntro: vi.fn(),
mockOutro: vi.fn(),
mockError: vi.fn(),
mockInfo: vi.fn(),
}));

vi.mock("@clack/prompts", () => ({
note: mockNote,
intro: mockIntro,
outro: mockOutro,
cancel: vi.fn(),
isCancel: vi.fn(() => false),
multiselect: vi.fn(),
select: vi.fn(),
groupMultiselect: vi.fn(),
confirm: vi.fn(),
text: vi.fn(),
spinner: vi.fn(() => ({ start: vi.fn(), stop: vi.fn() })),
log: {
success: vi.fn(),
step: vi.fn(),
warn: vi.fn(),
error: mockError,
info: mockInfo,
},
}));

vi.mock("../src/utils/shell-context.js", () => ({
isZshShell: vi.fn(() => false),
}));

import { runSetup, getWelcomeMessage } from "../src/setup.js";

describe("setup welcome UI", () => {
beforeEach(() => {
vi.clearAllMocks();
});

test("renders the welcome art inside a boxed note before shell validation", async () => {
await runSetup();

expect(mockNote).toHaveBeenCalledWith(getWelcomeMessage(), "Welcome");
expect(mockIntro).not.toHaveBeenCalled();
expect(mockError).toHaveBeenCalledWith("Suitup setup must be run from zsh.");
expect(mockInfo).toHaveBeenCalledWith(
'Switch to zsh first: run `zsh` for this session or `chsh -s "$(which zsh)"` to make it your default shell.'
);
expect(mockOutro).toHaveBeenCalledWith("No changes made.");
});
});
Loading