-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathflip.test.tsx
More file actions
54 lines (48 loc) · 1.66 KB
/
Copy pathflip.test.tsx
File metadata and controls
54 lines (48 loc) · 1.66 KB
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 { render } from '@testing-library/react';
import { FLIP_ITEM_MARK, markComponent } from '../../_utils/component-markers';
import Flip from '../index';
describe('<Flip />', () => {
it('should match the snapshot', () => {
const { asFragment } = render(
<Flip width={200} height={200}>
<Flip.Item><div>Front</div></Flip.Item>
<Flip.Item><div>Back</div></Flip.Item>
</Flip>
);
expect(asFragment()).toMatchSnapshot();
});
it('should render correctly', () => {
const { container } = render(
<Flip width={200} height={200}>
<Flip.Item><div>Front</div></Flip.Item>
<Flip.Item><div>Back</div></Flip.Item>
</Flip>
);
expect(container.firstChild).toHaveClass('ty-flip');
});
it('should render content', () => {
const { getByText } = render(
<Flip width={200} height={200}>
<Flip.Item><div>Front Side</div></Flip.Item>
<Flip.Item><div>Back Side</div></Flip.Item>
</Flip>
);
expect(getByText('Front Side')).toBeInTheDocument();
expect(getByText('Back Side')).toBeInTheDocument();
});
it('should recognize marker-based flip item wrappers', () => {
const WrappedItem = markComponent(
(props: React.ComponentProps<typeof Flip.Item>) => <Flip.Item {...props} />,
FLIP_ITEM_MARK
);
const { getByText } = render(
<Flip width={200} height={200}>
<WrappedItem><div>Front Wrapped</div></WrappedItem>
<WrappedItem><div>Back Wrapped</div></WrappedItem>
</Flip>
);
expect(getByText('Front Wrapped')).toBeInTheDocument();
expect(getByText('Back Wrapped')).toBeInTheDocument();
});
});