Skip to content

Commit

Permalink
fixed tests for total count of import instances and types to paginati…
Browse files Browse the repository at this point in the history
…on; fix #SNRGY-2894
  • Loading branch information
hahahannes committed Oct 12, 2023
1 parent c0265bf commit 21cdf01
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {Router, RouterModule} from '@angular/router';
import {ReactiveFormsModule} from '@angular/forms';
import {HttpClientModule} from '@angular/common/http';
import {MatDialog, MatDialogModule} from '@angular/material/dialog';
import {MatSnackBarModule} from '@angular/material/snack-bar';
import {MatSnackBar, MatSnackBarModule} from '@angular/material/snack-bar';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {FlexModule} from '@angular/flex-layout';
import {MatTooltipModule} from '@angular/material/tooltip';
Expand Down Expand Up @@ -65,7 +65,8 @@ describe('ImportInstancesComponent', () => {
importInstancesServiceSpy.userHasUpdateAuthorization.and.returnValue(of(true))
importInstancesServiceSpy.userHasDeleteAuthorization.and.returnValue(of(true))
importInstancesServiceSpy.userHasCreateAuthorization.and.returnValue(of(true))

importInstancesServiceSpy.getTotalCountOfInstances.and.returnValue(of(0))

const deleteDialogServiceSpy: Spy<DialogsService> = createSpyFromClass(DialogsService);
deleteDialogServiceSpy.openDeleteDialog.and.returnValue({afterClosed: () => of(true)});

Expand Down Expand Up @@ -110,7 +111,7 @@ describe('ImportInstancesComponent', () => {
{provide: DialogsService, useValue: deleteDialogServiceSpy},
{provide: Router, useValue: routerSpy},
{provide: SearchbarService, useValue: searchbarSpy},
{provide: MatDialog, useValue: dialogSpy},
{provide: MatDialog, useValue: dialogSpy}
],
}).compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import { Observable, catchError } from 'rxjs';
import { map } from 'rxjs/operators';
import { ImportInstancesModel } from './import-instances.model';
import { LadonService } from 'src/app/modules/admin/permissions/shared/services/ladom.service';
import { AllowedMethods, PermissionTestResponse } from 'src/app/modules/admin/permissions/shared/permission.model';
import { ErrorHandlerService } from 'src/app/core/services/error-handler.service';
import { PermissionTestResponse } from 'src/app/modules/admin/permissions/shared/permission.model';

@Injectable({
providedIn: 'root',
Expand All @@ -31,8 +30,7 @@ export class ImportInstancesService {

constructor(
private http: HttpClient,
private ladonService: LadonService,
private errorHandlerService: ErrorHandlerService
private ladonService: LadonService
) {
this.authorizations = this.ladonService.getUserAuthorizationsForURI(environment.importDeployUrl)
}
Expand Down Expand Up @@ -94,13 +92,5 @@ export class ImportInstancesService {
getTotalCountOfInstances(): Observable<any> {
return this.http
.get(environment.importDeployUrl + '/total/instances')
.pipe(
catchError(
this.errorHandlerService.handleError(
ImportInstancesService.name,
'getTotalCountOfInstances',
),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {Router, RouterModule} from '@angular/router';
import {ReactiveFormsModule} from '@angular/forms';
import {HttpClientModule} from '@angular/common/http';
import {MatDialog, MatDialogModule} from '@angular/material/dialog';
import {MatSnackBarModule} from '@angular/material/snack-bar';
import {MatSnackBar, MatSnackBarModule} from '@angular/material/snack-bar';
import {FlexModule} from '@angular/flex-layout';
import {MatTooltipModule} from '@angular/material/tooltip';
import {MatButtonModule} from '@angular/material/button';
Expand Down Expand Up @@ -64,7 +64,8 @@ describe('ImportTypesComponent', () => {
importTypesServiceSpy.userHasUpdateAuthorization.and.returnValue(of(true))
importTypesServiceSpy.userHasDeleteAuthorization.and.returnValue(of(true))
importTypesServiceSpy.userHasCreateAuthorization.and.returnValue(of(true))

importTypesServiceSpy.getTotalCountOfTypes.and.returnValue(of(0))

const deleteDialogServiceSpy: Spy<DialogsService> = createSpyFromClass(DialogsService);
deleteDialogServiceSpy.openDeleteDialog.and.returnValue({afterClosed: () => of(true)});

Expand Down Expand Up @@ -115,7 +116,7 @@ describe('ImportTypesComponent', () => {
{provide: PermissionsDialogService, useValue: permissionsDialogServiceSpy},
{provide: SearchbarService, useValue: searchbarSpy},
{provide: Router, useValue: routerSpy},
{provide: MatDialog, useValue: dialogSpy},
{provide: MatDialog, useValue: dialogSpy}
],
}).compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { map } from 'rxjs/operators';
import { delay } from 'rxjs/operators';
import { ExportValueModel } from '../../../exports/shared/export.model';
import { LadonService } from 'src/app/modules/admin/permissions/shared/services/ladom.service';
import { AllowedMethods, PermissionTestResponse } from 'src/app/modules/admin/permissions/shared/permission.model';
import { ErrorHandlerService } from 'src/app/core/services/error-handler.service';
import { PermissionTestResponse } from 'src/app/modules/admin/permissions/shared/permission.model';

@Injectable({
providedIn: 'root',
Expand All @@ -42,8 +41,7 @@ export class ImportTypesService {

constructor(
private http: HttpClient,
private ladonService: LadonService,
private errorHandlerService: ErrorHandlerService
private ladonService: LadonService
) {
this.authorizations = this.ladonService.getUserAuthorizationsForURI(environment.importRepoUrl)
}
Expand Down Expand Up @@ -171,13 +169,5 @@ export class ImportTypesService {
getTotalCountOfTypes(): Observable<any> {
return this.http
.get(environment.permissionSearchUrl + '/v3/total/import-types')
.pipe(
catchError(
this.errorHandlerService.handleError(
ImportTypesService.name,
'getTotalCountOfTypes',
),
),
);
}
}

0 comments on commit 21cdf01

Please sign in to comment.