Add a better unit test for headers validation

Signed-off-by: armandocomellas1 <cgarmando@google.com>
This commit is contained in:
armandocomellas1
2024-02-16 13:48:39 -06:00
parent 984d5084d1
commit 3e57ca7b65
+27 -3
View File
@@ -15,13 +15,37 @@
*/
import { gcpProjectsPlugin } from './plugin';
import * as container from '@backstage/plugin-gcp-projects';
import { GcpClient } from './api';
import { OAuthApi } from '@backstage/core-plugin-api';
import packageinfo from '../package.json';
describe('gcp-projects', () => {
let sut: GcpClient;
let googleAuthApi: OAuthApi;
beforeEach(() => {
sut = new GcpClient(googleAuthApi);
});
it('should export plugin', () => {
expect(gcpProjectsPlugin).toBeDefined();
});
it('should exist the GcpClient class', () => {
expect(container.GcpClient).toBeDefined();
it('should exist the GcpClient class', async () => {
const response: any = {
headers: {
Accept: '*/*',
'X-Goog-Api-Client': `backstage/cloudbuild/${packageinfo.version}`,
},
};
jest.spyOn(sut, 'listProjects').mockImplementation((): any => {
return response;
});
expect(response).toStrictEqual({
headers: {
Accept: '*/*',
'X-Goog-Api-Client': `backstage/cloudbuild/${packageinfo.version}`,
},
});
});
});