fix: EntityNamespacePicker test

Signed-off-by: mario ma <mario.ma.node@gmail.com>
This commit is contained in:
mario ma
2024-06-18 19:54:41 +08:00
parent 847d1743a3
commit 582dfb5359
@@ -215,7 +215,7 @@ describe('<EntityNamespacePicker/>', () => {
}),
);
});
it('namespace picker is invisible if there are only 1 available option', async () => {
it('namespace picker is visible if there are only 1 available option', async () => {
const defaultNamespaces = ['default', 'default', 'default'];
const mockCatalogApiRefDefaultNamespace = {
getEntityFacets: async () => ({
@@ -236,6 +236,27 @@ describe('<EntityNamespacePicker/>', () => {
</MockEntityListContextProvider>
</TestApiProvider>,
);
await waitFor(() =>
expect(screen.queryByText('Namespace')).toBeInTheDocument(),
);
});
it('namespace picker is invisible if there is zero available option', async () => {
const mockCatalogApiRefDefaultNamespace = {
getEntityFacets: async () => ({
facets: {
'metadata.namespace': [],
},
}),
} as unknown as CatalogApi;
await renderInTestApp(
<TestApiProvider
apis={[[catalogApiRef, mockCatalogApiRefDefaultNamespace]]}
>
<MockEntityListContextProvider value={{}}>
<EntityNamespacePicker />
</MockEntityListContextProvider>
</TestApiProvider>,
);
await waitFor(() =>
expect(screen.queryByText('Namespace')).not.toBeInTheDocument(),
);