11import { ComponentFixture , TestBed } from '@angular/core/testing' ;
2- import { of } from 'rxjs' ;
3- import { mock , when } from 'ts-mockito' ;
2+ import { anything , mock , when } from 'ts-mockito' ;
43import { I18nService } from 'xforge-common/i18n.service' ;
54import { configureTestingModule , getTestTranslocoModule } from 'xforge-common/test-utils' ;
6- import { ProgressService , TextProgress } from '../progress-service/progress.service' ;
5+ import { ProgressService , ProjectProgress } from '../progress-service/progress.service' ;
76import { Book } from './book-multi-select' ;
87import { BookMultiSelectComponent } from './book-multi-select.component' ;
98
@@ -35,22 +34,24 @@ describe('BookMultiSelectComponent', () => {
3534 { number : 1 , selected : true } ,
3635 { number : 3 , selected : true }
3736 ] ;
38- when ( mockedProgressService . isLoaded$ ) . thenReturn ( of ( true ) ) ;
39- when ( mockedProgressService . texts ) . thenReturn ( [
40- { text : { bookNum : 1 } , percentage : 0 } as TextProgress ,
41- { text : { bookNum : 2 } , percentage : 15 } as TextProgress ,
42- { text : { bookNum : 3 } , percentage : 30 } as TextProgress ,
43- { text : { bookNum : 40 } , percentage : 45 } as TextProgress ,
44- { text : { bookNum : 42 } , percentage : 60 } as TextProgress ,
45- { text : { bookNum : 67 } , percentage : 80 } as TextProgress ,
46- { text : { bookNum : 70 } , percentage : 100 } as TextProgress
47- ] ) ;
37+ when ( mockedProgressService . getProgress ( anything ( ) , anything ( ) ) ) . thenResolve (
38+ new ProjectProgress ( [
39+ { bookId : 'GEN' , verseSegments : 0 , blankVerseSegments : 0 } ,
40+ { bookId : 'EXO' , verseSegments : 10_000 , blankVerseSegments : 8_500 } ,
41+ { bookId : 'LEV' , verseSegments : 10_000 , blankVerseSegments : 7_000 } ,
42+ { bookId : 'MAT' , verseSegments : 10_000 , blankVerseSegments : 5_500 } ,
43+ { bookId : 'LUK' , verseSegments : 10_000 , blankVerseSegments : 4_000 } ,
44+ { bookId : 'TOB' , verseSegments : 10_000 , blankVerseSegments : 2_000 } ,
45+ { bookId : 'WIS' , verseSegments : 10_000 , blankVerseSegments : 0 }
46+ ] )
47+ ) ;
4848 when ( mockedI18nService . localeCode ) . thenReturn ( 'en' ) ;
4949
5050 fixture = TestBed . createComponent ( BookMultiSelectComponent ) ;
5151 component = fixture . componentInstance ;
5252 component . availableBooks = mockBooks ;
5353 component . selectedBooks = mockSelectedBooks ;
54+ component . projectId = 'test-project-id' ;
5455 fixture . detectChanges ( ) ;
5556 } ) ;
5657
@@ -76,17 +77,17 @@ describe('BookMultiSelectComponent', () => {
7677 } ) ;
7778
7879 it ( 'should not crash when texts have not yet loaded' , async ( ) => {
79- when ( mockedProgressService . texts ) . thenReturn ( [ ] ) ;
80+ when ( mockedProgressService . getProgress ( anything ( ) , anything ( ) ) ) . thenResolve ( new ProjectProgress ( [ ] ) ) ;
8081 await component . ngOnChanges ( ) ;
8182
8283 expect ( component . bookOptions ) . toEqual ( [
83- { bookNum : 1 , bookId : 'GEN' , selected : true , progressPercentage : 0 } ,
84- { bookNum : 2 , bookId : 'EXO' , selected : false , progressPercentage : 0 } ,
85- { bookNum : 3 , bookId : 'LEV' , selected : true , progressPercentage : 0 } ,
86- { bookNum : 40 , bookId : 'MAT' , selected : false , progressPercentage : 0 } ,
87- { bookNum : 42 , bookId : 'LUK' , selected : false , progressPercentage : 0 } ,
88- { bookNum : 67 , bookId : 'TOB' , selected : false , progressPercentage : 0 } ,
89- { bookNum : 70 , bookId : 'WIS' , selected : false , progressPercentage : 0 }
84+ { bookNum : 1 , bookId : 'GEN' , selected : true , progressPercentage : null } ,
85+ { bookNum : 2 , bookId : 'EXO' , selected : false , progressPercentage : null } ,
86+ { bookNum : 3 , bookId : 'LEV' , selected : true , progressPercentage : null } ,
87+ { bookNum : 40 , bookId : 'MAT' , selected : false , progressPercentage : null } ,
88+ { bookNum : 42 , bookId : 'LUK' , selected : false , progressPercentage : null } ,
89+ { bookNum : 67 , bookId : 'TOB' , selected : false , progressPercentage : null } ,
90+ { bookNum : 70 , bookId : 'WIS' , selected : false , progressPercentage : null }
9091 ] ) ;
9192 } ) ;
9293
0 commit comments