import { render, screen } from '@testing-library/react'; import DefaultLabelProvider, { useDefaultLabelContext } from './DefaultLabelProvider'; // DefaultLabelProvider is basically a passthrough to the React Context.Provider, so no tests required describe('useDefaultLabelContext', () => { it('returns provided string values for a supported component', () => { function TestComponent() { const { accessibilityHidePasswordLabel, accessibilityShowPasswordLabel } = useDefaultLabelContext('TextField'); return
{[accessibilityHidePasswordLabel, accessibilityShowPasswordLabel]}
; } render( , ); // This is a bit roundabout — we don't really care that these strings are in the document, but that they were returned from the Hook correctly expect(screen.getByText(/Hide password/)).toBeInTheDocument(); expect(screen.getByText(/Show password/)).toBeInTheDocument(); }); });