-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcalibration-files.test.ts
More file actions
95 lines (85 loc) · 2.92 KB
/
Copy pathcalibration-files.test.ts
File metadata and controls
95 lines (85 loc) · 2.92 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { describe, expect, it } from "@jest/globals";
import type { pipelineConfig } from "@/app/pipeline/(pipeline-configuration)/config-provider";
import { unsuppliedCalibrationFiles } from "@/app/pipeline/calibration-files";
/** The form's own defaults: every calibration field starts empty. */
function makeConfig(overrides: Partial<pipelineConfig> = {}): pipelineConfig {
return {
cameraResponseLocation: null,
correctionFiles: {
calibrationFactor: null,
fisheye: null,
neutralDensity: null,
vignetting: null,
},
fisheyeView: {
horizontalViewDegrees: 180,
projection: "vta",
verticalViewDegrees: 180,
},
inputSets: [],
lensMask: { radius: 100, x: 200, y: 200 },
outputSettings: { filterIrrelevantSrcImages: true, targetRes: 1000 },
validityCheck: { measuredVerticalIlluminanceLux: null },
...overrides,
};
}
describe("unsuppliedCalibrationFiles", () => {
// The state a fresh form is in. It used to validate clean and run.
it("names all five when nothing has been uploaded", () => {
expect(unsuppliedCalibrationFiles(makeConfig())).toEqual([
"Camera response",
"Fisheye correction",
"Vignetting correction",
"Neutral density correction",
"Calibration factor",
]);
});
it("names nothing when every file has been uploaded", () => {
const config = makeConfig({
cameraResponseLocation: "/calib/camera.rsp",
correctionFiles: {
calibrationFactor: "/calib/factor.cal",
fisheye: "/calib/fisheye.cal",
neutralDensity: "/calib/nd.cal",
vignetting: "/calib/vignetting.cal",
},
});
expect(unsuppliedCalibrationFiles(config)).toEqual([]);
});
it("names only the ones left out", () => {
const config = makeConfig({
cameraResponseLocation: "/calib/camera.rsp",
correctionFiles: {
calibrationFactor: null,
fisheye: "/calib/fisheye.cal",
neutralDensity: null,
vignetting: "/calib/vignetting.cal",
},
});
expect(unsuppliedCalibrationFiles(config)).toEqual([
"Neutral density correction",
"Calibration factor",
]);
});
// The field accepts pasted text, so whitespace is reachable. Letting it
// through here moves the failure to somewhere much harder to diagnose.
it("treats a whitespace-only path as unsupplied", () => {
const config = makeConfig({ cameraResponseLocation: " " });
expect(unsuppliedCalibrationFiles(config)).toContain("Camera response");
});
it("reports in the order the form asks for the files", () => {
const config = makeConfig({
correctionFiles: {
calibrationFactor: null,
fisheye: null,
neutralDensity: "/calib/nd.cal",
vignetting: "/calib/vignetting.cal",
},
});
expect(unsuppliedCalibrationFiles(config)).toEqual([
"Camera response",
"Fisheye correction",
"Calibration factor",
]);
});
});