import { HttpClient } from '@angular/common/http'; import { TestBed, inject } from '@angular/core/testing'; import { Router } from '@angular/router'; import { ConfigService } from '@arrow/bom/config'; import { SocketsService } from '@arrow/bom/core'; import { Observable, of } from 'rxjs'; import { ListService } from './list.service'; import { OrmService } from './ORM'; const mockRouter = { navigate: jasmine.createSpy('navigate'), events: new Observable() //events: jasmine.createSpy('events') //events: of({}) }; const mockSockets: Partial = { observeAction: subject => { switch (subject) { case 'rowDeleted': return of(0); default: return new Observable(); } }, emitAction: (actionName: string, params?: any) => { return of({}); } }; describe('ListService', () => { beforeEach(() => { const httpClientSpyObj = jasmine.createSpyObj('HttpClient', ['post', 'get']); const configServiceSpyObj = jasmine.createSpyObj('ConfigService', { 'apiCoreUrl': 'some url', }); TestBed.configureTestingModule({ providers: [ ListService, { provide: SocketsService, useValue: mockSockets }, { provide: OrmService, useValue: {} }, { provide: Router, useValue: mockRouter }, { provide: HttpClient, useValue: httpClientSpyObj }, { provide: ConfigService, useValue: configServiceSpyObj }, ] }); }); it('should be created', inject([ListService], (service: ListService) => { expect(service).toBeTruthy(); })); });