import React from 'react'; import RiveComponent from '../src/components/Rive'; import { render } from '@testing-library/react'; jest.mock('@rive-app/canvas', () => ({ Rive: jest.fn().mockImplementation(() => ({ on: jest.fn(), stop: jest.fn(), })), Layout: jest.fn(), Fit: { Cover: 'cover', }, Alignment: { Center: 'center', }, EventType: { Load: 'load', }, StateMachineInputType: { Number: 1, Boolean: 2, Trigger: 3, }, })); describe('Rive Component', () => { it('renders the component as a canvas and a div wrapper', () => { const { container, getByLabelText } = render( ); expect(container.firstChild).toHaveClass('container-styles'); expect(getByLabelText('Foo label').tagName).toEqual('CANVAS'); }); it('allows children to render in the canvas body', () => { const accessibleFallbackText = 'An animated test'; const { getByText } = render(

{accessibleFallbackText}

); expect(getByText(accessibleFallbackText)).not.toBeNull(); }); });