diff options
Diffstat (limited to 'spec/frontend/packages_and_registries/infrastructure_registry/components/list')
2 files changed, 53 insertions, 78 deletions
diff --git a/spec/frontend/packages_and_registries/infrastructure_registry/components/list/components/__snapshots__/packages_list_app_spec.js.snap b/spec/frontend/packages_and_registries/infrastructure_registry/components/list/components/__snapshots__/packages_list_app_spec.js.snap index d82af8f9e63..a33528d2d91 100644 --- a/spec/frontend/packages_and_registries/infrastructure_registry/components/list/components/__snapshots__/packages_list_app_spec.js.snap +++ b/spec/frontend/packages_and_registries/infrastructure_registry/components/list/components/__snapshots__/packages_list_app_spec.js.snap @@ -21,7 +21,7 @@ exports[`packages_list_app renders 1`] = ` > <img alt="" - class="gl-max-w-full" + class="gl-max-w-full gl-dark-invert-keep-hue" role="img" src="helpSvg" /> diff --git a/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js b/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js index 3fbfe1060dc..d596f2dae33 100644 --- a/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js +++ b/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js @@ -32,8 +32,8 @@ describe('Actions Package list store', () => { }; const filter = []; - it('should fetch the project packages list when isGroupPage is false', (done) => { - testAction( + it('should fetch the project packages list when isGroupPage is false', async () => { + await testAction( actions.requestPackagesList, undefined, { config: { isGroupPage: false, resourceId: 1 }, sorting, filter }, @@ -43,17 +43,14 @@ describe('Actions Package list store', () => { { type: 'receivePackagesListSuccess', payload: { data: 'foo', headers } }, { type: 'setLoading', payload: false }, ], - () => { - expect(Api.projectPackages).toHaveBeenCalledWith(1, { - params: { page: 1, per_page: 20, sort: sorting.sort, order_by: sorting.orderBy }, - }); - done(); - }, ); + expect(Api.projectPackages).toHaveBeenCalledWith(1, { + params: { page: 1, per_page: 20, sort: sorting.sort, order_by: sorting.orderBy }, + }); }); - it('should fetch the group packages list when isGroupPage is true', (done) => { - testAction( + it('should fetch the group packages list when isGroupPage is true', async () => { + await testAction( actions.requestPackagesList, undefined, { config: { isGroupPage: true, resourceId: 2 }, sorting, filter }, @@ -63,19 +60,16 @@ describe('Actions Package list store', () => { { type: 'receivePackagesListSuccess', payload: { data: 'baz', headers } }, { type: 'setLoading', payload: false }, ], - () => { - expect(Api.groupPackages).toHaveBeenCalledWith(2, { - params: { page: 1, per_page: 20, sort: sorting.sort, order_by: sorting.orderBy }, - }); - done(); - }, ); + expect(Api.groupPackages).toHaveBeenCalledWith(2, { + params: { page: 1, per_page: 20, sort: sorting.sort, order_by: sorting.orderBy }, + }); }); - it('should fetch packages of a certain type when a filter with a type is present', (done) => { + it('should fetch packages of a certain type when a filter with a type is present', async () => { const packageType = 'maven'; - testAction( + await testAction( actions.requestPackagesList, undefined, { @@ -89,24 +83,21 @@ describe('Actions Package list store', () => { { type: 'receivePackagesListSuccess', payload: { data: 'foo', headers } }, { type: 'setLoading', payload: false }, ], - () => { - expect(Api.projectPackages).toHaveBeenCalledWith(1, { - params: { - page: 1, - per_page: 20, - sort: sorting.sort, - order_by: sorting.orderBy, - package_type: packageType, - }, - }); - done(); - }, ); + expect(Api.projectPackages).toHaveBeenCalledWith(1, { + params: { + page: 1, + per_page: 20, + sort: sorting.sort, + order_by: sorting.orderBy, + package_type: packageType, + }, + }); }); - it('should create flash on API error', (done) => { + it('should create flash on API error', async () => { Api.projectPackages = jest.fn().mockRejectedValue(); - testAction( + await testAction( actions.requestPackagesList, undefined, { config: { isGroupPage: false, resourceId: 2 }, sorting, filter }, @@ -115,15 +106,12 @@ describe('Actions Package list store', () => { { type: 'setLoading', payload: true }, { type: 'setLoading', payload: false }, ], - () => { - expect(createFlash).toHaveBeenCalled(); - done(); - }, ); + expect(createFlash).toHaveBeenCalled(); }); - it('should force the terraform_module type when forceTerraform is true', (done) => { - testAction( + it('should force the terraform_module type when forceTerraform is true', async () => { + await testAction( actions.requestPackagesList, undefined, { config: { isGroupPage: false, resourceId: 1, forceTerraform: true }, sorting, filter }, @@ -133,27 +121,24 @@ describe('Actions Package list store', () => { { type: 'receivePackagesListSuccess', payload: { data: 'foo', headers } }, { type: 'setLoading', payload: false }, ], - () => { - expect(Api.projectPackages).toHaveBeenCalledWith(1, { - params: { - page: 1, - per_page: 20, - sort: sorting.sort, - order_by: sorting.orderBy, - package_type: 'terraform_module', - }, - }); - done(); - }, ); + expect(Api.projectPackages).toHaveBeenCalledWith(1, { + params: { + page: 1, + per_page: 20, + sort: sorting.sort, + order_by: sorting.orderBy, + package_type: 'terraform_module', + }, + }); }); }); describe('receivePackagesListSuccess', () => { - it('should set received packages', (done) => { + it('should set received packages', () => { const data = 'foo'; - testAction( + return testAction( actions.receivePackagesListSuccess, { data, headers }, null, @@ -162,33 +147,30 @@ describe('Actions Package list store', () => { { type: types.SET_PAGINATION, payload: headers }, ], [], - done, ); }); }); describe('setInitialState', () => { - it('should commit setInitialState', (done) => { - testAction( + it('should commit setInitialState', () => { + return testAction( actions.setInitialState, '1', null, [{ type: types.SET_INITIAL_STATE, payload: '1' }], [], - done, ); }); }); describe('setLoading', () => { - it('should commit set main loading', (done) => { - testAction( + it('should commit set main loading', () => { + return testAction( actions.setLoading, true, null, [{ type: types.SET_MAIN_LOADING, payload: true }], [], - done, ); }); }); @@ -199,11 +181,11 @@ describe('Actions Package list store', () => { delete_api_path: 'foo', }, }; - it('should perform a delete operation on _links.delete_api_path', (done) => { + it('should perform a delete operation on _links.delete_api_path', () => { mock.onDelete(payload._links.delete_api_path).replyOnce(200); Api.projectPackages = jest.fn().mockResolvedValue({ data: 'foo' }); - testAction( + return testAction( actions.requestDeletePackage, payload, { pagination: { page: 1 } }, @@ -212,13 +194,12 @@ describe('Actions Package list store', () => { { type: 'setLoading', payload: true }, { type: 'requestPackagesList', payload: { page: 1 } }, ], - done, ); }); - it('should stop the loading and call create flash on api error', (done) => { + it('should stop the loading and call create flash on api error', async () => { mock.onDelete(payload._links.delete_api_path).replyOnce(400); - testAction( + await testAction( actions.requestDeletePackage, payload, null, @@ -227,50 +208,44 @@ describe('Actions Package list store', () => { { type: 'setLoading', payload: true }, { type: 'setLoading', payload: false }, ], - () => { - expect(createFlash).toHaveBeenCalled(); - done(); - }, ); + expect(createFlash).toHaveBeenCalled(); }); it.each` property | actionPayload ${'_links'} | ${{}} ${'delete_api_path'} | ${{ _links: {} }} - `('should reject and createFlash when $property is missing', ({ actionPayload }, done) => { - testAction(actions.requestDeletePackage, actionPayload, null, [], []).catch((e) => { + `('should reject and createFlash when $property is missing', ({ actionPayload }) => { + return testAction(actions.requestDeletePackage, actionPayload, null, [], []).catch((e) => { expect(e).toEqual(new Error(MISSING_DELETE_PATH_ERROR)); expect(createFlash).toHaveBeenCalledWith({ message: DELETE_PACKAGE_ERROR_MESSAGE, }); - done(); }); }); }); describe('setSorting', () => { - it('should commit SET_SORTING', (done) => { - testAction( + it('should commit SET_SORTING', () => { + return testAction( actions.setSorting, 'foo', null, [{ type: types.SET_SORTING, payload: 'foo' }], [], - done, ); }); }); describe('setFilter', () => { - it('should commit SET_FILTER', (done) => { - testAction( + it('should commit SET_FILTER', () => { + return testAction( actions.setFilter, 'foo', null, [{ type: types.SET_FILTER, payload: 'foo' }], [], - done, ); }); }); |