Skip to content

Commit

Permalink
test: DocumentFilterForm test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanFreestone committed Nov 19, 2024
1 parent e33aadb commit 2c608a9
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions lib/DocumentFilter/DocumentFilterForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ describe('DocumentFilterForm', () => {

test('filter form is not open', async () => {
const { queryByText } = renderComponent;
await waitFor(async () => {
await expect(queryByText('DocumentFilterFieldArray')).not.toBeInTheDocument();
await waitFor(() => {
expect(queryByText('DocumentFilterFieldArray')).not.toBeInTheDocument();
});
});

Expand All @@ -83,8 +83,8 @@ describe('DocumentFilterForm', () => {

test('filter form is open', async () => {
const { queryByText } = renderComponent;
await waitFor(async () => {
await expect(queryByText('DocumentFilterFieldArray')).toBeInTheDocument();
await waitFor(() => {
expect(queryByText('DocumentFilterFieldArray')).toBeInTheDocument();
});
});
});
Expand Down Expand Up @@ -128,12 +128,11 @@ describe('DocumentFilterForm', () => {
});
});

it('should open the document filter builder modal when the edit button is clicked', async () => {
it('should render the document filter builder modal', async () => {
const { getByText } = renderComponent;
await waitFor(async () => {
await Button('Edit document filters').click();
await waitFor(() => {
expect(getByText('Document filter builder')).toBeInTheDocument();
});
expect(getByText('Document filter builder')).toBeInTheDocument();
});

describe('making form dirty for submittal', () => {
Expand All @@ -150,7 +149,7 @@ describe('DocumentFilterForm', () => {
});
});

it('should display the cancel button when the filter form is open', async () => {
it('should display the cancel button', async () => {
await waitFor(async () => {
await Button('ui-test-implementor.cancel').exists();
});
Expand All @@ -165,8 +164,8 @@ describe('DocumentFilterForm', () => {

it('should close the filter form', async () => {
const { queryByText } = renderComponent;
await waitFor(async () => {
await expect(queryByText('DocumentFilterFieldArray')).not.toBeInTheDocument();
await waitFor(() => {
expect(queryByText('DocumentFilterFieldArray')).not.toBeInTheDocument();
});
});
});
Expand All @@ -181,15 +180,15 @@ describe('DocumentFilterForm', () => {
});

test(`submit handler acted as expected for ${filtersInfo}`, async () => {
await waitFor(async () => {
await expect(filterHandlers.state.mock.calls[0][0]).toEqual(expectedSubmit);
await waitFor(() => {
expect(filterHandlers.state.mock.calls[0][0]).toEqual(expectedSubmit);
});
});

test('filter form is not open', async () => {
const { queryByText } = renderComponent;
await waitFor(async () => {
await expect(queryByText('DocumentFilterFieldArray')).not.toBeInTheDocument();
await waitFor(() => {
expect(queryByText('DocumentFilterFieldArray')).not.toBeInTheDocument();
});
});
});
Expand Down

0 comments on commit 2c608a9

Please sign in to comment.