Adjust tests to use only text & test drawer visibility

Signed-off-by: Philipp Hugenroth <philipph@spotify.com>
This commit is contained in:
Philipp Hugenroth
2021-07-19 21:57:18 +02:00
parent ef4acd1be8
commit 8d6408d05c
2 changed files with 9 additions and 6 deletions
@@ -248,13 +248,17 @@ describe('CatalogPage', () => {
it('should wrap filter in drawer on smaller screens', async () => {
mockBreakpoint({ matches: true });
const { getByTestId } = await renderWrapped(<CatalogPage />);
expect(getByTestId('entity-filters-drawer')).toBeInTheDocument();
const { getAllByText } = await renderWrapped(<CatalogPage />);
const elems = getAllByText('Filters');
expect(elems[0]).toBeVisible();
expect(elems[1]).not.toBeVisible();
fireEvent.click(elems[0]);
expect(elems[1]).toBeVisible();
});
it('should wrap filter in grid on larger screens', async () => {
mockBreakpoint({ matches: false });
const { getByTestId } = await renderWrapped(<CatalogPage />);
expect(getByTestId('entity-filters-grid')).toBeInTheDocument();
const { queryAllByText } = await renderWrapped(<CatalogPage />);
expect(queryAllByText('Filters').length).toBe(0);
});
});
@@ -44,7 +44,6 @@ export const FilterContainer = ({ children }: PropsWithChildren<{}>) => {
Filters
</Button>
<Drawer
data-testid="entity-filters-drawer"
open={filterDrawerOpen}
onClose={() => setFilterDrawerOpen(false)}
anchor="left"
@@ -65,7 +64,7 @@ export const FilterContainer = ({ children }: PropsWithChildren<{}>) => {
</Drawer>
</>
) : (
<Grid data-testid="entity-filters-grid" item lg={2}>
<Grid item lg={2}>
{children}
</Grid>
);