import React from "react"; import type { RenderAPI } from "@testing-library/react-native"; import { fireEvent, render, waitFor } from "@testing-library/react-native"; import { FormProvider, useForm } from "react-hook-form"; import { CheckboxGroup } from "./CheckboxGroup"; import { Checkbox } from "./Checkbox"; import type { CheckboxGroupState } from "./types"; import { Button } from "../Button"; const onSubmitMock = jest.fn(); const parentCheckboxLabel = "all condiments"; const firstCheckboxLabel = "relish"; const secondCheckboxLabel = "ketchup"; const thirdCheckboxLabel = "mustard"; const saveButtonText = "Save"; interface CheckboxGroupFormData { [key: string]: CheckboxGroupState; } interface CheckboxGroupFormOnChangeHandlers { relish?: (data: boolean) => void; mustard?: (data: boolean) => void; ketchup?: (data: boolean) => void; all?: (data: CheckboxGroupState) => void; } function setup( label: string | undefined, disabled?: boolean, childDisabled?: boolean, ) { const checkboxGroup = render( , ); return { checkboxGroup }; } function SetupWithForm({ initialValues, onChangeHandlers, }: { readonly initialValues: CheckboxGroupFormData; readonly onChangeHandlers?: CheckboxGroupFormOnChangeHandlers; }) { const formMethods = useForm({ defaultValues: initialValues }); return (