Fix tag picker and add test

Signed-off-by: Sarah Medeiros <smedeiros@wayfair.com>
This commit is contained in:
Sarah Medeiros
2022-12-15 15:55:42 -05:00
parent d4f85da71a
commit 5a42d71279
@@ -202,4 +202,33 @@ describe('<EntityTagPicker/>', () => {
tags: new EntityTagFilter(['tag2']),
});
});
it('removes tags from filters if there are none available', async () => {
const updateFilters = jest.fn();
const mockCatalogApiRefNoTags = {
getEntityFacets: async () => ({
facets: {
'metadata.tags': {},
},
}),
} as unknown as CatalogApi;
render(
<TestApiProvider apis={[[catalogApiRef, mockCatalogApiRefNoTags]]}>
<MockEntityListContextProvider
value={{
updateFilters,
queryParameters: { tags: ['tag1'] },
}}
>
<EntityTagPicker />
</MockEntityListContextProvider>
,
</TestApiProvider>,
);
await waitFor(() =>
expect(updateFilters).toHaveBeenLastCalledWith({
tags: undefined,
}),
);
});
});