message: add unit test for catalogClusterLocator
diff: @@ -18,8 +18,6 @@ import '@backstage/backend-common';
  import { CatalogClusterLocator } from './CatalogClusterLocator';
  import { CatalogApi } from '@backstage/catalog-client';
  -describe('CatalogClusterLocator', () => {
  - it('empty clusters returns empty cluster details', async () => {
  const mockCatalogApi = {
  getEntityByRef: jest.fn(),
  getEntities: async () => ({
  @@ -32,6 +30,11 @@ describe('CatalogClusterLocator', () => {
  'kubernetes.io/api-server': 'https://apiserver.com',
  'kubernetes.io/api-server-certificate-authority': 'caData',
  'kubernetes.io/auth-provider': 'aws',
  + 'kubernetes.io/oidc-token-provider': 'google',
  + 'kubernetes.io/skip-metrics-lookup': 'true',
  + 'kubernetes.io/skip-tls-verify': 'true',
  + 'kubernetes.io/dashboard-url': 'my-url',
  + 'kubernetes.io/dashboard-app': 'my-app',
  },
  name: 'owned',
  namespace: 'default',
  @@ -39,18 +42,42 @@ describe('CatalogClusterLocator', () => {
  },
  ],
  }),
  +} as unknown as CatalogApi;
  +
  +describe('CatalogClusterLocator', () => {
  + it('returns empty cluster details when the cluster is empty', async () => {
  + const emptyMockCatalogApi = {
  + getEntityByRef: jest.fn(),
  + getEntities: async () => ({
  + items: [],
  + }),
  } as Partial<CatalogApi> as CatalogApi;
  - const sut = CatalogClusterLocator.fromConfig(mockCatalogApi);
  + const clusterSupplier =
  + CatalogClusterLocator.fromConfig(emptyMockCatalogApi);
  +
  + const result = await clusterSupplier.getClusters();
  +
  + expect(result).toHaveLength(0);
  + expect(result).toStrictEqual([]);
  + });
  +
  + it('returns the cluster details provided by annotations', async () => {
  + const clusterSupplier = CatalogClusterLocator.fromConfig(mockCatalogApi);
  - const result = await sut.getClusters();
  + const result = await clusterSupplier.getClusters();
  expect(result).toHaveLength(1);
  - expect(result[0]).toMatchObject({
  + expect(result[0]).toStrictEqual({
  name: 'owned',
  url: 'https://apiserver.com',
  caData: 'caData',
  authProvider: 'aws',
  + oidcTokenProvider: 'google',
  + skipMetricsLookup: true,
  + skipTLSVerify: true,
  + dashboardUrl: 'my-url',
  + dashboardApp: 'my-app',
  });
  });
  });
  