|
1 | 1 | import { render } from '@testing-library/react'; |
2 | | -import { describe, expect, it } from 'vitest'; |
| 2 | +import { describe, expect, it, test } from 'vitest'; |
3 | 3 | import { Avatar } from '../'; |
| 4 | +import DefaultAvatar from '../components/DefaultAvatar'; |
| 5 | +import PictureAvatar from '../components/PictureAvatar'; |
4 | 6 |
|
5 | 7 | const FULL_NAME = 'My Internxt'; |
6 | 8 | const IMAGE_SRC = 'https://internxt.com/favicon.ico'; |
7 | 9 |
|
8 | 10 | describe('Avatar component', () => { |
9 | | - it('Avatar with full name (first letters) should render correctly', () => { |
| 11 | + test('Avatar with full name (first letters) should render correctly', () => { |
10 | 12 | const avatarComponent = render(<Avatar diameter={80} fullName={FULL_NAME} />); |
11 | 13 | expect(avatarComponent).toMatchSnapshot(); |
12 | 14 | }); |
13 | 15 |
|
14 | | - it('Avatar with fullname as null should render correctly with empty letters', () => { |
| 16 | + test('Avatar with single word name should render correctly', () => { |
| 17 | + const avatarComponent = render(<Avatar diameter={80} fullName="Javi" />); |
| 18 | + expect(avatarComponent).toMatchSnapshot(); |
| 19 | + }); |
| 20 | + |
| 21 | + test('Avatar with empty spaces name should return empty content', () => { |
| 22 | + const avatarComponent = render(<Avatar diameter={80} fullName=" " />); |
| 23 | + expect(avatarComponent).toMatchSnapshot(); |
| 24 | + }); |
| 25 | + |
| 26 | + test('Avatar with fullname as null should render correctly with empty letters', () => { |
15 | 27 | const avatarComponent = render(<Avatar diameter={80} fullName={null as any} />); |
16 | 28 | expect(avatarComponent).toMatchSnapshot(); |
17 | 29 | }); |
18 | 30 |
|
19 | | - it('Avatar with avatar (user image profile) should render correctly', () => { |
| 31 | + test('Avatar with avatar (user image profile) should render correctly', () => { |
20 | 32 | const avatarComponent = render(<Avatar fullName={FULL_NAME} diameter={80} src={IMAGE_SRC} />); |
21 | 33 | expect(avatarComponent).toMatchSnapshot(); |
22 | 34 | }); |
23 | 35 |
|
24 | | - it('XXS Avatar should render correctly', () => { |
| 36 | + test('XXS Avatar should render correctly', () => { |
25 | 37 | const avatarComponent = render(<Avatar fullName={FULL_NAME} size="xxs" src={IMAGE_SRC} />); |
26 | 38 | expect(avatarComponent).toMatchSnapshot(); |
27 | 39 | }); |
28 | | - it('XS Avatar should render correctly', () => { |
| 40 | + test('XS Avatar should render correctly', () => { |
29 | 41 | const avatarComponent = render(<Avatar fullName={FULL_NAME} size="xs" src={IMAGE_SRC} />); |
30 | 42 | expect(avatarComponent).toMatchSnapshot(); |
31 | 43 | }); |
32 | 44 |
|
33 | | - it('SM Avatar should render correctly', () => { |
| 45 | + test('SM Avatar should render correctly', () => { |
34 | 46 | const avatarComponent = render(<Avatar fullName={FULL_NAME} size="sm" src={IMAGE_SRC} />); |
35 | 47 | expect(avatarComponent).toMatchSnapshot(); |
36 | 48 | }); |
37 | 49 |
|
38 | | - it('Base Avatar should render correctly', () => { |
| 50 | + test('Base Avatar should render correctly', () => { |
39 | 51 | const avatarComponent = render(<Avatar fullName={FULL_NAME} size="base" src={IMAGE_SRC} />); |
40 | 52 | expect(avatarComponent).toMatchSnapshot(); |
41 | 53 | }); |
42 | | - it('LG Avatar should render correctly', () => { |
| 54 | + test('LG Avatar should render correctly', () => { |
43 | 55 | const avatarComponent = render(<Avatar fullName={FULL_NAME} size="lg" src={IMAGE_SRC} />); |
44 | 56 | expect(avatarComponent).toMatchSnapshot(); |
45 | 57 | }); |
46 | | - it('XL Avatar should render correctly', () => { |
| 58 | + test('XL Avatar should render correctly', () => { |
47 | 59 | const avatarComponent = render(<Avatar fullName={FULL_NAME} size="xl" src={IMAGE_SRC} />); |
48 | 60 | expect(avatarComponent).toMatchSnapshot(); |
49 | 61 | }); |
| 62 | + |
| 63 | + test('DefaultAvatar handles default parameters', () => { |
| 64 | + const avatarComponent = render(<DefaultAvatar fullName="John Doe" diameter={80} />); |
| 65 | + expect(avatarComponent).toMatchSnapshot(); |
| 66 | + }); |
| 67 | + |
| 68 | + test('PictureAvatar handles default parameters', () => { |
| 69 | + const avatarComponent = render(<PictureAvatar src={IMAGE_SRC} diameter={80} />); |
| 70 | + expect(avatarComponent).toMatchSnapshot(); |
| 71 | + }); |
50 | 72 | }); |
0 commit comments