fix test
This commit is contained in:
committed by
moustafab
parent
a2f791836e
commit
75d63ee0a0
+23
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
import { handleGetKubernetesObjectsForService } from './getKubernetesObjectsForServiceHandler';
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { ComponentEntityV1alpha1 } from '@backstage/catalog-model';
|
||||
import { ClusterDetails } from '..';
|
||||
|
||||
const TEST_SERVICE_ID = 'my-service';
|
||||
@@ -24,6 +25,26 @@ const fetchObjectsForService = jest.fn();
|
||||
|
||||
const getClustersByServiceId = jest.fn();
|
||||
|
||||
const goodEntity: ComponentEntityV1alpha1 = <ComponentEntityV1alpha1>{
|
||||
apiVersion: 'backstage.io/v1beta1',
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
name: 'test-component',
|
||||
},
|
||||
spec: {
|
||||
type: 'service',
|
||||
lifecycle: 'production',
|
||||
owner: 'joe',
|
||||
kubernetes: {
|
||||
selector: {
|
||||
matchLabels: {
|
||||
'backstage.io/test-label': 'test-component',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const mockFetch = (mock: jest.Mock) => {
|
||||
mock.mockImplementation((serviceId: string, clusterDetails: ClusterDetails) =>
|
||||
Promise.resolve({
|
||||
@@ -90,7 +111,7 @@ describe('handleGetKubernetesObjectsForService', () => {
|
||||
getClustersByServiceId,
|
||||
},
|
||||
getVoidLogger(),
|
||||
{},
|
||||
{ entity: goodEntity },
|
||||
);
|
||||
|
||||
expect(getClustersByServiceId.mock.calls.length).toBe(1);
|
||||
@@ -165,11 +186,11 @@ describe('handleGetKubernetesObjectsForService', () => {
|
||||
},
|
||||
getVoidLogger(),
|
||||
{
|
||||
entity: goodEntity,
|
||||
auth: {
|
||||
google: 'google_token_123',
|
||||
},
|
||||
},
|
||||
'',
|
||||
);
|
||||
|
||||
expect(getClustersByServiceId.mock.calls.length).toBe(1);
|
||||
|
||||
Reference in New Issue
Block a user