From db7ebfb16e24dd01261adb1776da4d7c035c6020 Mon Sep 17 00:00:00 2001 From: Marie Verdonck Date: Wed, 27 Nov 2019 10:37:38 +0100 Subject: [PATCH] Existing community list test fixes --- .../community-list-service.spec.ts | 18 +++++++++++++----- .../community-list.component.spec.ts | 12 ++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/app/community-list-page/community-list-service.spec.ts b/src/app/community-list-page/community-list-service.spec.ts index e55903a8c8..a150277d20 100644 --- a/src/app/community-list-page/community-list-service.spec.ts +++ b/src/app/community-list-page/community-list-service.spec.ts @@ -117,7 +117,7 @@ describe('CommunityListService', () => { beforeEach(async(() => { communityDataServiceStub = { findTop(options: FindListOptions = {}) { - const allTopComs = [...mockListOfTopCommunitiesPage1, ...mockListOfTopCommunitiesPage2] + const allTopComs = [...mockListOfTopCommunitiesPage1, ...mockListOfTopCommunitiesPage2]; let currentPage = options.currentPage; const elementsPerPage = 3; if (currentPage === undefined) { @@ -182,7 +182,9 @@ describe('CommunityListService', () => { TestBed.configureTestingModule({ providers: [CommunityListService, { provide: CollectionDataService, useValue: collectionDataServiceStub }, - { provide: CommunityDataService, useValue: communityDataServiceStub },], + { provide: CommunityDataService, useValue: communityDataServiceStub }, + { provide: Store, useValue: MockStore }, + ], }); store = TestBed.get(Store); service = new CommunityListService(communityDataServiceStub, collectionDataServiceStub, store); @@ -529,7 +531,9 @@ describe('CommunityListService', () => { 'dc.title': [{ language: 'en_US', value: 'Community 1' }] } }); - expect(service.getIsExpandable(communityWithSubcoms)).toEqual(observableOf(true)); + service.getIsExpandable(communityWithSubcoms).pipe(take(1)).subscribe((result) => { + expect(result).toEqual(true); + }); }); it('if community has collections', () => { const communityWithCollections = Object.assign(new Community(), { @@ -542,7 +546,9 @@ describe('CommunityListService', () => { 'dc.title': [{ language: 'en_US', value: 'Community 2' }] } }); - expect(service.getIsExpandable(communityWithCollections)).toEqual(observableOf(true)); + service.getIsExpandable(communityWithCollections).pipe(take(1)).subscribe((result) => { + expect(result).toEqual(true); + }); }); }); describe('should return false', () => { @@ -557,7 +563,9 @@ describe('CommunityListService', () => { 'dc.title': [{ language: 'en_US', value: 'Community 3' }] } }); - expect(service.getIsExpandable(communityWithNoSubcomsOrColls)).toEqual(observableOf(false)); + service.getIsExpandable(communityWithNoSubcomsOrColls).pipe(take(1)).subscribe((result) => { + expect(result).toEqual(false); + }); }); }); diff --git a/src/app/community-list-page/community-list/community-list.component.spec.ts b/src/app/community-list-page/community-list/community-list.component.spec.ts index 448c6d5b9f..c04aadda37 100644 --- a/src/app/community-list-page/community-list/community-list.component.spec.ts +++ b/src/app/community-list-page/community-list/community-list.component.spec.ts @@ -118,9 +118,21 @@ describe('CommunityListComponent', () => { topCurrentPage: 1, collectionPageSize: 2, subcommunityPageSize: 2, + expandedNodes: [], + loadingNode: null, getNextPageTopCommunities() { this.topCurrentPage++; }, + getLoadingNodeFromStore() { + return observableOf(this.loadingNode); + }, + getExpandedNodesFromStore() { + return observableOf(this.expandedNodes); + }, + saveCommunityListStateToStore(expandedNodes, loadingNode) { + this.expandedNodes = expandedNodes; + this.loadingNode = loadingNode; + }, loadCommunities(expandedNodes) { let flatnodes; let showMoreTopComNode = false;