remix-validated-form
Version:
Form component and utils for easy form validation in remix
16 lines (15 loc) • 616 B
JavaScript
export const getRadioChecked = (radioValue = "on", newValue) => {
if (typeof newValue === "string")
return newValue === radioValue;
return undefined;
};
if (import.meta.vitest) {
const { it, expect } = import.meta.vitest;
it("getRadioChecked", () => {
expect(getRadioChecked("on", "on")).toBe(true);
expect(getRadioChecked("on", undefined)).toBe(undefined);
expect(getRadioChecked("trueValue", undefined)).toBe(undefined);
expect(getRadioChecked("trueValue", "bob")).toBe(false);
expect(getRadioChecked("trueValue", "trueValue")).toBe(true);
});
}