@@ -12,6 +12,8 @@ import {
1212import { ThemeService } from '../theme.service' ;
1313import { ChannelListComponent } from './channel-list.component' ;
1414import { Subject , of } from 'rxjs' ;
15+ import { PaginatedListComponent } from '../paginated-list/paginated-list.component' ;
16+ import { Channel } from 'stream-chat' ;
1517
1618describe ( 'ChannelListComponent' , ( ) => {
1719 let channelServiceMock : MockChannelService ;
@@ -21,14 +23,17 @@ describe('ChannelListComponent', () => {
2123 let queryChannels : ( ) => ChannelPreviewComponent [ ] ;
2224 let queryChatdownContainer : ( ) => HTMLElement | null ;
2325 let queryLoadingIndicator : ( ) => HTMLElement | null ;
24- let queryLoadMoreButton : ( ) => HTMLElement | null ;
2526 let queryEmptyIndicator : ( ) => HTMLElement | null ;
2627
2728 beforeEach ( ( ) => {
2829 channelServiceMock = mockChannelService ( ) ;
2930 TestBed . configureTestingModule ( {
3031 imports : [ TranslateModule . forRoot ( ) ] ,
31- declarations : [ ChannelListComponent , ChannelPreviewComponent ] ,
32+ declarations : [
33+ ChannelListComponent ,
34+ ChannelPreviewComponent ,
35+ PaginatedListComponent ,
36+ ] ,
3237 providers : [
3338 { provide : ChannelService , useValue : channelServiceMock } ,
3439 {
@@ -51,9 +56,9 @@ describe('ChannelListComponent', () => {
5156 queryChatdownContainer = ( ) =>
5257 nativeElement . querySelector ( '[data-testid="chatdown-container"]' ) ;
5358 queryLoadingIndicator = ( ) =>
54- nativeElement . querySelector ( '[data-testid="loading-indicator"]' ) ;
55- queryLoadMoreButton = ( ) =>
56- nativeElement . querySelector ( '[data-testid="load-more"]' ) ;
59+ nativeElement . querySelector (
60+ '[data-testid="loading-indicator-full-size"]'
61+ ) ;
5762 queryEmptyIndicator = ( ) =>
5863 nativeElement . querySelector (
5964 '[data-testid="empty-channel-list-indicator"]'
@@ -121,30 +126,38 @@ describe('ChannelListComponent', () => {
121126 expect ( queryEmptyIndicator ( ) ) . not . toBeNull ( ) ;
122127 } ) ;
123128
124- it ( 'should display load more button ' , ( ) => {
129+ it ( 'should bind #hasMore ' , ( ) => {
125130 const channels = generateMockChannels ( ) ;
126131 channelServiceMock . channels$ . next ( channels ) ;
132+ fixture . detectChanges ( ) ;
133+ const paginatedListComponent = fixture . debugElement . query (
134+ By . directive ( PaginatedListComponent )
135+ ) . componentInstance as PaginatedListComponent < Channel > ;
127136 channelServiceMock . hasMoreChannels$ . next ( false ) ;
128137 fixture . detectChanges ( ) ;
129138
130- expect ( queryLoadMoreButton ( ) ) . toBeNull ( ) ;
139+ expect ( paginatedListComponent . hasMore ) . toBeFalse ( ) ;
131140
132141 channelServiceMock . hasMoreChannels$ . next ( true ) ;
133142 fixture . detectChanges ( ) ;
134143
135- expect ( queryLoadMoreButton ( ) ) . not . toBeNull ( ) ;
144+ expect ( paginatedListComponent . hasMore ) . toBeTrue ( ) ;
136145 } ) ;
137146
138- it ( `should load more channels, but shouldn't loading indicator` , ( ) => {
147+ it ( `should load more channels, but shouldn't display full-size loading indicator` , ( ) => {
139148 const channels = generateMockChannels ( ) ;
140149 channelServiceMock . channels$ . next ( channels ) ;
141150 channelServiceMock . hasMoreChannels$ . next ( true ) ;
142151 spyOn ( channelServiceMock , 'loadMoreChannels' ) ;
143152 fixture . detectChanges ( ) ;
144- queryLoadMoreButton ( ) ?. click ( ) ;
153+ const paginatedListComponent = fixture . debugElement . query (
154+ By . directive ( PaginatedListComponent )
155+ ) . componentInstance as PaginatedListComponent < Channel > ;
156+ paginatedListComponent . loadMore . emit ( ) ;
157+ fixture . detectChanges ( ) ;
145158
146- expect ( queryLoadingIndicator ( ) ) . toBeNull ( ) ;
147159 expect ( channelServiceMock . loadMoreChannels ) . toHaveBeenCalledWith ( ) ;
160+ expect ( queryLoadingIndicator ( ) ) . toBeNull ( ) ;
148161 } ) ;
149162
150163 it ( 'should apply dark/light theme' , ( ) => {
0 commit comments