Existing community list test fixes

This commit is contained in:
Marie Verdonck
2019-11-27 10:37:38 +01:00
parent 5ff634a26f
commit db7ebfb16e
2 changed files with 25 additions and 5 deletions

View File

@@ -117,7 +117,7 @@ describe('CommunityListService', () => {
beforeEach(async(() => { beforeEach(async(() => {
communityDataServiceStub = { communityDataServiceStub = {
findTop(options: FindListOptions = {}) { findTop(options: FindListOptions = {}) {
const allTopComs = [...mockListOfTopCommunitiesPage1, ...mockListOfTopCommunitiesPage2] const allTopComs = [...mockListOfTopCommunitiesPage1, ...mockListOfTopCommunitiesPage2];
let currentPage = options.currentPage; let currentPage = options.currentPage;
const elementsPerPage = 3; const elementsPerPage = 3;
if (currentPage === undefined) { if (currentPage === undefined) {
@@ -182,7 +182,9 @@ describe('CommunityListService', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
providers: [CommunityListService, providers: [CommunityListService,
{ provide: CollectionDataService, useValue: collectionDataServiceStub }, { provide: CollectionDataService, useValue: collectionDataServiceStub },
{ provide: CommunityDataService, useValue: communityDataServiceStub },], { provide: CommunityDataService, useValue: communityDataServiceStub },
{ provide: Store, useValue: MockStore },
],
}); });
store = TestBed.get(Store); store = TestBed.get(Store);
service = new CommunityListService(communityDataServiceStub, collectionDataServiceStub, store); service = new CommunityListService(communityDataServiceStub, collectionDataServiceStub, store);
@@ -529,7 +531,9 @@ describe('CommunityListService', () => {
'dc.title': [{ language: 'en_US', value: 'Community 1' }] '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', () => { it('if community has collections', () => {
const communityWithCollections = Object.assign(new Community(), { const communityWithCollections = Object.assign(new Community(), {
@@ -542,7 +546,9 @@ describe('CommunityListService', () => {
'dc.title': [{ language: 'en_US', value: 'Community 2' }] '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', () => { describe('should return false', () => {
@@ -557,7 +563,9 @@ describe('CommunityListService', () => {
'dc.title': [{ language: 'en_US', value: 'Community 3' }] '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);
});
}); });
}); });

View File

@@ -118,9 +118,21 @@ describe('CommunityListComponent', () => {
topCurrentPage: 1, topCurrentPage: 1,
collectionPageSize: 2, collectionPageSize: 2,
subcommunityPageSize: 2, subcommunityPageSize: 2,
expandedNodes: [],
loadingNode: null,
getNextPageTopCommunities() { getNextPageTopCommunities() {
this.topCurrentPage++; this.topCurrentPage++;
}, },
getLoadingNodeFromStore() {
return observableOf(this.loadingNode);
},
getExpandedNodesFromStore() {
return observableOf(this.expandedNodes);
},
saveCommunityListStateToStore(expandedNodes, loadingNode) {
this.expandedNodes = expandedNodes;
this.loadingNode = loadingNode;
},
loadCommunities(expandedNodes) { loadCommunities(expandedNodes) {
let flatnodes; let flatnodes;
let showMoreTopComNode = false; let showMoreTopComNode = false;