-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpresets.test.ts
More file actions
51 lines (44 loc) · 1.64 KB
/
Copy pathpresets.test.ts
File metadata and controls
51 lines (44 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { describe, expect, it } from "@jest/globals";
import type { pipelineConfig } from "../src/app/pipeline/(pipeline-configuration)/config-provider";
import { presetFields, sha256Hex } from "../src/lib/presets";
describe("sha256Hex", () => {
it("hashes deterministically", async () => {
const a = await sha256Hex(new Uint8Array([1, 2, 3]));
const b = await sha256Hex(new Uint8Array([1, 2, 3]));
const c = await sha256Hex(new Uint8Array([1, 2, 4]));
expect(a).toBe(b);
expect(a).not.toBe(c);
expect(a).toHaveLength(64);
});
});
describe("presetFields", () => {
const config: pipelineConfig = {
cameraResponseLocation: "/cal/response.rsp",
correctionFiles: {
calibrationFactor: "/cal/cf.cal",
fisheye: "/cal/fisheye.cal",
neutralDensity: null,
vignetting: "/cal/vig.cal",
},
fisheyeView: {
horizontalViewDegrees: 186,
projection: "vta",
verticalViewDegrees: 186,
},
inputSets: [],
lensMask: { radius: 1806, x: 2825, y: 1864 },
outputSettings: { filterIrrelevantSrcImages: true, targetRes: 1000 },
validityCheck: { measuredVerticalIlluminanceLux: 1240 },
};
it("keeps the one-time setup material", () => {
const fields = presetFields(config);
expect(fields.fisheyeView.verticalViewDegrees).toBe(186);
expect(fields.outputSettings.targetRes).toBe(1000);
expect(fields.lensMask).toEqual({ radius: 1806, x: 2825, y: 1864 });
});
it("excludes per-capture material", () => {
const fields = presetFields(config) as Record<string, unknown>;
expect(fields.inputSets).toBeUndefined();
expect(fields.validityCheck).toBeUndefined();
});
});