/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ import React from "react"; import { render } from "@testing-library/react"; import RadioButtons from "../RadioButtons"; test("renders radio buttons", async () => { const wrapper = render( , ); expect(wrapper.container).toMatchSnapshot(); }); test("selects a value by default", async () => { const { getByLabelText } = render( , ); expect(getByLabelText("Susan B. Anthony")).toHaveAttribute("checked"); expect(getByLabelText("Harriet Tubman")).not.toHaveAttribute("checked"); }); test("calls register function", async () => { const register = jest.fn(); render( , ); expect(register).toBeCalled(); }); test("renders an error", async () => { const wrapper = render( , ); expect(wrapper.container).toMatchSnapshot(); });