Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

pullRequestMediaSource.test.ts

25 lines1.0 KB

1import { describe, expect, it } from "vite-plus/test";
2import { EnvironmentId } from "@t3tools/contracts";
3import { filePreviewGallery } from "../../lib/filePreviewGallery";
4import { pullRequestImageSource } from "./pullRequestMediaSource";
5​
6const location = {
7 environmentId: EnvironmentId.make("test"),
8 cwd: "/repo",
9 repository: "enterprise/private",
10};
11const url = "https://github.com/user-attachments/assets/abc-123";
12​
13describe("PR media previews", () => {
14 it("keeps every gallery image resolvable and the tapped image appears only once", () => {
15 const first = pullRequestImageSource(url, location);
16 const second = pullRequestImageSource(`${url}-second`, location);
17 const selected = { ...second, sourceIdentifier: "tapped" };
18 const gallery = filePreviewGallery(selected, [first, second]);
19 expect(gallery).toEqual([first, selected]);
20 expect(gallery).toMatchObject([
21 { resource: { url, repository: location.repository } },
22 { resource: { url: `${url}-second`, repository: location.repository } },
23 ]);
24 });
25});