import { TestBed } from '@angular/core/testing' ; import { HttpClientTestingModule , HttpTestingController } from '@angular/common/http/testing' ; import { LogsService } from './logs.service' ; describe ( 'Logs Service' , ( ) => { let service ; let httpMock ; beforeEach ( ( ) => { TestBed . configureTestingModule ( { imports : [ HttpClientTestingModule ] , } ) ; service = TestBed . inject ( LogsService ) ; httpMock = TestBed . inject ( HttpTestingController ) ; } ) ; afterEach ( ( ) => { httpMock . verify ( ) ; } ) ; describe ( 'Service methods' , ( ) => { it ( 'should change log level' , ( ) => { service . changeLevel ( 'main' , 'ERROR' ) . subscribe ( ) ; const req = httpMock . expectOne ( { method : 'POST' } ) ; expect ( req . request . body ) . toEqual ( { configuredLevel : 'ERROR' } ) ; } ) ; } ) ; } ) ;