-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathindex.test.mjs
More file actions
46 lines (37 loc) · 1.08 KB
/
index.test.mjs
File metadata and controls
46 lines (37 loc) · 1.08 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
import { render, fireEvent } from '@testing-library/react';
import AvatarGroup from '../index';
import { getGitHubAvatarUrl } from '@/util/gitHubUtils';
const names = [
'ovflowd',
'bmuenzenmeyer',
'AugustinMauroy',
'HinataKah0',
'Harkunwar',
'rodion-arr',
'mikeesto',
'bnb',
'benhalverson',
'aymen94',
'shanpriyan',
'Wai-Dung',
'manishprivet',
'araujogui',
];
const avatars = names.map(name => ({
image: getGitHubAvatarUrl(name),
nickname: name,
}));
describe('AvatarGroup', () => {
it('renders the AvatarGroup component properly', () => {
const { getByText } = render(<AvatarGroup avatars={avatars} limit={2} />);
const showMoreButton = getByText('+12');
expect(showMoreButton).toBeInTheDocument();
});
it('displays the rest of the avatars when "show more" button is clicked', () => {
const { getByText } = render(<AvatarGroup avatars={avatars} limit={2} />);
const showMoreButton = getByText('+12');
fireEvent.click(showMoreButton);
const hideMoreButton = getByText('-12');
expect(hideMoreButton).toBeInTheDocument();
});
});