Skip to content

Commit

Permalink
Fix #3599: Tag Jest test (#3600)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Nov 9, 2022
1 parent 68563c3 commit bd34890
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 29 deletions.
25 changes: 11 additions & 14 deletions components/lib/divider/Divider.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import { Divider } from './Divider';

const snapshot = (props, name) => expect(render(<Divider {...props} />).container).toMatchSnapshot(name);
import { snapshot } from '../../test';

describe('Divider Snapshot', () => {
test('check snapshots', () => {
snapshot({}, 'default');
snapshot({ layout: 'horizontal', align: 'left' }, 'horizontal left');
snapshot({ layout: 'horizontal', align: 'right' }, 'horizontal right');
snapshot({ layout: 'horizontal', align: 'center' }, 'horizontal center');
snapshot({ layout: 'vertical', align: 'center' }, 'vertical center');
snapshot({ layout: 'vertical', align: 'top' }, 'vertical top');
snapshot({ layout: 'vertical', align: 'bottom' }, 'vertical bottom');
snapshot({ type: 'dashed' }, 'dashed');
snapshot({ type: 'dotted' }, 'dotted');
});
describe('Divider', () => {
snapshot(<Divider />, 'default');
snapshot(<Divider layout="horizontal" align="left" />, 'horizontal left');
snapshot(<Divider layout="horizontal" align="right" />, 'horizontal right');
snapshot(<Divider layout="horizontal" align="center" />, 'horizontal center');
snapshot(<Divider layout="vertical" align="center" />, 'vertical center');
snapshot(<Divider layout="vertical" align="top" />, 'vertical top');
snapshot(<Divider layout="vertical" align="bottom" />, 'vertical bottom');
snapshot(<Divider type="dashed" />, 'type dashed');
snapshot(<Divider type="dotted" />, 'type dotted');
});
30 changes: 15 additions & 15 deletions components/lib/divider/__snapshots__/Divider.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Divider Snapshot check snapshots: dashed 1`] = `
exports[`Divider default 1`] = `
<div>
<div
class="p-divider p-component p-divider-horizontal p-divider-dashed p-divider-left"
class="p-divider p-component p-divider-horizontal p-divider-solid p-divider-left"
role="separator"
>
<div
Expand All @@ -13,10 +13,10 @@ exports[`Divider Snapshot check snapshots: dashed 1`] = `
</div>
`;

exports[`Divider Snapshot check snapshots: default 1`] = `
exports[`Divider horizontal center 1`] = `
<div>
<div
class="p-divider p-component p-divider-horizontal p-divider-solid p-divider-left"
class="p-divider p-component p-divider-horizontal p-divider-solid p-divider-center"
role="separator"
>
<div
Expand All @@ -26,10 +26,10 @@ exports[`Divider Snapshot check snapshots: default 1`] = `
</div>
`;

exports[`Divider Snapshot check snapshots: dotted 1`] = `
exports[`Divider horizontal left 1`] = `
<div>
<div
class="p-divider p-component p-divider-horizontal p-divider-dotted p-divider-left"
class="p-divider p-component p-divider-horizontal p-divider-solid p-divider-left"
role="separator"
>
<div
Expand All @@ -39,10 +39,10 @@ exports[`Divider Snapshot check snapshots: dotted 1`] = `
</div>
`;

exports[`Divider Snapshot check snapshots: horizontal center 1`] = `
exports[`Divider horizontal right 1`] = `
<div>
<div
class="p-divider p-component p-divider-horizontal p-divider-solid p-divider-center"
class="p-divider p-component p-divider-horizontal p-divider-solid p-divider-right"
role="separator"
>
<div
Expand All @@ -52,10 +52,10 @@ exports[`Divider Snapshot check snapshots: horizontal center 1`] = `
</div>
`;

exports[`Divider Snapshot check snapshots: horizontal left 1`] = `
exports[`Divider type dashed 1`] = `
<div>
<div
class="p-divider p-component p-divider-horizontal p-divider-solid p-divider-left"
class="p-divider p-component p-divider-horizontal p-divider-dashed p-divider-left"
role="separator"
>
<div
Expand All @@ -65,10 +65,10 @@ exports[`Divider Snapshot check snapshots: horizontal left 1`] = `
</div>
`;

exports[`Divider Snapshot check snapshots: horizontal right 1`] = `
exports[`Divider type dotted 1`] = `
<div>
<div
class="p-divider p-component p-divider-horizontal p-divider-solid p-divider-right"
class="p-divider p-component p-divider-horizontal p-divider-dotted p-divider-left"
role="separator"
>
<div
Expand All @@ -78,7 +78,7 @@ exports[`Divider Snapshot check snapshots: horizontal right 1`] = `
</div>
`;

exports[`Divider Snapshot check snapshots: vertical bottom 1`] = `
exports[`Divider vertical bottom 1`] = `
<div>
<div
class="p-divider p-component p-divider-vertical p-divider-solid p-divider-bottom"
Expand All @@ -91,7 +91,7 @@ exports[`Divider Snapshot check snapshots: vertical bottom 1`] = `
</div>
`;

exports[`Divider Snapshot check snapshots: vertical center 1`] = `
exports[`Divider vertical center 1`] = `
<div>
<div
class="p-divider p-component p-divider-vertical p-divider-solid p-divider-center"
Expand All @@ -104,7 +104,7 @@ exports[`Divider Snapshot check snapshots: vertical center 1`] = `
</div>
`;

exports[`Divider Snapshot check snapshots: vertical top 1`] = `
exports[`Divider vertical top 1`] = `
<div>
<div
class="p-divider p-component p-divider-vertical p-divider-solid p-divider-top"
Expand Down
21 changes: 21 additions & 0 deletions components/lib/tag/Tag.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import '@testing-library/jest-dom';
import { Tag } from './Tag';

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

describe('Divider', () => {
snapshot(<Tag />, 'default');
snapshot(<Tag value={`jest`} />, 'value');
snapshot(<Tag severity="success" />, 'sevrity success');
snapshot(<Tag severity="info" />, 'sevrity info');
snapshot(<Tag severity="warning" />, 'sevrity warning');
snapshot(<Tag severity="danger" />, 'sevrity danger');
snapshot(<Tag rounded />, 'rounded');
snapshot(<Tag icon="pi pi-check" />, 'icon');
snapshot(
<Tag>
<div>hello</div>
</Tag>,
'children'
);
});
127 changes: 127 additions & 0 deletions components/lib/tag/__snapshots__/Tag.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

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

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

exports[`Divider icon 1`] = `
<div>
<span
class="p-tag p-component"
>
<span
class="p-tag-icon pi pi-check"
/>
<span
class="p-tag-value"
/>
<span />
</span>
</div>
`;

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

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

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

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

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

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

0 comments on commit bd34890

Please sign in to comment.