catalog-react: added MockStarredEntitiesApi + usage
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -13,40 +13,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {
|
||||
renderInTestApp,
|
||||
TestApiProvider,
|
||||
MockStorageApi,
|
||||
} from '@backstage/test-utils';
|
||||
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
|
||||
import {
|
||||
starredEntitiesApiRef,
|
||||
MockStarredEntitiesApi,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { DefaultStarredEntitiesApi } from '@backstage/plugin-catalog';
|
||||
import React from 'react';
|
||||
import { Content } from './Content';
|
||||
|
||||
describe('StarredEntitiesContent', () => {
|
||||
it('should render list of tools', async () => {
|
||||
const mockStorageApi = MockStorageApi.create();
|
||||
await mockStorageApi
|
||||
.forBucket('starredEntities')
|
||||
.set('entityRefs', [
|
||||
'component:default/mock-starred-entity',
|
||||
'component:default/mock-starred-entity-2',
|
||||
]);
|
||||
const mockedApi = new MockStarredEntitiesApi();
|
||||
mockedApi.toggleStarred('component:default/mock-starred-entity');
|
||||
mockedApi.toggleStarred('component:default/mock-starred-entity-2');
|
||||
|
||||
const { getByText } = await renderInTestApp(
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
[
|
||||
starredEntitiesApiRef,
|
||||
new DefaultStarredEntitiesApi({
|
||||
storageApi: mockStorageApi,
|
||||
}),
|
||||
],
|
||||
]}
|
||||
>
|
||||
<TestApiProvider apis={[[starredEntitiesApiRef, mockedApi]]}>
|
||||
<Content />
|
||||
</TestApiProvider>,
|
||||
{
|
||||
|
||||
@@ -22,9 +22,9 @@ import {
|
||||
} from '@backstage/test-utils';
|
||||
import {
|
||||
starredEntitiesApiRef,
|
||||
MockStarredEntitiesApi,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { DefaultStarredEntitiesApi } from '@backstage/plugin-catalog';
|
||||
import { Grid } from '@material-ui/core';
|
||||
import React, { ComponentType } from 'react';
|
||||
|
||||
@@ -44,14 +44,7 @@ export default {
|
||||
(Story: ComponentType<{}>) =>
|
||||
wrapInTestApp(
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
[
|
||||
starredEntitiesApiRef,
|
||||
new DefaultStarredEntitiesApi({
|
||||
storageApi: mockStorageApi,
|
||||
}),
|
||||
],
|
||||
]}
|
||||
apis={[[starredEntitiesApiRef, new MockStarredEntitiesApi()]]}
|
||||
>
|
||||
<Story />
|
||||
</TestApiProvider>,
|
||||
|
||||
@@ -25,9 +25,9 @@ import { wrapInTestApp, TestApiProvider, MockStorageApi} from '@backstage/test-u
|
||||
import { Content, Page, InfoCard } from '@backstage/core-components';
|
||||
import {
|
||||
starredEntitiesApiRef,
|
||||
MockStarredEntitiesApi,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { DefaultStarredEntitiesApi } from '@backstage/plugin-catalog';
|
||||
import {
|
||||
HomePageSearchBar,
|
||||
SearchContextProvider,
|
||||
@@ -57,9 +57,7 @@ export default {
|
||||
apis={[
|
||||
[
|
||||
starredEntitiesApiRef,
|
||||
new DefaultStarredEntitiesApi({
|
||||
storageApi: mockStorageApi,
|
||||
}),
|
||||
new MockStarredEntitiesApi(),
|
||||
],
|
||||
[searchApiRef, { query: () => Promise.resolve({ results: [] }) }],
|
||||
]}
|
||||
|
||||
Reference in New Issue
Block a user