import { render, screen } from '@testing-library/react'; import React from 'react'; import { PromoCardContext, usePromoCardContext } from './PromoCardContext'; // A simple component that consumes the context const TestComponent: React.FC> = () => { const context = usePromoCardContext(); return (

{`Value: ${context.state}`}

{`Disabled: ${context.isDisabled.toString()}`}

); }; describe('PromoCardContext', () => { it('default values are accessible', () => { const contextValue = { state: '', isDisabled: false, onChange: jest.fn(), // You can mock this function for testing }; render( , ); expect(screen.getByText('Value:')).toBeInTheDocument(); expect(screen.getByText('Disabled: false')).toBeInTheDocument(); }); it('context value changes are reflected', () => { const contextValue = { state: 'new value', isDisabled: true, onChange: jest.fn(), // You can mock this function for testing }; render( , ); expect(screen.getByText('Value: new value')).toBeInTheDocument(); expect(screen.getByText('Disabled: true')).toBeInTheDocument(); }); });