diff --git a/src/taxonomy/taxonomy-card/TaxonomyCard.test.jsx b/src/taxonomy/taxonomy-card/TaxonomyCard.test.jsx index 1b682828b2..6cbbf4c630 100644 --- a/src/taxonomy/taxonomy-card/TaxonomyCard.test.jsx +++ b/src/taxonomy/taxonomy-card/TaxonomyCard.test.jsx @@ -63,8 +63,8 @@ describe('', async () => { }); it('not show the system-defined badge with normal taxonomies', () => { - const { getByText } = render(); - expect(() => getByText('System-level')).toThrow(); + const { queryByText } = render(); + expect(queryByText('System-level')).not.toBeInTheDocument(); }); it('shows the system-defined badge with system taxonomies', () => { @@ -78,8 +78,8 @@ describe('', async () => { }); it('not show org count with taxonomies without orgs', () => { - const { getByText } = render(); - expect(() => getByText('Assigned to 0 orgs')).toThrow(); + const { queryByText } = render(); + expect(queryByText('Assigned to 0 orgs')).not.toBeInTheDocument(); }); it('shows org count with taxonomies with orgs', () => { diff --git a/src/taxonomy/taxonomy-menu/TaxonomyMenu.test.jsx b/src/taxonomy/taxonomy-menu/TaxonomyMenu.test.jsx index f441729b3b..54de7edca5 100644 --- a/src/taxonomy/taxonomy-menu/TaxonomyMenu.test.jsx +++ b/src/taxonomy/taxonomy-menu/TaxonomyMenu.test.jsx @@ -92,10 +92,10 @@ describe('', async () => { [true, false].forEach((iconMenu) => { test('should open and close menu on button click', () => { - const { getByTestId } = render(); + const { getByTestId, queryByTestId } = render(); // Menu closed/doesn't exist yet - expect(() => getByTestId('taxonomy-menu')).toThrow(); + expect(queryByTestId('taxonomy-menu')).not.toBeInTheDocument(); // Click on the menu button to open fireEvent.click(getByTestId('taxonomy-menu-button')); @@ -116,10 +116,10 @@ describe('', async () => { }); test('doesnt show systemDefined taxonomies disabled menus', () => { - const { getByTestId } = render(); + const { getByTestId, queryByTestId } = render(); // Menu closed/doesn't exist yet - expect(() => getByTestId('taxonomy-menu')).toThrow(); + expect(queryByTestId('taxonomy-menu')).not.toBeInTheDocument(); // Click on the menu button to open fireEvent.click(getByTestId('taxonomy-menu-button')); @@ -128,14 +128,14 @@ describe('', async () => { expect(getByTestId('taxonomy-menu')).toBeVisible(); // Check that the import menu is not show - expect(() => getByTestId('taxonomy-menu-import')).toThrow(); + expect(queryByTestId('taxonomy-menu-import')).not.toBeInTheDocument(); }); test('doesnt show freeText taxonomies disabled menus', () => { - const { getByTestId } = render(); + const { getByTestId, queryByTestId } = render(); // Menu closed/doesn't exist yet - expect(() => getByTestId('taxonomy-menu')).toThrow(); + expect(queryByTestId('taxonomy-menu')).not.toBeInTheDocument(); // Click on the menu button to open fireEvent.click(getByTestId('taxonomy-menu-button')); @@ -144,14 +144,14 @@ describe('', async () => { expect(getByTestId('taxonomy-menu')).toBeVisible(); // Check that the import menu is not show - expect(() => getByTestId('taxonomy-menu-import')).toThrow(); + expect(queryByTestId('taxonomy-menu-import')).not.toBeInTheDocument(); }); test('should open export modal on export menu click', () => { - const { getByTestId, getByText } = render(); + const { getByTestId, getByText, queryByText } = render(); // Modal closed - expect(() => getByText('Select format to export')).toThrow(); + expect(queryByText('Select format to export')).not.toBeInTheDocument(); // Click on export menu fireEvent.click(getByTestId('taxonomy-menu-button')); @@ -164,7 +164,7 @@ describe('', async () => { fireEvent.click(getByText('Cancel')); // Modal closed - expect(() => getByText('Select format to export')).toThrow(); + expect(queryByText('Select format to export')).not.toBeInTheDocument(); }); test('should call import tags when menu click', () => { @@ -178,7 +178,7 @@ describe('', async () => { }); test('should export a taxonomy', () => { - const { getByTestId, getByText } = render(); + const { getByTestId, getByText, queryByText } = render(); // Click on export menu fireEvent.click(getByTestId('taxonomy-menu-button')); @@ -189,15 +189,15 @@ describe('', async () => { fireEvent.click(getByTestId('export-button-1')); // Modal closed - expect(() => getByText('Select format to export')).toThrow(); + expect(queryByText('Select format to export')).not.toBeInTheDocument(); expect(getTaxonomyExportFile).toHaveBeenCalledWith(taxonomyId, 'json'); }); test('should open delete dialog on delete menu click', () => { - const { getByTestId, getByText } = render(); + const { getByTestId, getByText, queryByText } = render(); // Modal closed - expect(() => getByText(`Delete "${taxonomyName}"`)).toThrow(); + expect(queryByText(`Delete "${taxonomyName}"`)).not.toBeInTheDocument(); // Click on delete menu fireEvent.click(getByTestId('taxonomy-menu-button')); @@ -210,11 +210,11 @@ describe('', async () => { fireEvent.click(getByText('Cancel')); // Modal closed - expect(() => getByText(`Delete "${taxonomyName}"`)).toThrow(); + expect(queryByText(`Delete "${taxonomyName}"`)).not.toBeInTheDocument(); }); test('should delete a taxonomy', async () => { - const { getByTestId, getByText, getByLabelText } = render(); + const { getByTestId, getByText, getByLabelText, queryByText } = render(); // Click on delete menu fireEvent.click(getByTestId('taxonomy-menu-button')); @@ -238,7 +238,7 @@ describe('', async () => { fireEvent.click(deleteButton); // Modal closed - expect(() => getByText(`Delete "${taxonomyName}"`)).toThrow(); + expect(queryByText(`Delete "${taxonomyName}"`)).not.toBeInTheDocument(); await waitFor(async () => { expect(deleteTaxonomy).toBeCalledTimes(1);