import {
  extractCommandData,
  writeCommandDocumentation,
  writeCommandFlagInterface,
  writeCommandUsageExampleFile
} from "../../../chunk-AQD7SOU5.js";
import {
  describe,
  globalExpect,
  test,
  vi
} from "../../../chunk-ZGHNMRBX.js";
import "../../../chunk-LUHAPAT6.js";
import "../../../chunk-UIFACRCR.js";
import "../../../chunk-O5K4AU7Q.js";
import "../../../chunk-J3MMJFA5.js";
import "../../../chunk-OWRIOLFJ.js";
import "../../../chunk-4YRKVURS.js";
import "../../../chunk-EMHZBYE7.js";
import "../../../chunk-KLJ2TVHE.js";
import "../../../chunk-VSLR7ET4.js";
import "../../../chunk-HJBER2P6.js";
import "../../../chunk-BYPQXSAL.js";
import "../../../chunk-DD26C7GE.js";
import "../../../chunk-NLUGD7PZ.js";
import {
  writeFile
} from "../../../chunk-LA4HX5WI.js";
import "../../../chunk-XVNW332R.js";
import "../../../chunk-XEDHKQZA.js";
import "../../../chunk-T2GATXSP.js";
import "../../../chunk-CBD6UXLA.js";
import "../../../chunk-CBBS4CV7.js";
import "../../../chunk-SNOECVP4.js";
import "../../../chunk-NEOIQ6PN.js";
import "../../../chunk-7Q3MMWAC.js";
import "../../../chunk-MX4RJDBM.js";
import "../../../chunk-NB4NLOEJ.js";
import "../../../chunk-UBB7JKND.js";
import "../../../chunk-522OB3EU.js";
import "../../../chunk-PNN7RS7Y.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
