feat(generators): wire realtime entry into core-package dispatch table
This commit is contained in:
@@ -3,7 +3,7 @@ import type { PlopTypes } from "@turbo/gen";
|
||||
import generator from "./config";
|
||||
|
||||
describe("core-package generator", () => {
|
||||
it("is registered with an empty choices list initially", () => {
|
||||
it("is registered with realtime in choices list", () => {
|
||||
const captured: Array<{ name: string; def: PlopTypes.PlopGeneratorConfig }> = [];
|
||||
const plopMock = {
|
||||
setHelper: () => {},
|
||||
@@ -15,6 +15,24 @@ describe("core-package generator", () => {
|
||||
expect(corePkg).toBeDefined();
|
||||
const prompts = corePkg!.def.prompts as Array<{ name: string; choices: unknown[] }>;
|
||||
expect(prompts[0]!.name).toBe("name");
|
||||
expect(prompts[0]!.choices).toEqual([]);
|
||||
expect(prompts[0]!.choices).toContain("realtime");
|
||||
});
|
||||
});
|
||||
|
||||
describe("core-package realtime", () => {
|
||||
it("emits actions covering package files, transpilePackages, and ESLint rules", () => {
|
||||
// Capture the actions returned by the realtime entry.
|
||||
const captured: Array<{ name: string; def: PlopTypes.PlopGeneratorConfig }> = [];
|
||||
const plop = {
|
||||
setHelper: () => {},
|
||||
setGenerator: (n: string, d: unknown) => captured.push({ name: n, def: d as PlopTypes.PlopGeneratorConfig }),
|
||||
} as unknown as PlopTypes.NodePlopAPI;
|
||||
generator(plop);
|
||||
const corePkg = captured.find((c) => c.name === "core-package")!.def;
|
||||
const actions = (corePkg.actions as (a: { name: string }) => PlopTypes.ActionType[])(
|
||||
{ name: "realtime" },
|
||||
);
|
||||
// Expectations: at least one assertNotPresent guard, multiple `add` actions, and a transpilePackages action.
|
||||
expect(actions.length).toBeGreaterThan(20); // 28 files + extras
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user