| 1 | import { readFileSync } from "node:fs"; |
| 2 | import path from "node:path"; |
| 3 | import { describe, expect, it } from "vitest"; |
| 4 | // @ts-expect-error: a plain .mjs build script without type declarations |
| 5 | import { manifestFor, packageExtension, vsixManifest } from "../scripts/package.mjs"; |
| 6 | |
| 7 | const pkg = JSON.parse(readFileSync(path.join(__dirname, "../package.json"), "utf8")); |
| 8 | const updateDefault = (m: typeof pkg): boolean => m.contributes.configuration.properties["diffinery.checkForUpdates"].default; |
| 9 | |
| 10 | describe("package.mjs", () => { |
| 11 | it("keeps the self-update check on for diffinery.com's build and turns it off for marketplaces", () => { |
| 12 | expect(updateDefault(manifestFor(pkg))).toBe(true); |
| 13 | expect(updateDefault(manifestFor(pkg, { marketplace: true }))).toBe(false); |
| 14 | expect(updateDefault(pkg)).toBe(true); |
| 15 | expect(manifestFor(pkg, { marketplace: true })).toMatchObject({ name: "diffinery", publisher: "codician", license: "Apache-2.0" }); |
| 16 | }); |
| 17 | |
| 18 | it("ships the license in both builds", async () => { |
| 19 | for (const marketplace of [false, true]) { |
| 20 | const { vsix } = await packageExtension({ marketplace }); |
| 21 | const text = Buffer.from(vsix).toString("latin1"); |
| 22 | expect(text).toContain("extension/LICENSE.txt"); |
| 23 | } |
| 24 | expect(vsixManifest(manifestFor(pkg))).toContain('<Asset Type="Microsoft.VisualStudio.Services.Content.License" Path="extension/LICENSE.txt" Addressable="true" />'); |
| 25 | }); |
| 26 | }); |