diff --git a/src/app/pages/album/album-detail/album-detail.component.spec.ts b/src/app/pages/album/album-detail/album-detail.component.spec.ts index 6c10ca3..1376a62 100644 --- a/src/app/pages/album/album-detail/album-detail.component.spec.ts +++ b/src/app/pages/album/album-detail/album-detail.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TestingDependsModule, getTranslocoModule } from 'src/testing/'; +import { PhotoCommonModule } from 'src/app/pages/photo-common/photo-common.module'; import { AlbumDetailComponent } from './album-detail.component'; describe('AlbumDetailComponent', () => { @@ -11,6 +12,7 @@ describe('AlbumDetailComponent', () => { await TestBed.configureTestingModule({ imports: [ TestingDependsModule, + PhotoCommonModule, getTranslocoModule(), ], declarations: [ AlbumDetailComponent ] diff --git a/src/app/pages/photo-common/photo-list-core/photo-list-core.component.spec.ts b/src/app/pages/photo-common/photo-list-core/photo-list-core.component.spec.ts index 4f269c5..e4facd9 100644 --- a/src/app/pages/photo-common/photo-list-core/photo-list-core.component.spec.ts +++ b/src/app/pages/photo-common/photo-list-core/photo-list-core.component.spec.ts @@ -1,14 +1,35 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; import { PhotoListCoreComponent } from './photo-list-core.component'; +import { TestingDependsModule, getTranslocoModule } from 'src/testing/'; +import { OdataService, UIInfoService } from 'src/app/services'; describe('PhotoListCoreComponent', () => { let component: PhotoListCoreComponent; let fixture: ComponentFixture; + let odataService: any; + let deletePhotoSpy: any; + let getPhotoEXIFSpy: any; beforeEach(async () => { + odataService = jasmine.createSpyObj('OdataService', [ + 'deletePhoto', + 'getPhotoEXIF' + ]); + deletePhotoSpy = odataService.deletePhoto.and.returnValue(of(true)); + getPhotoEXIFSpy = odataService.getPhotoEXIF.and.returnValue(of({})); + await TestBed.configureTestingModule({ - declarations: [ PhotoListCoreComponent ] + imports: [ + TestingDependsModule, + getTranslocoModule(), + ], + declarations: [ PhotoListCoreComponent ], + providers: [ + { provide: OdataService, useValue: odataService }, + UIInfoService, + ] }) .compileComponents(); }); diff --git a/src/app/pages/photo/photo-list/photo-list.component.spec.ts b/src/app/pages/photo/photo-list/photo-list.component.spec.ts index 6bdd793..fc9ace8 100644 --- a/src/app/pages/photo/photo-list/photo-list.component.spec.ts +++ b/src/app/pages/photo/photo-list/photo-list.component.spec.ts @@ -1,20 +1,34 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; import { TestingDependsModule, getTranslocoModule } from 'src/testing/'; +import { PhotoCommonModule } from 'src/app/pages/photo-common/photo-common.module'; import { PhotoListComponent } from './photo-list.component'; +import { OdataService, UIInfoService } from 'src/app/services'; describe('PhotoListComponent', () => { let component: PhotoListComponent; - let fixture: ComponentFixture; + let fixture: ComponentFixture; + let odataService: any; + let getPhotosSpy: any; beforeEach(async () => { + odataService = jasmine.createSpyObj('OdataService', [ + 'getPhotos', + ]); + getPhotosSpy = odataService.getPhotos.and.returnValue(of([])); await TestBed.configureTestingModule({ imports: [ TestingDependsModule, + PhotoCommonModule, getTranslocoModule(), ], declarations: [ PhotoListComponent, + ], + providers: [ + { provide: OdataService, useValue: odataService }, + UIInfoService, ] }) .compileComponents(); diff --git a/src/app/pages/photo/photo-list/photo-list.component.ts b/src/app/pages/photo/photo-list/photo-list.component.ts index 287d38c..8a2ba87 100644 --- a/src/app/pages/photo/photo-list/photo-list.component.ts +++ b/src/app/pages/photo/photo-list/photo-list.component.ts @@ -49,11 +49,12 @@ export class PhotoListComponent implements OnInit { onFetchData(top, skip): void { this.odataSvc.getPhotos(skip, top).subscribe({ next: val => { - // console.log(val); - this.totalCount = val.totalCount; - this.photos = []; - for(let i = 0; i < val.items.Length(); i++) { - this.photos.push(val.items.GetElement(i)); + if (val && val.items) { + this.totalCount = val.totalCount; + this.photos = []; + for(let i = 0; i < val.items.Length(); i++) { + this.photos.push(val.items.GetElement(i)); + } } }, error: err => { diff --git a/src/app/pages/photo/photo-search/photo-search.component.spec.ts b/src/app/pages/photo/photo-search/photo-search.component.spec.ts index f90cbf7..c808c9a 100644 --- a/src/app/pages/photo/photo-search/photo-search.component.spec.ts +++ b/src/app/pages/photo/photo-search/photo-search.component.spec.ts @@ -1,5 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { TestingDependsModule, getTranslocoModule } from 'src/testing/'; import { PhotoSearchComponent } from './photo-search.component'; describe('PhotoSearchComponent', () => { @@ -8,6 +9,10 @@ describe('PhotoSearchComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ + imports: [ + TestingDependsModule, + getTranslocoModule(), + ], declarations: [ PhotoSearchComponent ] }) .compileComponents(); diff --git a/src/app/pages/user-detail/user-detail/user-detail.component.spec.ts b/src/app/pages/user-detail/user-detail/user-detail.component.spec.ts index 66c3622..1436585 100644 --- a/src/app/pages/user-detail/user-detail/user-detail.component.spec.ts +++ b/src/app/pages/user-detail/user-detail/user-detail.component.spec.ts @@ -1,5 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { TestingDependsModule, getTranslocoModule } from 'src/testing/'; import { UserDetailComponent } from './user-detail.component'; describe('UserDetailComponent', () => { @@ -8,6 +9,10 @@ describe('UserDetailComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ + imports: [ + TestingDependsModule, + getTranslocoModule(), + ], declarations: [ UserDetailComponent ] }) .compileComponents(); diff --git a/src/app/pages/welcome/welcome.component.spec.ts b/src/app/pages/welcome/welcome.component.spec.ts index a1eb9ad..556ae72 100644 --- a/src/app/pages/welcome/welcome.component.spec.ts +++ b/src/app/pages/welcome/welcome.component.spec.ts @@ -1,6 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { TestingDependsModule } from 'src/testing/'; +import { TestingDependsModule, getTranslocoModule } from 'src/testing/'; import { WelcomeComponent } from './'; describe('WelcomeComponent', () => { @@ -11,6 +11,7 @@ describe('WelcomeComponent', () => { await TestBed.configureTestingModule({ imports: [ TestingDependsModule, + getTranslocoModule(), ], declarations: [ WelcomeComponent ] })