test(web): keep provider field readers private (#9952)
This commit is contained in:
1 parent
e5a87e8b9c
commit
07d2497db8
2 files changed
+2
-20
No files matched your search
@@ -5,8 +5,6 @@ import { DRIVER_OPTION_BY_VALUE } from "./providerDriverMeta";
|
||||
import {
|
||||
deriveProviderSettingsFields,
|
||||
nextProviderConfigWithFieldValue,
|
||||
readProviderConfigBoolean,
|
||||
readProviderConfigString,
|
||||
} from "./ProviderSettingsForm";
|
||||
|
||||
describe("ProviderSettingsForm helpers", () => {
|
||||
@@ -90,10 +88,6 @@ describe("ProviderSettingsForm helpers", () => {
|
||||
expect(next).toEqual({ forkOwned: 1 });
|
||||
});
|
||||
|
||||
it("reads non-string config values as blank strings", () => {
|
||||
expect(readProviderConfigString({ binaryPath: 123 }, "binaryPath")).toBe("");
|
||||
});
|
||||
|
||||
it("omits false boolean fields when clearWhenEmpty is omit", () => {
|
||||
const next = nextProviderConfigWithFieldValue(
|
||||
{ forkOwned: 1, experimental: true },
|
||||
@@ -156,12 +150,4 @@ describe("ProviderSettingsForm helpers", () => {
|
||||
|
||||
expect(next).toEqual({ experimental: false });
|
||||
});
|
||||
|
||||
it("reads non-boolean config values as false booleans", () => {
|
||||
expect(readProviderConfigBoolean({ experimental: "true" }, "experimental")).toBe(false);
|
||||
});
|
||||
|
||||
it("reads missing boolean config values from the supplied default", () => {
|
||||
expect(readProviderConfigBoolean({}, "experimental", true)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -119,17 +119,13 @@ export function deriveProviderSettingsFields(
|
||||
});
|
||||
}
|
||||
|
||||
export function readProviderConfigString(config: unknown, key: string): string {
|
||||
function readProviderConfigString(config: unknown, key: string): string {
|
||||
if (config === null || typeof config !== "object") return "";
|
||||
const value = (config as Record<string, unknown>)[key];
|
||||
return typeof value === "string" ? value : "";
|
||||
}
|
||||
|
||||
export function readProviderConfigBoolean(
|
||||
config: unknown,
|
||||
key: string,
|
||||
defaultValue = false,
|
||||
): boolean {
|
||||
function readProviderConfigBoolean(config: unknown, key: string, defaultValue = false): boolean {
|
||||
if (config === null || typeof config !== "object") return defaultValue;
|
||||
const value = (config as Record<string, unknown>)[key];
|
||||
return typeof value === "boolean" ? value : defaultValue;
|
||||
|
||||
Reference in new issue
Block a user