Files
openclaw/packages/normalization-core/src/expect.test.ts
Peter Steinberger e686693732 feat(tooling): adopt noUncheckedIndexedAccess via a strict-ratchet lane (phase 1) (#104577)
* feat(tooling): add noUncheckedIndexedAccess strict-ratchet lane

* fix(packages): make indexed access explicit across ratchet packages

Burns down all 65 noUncheckedIndexedAccess errors in the seven ratchet
packages with behavior-identical restructuring (iteration, charAt/slice,
regex-group guards, validated hextet tuple). net-policy invariant
violations now throw instead of failing open. Adds
@openclaw/normalization-core/expect (expectDefined/first/last) with
subpath export and tests. memory-host-sdk fixes kept but the package
stays out of the lane: it re-exports core src/** so the flag would apply
transitively to all of core.

* fix(lint): keep .oxlintrc.json strict-JSON parseable for extension lint wrappers
2026-07-11 10:26:12 -07:00

20 lines
644 B
TypeScript

import { describe, expect, it } from "vitest";
import { expectDefined, first, last } from "./expect.js";
describe("expect helpers", () => {
it("returns defined values", () => {
expect(expectDefined(0, "number")).toBe(0);
});
it.each([null, undefined])("rejects missing values", (value) => {
expect(() => expectDefined(value, "test value")).toThrow("expected test value to be defined");
});
it("reads array boundaries without claiming they exist", () => {
expect(first(["a", "b"])).toBe("a");
expect(last(["a", "b"])).toBe("b");
expect(first([])).toBeUndefined();
expect(last([])).toBeUndefined();
});
});