Skip to content

Commit

Permalink
Update Jest test for loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
kangaree committed Aug 12, 2024
1 parent 47099c4 commit a4adfb8
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion playbook/app/pb_kits/playbook/pb_dialog/dialog.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useState} from 'react'
import { render, cleanup, waitFor, fireEvent } from "../utilities/test-utils";
import { render, cleanup, waitFor, fireEvent, screen } from "../utilities/test-utils";
import { Dialog, Button } from 'playbook-ui'

const text="Hello Body Text, Nice to meet ya."
Expand Down Expand Up @@ -110,3 +110,22 @@ test("renders the right placement dialog", async () => {
cleanup()
});

test('renders loading dialog with disabled buttons', async () => {

const { queryByText } = render(<DialogTest />);

fireEvent.click(queryByText('Open Dialog'));

await waitFor(() => expect(queryByText("Okay")).toHaveTextContent(confirmButton));
await waitFor(() => expect(queryByText("Cancel Button")).toHaveTextContent(cancelButton));

fireEvent.click(queryByText('Okay'));

const loadingIconDiv = document.querySelector('.loading-icon');
expect(loadingIconDiv).toBeInTheDocument();

const cancelBtn = screen.getByRole('button', { name: cancelButton });
expect(cancelBtn).toBeDisabled();

cleanup()
})

0 comments on commit a4adfb8

Please sign in to comment.