-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathindex.test.jsx
More file actions
55 lines (45 loc) · 1.26 KB
/
index.test.jsx
File metadata and controls
55 lines (45 loc) · 1.26 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
55
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { render, fireEvent } from '@testing-library/react';
import AvatarGroup from '../index';
const names = [
'ovflowd',
'bmuenzenmeyer',
'AugustinMauroy',
'HinataKah0',
'Harkunwar',
'rodion-arr',
'avivkeller',
'mikeesto',
'bnb',
'benhalverson',
'aymen94',
'shanpriyan',
'Wai-Dung',
'manishprivet',
'araujogui',
];
const avatars = names.map(name => ({
image: `https://avatars.githubusercontent.com/${name}`,
nickname: name,
}));
const limit = 2;
const remaining = names.length - limit;
describe('AvatarGroup', () => {
it('renders the AvatarGroup component properly', () => {
const { getByText } = render(
<AvatarGroup avatars={avatars} limit={limit} />
);
const showMoreButton = getByText(`+${remaining}`);
assert.ok(showMoreButton.ownerDocument);
});
it('displays the rest of the avatars when "show more" button is clicked', () => {
const { getByText } = render(
<AvatarGroup avatars={avatars} limit={limit} />
);
const showMoreButton = getByText(`+${remaining}`);
fireEvent.click(showMoreButton);
const hideMoreButton = getByText(`-${remaining}`);
assert.ok(hideMoreButton.ownerDocument);
});
});