Add test coverage to NoTypePolicyInstanceDialog
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / ei-coordinator / ei-job.datasource.spec.ts
index cb530a6..c50f69e 100644 (file)
  * limitations under the License.
  * ========================LICENSE_END===================================
  */
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-import { BehaviorSubject, of } from 'rxjs';
+import { TestBed } from '@angular/core/testing';
+import { of } from 'rxjs';
 
 import { EIJobDataSource } from './ei-job.datasource';
 import { EIService } from '../services/ei/ei.service';
-import { NotificationService } from '../services/ui/notification.service';
 import { ToastrModule } from 'ngx-toastr';
 import { EIJob } from '../interfaces/ei.types';
 
@@ -30,7 +29,7 @@ describe('EIJobDataSource', () => {
     let dataSource: EIJobDataSource;
     let eiServiceSpy: any;
 
-    let job = { ei_job_identity: '1', ei_job_data: 'data', ei_type_identity: 'Type ID 1',  target_uri: 'hhtp://url', owner: 'owner'};
+    const job = { ei_job_identity: '1', ei_job_data: 'data', ei_type_identity: 'Type ID 1',  target_uri: 'hhtp://url', owner: 'owner'};
 
     beforeEach(() => {
         eiServiceSpy = jasmine.createSpyObj('EIService', ['getProducerIds', 'getJobsForProducer']);
@@ -40,22 +39,20 @@ describe('EIJobDataSource', () => {
         TestBed.configureTestingModule({
             imports: [ToastrModule.forRoot()],
             providers: [
-                { provide: EIService, useValue: eiServiceSpy },
-                NotificationService
+                { provide: EIService, useValue: eiServiceSpy }
             ]
         });
     });
 
     it('should create', () => {
-        dataSource = TestBed.get(EIJobDataSource);
+        dataSource = TestBed.inject(EIJobDataSource);
         expect(dataSource).toBeTruthy();
     });
 
-    it('#getJobs and connect', () => {
-        dataSource.getJobs();
-        const jobsSubject: BehaviorSubject<EIJob[]> = dataSource.eiJobsSubject;
-        const value = jobsSubject.getValue();
-        expect(value).toEqual([ job, job ]);
+    it('#getJobs', () => {
+        dataSource.loadJobs();
+        const actualJobs: EIJob[] = dataSource.eiJobs();
+        expect(actualJobs).toEqual([ job, job ]);
         expect(dataSource.rowCount).toEqual(2);
     });
 });