test: guard cli null helpers

This commit is contained in:
Peter Steinberger
2026-05-11 21:07:47 +01:00
parent e986012043
commit e19c7ab95e
8 changed files with 36 additions and 22 deletions

View File

@@ -183,8 +183,9 @@ function expectFirstInstallPlanCallOmitsToken() {
}
function expectFields(value: unknown, expected: Record<string, unknown>): void {
expect(value).toBeTypeOf("object");
expect(value).not.toBeNull();
if (!value || typeof value !== "object") {
throw new Error("expected fields object");
}
const record = value as Record<string, unknown>;
for (const [key, expectedValue] of Object.entries(expected)) {
expect(record[key], key).toEqual(expectedValue);