Skip to content

Commit de85023

Browse files
[DSC-1601] - Added test case
1 parent 0aae329 commit de85023

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/app/item-page/full/field-components/file-section/full-file-section.component.spec.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { APP_CONFIG } from 'src/config/app-config.interface';
2222
import { environment } from 'src/environments/environment';
2323
import { UUIDService } from '../../../../core/shared/uuid.service';
2424
import { getMockUUIDService } from '../../../../shared/mocks/uuid.service.mock';
25+
import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service';
2526

2627
describe('FullFileSectionComponent', () => {
2728
let comp: FullFileSectionComponent;
@@ -58,6 +59,10 @@ describe('FullFileSectionComponent', () => {
5859
findAllByItemAndBundleName: createSuccessfulRemoteDataObject$(createPaginatedList([mockBitstream, mockBitstream, mockBitstream]))
5960
});
6061

62+
const authorizedDataService = jasmine.createSpyObj('authorizedDataService',{
63+
isAuthorized: observableOf(false),
64+
});
65+
6166
const paginationService = new PaginationServiceStub();
6267

6368
beforeEach(waitForAsync(() => {
@@ -75,7 +80,8 @@ describe('FullFileSectionComponent', () => {
7580
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
7681
{ provide: PaginationService, useValue: paginationService },
7782
{ provide: APP_CONFIG, useValue: environment },
78-
{ provide: UUIDService, useValue: getMockUUIDService() }
83+
{ provide: UUIDService, useValue: getMockUUIDService() },
84+
{ provide: AuthorizationDataService, useValue: authorizedDataService },
7985
],
8086

8187
schemas: [NO_ERRORS_SCHEMA]
@@ -98,5 +104,14 @@ describe('FullFileSectionComponent', () => {
98104
const fileNameElement = fixture.debugElement.query(By.css('[data-test="file-name"]')).nativeElement;
99105
expect(fileNameElement.classList).toContain('text-break');
100106
});
107+
108+
it('canDownload should return an observable with false value, if user is not authorized to download bitstream', waitForAsync(() => {
109+
authorizedDataService.isAuthorized.and.returnValue(observableOf(false));
110+
comp.canDownload(mockBitstream).subscribe(canDownload => expect(canDownload).toBeFalse());
111+
}));
112+
it('canDownload should return an observable with true value, if user is authorized to download bitstream', waitForAsync(() => {
113+
authorizedDataService.isAuthorized.and.returnValue(observableOf(true));
114+
comp.canDownload(mockBitstream).subscribe(canDownload => expect(canDownload).toBeTrue());
115+
}));
101116
});
102117
});

0 commit comments

Comments
 (0)