11import { NO_ERRORS_SCHEMA } from '@angular/core' ;
22import {
33 ComponentFixture ,
4+ fakeAsync ,
45 TestBed ,
56 waitForAsync ,
67} from '@angular/core/testing' ;
@@ -9,13 +10,22 @@ import { RouterTestingModule } from '@angular/router/testing';
910import { TranslateModule } from '@ngx-translate/core' ;
1011import { of } from 'rxjs' ;
1112
12- import { AuditDataService } from '../../core/audit/audit-data.service' ;
13+ import {
14+ AuditDataService ,
15+ AuditDetails ,
16+ } from '../../core/audit/audit-data.service' ;
1317import { Audit } from '../../core/audit/model/audit.model' ;
1418import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service' ;
1519import { PaginationService } from '../../core/pagination/pagination.service' ;
1620import { PaginationComponent } from '../../shared/pagination/pagination.component' ;
17- import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils' ;
18- import { AuditMock } from '../../shared/testing/audit.mock' ;
21+ import {
22+ createSuccessfulRemoteDataObject ,
23+ createSuccessfulRemoteDataObject$ ,
24+ } from '../../shared/remote-data.utils' ;
25+ import {
26+ AuditDetailsMock ,
27+ AuditMock ,
28+ } from '../../shared/testing/audit.mock' ;
1929import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub' ;
2030import { createPaginatedList } from '../../shared/testing/utils.test' ;
2131import { VarDirective } from '../../shared/utils/var.directive' ;
@@ -28,15 +38,21 @@ describe('AuditOverviewComponent', () => {
2838 let auditService : AuditDataService ;
2939 let authorizationService : any ;
3040 let audits : Audit [ ] ;
41+ let auditDetails : AuditDetails [ ] ;
3142 const paginationService = new PaginationServiceStub ( ) ;
3243
3344 function init ( ) {
34- audits = [ AuditMock , AuditMock , AuditMock ] ;
35- auditService = jasmine . createSpyObj ( 'processService' , {
45+ audits = [ AuditMock , AuditMock , AuditMock ] ;
46+ auditDetails = [ AuditDetailsMock , AuditDetailsMock , AuditDetailsMock ] ;
47+ auditService = jasmine . createSpyObj ( 'auditService' , {
3648 findAll : createSuccessfulRemoteDataObject$ ( createPaginatedList ( audits ) ) ,
3749 getEpersonName : of ( 'Eperson Name' ) ,
50+ mapToAuditDetails : createSuccessfulRemoteDataObject ( createPaginatedList ( auditDetails ) ) ,
51+ } ) ;
52+
53+ authorizationService = jasmine . createSpyObj ( 'authorizationService' , {
54+ isAuthorized : jasmine . createSpy ( 'isAuthorized' ) ,
3855 } ) ;
39- authorizationService = jasmine . createSpyObj ( 'authorizationService' , [ 'isAuthorized' ] ) ;
4056 }
4157
4258 beforeEach ( waitForAsync ( ( ) => {
@@ -54,13 +70,13 @@ describe('AuditOverviewComponent', () => {
5470
5571 describe ( 'if the current user is an admin' , ( ) => {
5672
57- beforeEach ( ( ) => {
58- authorizationService . isAuthorized . and . callFake ( ( ) => of ( true ) ) ;
73+ beforeEach ( fakeAsync ( ( ) => {
74+ authorizationService . isAuthorized . and . returnValue ( of ( true ) ) ;
5975
6076 fixture = TestBed . createComponent ( AuditOverviewComponent ) ;
6177 component = fixture . componentInstance ;
6278 fixture . detectChanges ( ) ;
63- } ) ;
79+ } ) ) ;
6480
6581 describe ( 'table structure' , ( ) => {
6682 let rowElements ;
@@ -118,7 +134,7 @@ describe('AuditOverviewComponent', () => {
118134 it ( 'should display the eperson name in the seventh column' , ( ) => {
119135 rowElements . forEach ( ( rowElement , index ) => {
120136 const el = rowElement . query ( By . css ( 'td:nth-child(7)' ) ) . nativeElement ;
121- expect ( el . textContent ) . toContain ( 'Eperson Name ' ) ;
137+ expect ( el . textContent ) . toContain ( 'Eperson Test ' ) ;
122138 } ) ;
123139 } ) ;
124140
0 commit comments