Skip to content

Commit

Permalink
Fix #3601: Avatar/AvatarGroup Jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Nov 9, 2022
1 parent bd34890 commit 7c4474b
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 11 deletions.
23 changes: 23 additions & 0 deletions components/lib/avatar/Avatar.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import '@testing-library/jest-dom';
import { Badge } from '../badge/Badge';
import { Avatar } from './Avatar';

import { snapshot } from '../../test';

describe('Avatar', () => {
snapshot(<Avatar />, 'default');
snapshot(<Avatar label="P" />, 'label');
snapshot(<Avatar icon="pi pi-search" />, 'icon');
snapshot(<Avatar image="user.png" />, 'image');
snapshot(<Avatar size="large" />, 'size large');
snapshot(<Avatar size="xlarge" />, 'size xlarge');
snapshot(<Avatar shape="square" />, 'shape square');
snapshot(<Avatar size="cirle" />, 'shape cirle');
snapshot(<Avatar>Content</Avatar>, 'templating');
snapshot(
<Avatar image="user.png" size="xlarge">
<Badge value="4" severity="danger" />
</Avatar>,
'badge'
);
});
108 changes: 108 additions & 0 deletions components/lib/avatar/__snapshots__/Avatar.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Avatar badge 1`] = `
<div>
<div
class="p-avatar p-component p-avatar-image p-avatar-xl"
>
<img
alt="avatar"
src="user.png"
/>
<span
class="p-badge p-component p-badge-no-gutter p-badge-danger"
>
4
</span>
</div>
</div>
`;

exports[`Avatar default 1`] = `
<div>
<div
class="p-avatar p-component"
/>
</div>
`;

exports[`Avatar icon 1`] = `
<div>
<div
class="p-avatar p-component"
>
<span
class="p-avatar-icon pi pi-search"
/>
</div>
</div>
`;

exports[`Avatar image 1`] = `
<div>
<div
class="p-avatar p-component p-avatar-image"
>
<img
alt="avatar"
src="user.png"
/>
</div>
</div>
`;

exports[`Avatar label 1`] = `
<div>
<div
class="p-avatar p-component"
>
<span
class="p-avatar-text"
>
P
</span>
</div>
</div>
`;

exports[`Avatar shape cirle 1`] = `
<div>
<div
class="p-avatar p-component"
/>
</div>
`;

exports[`Avatar shape square 1`] = `
<div>
<div
class="p-avatar p-component"
/>
</div>
`;

exports[`Avatar size large 1`] = `
<div>
<div
class="p-avatar p-component p-avatar-lg"
/>
</div>
`;

exports[`Avatar size xlarge 1`] = `
<div>
<div
class="p-avatar p-component p-avatar-xl"
/>
</div>
`;

exports[`Avatar templating 1`] = `
<div>
<div
class="p-avatar p-component"
>
Content
</div>
</div>
`;
18 changes: 18 additions & 0 deletions components/lib/avatargroup/AvatarGroup.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import '@testing-library/jest-dom';
import { Avatar } from '../avatar/Avatar';
import { AvatarGroup } from './AvatarGroup';

import { snapshot } from '../../test';

describe('AvatarGroup', () => {
snapshot(<AvatarGroup />, 'default');
snapshot(
<AvatarGroup>
<Avatar label="P" />
<Avatar icon="pi pi-search" />
<Avatar image="user.png" />
<Avatar label="+2" />
</AvatarGroup>,
'group'
);
});
51 changes: 51 additions & 0 deletions components/lib/avatargroup/__snapshots__/AvatarGroup.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AvatarGroup default 1`] = `
<div>
<div
class="p-avatar-group p-component"
/>
</div>
`;

exports[`AvatarGroup group 1`] = `
<div>
<div
class="p-avatar-group p-component"
>
<div
class="p-avatar p-component"
>
<span
class="p-avatar-text"
>
P
</span>
</div>
<div
class="p-avatar p-component"
>
<span
class="p-avatar-icon pi pi-search"
/>
</div>
<div
class="p-avatar p-component p-avatar-image"
>
<img
alt="avatar"
src="user.png"
/>
</div>
<div
class="p-avatar p-component"
>
<span
class="p-avatar-text"
>
+2
</span>
</div>
</div>
</div>
`;
4 changes: 2 additions & 2 deletions components/lib/tag/Tag.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Tag } from './Tag';

import { snapshot } from '../../test';

describe('Divider', () => {
describe('Tag', () => {
snapshot(<Tag />, 'default');
snapshot(<Tag value={`jest`} />, 'value');
snapshot(<Tag severity="success" />, 'sevrity success');
Expand All @@ -16,6 +16,6 @@ describe('Divider', () => {
<Tag>
<div>hello</div>
</Tag>,
'children'
'templating'
);
});
18 changes: 9 additions & 9 deletions components/lib/tag/__snapshots__/Tag.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Divider children 1`] = `
exports[`Tag children 1`] = `
<div>
<span
class="p-tag p-component"
Expand All @@ -17,7 +17,7 @@ exports[`Divider children 1`] = `
</div>
`;

exports[`Divider default 1`] = `
exports[`Tag default 1`] = `
<div>
<span
class="p-tag p-component"
Expand All @@ -30,7 +30,7 @@ exports[`Divider default 1`] = `
</div>
`;

exports[`Divider icon 1`] = `
exports[`Tag icon 1`] = `
<div>
<span
class="p-tag p-component"
Expand All @@ -46,7 +46,7 @@ exports[`Divider icon 1`] = `
</div>
`;

exports[`Divider rounded 1`] = `
exports[`Tag rounded 1`] = `
<div>
<span
class="p-tag p-component p-tag-rounded"
Expand All @@ -59,7 +59,7 @@ exports[`Divider rounded 1`] = `
</div>
`;

exports[`Divider sevrity danger 1`] = `
exports[`Tag sevrity danger 1`] = `
<div>
<span
class="p-tag p-component p-tag-danger"
Expand All @@ -72,7 +72,7 @@ exports[`Divider sevrity danger 1`] = `
</div>
`;

exports[`Divider sevrity info 1`] = `
exports[`Tag sevrity info 1`] = `
<div>
<span
class="p-tag p-component p-tag-info"
Expand All @@ -85,7 +85,7 @@ exports[`Divider sevrity info 1`] = `
</div>
`;

exports[`Divider sevrity success 1`] = `
exports[`Tag sevrity success 1`] = `
<div>
<span
class="p-tag p-component p-tag-success"
Expand All @@ -98,7 +98,7 @@ exports[`Divider sevrity success 1`] = `
</div>
`;

exports[`Divider sevrity warning 1`] = `
exports[`Tag sevrity warning 1`] = `
<div>
<span
class="p-tag p-component p-tag-warning"
Expand All @@ -111,7 +111,7 @@ exports[`Divider sevrity warning 1`] = `
</div>
`;

exports[`Divider value 1`] = `
exports[`Tag value 1`] = `
<div>
<span
class="p-tag p-component"
Expand Down

0 comments on commit 7c4474b

Please sign in to comment.