Skip to content

Commit 6c408a8

Browse files
fix: ai-config tests
1 parent 8e8fb45 commit 6c408a8

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

spec/unit/ai-config-spec.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ describe("Unit - ai-config command", () => {
278278
App.container.set(FS_TOKEN, createMockFs());
279279
spyOn(Util, "canPrompt").and.returnValue(true);
280280
spyOn(InquirerWrapper, "checkbox").and.returnValues(
281-
Promise.resolve(["vscode"]),
282-
Promise.resolve(["claude"])
281+
Promise.resolve(["claude"]),
282+
Promise.resolve(["vscode"])
283283
);
284284

285285
await aiConfig.default.handler({ _: ["ai-config"], $0: "ig" });
@@ -307,7 +307,6 @@ describe("Unit - ai-config command", () => {
307307
App.container.set(FS_TOKEN, createMockFs());
308308
spyOn(Util, "canPrompt").and.returnValue(true);
309309
spyOn(InquirerWrapper, "checkbox").and.returnValue(Promise.resolve(["none"]));
310-
spyOn(InquirerWrapper, "select").and.returnValue(Promise.resolve("vscode"));
311310

312311
await aiConfig.default.handler({ _: ["ai-config"], $0: "ig" });
313312

@@ -319,25 +318,25 @@ describe("Unit - ai-config command", () => {
319318
it("still configures MCP when none is selected for skills", async () => {
320319
const mockFs = createMockFs();
321320
App.container.set(FS_TOKEN, mockFs);
321+
spyOn(Util, "canPrompt").and.returnValue(true);
322322
spyOn(InquirerWrapper, "checkbox").and.returnValues(
323-
Promise.resolve(["vscode"]),
324-
Promise.resolve(["none"])
323+
Promise.resolve(["none"]),
324+
Promise.resolve(["vscode"])
325325
);
326326

327327
await aiConfig.default.handler({ _: ["ai-config"], $0: "ig" });
328328

329-
expect(mockFs.writeFile).toHaveBeenCalled();
330-
// TODO: toHaveBeenCalledWith check for mcp.json
331329
expect(GoogleAnalytics.post).toHaveBeenCalledWith(jasmine.objectContaining({ t: "screenview", cd: "Ai Config" }));
332-
expect(GoogleAnalytics.post).toHaveBeenCalledWith(jasmine.objectContaining({ ea: "agent: none; assistant: none" }));
330+
expect(GoogleAnalytics.post).toHaveBeenCalledWith(jasmine.objectContaining({ ea: "agent: none; assistant: vscode" }));
331+
expect(Util.log).toHaveBeenCalledWith(jasmine.stringContaining("Skipping"));
333332
});
334333

335334
it("configures multiple agents when selected interactively", async () => {
336335
App.container.set(FS_TOKEN, createMockFs());
337336
spyOn(Util, "canPrompt").and.returnValue(true);
338337
spyOn(InquirerWrapper, "checkbox").and.returnValues(
339-
Promise.resolve(["vscode"]),
340-
Promise.resolve(["claude", "cursor"])
338+
Promise.resolve(["claude", "cursor"]),
339+
Promise.resolve(["vscode"])
341340
);
342341

343342
await aiConfig.default.handler({ _: ["ai-config"], $0: "ig" });
@@ -350,6 +349,7 @@ describe("Unit - ai-config command", () => {
350349

351350
it("skips prompt when --agent is provided", async () => {
352351
App.container.set(FS_TOKEN, createMockFs());
352+
spyOn(Util, "canPrompt").and.returnValue(true);
353353
spyOn(InquirerWrapper, "checkbox").and.returnValue(Promise.resolve(["vscode"]));
354354

355355
await aiConfig.default.handler({ _: ["ai-config"], $0: "ig", agent: ["cursor"] });
@@ -362,6 +362,7 @@ describe("Unit - ai-config command", () => {
362362

363363
it("skips assistant prompt when --assistant is provided", async () => {
364364
App.container.set(FS_TOKEN, createMockFs());
365+
spyOn(Util, "canPrompt").and.returnValue(true);
365366
spyOn(InquirerWrapper, "checkbox").and.returnValue(Promise.resolve(["claude"]));
366367

367368
await aiConfig.default.handler({ _: ["ai-config"], $0: "ig", assistant: ["cursor"] });
@@ -371,9 +372,10 @@ describe("Unit - ai-config command", () => {
371372

372373
it("prompts for assistant with correct message", async () => {
373374
App.container.set(FS_TOKEN, createMockFs());
375+
spyOn(Util, "canPrompt").and.returnValue(true);
374376
spyOn(InquirerWrapper, "checkbox").and.returnValues(
375-
Promise.resolve(["cursor"]),
376-
Promise.resolve(["claude"])
377+
Promise.resolve(["claude"]),
378+
Promise.resolve(["vscode"])
377379
);
378380

379381
await aiConfig.default.handler({ _: ["ai-config"], $0: "ig" });
@@ -386,9 +388,10 @@ describe("Unit - ai-config command", () => {
386388
it("writes to correct config path for selected assistant", async () => {
387389
const mockFs = createMockFs();
388390
App.container.set(FS_TOKEN, mockFs);
391+
spyOn(Util, "canPrompt").and.returnValue(true);
389392
spyOn(InquirerWrapper, "checkbox").and.returnValues(
390-
Promise.resolve(["claude-code"]),
391-
Promise.resolve(["none"])
393+
Promise.resolve(["claude"]),
394+
Promise.resolve(["claude-code"])
392395
);
393396

394397
await aiConfig.default.handler({ _: ["ai-config"], $0: "ig" });

spec/unit/new-spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,23 +408,23 @@ describe("Unit - New command", () => {
408408

409409
await newCmd.handler({ name: "Test", framework: "jq", agents: ["claude", "cursor"], _: ["new"], $0: "new" });
410410

411-
expect(configureSpy).toHaveBeenCalledWith(["claude", "cursor"]);
411+
expect(configureSpy).toHaveBeenCalledWith(["claude", "cursor"], true, undefined);
412412
});
413413

414414
it("calls configure with undefined when --agents is not provided", async () => {
415415
createProjectMocks();
416416

417417
await newCmd.handler({ name: "Test", framework: "jq", _: ["new"], $0: "new" });
418418

419-
expect(configureSpy).toHaveBeenCalledWith(undefined);
419+
expect(configureSpy).toHaveBeenCalledWith(undefined, true, undefined);
420420
});
421421

422422
it("calls configure with single agent", async () => {
423423
createProjectMocks();
424424

425425
await newCmd.handler({ name: "Test", framework: "jq", agents: ["generic"], _: ["new"], $0: "new" });
426426

427-
expect(configureSpy).toHaveBeenCalledWith(["generic"]);
427+
expect(configureSpy).toHaveBeenCalledWith(["generic"], true, undefined);
428428
});
429429

430430
it("calls configure after project creation and package install", async () => {
@@ -469,7 +469,7 @@ describe("Unit - New command", () => {
469469
await newCmd.handler({ name: "Test", framework: "jq", skipInstall: true, agents: ["claude"], _: ["new"], $0: "new" });
470470

471471
expect(PackageManager.installPackages).not.toHaveBeenCalled();
472-
expect(configureSpy).toHaveBeenCalledWith(["claude"]);
472+
expect(configureSpy).toHaveBeenCalledWith(["claude"], true, undefined);
473473
});
474474

475475
it("does not call configure when project creation fails (bad name)", async () => {

0 commit comments

Comments
 (0)