import { buildDependentPrTitle, buildPrTitle } from "./github-utils"

describe("GitHub Utils", () => {
  describe("buildPrTitle", () => {
    it("should build a title for a function", () => {
      const title = buildPrTitle("myFunction", "20%")
      expect(title).toBe("⚡️ Speed up function `myFunction` by 20%")
    })

    it("should build a title for a method", () => {
      const title = buildPrTitle("myObject.myMethod", "30%")
      expect(title).toBe("⚡️ Speed up method `myObject.myMethod` by 30%")
    })
  })

  describe("buildDependentPrTitle", () => {
    it("should build a title for a dependent PR for a function", () => {
      const title = buildDependentPrTitle("myFunction", "20%", 123, "main")
      expect(title).toBe("⚡️ Speed up function `myFunction` by 20% in PR #123 (`main`)")
    })

    it("should build a title for a dependent PR with a method", () => {
      const title = buildDependentPrTitle("myObject.myMethod", "30%", 456, "develop")
      expect(title).toBe("⚡️ Speed up method `myObject.myMethod` by 30% in PR #456 (`develop`)")
    })
  })
})
