Files
OmniRoute/tests/unit/providerModelMutationSchema-isfree.test.ts
Diego Rodrigues de Sa e Souza 3b752f9d4c chore(quality): type the 55 no-explicit-any sites frozen under #11924 (#11975)
Production (open-sse/utils/socksConnectorWithFamily.ts, 4 sites): every cast was
redundant — undici's buildConnector.BuildOptions already has `timeout?: number | null`,
socks' SocksClientOptions has `timeout?: number`, and Agent.Options' `connect` /
`connectTimeout` narrow to the connector's parameter types on their own. Behaviour
unchanged; check:open-sse-typecheck stays at the frozen 5.

Tests (51 sites): the socks-timeout mocks now carry the real types — the patched
SocksClient.createConnection is typed as the static it replaces, the fake
buildConnector returns buildConnector.connector, the proxy is a SocksProxy, the
dynamic import is typed as the module it loads; the e2e suite passes a SocksProxy and
Agent.Options and no longer casts undici's fetch init (its RequestInit already has
`dispatcher`); the isFree suites narrow getCustomModels()' JSON to a declared row
shape, feed deliberately-wrong values through `unknown`, and stop casting for
zod's safeParse, which takes unknown.

The six files' suppression entries are removed: 1238 → 1232 files, 5487 → 5432
suppressed. ESLint without the suppressions file reports 0 problems on all six;
with it, no stale entry is left. The five suites pass (4, 2, 5, 4, 4).
2026-08-29 03:06:50 -03:00

39 lines
1.2 KiB
TypeScript

import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { providerModelMutationSchema } from "../../src/shared/validation/schemas/provider.ts";
describe("providerModelMutationSchema isFree", () => {
it("isFree:true accepted", () => {
assert.equal(
providerModelMutationSchema.safeParse({ provider: "p", modelId: "m", isFree: true }).success,
true
);
});
it("old payload without isFree still valid", () => {
assert.equal(
providerModelMutationSchema.safeParse({ provider: "p", modelId: "m" }).success,
true
);
});
it('rejects isFree:0 and isFree:"yes"', () => {
assert.equal(
providerModelMutationSchema.safeParse({ provider: "p", modelId: "m", isFree: 0 }).success,
false
);
assert.equal(
providerModelMutationSchema.safeParse({ provider: "p", modelId: "m", isFree: "yes" }).success,
false
);
});
it("nullable true/false/null accepted", () => {
assert.equal(
providerModelMutationSchema.safeParse({ provider: "p", modelId: "m", isFree: null }).success,
true
);
assert.equal(
providerModelMutationSchema.safeParse({ provider: "p", modelId: "m", isFree: false }).success,
true
);
});
});