From 44c227ffff052225ad88990fe0c22d00b4cfed38 Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Fri, 26 Oct 2018 10:55:27 +0200 Subject: [PATCH] 55959: Add additional test when no subcommunities When the subcommunity list is empty, the subcommunity section should be hidden. --- ...-page-sub-community-list.component.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts index b4203eb11a..a3efc2ebc5 100644 --- a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts @@ -39,6 +39,17 @@ describe('SubCommunityList Component', () => { }) ]; + const emptySubCommunitiesCommunity = Object.assign(new Community(), { + metadata: [ + { + key: 'dc.title', + language: 'en_US', + value: 'Test title' + }], + subcommunities: Observable.of(new RemoteData(true, true, true, + undefined, new PaginatedList(new PageInfo(), []))) + }); + const mockCommunity = Object.assign(new Community(), { metadata: [ { @@ -75,4 +86,12 @@ describe('SubCommunityList Component', () => { expect(subComList[0].nativeElement.textContent).toContain('SubCommunity 1'); expect(subComList[1].nativeElement.textContent).toContain('SubCommunity 2'); }); + + it('should not display the header when subCommunities are empty', () => { + comp.community = emptySubCommunitiesCommunity; + fixture.detectChanges(); + + const subComHead = fixture.debugElement.queryAll(By.css('h2')); + expect(subComHead.length).toEqual(0); + }); });