mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Existing community list test fixes
This commit is contained in:
@@ -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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
|
Reference in New Issue
Block a user