authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 01:56:35-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 01:56:35-07:00
log38812c101e562c4f8d9bea7b1a592a4b02954a39
tree3a3219c0c201b6653b7ef063724ffcbd4c9005ec
parent25cbcd62d9750d3e8903fd752078e66c7943ecdb
signature Signed by PGP key B5690EEEBB952194

test(web): remove mocked diff view prop snapshot (#10073)


1 files changed, 0 insertions(+), 48 deletions(-)

apps/web/src/components/diffs/StyledDiffCodeView.test.tsx-48
......@@ -18,13 +18,10 @@ import {
1818 useState,
1919 type Ref,
2020} from "react";
21import { renderToStaticMarkup } from "react-dom/server";
2221import { create, type ReactTestRenderer } from "react-test-renderer";
2322import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
2423
2524const testState = vi.hoisted(() => ({
26 codeViewClassName: null as string | null,
27 codeViewOptions: null as Record<string, unknown> | null,
2825 workers: [] as NodeWorkerThreads.Worker[],
2926 terminations: [] as Promise<number>[],
3027 requests: [] as WorkerRequest[],
......@@ -102,8 +99,6 @@ vi.mock("@pierre/diffs/worker/worker.js?worker", async () => {
10299vi.mock("@pierre/diffs/react", async (importOriginal) => ({
103100 ...(await importOriginal<typeof import("@pierre/diffs/react")>()),
104101 CodeView: (props: CodeViewProps) => {
105 testState.codeViewClassName = props.className ?? null;
106 testState.codeViewOptions = props.options ? { ...props.options } : null;
107102 return props.items?.map((item) =>
108103 item.type === "file" ? <FileOutput key={item.id} file={item.file} /> : null,
109104 );
......@@ -158,49 +153,6 @@ function renderViews(count: number) {
158153 );
159154}
160155
161describe("StyledDiffCodeView", () => {
162 beforeEach(() => {
163 testState.codeViewClassName = null;
164 testState.codeViewOptions = null;
165 });
166
167 it("always pairs the shared diff styling with its virtualized geometry", () => {
168 const loadDiffFiles = vi.fn(async () => ({
169 oldFile: { name: "before.ts", contents: "before\n" },
170 newFile: { name: "after.ts", contents: "after\n" },
171 }));
172 renderToStaticMarkup(
173 <StyledDiffCodeView
174 className="min-h-0"
175 items={[]}
176 options={{ theme: "pierre-dark", stickyHeaders: true, loadDiffFiles }}
177 />,
178 );
179
180 expect(testState.codeViewClassName).toBe(
181 "diff-render-surface [--code-background:var(--background)] outline-none min-h-0",
182 );
183 expect(testState.codeViewOptions).toMatchObject({
184 theme: "pierre-dark",
185 stickyHeaders: true,
186 loadDiffFiles,
187 itemMetrics: {
188 diffHeaderHeight: 32,
189 hunkSeparatorHeight: 24,
190 paddingTop: 0,
191 paddingBottom: 8,
192 },
193 layout: { paddingTop: 0, paddingBottom: 0, gap: 0 },
194 });
195 expect(testState.codeViewOptions?.unsafeCSS).toEqual(
196 expect.stringContaining("[data-unmodified-lines]::before"),
197 );
198 expect(testState.codeViewOptions?.unsafeCSS).toEqual(
199 expect.stringContaining(")[data-expand-index]\n [data-unmodified-lines]"),
200 );
201 });
202});
203
204156describe("code-view worker lifecycle", () => {
205157 let renderer: ReactTestRenderer | undefined;
206158