From 3e5e2a5f1d10cb7ce14b80139b7ff1fe076248ad Mon Sep 17 00:00:00 2001 From: Quentin Date: Sat, 27 Jan 2024 21:54:09 +0100 Subject: [PATCH] [Angular] The signature '(error: any): Observable' of 'throwError' is deprecated --- .../password-reset-init.component.spec.ts.ejs | 6 ++---- .../register/register.component.spec.ts.ejs | 17 ++++++----------- .../sessions/sessions.component.spec.ts.ejs | 2 +- .../app/login/login.component.spec.ts.ejs | 2 +- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/generators/angular/templates/src/main/webapp/app/account/password-reset/init/password-reset-init.component.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/account/password-reset/init/password-reset-init.component.spec.ts.ejs index aeacec1fbd4f..f1fabdeaf50f 100644 --- a/generators/angular/templates/src/main/webapp/app/account/password-reset/init/password-reset-init.component.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/account/password-reset/init/password-reset-init.component.spec.ts.ejs @@ -63,11 +63,9 @@ describe('PasswordResetInitComponent', () => { })); it('no notification of success upon error response', inject([PasswordResetInitService], (service: PasswordResetInitService) => { + const err = { status: 503, data: 'something else' }; jest.spyOn(service, 'save').mockReturnValue( - throwError({ - status: 503, - data: 'something else', - }) + throwError(() => err) ); comp.resetRequestForm.patchValue({ email: 'user@domain.com', diff --git a/generators/angular/templates/src/main/webapp/app/account/register/register.component.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/account/register/register.component.spec.ts.ejs index eacc320904d4..333bef06543d 100644 --- a/generators/angular/templates/src/main/webapp/app/account/register/register.component.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/account/register/register.component.spec.ts.ejs @@ -97,11 +97,9 @@ describe('RegisterComponent', () => { it('should notify of user existence upon 400/login already in use', inject( [RegisterService], fakeAsync((service: RegisterService) => { + const err = { status: 400, error: { type: LOGIN_ALREADY_USED_TYPE } }; jest.spyOn(service, 'save').mockReturnValue( - throwError({ - status: 400, - error: { type: LOGIN_ALREADY_USED_TYPE }, - }) + throwError(() => err) ); comp.registerForm.patchValue({ password: 'password', @@ -120,11 +118,9 @@ describe('RegisterComponent', () => { it('should notify of email existence upon 400/email address already in use', inject( [RegisterService], fakeAsync((service: RegisterService) => { + const err = { status: 400, error: { type: EMAIL_ALREADY_USED_TYPE } }; jest.spyOn(service, 'save').mockReturnValue( - throwError({ - status: 400, - error: { type: EMAIL_ALREADY_USED_TYPE }, - }) + throwError(() => err) ); comp.registerForm.patchValue({ password: 'password', @@ -143,10 +139,9 @@ describe('RegisterComponent', () => { it('should notify of generic error', inject( [RegisterService], fakeAsync((service: RegisterService) => { + const err = { status: 503 }; jest.spyOn(service, 'save').mockReturnValue( - throwError({ - status: 503, - }) + throwError(() => err) ); comp.registerForm.patchValue({ password: 'password', diff --git a/generators/angular/templates/src/main/webapp/app/account/sessions/sessions.component.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/account/sessions/sessions.component.spec.ts.ejs index f1ac8c0e4edb..70ba4adb303e 100644 --- a/generators/angular/templates/src/main/webapp/app/account/sessions/sessions.component.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/account/sessions/sessions.component.spec.ts.ejs @@ -92,7 +92,7 @@ describe('SessionsComponent', () => { fakeAsync((mockAccountService: AccountService, service: SessionsService) => { mockAccountService.identity = jest.fn(() => of(account)); jest.spyOn(service, 'findAll').mockReturnValue(of(sessions)); - jest.spyOn(service, 'delete').mockReturnValue(throwError({})); + jest.spyOn(service, 'delete').mockReturnValue(throwError(() => {})); comp.ngOnInit(); comp.invalidate('xyz'); diff --git a/generators/angular/templates/src/main/webapp/app/login/login.component.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/login/login.component.spec.ts.ejs index e89fda75bdd4..27dbf7e52b1d 100644 --- a/generators/angular/templates/src/main/webapp/app/login/login.component.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/login/login.component.spec.ts.ejs @@ -159,7 +159,7 @@ describe('LoginComponent', () => { it('should stay on login form and show error message on login error', () => { // GIVEN - mockLoginService.login = jest.fn(() => throwError({})); + mockLoginService.login = jest.fn(() => throwError(() => {})); // WHEN comp.login();