Skip to content

Commit

Permalink
test: add coverage to missing lines
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoPedroPP committed Nov 1, 2024
1 parent 8a066aa commit 7109335
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/components/Secrets/__tests___/secret-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@testing-library/jest-dom';
import { k8sCreateResource } from '@openshift/dynamic-plugin-sdk-utils';
import { k8sCreateResource, k8sGetResource } from '@openshift/dynamic-plugin-sdk-utils';
import {
AddSecretFormValues,
ImagePullSecretType,
Expand Down Expand Up @@ -27,12 +27,14 @@ import {
typeToLabel,
getSecretRowLabels,
getSecretTypetoLabel,
getSecretResource,
} from '../utils/secret-utils';
import { sampleImagePullSecret, sampleOpaqueSecret, sampleRemoteSecrets } from './secret-data';

jest.mock('@openshift/dynamic-plugin-sdk-utils');

const createResourceMock = k8sCreateResource as jest.Mock;
const getSecretResourceMock = k8sGetResource as jest.Mock;

describe('getSupportedPartnerTaskKeyValuePairs', () => {
it('should return empty array ', () => {
Expand Down Expand Up @@ -67,6 +69,20 @@ describe('getSupportedPartnerTaskSecrets', () => {
});
});

describe('getSecretResource', () => {
it('should retrive secrets from a namespace', () => {
getSecretResource('test-ns');

expect(getSecretResourceMock).toHaveBeenCalledWith(
expect.objectContaining({
queryOptions: expect.objectContaining({
ns: 'test-ns',
}),
}),
);
});
});

describe('createSecretResource', () => {
it('should create Opaque secret resource', () => {
createSecretResource(sampleOpaqueSecret, 'test-ns', false);
Expand Down

0 comments on commit 7109335

Please sign in to comment.