diff --git a/src/web/app/components/account-requests-table/account-request-table.component.spec.ts b/src/web/app/components/account-requests-table/account-request-table.component.spec.ts index 6de7c277b22..8434b006bb5 100644 --- a/src/web/app/components/account-requests-table/account-request-table.component.spec.ts +++ b/src/web/app/components/account-requests-table/account-request-table.component.spec.ts @@ -294,9 +294,12 @@ describe('AccountRequestTableComponent', () => { component.accountRequests = accountRequestResults; fixture.detectChanges(); - const modalSpy = jest.spyOn(ngbModal, 'open').mockImplementation(() => { - return createMockNgbModalRef({}); - }); + const mockModalRef = { + componentInstance: {}, + result: Promise.resolve({}), + }; + + const modalSpy = jest.spyOn(ngbModal, 'open').mockReturnValue(mockModalRef as any); const editButton: any = fixture.debugElement.nativeElement.querySelector('#edit-account-request-0'); editButton.click(); @@ -381,9 +384,12 @@ describe('AccountRequestTableComponent', () => { component.accountRequests = accountRequestResults; fixture.detectChanges(); - jest.spyOn(ngbModal, 'open').mockImplementation(() => { - return createMockNgbModalRef({}); - }); + const mockModalRef = { + componentInstance: {}, + result: Promise.resolve({}), + }; + + jest.spyOn(ngbModal, 'open').mockReturnValue(mockModalRef as any); jest.spyOn(accountService, 'editAccountRequest').mockReturnValue(throwError(() => ({ error: { @@ -410,9 +416,12 @@ describe('AccountRequestTableComponent', () => { component.accountRequests = accountRequestResults; fixture.detectChanges(); - const modalSpy = jest.spyOn(ngbModal, 'open').mockImplementation(() => { - return createMockNgbModalRef({}); - }); + const mockModalRef = { + componentInstance: {}, + result: Promise.resolve({}), + }; + + const modalSpy = jest.spyOn(ngbModal, 'open').mockReturnValue(mockModalRef as any); const editedAccountRequest : AccountRequest = { id: 'id', diff --git a/src/web/app/components/account-requests-table/account-request-table.component.ts b/src/web/app/components/account-requests-table/account-request-table.component.ts index ce51e6ef3c7..889571e5b78 100755 --- a/src/web/app/components/account-requests-table/account-request-table.component.ts +++ b/src/web/app/components/account-requests-table/account-request-table.component.ts @@ -1,6 +1,7 @@ import { Component, Input } from '@angular/core'; import { NgbModalRef, NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { AccountRequestTableRowModel } from './account-request-table-model'; +import { EditRequestModalComponentResult } from './admin-edit-request-modal/admin-edit-request-modal-model'; import { EditRequestModalComponent } from './admin-edit-request-modal/admin-edit-request-modal.component'; import { RejectWithReasonModalComponent, @@ -63,14 +64,14 @@ export class AccountRequestTableComponent { modalRef.componentInstance.accountRequestInstitution = accountRequest.instituteAndCountry; modalRef.componentInstance.accountRequestComments = accountRequest.comments; - modalRef.result.then(() => { + modalRef.result.then((res: EditRequestModalComponentResult) => { this.accountService.editAccountRequest( accountRequest.id, - modalRef.componentInstance.accountRequestName, - modalRef.componentInstance.accountRequestEmail, - modalRef.componentInstance.accountRequestInstitution, + res.accountRequestName, + res.accountRequestEmail, + res.accountRequestInstitution, accountRequest.status, - modalRef.componentInstance.accountRequestComments) + res.accountRequestComment) .subscribe({ next: (resp: AccountRequest) => { accountRequest.comments = resp.comments ?? '';