import {
  extractCommandData,
  writeCommandDocumentation,
  writeCommandFlagInterface,
  writeCommandUsageExampleFile
} from "../../../chunk-6LQP3RF5.js";
import {
  describe,
  globalExpect,
  test,
  vi
} from "../../../chunk-HSTSRNLJ.js";
import "../../../chunk-YUAWAF5Y.js";
import "../../../chunk-5Q3KPCWB.js";
import "../../../chunk-O5K4AU7Q.js";
import "../../../chunk-MFMYWNKT.js";
import "../../../chunk-KCSGBKEZ.js";
import "../../../chunk-MRPJCXG3.js";
import "../../../chunk-ORDFLOPR.js";
import "../../../chunk-YGOJRISK.js";
import "../../../chunk-VSLR7ET4.js";
import "../../../chunk-7AFORNYD.js";
import "../../../chunk-NHHBSREL.js";
import "../../../chunk-BYPQXSAL.js";
import {
  writeFile
} from "../../../chunk-NEEJ5XET.js";
import "../../../chunk-2HGYYNE5.js";
import "../../../chunk-XVNW332R.js";
import "../../../chunk-HFAVKTDR.js";
import "../../../chunk-EI5KZ5NN.js";
import "../../../chunk-CBBS4CV7.js";
import "../../../chunk-SNOECVP4.js";
import "../../../chunk-UBB7JKND.js";
import "../../../chunk-NEOIQ6PN.js";
import "../../../chunk-7Q3MMWAC.js";
import "../../../chunk-MX4RJDBM.js";
import "../../../chunk-NB4NLOEJ.js";
import "../../../chunk-522OB3EU.js";
import {
  init_cjs_shims
} from "../../../chunk-POZ5MGPT.js";

// src/cli/commands/docs/generate.test.ts
init_cjs_shims();
vi.mock("@shopify/cli-kit/node/fs");
var testCommand = {
  aliases: [],
  args: {},
  flags: {
    flag1: {
      name: "flag1",
      type: "option",
      char: "f",
      description: "flag description"
    },
    flag2: {
      name: "flag2",
      type: "boolean",
      char: "a",
      description: "another flag description",
      env: "FLAG_ENV",
      allowNo: !1
    }
  },
  descriptionWithMarkdown: "command markdown description",
  description: "command description",
  summary: "command summary",
  hidden: !1,
  hiddenAliases: [],
  id: "topic:test-command",
  load: () => Promise.resolve({})
}, commandData = {
  commandName: "topic test-command",
  fileName: "topic-test-command",
  interfaceName: "topictestcommand",
  hasTopic: !0,
  topic: "topic",
  hasFlags: !0
};
describe("extractCommandData", () => {
  test("returns the correct data", () => {
    globalExpect(extractCommandData(testCommand)).toEqual(commandData);
  });
});
describe("writeCommandFlagInterface", () => {
  test("calls writeFile with the correct content", async () => {
    await writeCommandFlagInterface(testCommand, commandData), globalExpect(writeFile).toHaveBeenCalledWith(
      globalExpect.stringContaining("docs-shopify.dev/commands/interfaces/topic-test-command.interface.ts"),
      `// This is an autogenerated file. Don't edit this file manually.
export interface topictestcommand {
  /**
   * flag description
   *
   */
  '-f, --flag1 <value>'?: string

  /**
   * another flag description
   * @environment FLAG_ENV
   */
  '-a, --flag2'?: ''
}
`
    );
  }), test("calls writeFile with the correct content for a command with no flags", async () => {
    await writeCommandFlagInterface({ ...testCommand, flags: {} }, commandData), globalExpect(writeFile).toHaveBeenCalledWith(
      globalExpect.stringContaining("docs-shopify.dev/commands/interfaces/topic-test-command.interface.ts"),
      `// This is an autogenerated file. Don't edit this file manually.
export interface topictestcommand {

}
`
    );
  });
});
describe("writeCommandDocs", () => {
  test("calls writeFile with the correct content", async () => {
    await writeCommandDocumentation(testCommand, commandData), globalExpect(writeFile).toHaveBeenCalledWith(
      globalExpect.stringContaining("docs-shopify.dev/commands/topic-test-command.doc.ts"),
      `// This is an autogenerated file. Don't edit this file manually.
import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'

const data: ReferenceEntityTemplateSchema = {
  name: 'topic test-command',
  description: \`command markdown description\`,
  overviewPreviewDescription: \`command summary\`,
  type: 'command',
  isVisualComponent: false,
  defaultExample: {
    codeblock: {
      tabs: [
        {
          title: 'topic test-command',
          code: './examples/topic-test-command.example.sh',
          language: 'bash',
        },
      ],
      title: 'topic test-command',
    },
  },
  definitions: [
  {
    title: 'Flags',
    description: 'The following flags are available for the \`topic test-command\` command:',
    type: 'topictestcommand',
  },
  ],
  category: 'topic',
  related: [
  ],
}

export default data`
    );
  });
});
describe("writeCommandUsageExampleFile", () => {
  test("calls writeFile with the correct content", async () => {
    await writeCommandUsageExampleFile(testCommand, commandData), globalExpect(writeFile).toHaveBeenCalledWith(
      globalExpect.stringContaining("docs-shopify.dev/commands/examples/topic-test-command.example.sh"),
      "shopify topic test-command [flags]"
    );
  });
});
//# sourceMappingURL=generate.test.js.map
