-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathRive.test.tsx
54 lines (50 loc) · 1.28 KB
/
Rive.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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(
<RiveComponent
src="foo.riv"
className="container-styles"
aria-label="Foo label"
/>
);
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(
<RiveComponent
src="foo.riv"
className="container-styles"
aria-label="Foo label"
>
<p>{accessibleFallbackText}</p>
</RiveComponent>
);
expect(getByText(accessibleFallbackText)).not.toBeNull();
});
});