Skip to content

Commit

Permalink
Failed attempt at fixing process-detail.component.spec.ts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Pauwels committed Sep 1, 2023
1 parent 3be90eb commit a59776d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 33 deletions.
29 changes: 0 additions & 29 deletions src/app/core/data/processes/process-data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,34 +124,5 @@ describe('ProcessDataService', () => {
expect(processDataService.findById).toHaveBeenCalledTimes(1);
expect(processDataService.invalidateByHref).toHaveBeenCalledTimes(1);
});

});

// /**
// * Tests whether calls to `FindAllData` methods are correctly patched through in a concrete data service that implements it
// */
// export function testFindAllDataImplementation(serviceFactory: () => FindAllData<any>) {
// let service;
//
// describe('FindAllData implementation', () => {
// const OPTIONS = Object.assign(new FindListOptions(), { elementsPerPage: 10, currentPage: 3 });
// const FOLLOWLINKS = [
// followLink('test'),
// followLink('something'),
// ];
//
// beforeAll(() => {
// service = serviceFactory();
// (service as any).findAllData = jasmine.createSpyObj('findAllData', {
// findAll: 'TEST findAll',
// });
// });
//
// it('should handle calls to findAll', () => {
// const out: any = service.findAll(OPTIONS, false, true, ...FOLLOWLINKS);
//
// expect((service as any).findAllData.findAll).toHaveBeenCalledWith(OPTIONS, false, true, ...FOLLOWLINKS);
// expect(out).toBe('TEST findAll');
// });
// });
});
9 changes: 6 additions & 3 deletions src/app/process-page/detail/process-detail.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ describe('ProcessDetailComponent', () => {
content: { href: 'log-selflink' }
}
});
const processRD$ = createSuccessfulRemoteDataObject$(process);
processService = jasmine.createSpyObj('processService', {
getFiles: createSuccessfulRemoteDataObject$(createPaginatedList(files)),
delete: createSuccessfulRemoteDataObject$(null),
findById: createSuccessfulRemoteDataObject$(process),
findById: processRD$,
autoRefreshUntilCompletion: processRD$
});
bitstreamDataService = jasmine.createSpyObj('bitstreamDataService', {
findByHref: createSuccessfulRemoteDataObject$(logBitstream)
Expand All @@ -132,7 +134,7 @@ describe('ProcessDetailComponent', () => {
});

route = jasmine.createSpyObj('route', {
data: observableOf({ process: createSuccessfulRemoteDataObject(process) }),
data: observableOf({ process: processRD$ }),
snapshot: {
params: { id: process.processId }
}
Expand All @@ -158,7 +160,8 @@ describe('ProcessDetailComponent', () => {
{ provide: NotificationsService, useValue: notificationsService },
{ provide: Router, useValue: router },
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
// schemas: [CUSTOM_ELEMENTS_SCHEMA]
schemas: []
}).compileComponents();
}));

Expand Down
6 changes: 5 additions & 1 deletion src/app/process-page/detail/process-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,18 @@ export class ProcessDetailComponent implements OnInit {
this.processRD$ = this.route.data.pipe(
switchMap((data) => {
if (isPlatformBrowser(this.platformId)) {
return this.processService.autoRefreshUntilCompletion(this.route.snapshot.params.id, 5000);
const x = this.processService.autoRefreshUntilCompletion(this.route.snapshot.params.id, 5000);
//[data.process as RemoteData<Process>];
console.log("ASDF", x);
return x;
} else {
return [data.process as RemoteData<Process>];
}
}),
redirectOn4xx(this.router, this.authService),
);

this.processRD$.subscribe(x => console.log("QWER", x));
this.isRefreshing$ = this.processRD$.pipe(
find((processRD: RemoteData<Process>) => this.processService.hasCompletedOrFailed(processRD.payload)),
map(() => false),
Expand Down

0 comments on commit a59776d

Please sign in to comment.