History

Add native mobile review diff rendering and static checks

- Add iOS review diff module, parser, and highlighter support - Wire mobile native lint tooling into CI and local docs - Include fixtures and tests for the new diff pipeline

Julius Marminge committed 6 months ago

Commit 37908161 parent da56bd526 files · +4834 −190Browse files

Showing the changes to apps/mobile/src/features/debug/native-review-diff/nativeReviewDiffModule.test.ts (1 of 26 files). Show all

Unified · Split

apps/mobile/src/features/debug/native-review-diff/nativeReviewDiffModule.test.ts+69−0
@@ -0,0 +1,69 @@
1import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
3const expoModulesCoreMocks = vi.hoisted(() => ({
4 requireNativeViewManager: vi.fn(),
5}));
6const nativeView = () => null;
7const originalExpo = globalThis.expo;
8
9function setExpoViewConfigAvailable() {
10 globalThis.expo = {
11 getViewConfig: vi.fn().mockReturnValue({ validAttributes: {}, directEventTypes: {} }),
12 } as unknown as typeof globalThis.expo;
13}
14
15vi.mock("expo-modules-core", () => ({
16 requireNativeViewManager: expoModulesCoreMocks.requireNativeViewManager,
17}));
18
19describe("resolveNativeReviewDiffView", () => {
20 beforeEach(() => {
21 vi.clearAllMocks();
22 vi.resetModules();
23 globalThis.expo = undefined as unknown as typeof globalThis.expo;
24 });
25
26 afterEach(() => {
27 globalThis.expo = originalExpo;
28 });
29
30 it("returns null when the native review diff view config is unavailable", async () => {
31 const { resolveNativeReviewDiffView } = await import("./nativeReviewDiffModule");
32 expect(resolveNativeReviewDiffView()).toBeNull();
33 expect(expoModulesCoreMocks.requireNativeViewManager).not.toHaveBeenCalled();
34 });
35
36 it("returns the native review diff view when the view config is installed", async () => {
37 setExpoViewConfigAvailable();
38 expoModulesCoreMocks.requireNativeViewManager.mockReturnValue(nativeView);
39 const { resolveNativeReviewDiffView } = await import("./nativeReviewDiffModule");
40 expect(resolveNativeReviewDiffView()).toBe(nativeView);
41 expect(expoModulesCoreMocks.requireNativeViewManager).toHaveBeenCalledWith(
42 "T3ReviewDiffSurface",
43 );
44 });
45
46 it("does not fall back to stale legacy native review diff view names", async () => {
47 globalThis.expo = {
48 getViewConfig: vi.fn().mockImplementation((moduleName: string) => {
49 if (moduleName === "T3ReviewDiffView") {
50 return { validAttributes: {}, directEventTypes: {} };
51 }
52 return null;
53 }),
54 } as unknown as typeof globalThis.expo;
55 expoModulesCoreMocks.requireNativeViewManager.mockReturnValue(nativeView);
56 const { resolveNativeReviewDiffView } = await import("./nativeReviewDiffModule");
57 expect(resolveNativeReviewDiffView()).toBeNull();
58 expect(expoModulesCoreMocks.requireNativeViewManager).not.toHaveBeenCalled();
59 });
60
61 it("returns null when the view manager cannot be required", async () => {
62 setExpoViewConfigAvailable();
63 expoModulesCoreMocks.requireNativeViewManager.mockImplementation(() => {
64 throw new Error("boom");
65 });
66 const { resolveNativeReviewDiffView } = await import("./nativeReviewDiffModule");
67 expect(resolveNativeReviewDiffView()).toBeNull();
68 });
69});

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t