import { describe, expect, it } from "vite-plus/test";
import { EnvironmentId } from "@t3tools/contracts";
import { filePreviewGallery } from "../../lib/filePreviewGallery";
import { pullRequestImageSource } from "./pullRequestMediaSource";
const location = {
environmentId: EnvironmentId.make("test"),
cwd: "/repo",
repository: "enterprise/private",
};
const url = "https://github.com/user-attachments/assets/abc-123";
describe("PR media previews", () => {
it("keeps every gallery image resolvable and the tapped image appears only once", () => {
const first = pullRequestImageSource(url, location);
const second = pullRequestImageSource(`${url}-second`, location);
const selected = { ...second, sourceIdentifier: "tapped" };
const gallery = filePreviewGallery(selected, [first, second]);
expect(gallery).toEqual([first, selected]);
expect(gallery).toMatchObject([
{ resource: { url, repository: location.repository } },
{ resource: { url: `${url}-second`, repository: location.repository } },
]);
});
});