X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fei-coordinator%2Fei-coordinator.component.spec.ts;h=d516b14b06580a9449b55cb15f86fb3e359896a6;hb=923a26d056fd5b613aa1342fff7d7f0f74d9267e;hp=b1007c2c4ac820fb022737661cdaa6c62ab9c9f8;hpb=7ca2d23ec5f7405f219951ccd669dcb17778c56a;p=portal%2Fnonrtric-controlpanel.git diff --git a/webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.spec.ts b/webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.spec.ts index b1007c2..d516b14 100644 --- a/webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.spec.ts +++ b/webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.spec.ts @@ -17,16 +17,17 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations' import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; -import {HarnessLoader} from '@angular/cdk/testing'; +import { HarnessLoader } from '@angular/cdk/testing'; import { MatIconModule } from '@angular/material/icon'; import { MatInputHarness } from '@angular/material/input/testing' import { MatTableModule } from '@angular/material/table'; import { MatTableHarness } from '@angular/material/table/testing'; import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed'; +import { of } from 'rxjs'; import { EICoordinatorComponent } from './ei-coordinator.component'; import { EIJobDataSource } from './ei-job.datasource'; @@ -66,8 +67,11 @@ describe('EICoordinatorComponent', () => { } as EIJob; beforeEach(async () => { - producerDataSourceSpy = jasmine.createSpyObj('EIProducerDataSource', [ 'loadProducers', 'eiProducers' ]); - jobDataSourceSpy = jasmine.createSpyObj('EIJobDataSource', [ 'loadJobs', 'eiJobs' ]); + producerDataSourceSpy = jasmine.createSpyObj('EIProducerDataSource', [ 'loadProducers', 'eiProducers', 'eiProducersSubject' ]); + jobDataSourceSpy = jasmine.createSpyObj('EIJobDataSource', [ 'loadJobs', 'eiJobs', 'eiJobsSubject' ]); + + producerDataSourceSpy.eiProducersSubject.and.returnValue(of({ producers: [producer1, producer2] })); + jobDataSourceSpy.eiJobsSubject.and.returnValue(of({ jobs: [job1, job2] })); await TestBed.configureTestingModule({ imports: [ @@ -102,7 +106,7 @@ describe('EICoordinatorComponent', () => { }); describe('#content', () => { - it('should contain refresh button with coorect icon', () => { + it('should contain refresh button with correct icon', () => { const button = fixture.debugElement.nativeElement.querySelector('#refreshButton'); expect(button).toBeTruthy(); expect(button.innerHTML).toContain('refresh'); @@ -139,7 +143,7 @@ describe('EICoordinatorComponent', () => { const expectedProducer1Row = { id: 'producer1', types: 'type1,type2', status: 'ENABLED' }; beforeEach(() => { const producers: EIProducer[] =[ producer1, producer2 ]; - producerDataSourceSpy.eiProducers.and.returnValue(producers); + producerDataSourceSpy.eiProducersSubject.and.returnValue(of(producers)); }); it('should contain data after initialization', async () => { @@ -164,7 +168,7 @@ describe('EICoordinatorComponent', () => { ei_producer_id: 'producer1' } as EIProducer; const producers: EIProducer[] =[ producerMissingProperties ]; - producerDataSourceSpy.eiProducers.and.returnValue(producers); + producerDataSourceSpy.eiProducersSubject.and.returnValue(of(producers)); component.ngOnInit(); const expectedProducerRow = { id: 'producer1', types: '< No types >', status: '< No status >' }; @@ -179,7 +183,7 @@ describe('EICoordinatorComponent', () => { target_uri: 'http://one' } as EIJob; const jobs: EIJob[] =[ jobMissingProperties ]; - jobDataSourceSpy.eiJobs.and.returnValue(jobs); + jobDataSourceSpy.eiJobsSubject.and.returnValue(of(jobs)); component.ngOnInit(); const expectedJobRow = { id: 'job1', typeId: '< No type >', owner: '< No owner >', targetUri: 'http://one' }; @@ -222,7 +226,7 @@ describe('EICoordinatorComponent', () => { const expectedJob1Row = { id: 'job1', typeId: 'type1', owner: 'owner1', targetUri: 'http://one' }; beforeEach(() => { const jobs: EIJob[] =[ job1, job2 ]; - jobDataSourceSpy.eiJobs.and.returnValue(jobs); + jobDataSourceSpy.eiJobsSubject.and.returnValue(of(jobs)); }); it('should contain data after initialization', async () => {