Skip to content

Commit

Permalink
test: add missging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoPedroPP committed Oct 28, 2024
1 parent 1e42303 commit ffcf5fe
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/ImportForm/__tests__/submit-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
createImageRepository,
} from '../../../utils/create-utils';
import { createIntegrationTest } from '../../IntegrationTest/IntegrationTestForm/utils/create-utils';
import { getSecretResource } from '../../Secrets/utils/secret-utils';
import { createResources } from '../submit-utils';

jest.mock('@redhat-cloud-services/frontend-components-notifications/redux');
Expand All @@ -19,10 +20,16 @@ jest.mock('../../IntegrationTest/IntegrationTestForm/utils/create-utils', () =>
createIntegrationTest: jest.fn(),
}));

jest.mock('../../Secrets/utils/secret-utils', () => ({
...(jest.requireActual('../../Secrets/utils/secret-utils') as object),
getSecretResource: jest.fn(),
}));

const createApplicationMock = createApplication as jest.Mock;
const createComponentMock = createComponent as jest.Mock;
const createIntegrationTestMock = createIntegrationTest as jest.Mock;
const createImageRepositoryMock = createImageRepository as jest.Mock;
const getSecretResourceMock = getSecretResource as jest.Mock;

describe('Submit Utils: createResources', () => {
it('should create application and components', async () => {
Expand All @@ -46,6 +53,7 @@ describe('Submit Utils: createResources', () => {
'test-ws',
'url.bombino',
);
expect(getSecretResourceMock).toHaveBeenCalledTimes(1);
expect(createApplicationMock).toHaveBeenCalledTimes(2);
expect(createIntegrationTestMock).toHaveBeenCalledTimes(2);
expect(createComponentMock).toHaveBeenCalledTimes(2);
Expand Down Expand Up @@ -76,6 +84,7 @@ describe('Submit Utils: createResources', () => {
expect(createApplicationMock).toHaveBeenCalledTimes(2);
expect(createIntegrationTestMock).toHaveBeenCalledTimes(2);
expect(createComponentMock).toHaveBeenCalledTimes(0);
expect(getSecretResourceMock).toHaveBeenCalledTimes(0);
expect(createImageRepositoryMock).toHaveBeenCalledTimes(0);
});

Expand All @@ -102,6 +111,7 @@ describe('Submit Utils: createResources', () => {
);
expect(createApplicationMock).toHaveBeenCalledTimes(0);
expect(createIntegrationTestMock).toHaveBeenCalledTimes(0);
expect(getSecretResourceMock).toHaveBeenCalledTimes(1);
expect(createComponentMock).toHaveBeenCalledTimes(2);
expect(createImageRepositoryMock).toHaveBeenCalledTimes(2);
});
Expand Down

0 comments on commit ffcf5fe

Please sign in to comment.