added a case when there is 1 option available

Signed-off-by: David An <a-daan@expediagroup.com>
This commit is contained in:
David An
2023-03-29 16:07:06 -06:00
parent 235950ed30
commit 8232ad4144
@@ -194,7 +194,7 @@ describe('<EntityNamespacePicker/>', () => {
const mockCatalogApiRefNoNamespace = {
getEntityFacets: async () => ({
facets: {
'metadata.tags': {},
'metadata.namespace': {},
},
}),
} as unknown as CatalogApi;
@@ -217,4 +217,29 @@ describe('<EntityNamespacePicker/>', () => {
}),
);
});
it('namespace picker is invisible if there are only 1 available option', async () => {
const defaultNamespaces = ['default', 'default', 'default'];
const mockCatalogApiRefDefaultNamespace = {
getEntityFacets: async () => ({
facets: {
'metadata.namespace': defaultNamespaces.map((value, idx) => ({
value,
count: idx,
})),
},
}),
} as unknown as CatalogApi;
render(
<TestApiProvider
apis={[[catalogApiRef, mockCatalogApiRefDefaultNamespace]]}
>
<MockEntityListContextProvider value={{}}>
<EntityNamespacePicker />
</MockEntityListContextProvider>
</TestApiProvider>,
);
await waitFor(() =>
expect(screen.queryByText('Namespace')).not.toBeInTheDocument(),
);
});
});