From ab88dc3c77222b83d81d764171440a92f8e70ed8 Mon Sep 17 00:00:00 2001 From: Marie Verdonck Date: Thu, 22 Oct 2020 17:05:46 +0200 Subject: [PATCH] 74179: Test fixes after changes for empty results in eperson/group registries --- .../epeople-registry.component.spec.ts | 10 +++++----- .../groups-registry.component.spec.ts | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/app/+admin/admin-access-control/epeople-registry/epeople-registry.component.spec.ts b/src/app/+admin/admin-access-control/epeople-registry/epeople-registry.component.spec.ts index 0ff07d688c..3cc44118cf 100644 --- a/src/app/+admin/admin-access-control/epeople-registry/epeople-registry.component.spec.ts +++ b/src/app/+admin/admin-access-control/epeople-registry/epeople-registry.component.spec.ts @@ -44,7 +44,7 @@ describe('EPeopleRegistryComponent', () => { activeEPerson: null, allEpeople: mockEPeople, getEPeople(): Observable>> { - return createSuccessfulRemoteDataObject$(new PaginatedList(null, this.allEpeople)); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: this.allEpeople.length, totalElements: this.allEpeople.length, totalPages: 1, currentPage: 1 }), this.allEpeople)); }, getActiveEPerson(): Observable { return observableOf(this.activeEPerson); @@ -54,18 +54,18 @@ describe('EPeopleRegistryComponent', () => { const result = this.allEpeople.find((ePerson: EPerson) => { return ePerson.email === query }); - return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [result])); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: [result].length, totalElements: [result].length, totalPages: 1, currentPage: 1 }), [result])); } if (scope === 'metadata') { if (query === '') { - return createSuccessfulRemoteDataObject$(new PaginatedList(null, this.allEpeople)); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: this.allEpeople.length, totalElements: this.allEpeople.length, totalPages: 1, currentPage: 1 }), this.allEpeople)); } const result = this.allEpeople.find((ePerson: EPerson) => { return (ePerson.name.includes(query) || ePerson.email.includes(query)) }); - return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [result])); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: [result].length, totalElements: [result].length, totalPages: 1, currentPage: 1 }), [result])); } - return createSuccessfulRemoteDataObject$(new PaginatedList(null, this.allEpeople)); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: this.allEpeople.length, totalElements: this.allEpeople.length, totalPages: 1, currentPage: 1 }), this.allEpeople)); }, deleteEPerson(ePerson: EPerson): Observable { this.allEpeople = this.allEpeople.filter((ePerson2: EPerson) => { diff --git a/src/app/+admin/admin-access-control/group-registry/groups-registry.component.spec.ts b/src/app/+admin/admin-access-control/group-registry/groups-registry.component.spec.ts index e09a49d870..da93acf9e6 100644 --- a/src/app/+admin/admin-access-control/group-registry/groups-registry.component.spec.ts +++ b/src/app/+admin/admin-access-control/group-registry/groups-registry.component.spec.ts @@ -43,11 +43,11 @@ describe('GroupRegistryComponent', () => { findAllByHref(href: string): Observable>> { switch (href) { case 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid2/epersons': - return createSuccessfulRemoteDataObject$(new PaginatedList(null, [])); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: 1, totalElements: 0, totalPages: 0, currentPage: 1 }), [])); case 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid/epersons': - return createSuccessfulRemoteDataObject$(new PaginatedList(null, [EPersonMock])); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: 1, totalElements: 1, totalPages: 1, currentPage: 1 }), [EPersonMock])); default: - return createSuccessfulRemoteDataObject$(new PaginatedList(null, [])); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: 1, totalElements: 0, totalPages: 0, currentPage: 1 }), [])); } } }; @@ -56,11 +56,11 @@ describe('GroupRegistryComponent', () => { findAllByHref(href: string): Observable>> { switch (href) { case 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid2/groups': - return createSuccessfulRemoteDataObject$(new PaginatedList(null, [])); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: 1, totalElements: 0, totalPages: 0, currentPage: 1 }), [])); case 'https://dspace.4science.it/dspace-spring-rest/api/eperson/groups/testgroupid/groups': - return createSuccessfulRemoteDataObject$(new PaginatedList(null, [GroupMock2])); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: 1, totalElements: 1, totalPages: 1, currentPage: 1 }), [GroupMock2])); default: - return createSuccessfulRemoteDataObject$(new PaginatedList(null, [])); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: 1, totalElements: 0, totalPages: 0, currentPage: 1 }), [])); } }, getGroupEditPageRouterLink(group: Group): string { @@ -71,12 +71,12 @@ describe('GroupRegistryComponent', () => { }, searchGroups(query: string): Observable>> { if (query === '') { - return createSuccessfulRemoteDataObject$(new PaginatedList(null, this.allGroups)); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: this.allGroups.length, totalElements: this.allGroups.length, totalPages: 1, currentPage: 1 }), this.allGroups)); } const result = this.allGroups.find((group: Group) => { return (group.id.includes(query)) }); - return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [result])); + return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo({ elementsPerPage: [result].length, totalElements: [result].length, totalPages: 1, currentPage: 1 }), [result])); } }; authorizationService = jasmine.createSpyObj('authorizationService', {