import { Injectable } from '@angular/core'; import { GCMockModule } from '@core/mocks/gc-module.mock'; import { BeforeEach, Spec, TestCase } from '@yourcause/test-decorators'; import { DescribeAngularService } from '@yourcause/test-decorators/angular'; import { expect } from 'chai'; import { ClientUserService } from './client-user.service'; @Injectable({ providedIn: 'root' }) @DescribeAngularService(ClientUserService, { imports: [ GCMockModule ] }) export class ClientUserServiceSpec implements Spec { resetPasswordResponse = { validPassword: false, containsUserInfo: true, passwordPreviouslyUsed: true }; @BeforeEach() async mock (service: ClientUserService) { service['determinationService']['_routeBase'] = 'management'; service['clientUserResources']['resetPassword'] = async () => { return this.resetPasswordResponse; }; } @TestCase('should return password validity response on reset password') async handleResetPassword (service: ClientUserService) { const payload = { token: 'token', password: 'password', confirmPassword: 'confirmPassword' }; const response = await service.handleResetPassword( payload, null, null ); expect(response.validPassword).to.be.equal( this.resetPasswordResponse.validPassword ); expect(response.containsUserInfo).to.be.equal( this.resetPasswordResponse.containsUserInfo ); expect(response.passwordPreviouslyUsed).to.be.equal( this.resetPasswordResponse.passwordPreviouslyUsed ); } }