mirror of
https://github.com/morluto/rea.git
synced 2026-11-05 14:26:07 +00:00
Use one typed CDP resource-size owner in web and Electron capture. Supplied invalid sizes retain null plus completeness diagnostics; omitted sizes remain unknown without inventing malformed metadata. Preserve other resource facts and valid zero/positive values. Validation: public CLI regression failed against baseline clamping; 36 focused controls passed after the fix, check:fast and docs:check passed. Fake CDP producer with real CLI/transport and tiny local files; no real Electron/browser or heavy profiling qualification. Refs #4708
22 lines
570 B
TypeScript
22 lines
570 B
TypeScript
import { expect, it } from "vitest";
|
|
import { resourceContentSize } from "./CdpCaptureValues.js";
|
|
|
|
it.each([
|
|
[undefined, null],
|
|
[0, 0],
|
|
[128, 128],
|
|
[0.5, 0.5],
|
|
])("preserves optional CDP size %s as %s", (input, value) => {
|
|
expect(resourceContentSize(input)).toEqual({ ok: true, value });
|
|
});
|
|
|
|
it.each([-1, null, "4", NaN, Infinity, -Infinity, {}])(
|
|
"rejects supplied invalid CDP size %s without inventing zero",
|
|
(value) => {
|
|
expect(resourceContentSize(value)).toEqual({
|
|
ok: false,
|
|
error: { _tag: "InvalidCdpResourceSize" },
|
|
});
|
|
},
|
|
);
|