| 1 | import { describe, expect, it } from "vitest"; |
| 2 | import { desktopDownload } from "./desktop-release"; |
| 3 | import { getHome } from "./i18n/dictionaries"; |
| 4 | import { ORGANIZATION_ID } from "./site-schema"; |
| 5 | import { buildSoftwareApplicationJsonLd } from "./software-application-schema"; |
| 6 | |
| 7 | describe("SoftwareApplication structured data", () => { |
| 8 | it("uses the published version advertised by the release-backed install URL", () => { |
| 9 | const schema = buildSoftwareApplicationJsonLd({ version: "0.9.3" }); |
| 10 | |
| 11 | expect(schema.downloadUrl).toBe(desktopDownload()?.url ?? "https://codewhale.net/en/install"); |
| 12 | expect(schema.softwareVersion).toBe("0.9.3"); |
| 13 | expect(schema.author).toEqual({ "@id": ORGANIZATION_ID }); |
| 14 | }); |
| 15 | |
| 16 | it("omits softwareVersion when no published release receipt is available", () => { |
| 17 | const schema = buildSoftwareApplicationJsonLd(null); |
| 18 | |
| 19 | expect(schema).not.toHaveProperty("softwareVersion"); |
| 20 | expect(schema.author).toEqual({ "@id": ORGANIZATION_ID }); |
| 21 | }); |
| 22 | |
| 23 | it("lists only released operating systems, carries no price or free claim, and links the locale's install page", () => { |
| 24 | const schema = buildSoftwareApplicationJsonLd({ version: "0.9.3" }, "zh"); |
| 25 | |
| 26 | expect(schema.operatingSystem).toBe("macOS, Linux, Windows"); |
| 27 | expect(schema).not.toHaveProperty("isAccessibleForFree"); |
| 28 | expect(schema).not.toHaveProperty("offers"); |
| 29 | expect(schema.downloadUrl).toBe(desktopDownload()?.url ?? "https://codewhale.net/zh/install"); |
| 30 | expect(schema.description).toBe(getHome("zh").metaDescription); |
| 31 | }); |
| 32 | }); |
| 33 |