1import { describe, expect, it } from "vite-plus/test";
2
3import {
4 buildNativeSourceRows,
5 buildNativeSourceTokens,
6 nativeSourceRowId,
7} from "./nativeSourceFileAdapter";
8
9describe("nativeSourceFileAdapter", () => {
10 it("maps plain source lines onto context rows with stable line numbers", () => {
11 expect(buildNativeSourceRows(["const value = 1;", "\treturn value;"])).toEqual([
12 {
13 kind: "line",
14 id: nativeSourceRowId(0),
15 fileId: "source-file",
16 content: "const value = 1;",
17 change: "context",
18 newLineNumber: 1,
19 },
20 {
21 kind: "line",
22 id: nativeSourceRowId(1),
23 fileId: "source-file",
24 content: " return value;",
25 change: "context",
26 newLineNumber: 2,
27 },
28 ]);
29 });
30
31 it("maps cached source tokens to the same row identifiers", () => {
32 expect(
33 buildNativeSourceTokens([
34 [{ content: "const", color: "#ff0000", fontStyle: 2 }],
35 [{ content: "\tvalue", color: null, fontStyle: null }],
36 ]),
37 ).toEqual({
38 [nativeSourceRowId(0)]: [{ content: "const", color: "#ff0000", fontStyle: 2 }],
39 [nativeSourceRowId(1)]: [{ content: " value", color: null, fontStyle: null }],
40 });
41 });
42
43 it("clears native tokens while highlighting is unavailable", () => {
44 expect(buildNativeSourceTokens(null)).toEqual({});
45 });
46});