Skip to content

Commit 7a86c7d

Browse files
authored
Merge pull request #94 from internxt/feat/update-test-coverage
[PB-3528]:feat/update coverage for components
2 parents d929190 + c414f30 commit 7a86c7d

10 files changed

Lines changed: 539 additions & 12 deletions

File tree

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,72 @@
11
import { render } from '@testing-library/react';
2-
import { describe, expect, it } from 'vitest';
2+
import { describe, expect, it, test } from 'vitest';
33
import { Avatar } from '../';
4+
import DefaultAvatar from '../components/DefaultAvatar';
5+
import PictureAvatar from '../components/PictureAvatar';
46

57
const FULL_NAME = 'My Internxt';
68
const IMAGE_SRC = 'https://internxt.com/favicon.ico';
79

810
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', () => {
1012
const avatarComponent = render(<Avatar diameter={80} fullName={FULL_NAME} />);
1113
expect(avatarComponent).toMatchSnapshot();
1214
});
1315

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', () => {
1527
const avatarComponent = render(<Avatar diameter={80} fullName={null as any} />);
1628
expect(avatarComponent).toMatchSnapshot();
1729
});
1830

19-
it('Avatar with avatar (user image profile) should render correctly', () => {
31+
test('Avatar with avatar (user image profile) should render correctly', () => {
2032
const avatarComponent = render(<Avatar fullName={FULL_NAME} diameter={80} src={IMAGE_SRC} />);
2133
expect(avatarComponent).toMatchSnapshot();
2234
});
2335

24-
it('XXS Avatar should render correctly', () => {
36+
test('XXS Avatar should render correctly', () => {
2537
const avatarComponent = render(<Avatar fullName={FULL_NAME} size="xxs" src={IMAGE_SRC} />);
2638
expect(avatarComponent).toMatchSnapshot();
2739
});
28-
it('XS Avatar should render correctly', () => {
40+
test('XS Avatar should render correctly', () => {
2941
const avatarComponent = render(<Avatar fullName={FULL_NAME} size="xs" src={IMAGE_SRC} />);
3042
expect(avatarComponent).toMatchSnapshot();
3143
});
3244

33-
it('SM Avatar should render correctly', () => {
45+
test('SM Avatar should render correctly', () => {
3446
const avatarComponent = render(<Avatar fullName={FULL_NAME} size="sm" src={IMAGE_SRC} />);
3547
expect(avatarComponent).toMatchSnapshot();
3648
});
3749

38-
it('Base Avatar should render correctly', () => {
50+
test('Base Avatar should render correctly', () => {
3951
const avatarComponent = render(<Avatar fullName={FULL_NAME} size="base" src={IMAGE_SRC} />);
4052
expect(avatarComponent).toMatchSnapshot();
4153
});
42-
it('LG Avatar should render correctly', () => {
54+
test('LG Avatar should render correctly', () => {
4355
const avatarComponent = render(<Avatar fullName={FULL_NAME} size="lg" src={IMAGE_SRC} />);
4456
expect(avatarComponent).toMatchSnapshot();
4557
});
46-
it('XL Avatar should render correctly', () => {
58+
test('XL Avatar should render correctly', () => {
4759
const avatarComponent = render(<Avatar fullName={FULL_NAME} size="xl" src={IMAGE_SRC} />);
4860
expect(avatarComponent).toMatchSnapshot();
4961
});
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+
});
5072
});

0 commit comments

Comments
 (0)