1- import { NO_ERRORS_SCHEMA } from '@angular/core' ;
1+ import { NO_ERRORS_SCHEMA , PLATFORM_ID } from '@angular/core' ;
22import {
33 ComponentFixture ,
44 TestBed ,
@@ -29,10 +29,17 @@ import { ThemeService } from '../../shared/theme-support/theme.service';
2929import { FileSizePipe } from '../../shared/utils/file-size-pipe' ;
3030import { VarDirective } from '../../shared/utils/var.directive' ;
3131import { MediaViewerComponent } from './media-viewer.component' ;
32+ import {
33+ AuthorizationDataService
34+ } from '../../core/data/feature-authorization/authorization-data.service' ;
35+ import { FileService } from '../../core/shared/file.service' ;
3236
3337describe ( 'MediaViewerComponent' , ( ) => {
3438 let comp : MediaViewerComponent ;
3539 let fixture : ComponentFixture < MediaViewerComponent > ;
40+ let authService ;
41+ let authorizationService ;
42+ let fileService ;
3643
3744 const mockBitstream : Bitstream = Object . assign ( new Bitstream ( ) , {
3845 sizeBytes : 10201 ,
@@ -57,7 +64,7 @@ describe('MediaViewerComponent', () => {
5764 'dc.title' : [
5865 {
5966 language : null ,
60- value : 'test_word.docx ' ,
67+ value : 'test_image.jpg ' ,
6168 } ,
6269 ] ,
6370 } ,
@@ -75,6 +82,15 @@ describe('MediaViewerComponent', () => {
7582 ) ;
7683
7784 beforeEach ( waitForAsync ( ( ) => {
85+ authService = jasmine . createSpyObj ( 'AuthService' , {
86+ isAuthenticated : observableOf ( true ) ,
87+ } ) ;
88+ authorizationService = jasmine . createSpyObj ( 'AuthorizationService' , {
89+ isAuthorized : observableOf ( true ) ,
90+ } ) ;
91+ fileService = jasmine . createSpyObj ( 'FileService' , {
92+ retrieveFileDownloadLink : null ,
93+ } ) ;
7894 return TestBed . configureTestingModule ( {
7995 imports : [
8096 TranslateModule . forRoot ( {
@@ -90,6 +106,10 @@ describe('MediaViewerComponent', () => {
90106 MetadataFieldWrapperComponent ,
91107 ] ,
92108 providers : [
109+ { provide : AuthService , useValue : authService } ,
110+ { provide : AuthorizationDataService , useValue : authorizationService } ,
111+ { provide : FileService , useValue : fileService } ,
112+ { provide : PLATFORM_ID , useValue : 'browser' } ,
93113 { provide : BitstreamDataService , useValue : bitstreamDataService } ,
94114 { provide : ThemeService , useValue : getMockThemeService ( ) } ,
95115 { provide : AuthService , useValue : new AuthServiceMock ( ) } ,
@@ -153,9 +173,9 @@ describe('MediaViewerComponent', () => {
153173 expect ( mediaItem . thumbnail ) . toBe ( null ) ;
154174 } ) ;
155175
156- it ( 'should display a default, thumbnail' , ( ) => {
176+ it ( 'should display a default thumbnail' , ( ) => {
157177 const defaultThumbnail = fixture . debugElement . query (
158- By . css ( 'ds-media-viewer-image' ) ,
178+ By . css ( 'ds-thumbnail' )
159179 ) ;
160180 expect ( defaultThumbnail . nativeElement ) . toBeDefined ( ) ;
161181 } ) ;
0 commit comments