From 1fafc3a5d54bcfee13e831e48309f5d1a24fc359 Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Fri, 18 Oct 2019 10:35:25 +0200 Subject: [PATCH] 65240: Additional tests --- .../comcol-form/comcol-form.component.spec.ts | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts b/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts index 455e2ef4e0..0a7c55a118 100644 --- a/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts +++ b/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts @@ -20,6 +20,8 @@ import { RemoteData } from '../../../core/data/remote-data'; import { RestRequestMethod } from '../../../core/data/rest-request-method'; import { ErrorResponse, RestResponse } from '../../../core/cache/response.models'; import { RequestError } from '../../../core/data/request.models'; +import { RequestService } from '../../../core/data/request.service'; +import { ObjectCacheService } from '../../../core/cache/object-cache.service'; describe('ComColFormComponent', () => { let comp: ComColFormComponent; @@ -69,6 +71,13 @@ describe('ComColFormComponent', () => { const locationStub = jasmine.createSpyObj('location', ['back']); /* tslint:enable:no-empty */ + const requestServiceStub = jasmine.createSpyObj({ + removeByHrefSubstring: {} + }); + const objectCacheStub = jasmine.createSpyObj({ + remove: {} + }); + beforeEach(async(() => { TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), RouterTestingModule], @@ -77,7 +86,9 @@ describe('ComColFormComponent', () => { { provide: Location, useValue: locationStub }, { provide: DynamicFormService, useValue: formServiceStub }, { provide: NotificationsService, useValue: notificationsService }, - { provide: AuthService, useValue: new AuthServiceMock() } + { provide: AuthService, useValue: new AuthServiceMock() }, + { provide: RequestService, useValue: requestServiceStub }, + { provide: ObjectCacheService, useValue: objectCacheStub } ], schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); @@ -151,6 +162,11 @@ describe('ComColFormComponent', () => { it('should emit finishUpload', () => { expect(comp.finishUpload.emit).toHaveBeenCalled(); }); + + it('should remove the object\'s cache', () => { + expect(requestServiceStub.removeByHrefSubstring).toHaveBeenCalled(); + expect(objectCacheStub.remove).toHaveBeenCalled(); + }); }); describe('onUploadError', () => { @@ -215,6 +231,11 @@ describe('ComColFormComponent', () => { it('should display a success notification', () => { expect(notificationsService.success).toHaveBeenCalled(); }); + + it('should remove the object\'s cache', () => { + expect(requestServiceStub.removeByHrefSubstring).toHaveBeenCalled(); + expect(objectCacheStub.remove).toHaveBeenCalled(); + }); }); describe('when dsoService.deleteLogo returns an error response', () => { @@ -228,6 +249,11 @@ describe('ComColFormComponent', () => { it('should display an error notification', () => { expect(notificationsService.error).toHaveBeenCalled(); }); + + it('should remove the object\'s cache', () => { + expect(requestServiceStub.removeByHrefSubstring).toHaveBeenCalled(); + expect(objectCacheStub.remove).toHaveBeenCalled(); + }); }); }); });