Skip to content

Commit 133f35c

Browse files
kshepherdhpwBLN
authored andcommitted
[TLC-372] Wait for async before testing obj lists in some tests
Browse by, obj list and other related components were themed in this PR and added to lazy theme module.
1 parent 8805ac3 commit 133f35c

4 files changed

Lines changed: 52 additions & 38 deletions

File tree

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,20 @@ describe('CommunityPageSubCollectionList Component', () => {
180180
comp.community = mockCommunity;
181181
});
182182

183-
it('should display a list of collections', () => {
184-
subCollList = collections;
185-
fixture.detectChanges();
186183

187-
const collList = fixture.debugElement.queryAll(By.css('li'));
188-
expect(collList.length).toEqual(5);
189-
expect(collList[0].nativeElement.textContent).toContain('Collection 1');
190-
expect(collList[1].nativeElement.textContent).toContain('Collection 2');
191-
expect(collList[2].nativeElement.textContent).toContain('Collection 3');
192-
expect(collList[3].nativeElement.textContent).toContain('Collection 4');
193-
expect(collList[4].nativeElement.textContent).toContain('Collection 5');
184+
it('should display a list of collections', () => {
185+
waitForAsync(() => {
186+
subCollList = collections;
187+
fixture.detectChanges();
188+
189+
const collList = fixture.debugElement.queryAll(By.css('li'));
190+
expect(collList.length).toEqual(5);
191+
expect(collList[0].nativeElement.textContent).toContain('Collection 1');
192+
expect(collList[1].nativeElement.textContent).toContain('Collection 2');
193+
expect(collList[2].nativeElement.textContent).toContain('Collection 3');
194+
expect(collList[3].nativeElement.textContent).toContain('Collection 4');
195+
expect(collList[4].nativeElement.textContent).toContain('Collection 5');
196+
});
194197
});
195198

196199
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 & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,20 @@ describe('CommunityPageSubCommunityListComponent Component', () => {
181181

182182
});
183183

184-
it('should display a list of sub-communities', () => {
185-
subCommList = subcommunities;
186-
fixture.detectChanges();
187184

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');
185+
it('should display a list of sub-communities', () => {
186+
waitForAsync(() => {
187+
subCommList = subcommunities;
188+
fixture.detectChanges();
189+
190+
const subComList = fixture.debugElement.queryAll(By.css('li'));
191+
expect(subComList.length).toEqual(5);
192+
expect(subComList[0].nativeElement.textContent).toContain('SubCommunity 1');
193+
expect(subComList[1].nativeElement.textContent).toContain('SubCommunity 2');
194+
expect(subComList[2].nativeElement.textContent).toContain('SubCommunity 3');
195+
expect(subComList[3].nativeElement.textContent).toContain('SubCommunity 4');
196+
expect(subComList[4].nativeElement.textContent).toContain('SubCommunity 5');
197+
});
195198
});
196199

197200
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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,18 @@ describe('TopLevelCommunityList Component', () => {
175175

176176
});
177177

178+
178179
it('should display a list of top-communities', () => {
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');
180+
waitForAsync(() => {
181+
const subComList = fixture.debugElement.queryAll(By.css('li'));
182+
183+
expect(subComList.length).toEqual(5);
184+
expect(subComList[0].nativeElement.textContent).toContain('TopCommunity 1');
185+
expect(subComList[1].nativeElement.textContent).toContain('TopCommunity 2');
186+
expect(subComList[2].nativeElement.textContent).toContain('TopCommunity 3');
187+
expect(subComList[3].nativeElement.textContent).toContain('TopCommunity 4');
188+
expect(subComList[4].nativeElement.textContent).toContain('TopCommunity 5');
189+
});
187190
});
191+
188192
});

src/app/shared/browse-by/browse-by.component.spec.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,13 @@ describe('BrowseByComponent', () => {
198198
});
199199

200200
it('should use the base component to render browse entries', () => {
201-
const componentLoaders = fixture.debugElement.queryAll(By.directive(ListableObjectComponentLoaderComponent));
202-
expect(componentLoaders.length).toEqual(browseEntries.length);
203-
componentLoaders.forEach((componentLoader) => {
204-
const browseEntry = componentLoader.query(By.css('ds-browse-entry-list-element'));
205-
expect(browseEntry.componentInstance).toBeInstanceOf(BrowseEntryListElementComponent);
201+
waitForAsync(() => {
202+
const componentLoaders = fixture.debugElement.queryAll(By.directive(ListableObjectComponentLoaderComponent));
203+
expect(componentLoaders.length).toEqual(browseEntries.length);
204+
componentLoaders.forEach((componentLoader) => {
205+
const browseEntry = componentLoader.query(By.css('ds-browse-entry-list-element'));
206+
expect(browseEntry.componentInstance).toBeInstanceOf(BrowseEntryListElementComponent);
207+
});
206208
});
207209
});
208210
});
@@ -215,11 +217,13 @@ describe('BrowseByComponent', () => {
215217
});
216218

217219
it('should use the themed component to render browse entries', () => {
218-
const componentLoaders = fixture.debugElement.queryAll(By.directive(ListableObjectComponentLoaderComponent));
219-
expect(componentLoaders.length).toEqual(browseEntries.length);
220-
componentLoaders.forEach((componentLoader) => {
221-
const browseEntry = componentLoader.query(By.css('ds-browse-entry-list-element'));
222-
expect(browseEntry.componentInstance).toBeInstanceOf(MockThemedBrowseEntryListElementComponent);
220+
waitForAsync(() => {
221+
const componentLoaders = fixture.debugElement.queryAll(By.directive(ListableObjectComponentLoaderComponent));
222+
expect(componentLoaders.length).toEqual(browseEntries.length);
223+
componentLoaders.forEach((componentLoader) => {
224+
const browseEntry = componentLoader.query(By.css('ds-browse-entry-list-element'));
225+
expect(browseEntry.componentInstance).toBeInstanceOf(MockThemedBrowseEntryListElementComponent);
226+
});
223227
});
224228
});
225229
});

0 commit comments

Comments
 (0)