Skip to content

Commit 88cc613

Browse files
author
spawn-qa-bot
committed
test: remove theatrical showNonBillingError test and replace with real assertions
Replace the 'does not throw' test for showNonBillingError with three real tests that verify logWarn/logInfo are called with correct args. Adds coverage for the empty-billingUrl and empty-causes branches. -- qa/dedup-scanner
1 parent ccd8600 commit 88cc613

1 file changed

Lines changed: 32 additions & 16 deletions

File tree

packages/cli/src/__tests__/billing-guidance.test.ts

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,26 +157,42 @@ describe("handleBillingError", () => {
157157
});
158158

159159
describe("showNonBillingError", () => {
160-
let stderrSpy: ReturnType<typeof spyOn>;
161-
162-
beforeEach(() => {
163-
stderrSpy = spyOn(process.stderr, "write").mockImplementation(() => true);
160+
it("logs each cause and the billing URL", () => {
161+
const deps = createMockDeps();
162+
showNonBillingError(
163+
hetznerBilling,
164+
[
165+
"Server limit reached for your account",
166+
],
167+
deps,
168+
);
169+
expect(deps.logWarn).toHaveBeenCalledWith("Possible causes:");
170+
expect(deps.logWarn).toHaveBeenCalledWith(" - Server limit reached for your account");
171+
expect(deps.logInfo).toHaveBeenCalledWith("Dashboard: https://console.hetzner.cloud/");
164172
});
165173

166-
afterEach(() => {
167-
stderrSpy.mockRestore();
174+
it("skips billing URL line when billingUrl is empty", () => {
175+
const deps = createMockDeps();
176+
const noBillingUrl = {
177+
billingUrl: "",
178+
setupSteps: [],
179+
errorPatterns: [],
180+
};
181+
showNonBillingError(
182+
noBillingUrl,
183+
[
184+
"Some cause",
185+
],
186+
deps,
187+
);
188+
expect(deps.logWarn).toHaveBeenCalledWith("Possible causes:");
189+
expect(deps.logInfo).not.toHaveBeenCalled();
168190
});
169191

170-
it("does not throw", () => {
192+
it("skips cause header when causes array is empty", () => {
171193
const deps = createMockDeps();
172-
expect(() => {
173-
showNonBillingError(
174-
hetznerBilling,
175-
[
176-
"Server limit reached for your account",
177-
],
178-
deps,
179-
);
180-
}).not.toThrow();
194+
showNonBillingError(hetznerBilling, [], deps);
195+
expect(deps.logWarn).not.toHaveBeenCalled();
196+
expect(deps.logInfo).toHaveBeenCalledWith("Dashboard: https://console.hetzner.cloud/");
181197
});
182198
});

0 commit comments

Comments
 (0)