Skip to content

Commit

Permalink
Fix #3601: Avatar/AvatarGroup Jest tests (#3602)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Nov 9, 2022
1 parent bd34890 commit c718d79
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 26 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'
);
});
48 changes: 24 additions & 24 deletions components/lib/tag/__snapshots__/Tag.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Divider children 1`] = `
exports[`Tag default 1`] = `
<div>
<span
class="p-tag p-component"
>
<span
class="p-tag-value"
/>
<span>
<div>
hello
</div>
</span>
<span />
</span>
</div>
`;

exports[`Divider default 1`] = `
exports[`Tag icon 1`] = `
<div>
<span
class="p-tag p-component"
>
<span
class="p-tag-icon pi pi-check"
/>
<span
class="p-tag-value"
/>
Expand All @@ -30,14 +29,11 @@ exports[`Divider default 1`] = `
</div>
`;

exports[`Divider icon 1`] = `
exports[`Tag rounded 1`] = `
<div>
<span
class="p-tag p-component"
class="p-tag p-component p-tag-rounded"
>
<span
class="p-tag-icon pi pi-check"
/>
<span
class="p-tag-value"
/>
Expand All @@ -46,10 +42,10 @@ exports[`Divider icon 1`] = `
</div>
`;

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

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

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

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

exports[`Divider sevrity warning 1`] = `
exports[`Tag templating 1`] = `
<div>
<span
class="p-tag p-component p-tag-warning"
class="p-tag p-component"
>
<span
class="p-tag-value"
/>
<span />
<span>
<div>
hello
</div>
</span>
</span>
</div>
`;

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

0 comments on commit c718d79

Please sign in to comment.