Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/packages_and_registries/infrastructure_registry/components')
-rw-r--r--spec/frontend/packages_and_registries/infrastructure_registry/components/details/store/actions_spec.js108
-rw-r--r--spec/frontend/packages_and_registries/infrastructure_registry/components/list/components/__snapshots__/packages_list_app_spec.js.snap2
-rw-r--r--spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js129
3 files changed, 94 insertions, 145 deletions
diff --git a/spec/frontend/packages_and_registries/infrastructure_registry/components/details/store/actions_spec.js b/spec/frontend/packages_and_registries/infrastructure_registry/components/details/store/actions_spec.js
index b9383d6c38c..31ab108558c 100644
--- a/spec/frontend/packages_and_registries/infrastructure_registry/components/details/store/actions_spec.js
+++ b/spec/frontend/packages_and_registries/infrastructure_registry/components/details/store/actions_spec.js
@@ -20,10 +20,10 @@ jest.mock('~/api.js');
describe('Actions Package details store', () => {
describe('fetchPackageVersions', () => {
- it('should fetch the package versions', (done) => {
+ it('should fetch the package versions', async () => {
Api.projectPackage = jest.fn().mockResolvedValue({ data: packageEntity });
- testAction(
+ await testAction(
fetchPackageVersions,
undefined,
{ packageEntity },
@@ -33,20 +33,14 @@ describe('Actions Package details store', () => {
{ type: types.SET_LOADING, payload: false },
],
[],
- () => {
- expect(Api.projectPackage).toHaveBeenCalledWith(
- packageEntity.project_id,
- packageEntity.id,
- );
- done();
- },
);
+ expect(Api.projectPackage).toHaveBeenCalledWith(packageEntity.project_id, packageEntity.id);
});
- it("does not set the versions if they don't exist", (done) => {
+ it("does not set the versions if they don't exist", async () => {
Api.projectPackage = jest.fn().mockResolvedValue({ data: { packageEntity, versions: null } });
- testAction(
+ await testAction(
fetchPackageVersions,
undefined,
{ packageEntity },
@@ -55,20 +49,14 @@ describe('Actions Package details store', () => {
{ type: types.SET_LOADING, payload: false },
],
[],
- () => {
- expect(Api.projectPackage).toHaveBeenCalledWith(
- packageEntity.project_id,
- packageEntity.id,
- );
- done();
- },
);
+ expect(Api.projectPackage).toHaveBeenCalledWith(packageEntity.project_id, packageEntity.id);
});
- it('should create flash on API error', (done) => {
+ it('should create flash on API error', async () => {
Api.projectPackage = jest.fn().mockRejectedValue();
- testAction(
+ await testAction(
fetchPackageVersions,
undefined,
{ packageEntity },
@@ -77,41 +65,31 @@ describe('Actions Package details store', () => {
{ type: types.SET_LOADING, payload: false },
],
[],
- () => {
- expect(Api.projectPackage).toHaveBeenCalledWith(
- packageEntity.project_id,
- packageEntity.id,
- );
- expect(createFlash).toHaveBeenCalledWith({
- message: FETCH_PACKAGE_VERSIONS_ERROR,
- type: 'warning',
- });
- done();
- },
);
+ expect(Api.projectPackage).toHaveBeenCalledWith(packageEntity.project_id, packageEntity.id);
+ expect(createFlash).toHaveBeenCalledWith({
+ message: FETCH_PACKAGE_VERSIONS_ERROR,
+ type: 'warning',
+ });
});
});
describe('deletePackage', () => {
- it('should call Api.deleteProjectPackage', (done) => {
+ it('should call Api.deleteProjectPackage', async () => {
Api.deleteProjectPackage = jest.fn().mockResolvedValue();
- testAction(deletePackage, undefined, { packageEntity }, [], [], () => {
- expect(Api.deleteProjectPackage).toHaveBeenCalledWith(
- packageEntity.project_id,
- packageEntity.id,
- );
- done();
- });
+ await testAction(deletePackage, undefined, { packageEntity }, [], []);
+ expect(Api.deleteProjectPackage).toHaveBeenCalledWith(
+ packageEntity.project_id,
+ packageEntity.id,
+ );
});
- it('should create flash on API error', (done) => {
+ it('should create flash on API error', async () => {
Api.deleteProjectPackage = jest.fn().mockRejectedValue();
- testAction(deletePackage, undefined, { packageEntity }, [], [], () => {
- expect(createFlash).toHaveBeenCalledWith({
- message: DELETE_PACKAGE_ERROR_MESSAGE,
- type: 'warning',
- });
- done();
+ await testAction(deletePackage, undefined, { packageEntity }, [], []);
+ expect(createFlash).toHaveBeenCalledWith({
+ message: DELETE_PACKAGE_ERROR_MESSAGE,
+ type: 'warning',
});
});
});
@@ -119,37 +97,33 @@ describe('Actions Package details store', () => {
describe('deletePackageFile', () => {
const fileId = 'a_file_id';
- it('should call Api.deleteProjectPackageFile and commit the right data', (done) => {
+ it('should call Api.deleteProjectPackageFile and commit the right data', async () => {
const packageFiles = [{ id: 'foo' }, { id: fileId }];
Api.deleteProjectPackageFile = jest.fn().mockResolvedValue();
- testAction(
+ await testAction(
deletePackageFile,
fileId,
{ packageEntity, packageFiles },
[{ type: types.UPDATE_PACKAGE_FILES, payload: [{ id: 'foo' }] }],
[],
- () => {
- expect(Api.deleteProjectPackageFile).toHaveBeenCalledWith(
- packageEntity.project_id,
- packageEntity.id,
- fileId,
- );
- expect(createFlash).toHaveBeenCalledWith({
- message: DELETE_PACKAGE_FILE_SUCCESS_MESSAGE,
- type: 'success',
- });
- done();
- },
);
+ expect(Api.deleteProjectPackageFile).toHaveBeenCalledWith(
+ packageEntity.project_id,
+ packageEntity.id,
+ fileId,
+ );
+ expect(createFlash).toHaveBeenCalledWith({
+ message: DELETE_PACKAGE_FILE_SUCCESS_MESSAGE,
+ type: 'success',
+ });
});
- it('should create flash on API error', (done) => {
+
+ it('should create flash on API error', async () => {
Api.deleteProjectPackageFile = jest.fn().mockRejectedValue();
- testAction(deletePackageFile, fileId, { packageEntity }, [], [], () => {
- expect(createFlash).toHaveBeenCalledWith({
- message: DELETE_PACKAGE_FILE_ERROR_MESSAGE,
- type: 'warning',
- });
- done();
+ await testAction(deletePackageFile, fileId, { packageEntity }, [], []);
+ expect(createFlash).toHaveBeenCalledWith({
+ message: DELETE_PACKAGE_FILE_ERROR_MESSAGE,
+ type: 'warning',
});
});
});
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,
);
});
});