Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 27, 2023
1 parent 394f2b6 commit 01b42e0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 21 deletions.
5 changes: 5 additions & 0 deletions components/lib/blockui/__snapshots__/BlockUI.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ exports[`BlockUI block and unblock panel events: blocked-event 1`] = `
>
<div
class="p-panel p-component"
id="pr_id_3"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -69,6 +70,7 @@ exports[`BlockUI block and unblock panel events: unblocked-event 1`] = `
>
<div
class="p-panel p-component"
id="pr_id_3"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -118,6 +120,7 @@ exports[`BlockUI block panel 1`] = `
>
<div
class="p-panel p-component"
id="pr_id_1"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -153,6 +156,7 @@ exports[`BlockUI container style and className 1`] = `
>
<div
class="p-panel p-component"
id="pr_id_4"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -187,6 +191,7 @@ exports[`BlockUI unblock panel 1`] = `
>
<div
class="p-panel p-component"
id="pr_id_2"
>
<div
aria-hidden="false"
Expand Down
30 changes: 18 additions & 12 deletions components/lib/fieldset/Fieldset.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import { render, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { snapshot } from '../../test';
import { Fieldset } from './Fieldset';
Expand All @@ -25,11 +25,13 @@ describe('Fieldset', () => {
expect(container).toMatchSnapshot('toggleable-open');

// Act
await userEvent.click(legend);
userEvent.click(legend);

// Assert
expect(toggleOn).toHaveBeenCalledTimes(1);
expect(container).toMatchSnapshot('toggleable-closed');
await waitFor(() => {
expect(toggleOn).toHaveBeenCalledTimes(1);
expect(container).toMatchSnapshot('toggleable-closed');
});
});
test('when Fieldset is toggleable it must expand and collapse', async () => {
// Arrange
Expand All @@ -45,19 +47,23 @@ describe('Fieldset', () => {
expect(container).toMatchSnapshot('expandable-open');

// Act
await userEvent.click(legend);
userEvent.click(legend);

// Assert
expect(expandOn).toHaveBeenCalledTimes(0);
expect(collapseOn).toHaveBeenCalledTimes(1);
expect(container).toMatchSnapshot('expandable-closed');
await waitFor(() => {
expect(expandOn).toHaveBeenCalledTimes(0);
expect(collapseOn).toHaveBeenCalledTimes(1);
expect(container).toMatchSnapshot('expandable-closed');
});

// Act
await userEvent.click(legend);
userEvent.click(legend);

// Assert
expect(expandOn).toHaveBeenCalledTimes(1);
expect(collapseOn).toHaveBeenCalledTimes(1);
expect(container).toMatchSnapshot('expandable-open');
await waitFor(() => {
expect(expandOn).toHaveBeenCalledTimes(1);
expect(collapseOn).toHaveBeenCalledTimes(1);
expect(container).toMatchSnapshot('expandable-open');
});
});
});
22 changes: 13 additions & 9 deletions components/lib/panel/Panel.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import { render, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { snapshot } from '../../test';
import { Panel } from './Panel';
Expand Down Expand Up @@ -66,19 +66,23 @@ describe('Panel', () => {
expect(container).toMatchSnapshot('expandable-open');

// Act
await userEvent.click(toggler);
userEvent.click(toggler);

// Assert
expect(expandOn).toHaveBeenCalledTimes(0);
expect(collapseOn).toHaveBeenCalledTimes(1);
expect(container).toMatchSnapshot('expandable-closed');
await waitFor(() => {
expect(expandOn).toHaveBeenCalledTimes(0);
expect(collapseOn).toHaveBeenCalledTimes(1);
expect(container).toMatchSnapshot('expandable-closed');
});

// Act
await userEvent.click(toggler);
userEvent.click(toggler);

// Assert
expect(expandOn).toHaveBeenCalledTimes(1);
expect(collapseOn).toHaveBeenCalledTimes(1);
expect(container).toMatchSnapshot('expandable-open');
await waitFor(() => {
expect(expandOn).toHaveBeenCalledTimes(1);
expect(collapseOn).toHaveBeenCalledTimes(1);
expect(container).toMatchSnapshot('expandable-open');
});
});
});
7 changes: 7 additions & 0 deletions components/lib/panel/__snapshots__/Panel.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Panel default 1`] = `
<div>
<div
class="p-panel p-component"
id="pr_id_1"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -60,6 +61,7 @@ exports[`Panel headerTemplate 1`] = `
<div>
<div
class="p-panel p-component p-panel-toggleable"
id="pr_id_2"
>
<div
class="p-panel-header justify-content-start"
Expand Down Expand Up @@ -97,6 +99,7 @@ exports[`Panel when Panel is toggleable it must expand and collapse: expandable-
<div>
<div
class="p-panel p-component p-panel-toggleable"
id="pr_id_4"
>
<div
class="p-panel-header"
Expand Down Expand Up @@ -172,6 +175,7 @@ exports[`Panel when Panel is toggleable it must expand and collapse: expandable-
<div>
<div
class="p-panel p-component p-panel-toggleable"
id="pr_id_4"
>
<div
class="p-panel-header"
Expand Down Expand Up @@ -231,6 +235,7 @@ exports[`Panel when Panel is toggleable it must expand and collapse: expandable-
<div>
<div
class="p-panel p-component p-panel-toggleable"
id="pr_id_4"
>
<div
class="p-panel-header"
Expand Down Expand Up @@ -291,6 +296,7 @@ exports[`Panel when Panel is toggleable it will toggle when clicked: toggleable-
<div>
<div
class="p-panel p-component p-panel-toggleable"
id="pr_id_3"
>
<div
class="p-panel-header"
Expand Down Expand Up @@ -350,6 +356,7 @@ exports[`Panel when Panel is toggleable it will toggle when clicked: toggleable-
<div>
<div
class="p-panel p-component p-panel-toggleable"
id="pr_id_3"
>
<div
class="p-panel-header"
Expand Down

0 comments on commit 01b42e0

Please sign in to comment.