test(cli): add tests for generate command
This commit is contained in:
parent
41d8ff83a5
commit
ea06089c4a
2 changed files with 25 additions and 2 deletions
|
@ -3,12 +3,20 @@
|
|||
import { consola } from "consola";
|
||||
import { defineCommand } from "citty";
|
||||
|
||||
function generate() {
|
||||
consola.box("Generate a McFly building block (In-progress)");
|
||||
}
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
name: "prepare",
|
||||
description: "Generates building blocks for a McFly app.",
|
||||
},
|
||||
async run() {
|
||||
consola.box("Generate a McFly building block (In-progress)");
|
||||
run() {
|
||||
generate();
|
||||
},
|
||||
});
|
||||
|
||||
export const exportedForTest = {
|
||||
generate,
|
||||
};
|
||||
|
|
15
packages/cli/test/generate.test.js
Normal file
15
packages/cli/test/generate.test.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { expect, test, vi } from "vitest";
|
||||
import { exportedForTest } from "../commands/generate.mjs";
|
||||
import consola from "consola";
|
||||
|
||||
const testFn = exportedForTest.generate;
|
||||
|
||||
test("show box message in-progress", () => {
|
||||
const spy = vi.spyOn(consola, "box");
|
||||
|
||||
testFn();
|
||||
const arg = spy.mock.calls[0][0];
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(arg).toContain("In-progress");
|
||||
});
|
Loading…
Reference in a new issue