From ffcf5fede9c5f37ef7abdc992948f311974740ef Mon Sep 17 00:00:00 2001 From: Joao Pedro Poloni Ponce Date: Mon, 28 Oct 2024 15:55:42 -0300 Subject: [PATCH] test: add missging tests --- .../ImportForm/__tests__/submit-utils.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/ImportForm/__tests__/submit-utils.spec.ts b/src/components/ImportForm/__tests__/submit-utils.spec.ts index 8e1acc695..4f0a7d90a 100644 --- a/src/components/ImportForm/__tests__/submit-utils.spec.ts +++ b/src/components/ImportForm/__tests__/submit-utils.spec.ts @@ -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'); @@ -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 () => { @@ -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); @@ -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); }); @@ -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); });