Skip to content

Commit 430b3b2

Browse files
Fix TopLevelCommunityListComponent, CommunityPageSubCollectionListComponent, CommunityPageSubCommunityListComponent no expectation tests
Because their child components use a themed component the changes need to be detected twice, this is a side effect from the component being created dynamically
1 parent 4b1a8a9 commit 430b3b2

3 files changed

Lines changed: 38 additions & 38 deletions

File tree

src/app/community-page/sub-collection-list/community-page-sub-collection-list.component.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { ConfigurationProperty } from '../../core/shared/configuration-property.
3030
import { createPaginatedList } from '../../shared/testing/utils.test';
3131
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
3232

33-
describe('CommunityPageSubCollectionList Component', () => {
33+
describe('CommunityPageSubCollectionListComponent', () => {
3434
let comp: CommunityPageSubCollectionListComponent;
3535
let fixture: ComponentFixture<CommunityPageSubCollectionListComponent>;
3636
let collectionDataServiceStub: any;
@@ -177,19 +177,19 @@ describe('CommunityPageSubCollectionList Component', () => {
177177
});
178178

179179

180-
it('should display a list of collections', () => {
181-
waitForAsync(() => {
182-
subCollList = collections;
183-
fixture.detectChanges();
180+
it('should display a list of collections', async () => {
181+
subCollList = collections;
182+
fixture.detectChanges();
183+
await fixture.whenStable();
184+
fixture.detectChanges();
184185

185-
const collList = fixture.debugElement.queryAll(By.css('li'));
186-
expect(collList.length).toEqual(5);
187-
expect(collList[0].nativeElement.textContent).toContain('Collection 1');
188-
expect(collList[1].nativeElement.textContent).toContain('Collection 2');
189-
expect(collList[2].nativeElement.textContent).toContain('Collection 3');
190-
expect(collList[3].nativeElement.textContent).toContain('Collection 4');
191-
expect(collList[4].nativeElement.textContent).toContain('Collection 5');
192-
});
186+
const collList = fixture.debugElement.queryAll(By.css('li'));
187+
expect(collList.length).toEqual(5);
188+
expect(collList[0].nativeElement.textContent).toContain('Collection 1');
189+
expect(collList[1].nativeElement.textContent).toContain('Collection 2');
190+
expect(collList[2].nativeElement.textContent).toContain('Collection 3');
191+
expect(collList[3].nativeElement.textContent).toContain('Collection 4');
192+
expect(collList[4].nativeElement.textContent).toContain('Collection 5');
193193
});
194194

195195
it('should not display the header when list of collections is empty', () => {

src/app/community-page/sub-community-list/community-page-sub-community-list.component.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { SearchConfigurationServiceStub } from '../../shared/testing/search-conf
3030
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
3131
import { createPaginatedList } from '../../shared/testing/utils.test';
3232

33-
describe('CommunityPageSubCommunityListComponent Component', () => {
33+
describe('CommunityPageSubCommunityListComponent', () => {
3434
let comp: CommunityPageSubCommunityListComponent;
3535
let fixture: ComponentFixture<CommunityPageSubCommunityListComponent>;
3636
let communityDataServiceStub: any;
@@ -179,19 +179,19 @@ describe('CommunityPageSubCommunityListComponent Component', () => {
179179
});
180180

181181

182-
it('should display a list of sub-communities', () => {
183-
waitForAsync(() => {
184-
subCommList = subcommunities;
185-
fixture.detectChanges();
182+
it('should display a list of sub-communities', async () => {
183+
subCommList = subcommunities;
184+
fixture.detectChanges();
185+
await fixture.whenStable();
186+
fixture.detectChanges();
186187

187-
const subComList = fixture.debugElement.queryAll(By.css('li'));
188-
expect(subComList.length).toEqual(5);
189-
expect(subComList[0].nativeElement.textContent).toContain('SubCommunity 1');
190-
expect(subComList[1].nativeElement.textContent).toContain('SubCommunity 2');
191-
expect(subComList[2].nativeElement.textContent).toContain('SubCommunity 3');
192-
expect(subComList[3].nativeElement.textContent).toContain('SubCommunity 4');
193-
expect(subComList[4].nativeElement.textContent).toContain('SubCommunity 5');
194-
});
188+
const subComList = fixture.debugElement.queryAll(By.css('li'));
189+
expect(subComList.length).toEqual(5);
190+
expect(subComList[0].nativeElement.textContent).toContain('SubCommunity 1');
191+
expect(subComList[1].nativeElement.textContent).toContain('SubCommunity 2');
192+
expect(subComList[2].nativeElement.textContent).toContain('SubCommunity 3');
193+
expect(subComList[3].nativeElement.textContent).toContain('SubCommunity 4');
194+
expect(subComList[4].nativeElement.textContent).toContain('SubCommunity 5');
195195
});
196196

197197
it('should not display the header when list of sub-communities is empty', () => {

src/app/home-page/top-level-community-list/top-level-community-list.component.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { SearchConfigurationServiceStub } from '../../shared/testing/search-conf
3232
import { APP_CONFIG } from 'src/config/app-config.interface';
3333
import { environment } from 'src/environments/environment.test';
3434

35-
describe('TopLevelCommunityList Component', () => {
35+
describe('TopLevelCommunityListComponent', () => {
3636
let comp: TopLevelCommunityListComponent;
3737
let fixture: ComponentFixture<TopLevelCommunityListComponent>;
3838
let communityDataServiceStub: any;
@@ -173,17 +173,17 @@ describe('TopLevelCommunityList Component', () => {
173173
});
174174

175175

176-
it('should display a list of top-communities', () => {
177-
waitForAsync(() => {
178-
const subComList = fixture.debugElement.queryAll(By.css('li'));
179-
180-
expect(subComList.length).toEqual(5);
181-
expect(subComList[0].nativeElement.textContent).toContain('TopCommunity 1');
182-
expect(subComList[1].nativeElement.textContent).toContain('TopCommunity 2');
183-
expect(subComList[2].nativeElement.textContent).toContain('TopCommunity 3');
184-
expect(subComList[3].nativeElement.textContent).toContain('TopCommunity 4');
185-
expect(subComList[4].nativeElement.textContent).toContain('TopCommunity 5');
186-
});
176+
it('should display a list of top-communities', async () => {
177+
await fixture.whenStable();
178+
fixture.detectChanges();
179+
const subComList = fixture.debugElement.queryAll(By.css('li'));
180+
181+
expect(subComList.length).toEqual(5);
182+
expect(subComList[0].nativeElement.textContent).toContain('TopCommunity 1');
183+
expect(subComList[1].nativeElement.textContent).toContain('TopCommunity 2');
184+
expect(subComList[2].nativeElement.textContent).toContain('TopCommunity 3');
185+
expect(subComList[3].nativeElement.textContent).toContain('TopCommunity 4');
186+
expect(subComList[4].nativeElement.textContent).toContain('TopCommunity 5');
187187
});
188188

189189
});

0 commit comments

Comments
 (0)