diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.spec.ts b/src/app/item-page/full/field-components/file-section/full-file-section.component.spec.ts index b2e956efafb..37e75d30aa0 100644 --- a/src/app/item-page/full/field-components/file-section/full-file-section.component.spec.ts +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.spec.ts @@ -22,6 +22,7 @@ import { APP_CONFIG } from 'src/config/app-config.interface'; import { environment } from 'src/environments/environment'; import { UUIDService } from '../../../../core/shared/uuid.service'; import { getMockUUIDService } from '../../../../shared/mocks/uuid.service.mock'; +import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service'; describe('FullFileSectionComponent', () => { let comp: FullFileSectionComponent; @@ -58,6 +59,10 @@ describe('FullFileSectionComponent', () => { findAllByItemAndBundleName: createSuccessfulRemoteDataObject$(createPaginatedList([mockBitstream, mockBitstream, mockBitstream])) }); + const authorizedDataService = jasmine.createSpyObj('authorizedDataService',{ + isAuthorized: observableOf(false), + }); + const paginationService = new PaginationServiceStub(); beforeEach(waitForAsync(() => { @@ -75,7 +80,8 @@ describe('FullFileSectionComponent', () => { { provide: NotificationsService, useValue: new NotificationsServiceStub() }, { provide: PaginationService, useValue: paginationService }, { provide: APP_CONFIG, useValue: environment }, - { provide: UUIDService, useValue: getMockUUIDService() } + { provide: UUIDService, useValue: getMockUUIDService() }, + { provide: AuthorizationDataService, useValue: authorizedDataService }, ], schemas: [NO_ERRORS_SCHEMA] @@ -98,5 +104,14 @@ describe('FullFileSectionComponent', () => { const fileNameElement = fixture.debugElement.query(By.css('[data-test="file-name"]')).nativeElement; expect(fileNameElement.classList).toContain('text-break'); }); + + it('canDownload should return an observable with false value, if user is not authorized to download bitstream', waitForAsync(() => { + authorizedDataService.isAuthorized.and.returnValue(observableOf(false)); + comp.canDownload(mockBitstream).subscribe(canDownload => expect(canDownload).toBeFalse()); + })); + it('canDownload should return an observable with true value, if user is authorized to download bitstream', waitForAsync(() => { + authorizedDataService.isAuthorized.and.returnValue(observableOf(true)); + comp.canDownload(mockBitstream).subscribe(canDownload => expect(canDownload).toBeTrue()); + })); }); });