import { TestBed } from '@angular/core/testing' ; import { HttpClientTestingModule , HttpTestingController } from '@angular/common/http/testing' ; import { PasswordResetFinishService } from './password-reset-finish.service' ; import { ApplicationConfigService } from 'app/core/config/application-config.service' ; describe ( 'PasswordResetFinish Service' , ( ) => { let service ; let httpMock ; let applicationConfigService ; beforeEach ( ( ) => { TestBed . configureTestingModule ( { imports : [ HttpClientTestingModule ] , } ) ; service = TestBed . inject ( PasswordResetFinishService ) ; applicationConfigService = TestBed . inject ( ApplicationConfigService ) ; httpMock = TestBed . inject ( HttpTestingController ) ; } ) ; afterEach ( ( ) => { httpMock . verify ( ) ; } ) ; describe ( 'Service methods' , ( ) => { it ( 'should call reset-password/finish endpoint with correct values' , ( ) => { const key = 'abc' ; const newPassword = 'password' ; service . save ( key , newPassword ) . subscribe ( ) ; const testRequest = httpMock . expectOne ( { method : 'POST' , url : applicationConfigService . getEndpointFor ( 'api/account/reset-password/finish' ) , } ) ; expect ( testRequest . request . body ) . toEqual ( { key , newPassword } ) ; } ) ; } ) ; } ) ;