@@ -92,22 +92,59 @@ describe('Query history info', () => {
9292 } ) ;
9393
9494 describe ( 'buildRepoLabel' , ( ) => {
95- it ( 'should build the repo label for remote query history items' , ( ) => {
96- const repoLabel = buildRepoLabel ( remoteQueryHistoryItem ) ;
97- const expectedRepoLabel = `${ remoteQueryHistoryItem . remoteQuery . controllerRepository . owner } /${ remoteQueryHistoryItem . remoteQuery . controllerRepository . name } ` ;
98-
99- expect ( repoLabel ) . to . equal ( expectedRepoLabel ) ;
100-
101- const remoteQueryHistoryItem2 = createMockRemoteQueryHistoryItem ( { repositoryCount : 3 } ) ;
102- const repoLabel2 = buildRepoLabel ( remoteQueryHistoryItem2 ) ;
103- const expectedRepoLabel2 = '3 repositories' ;
104-
105- expect ( repoLabel2 ) . to . equal ( expectedRepoLabel2 ) ;
95+ describe ( 'repo label for remote query history items' , ( ) => {
96+ it ( 'should return controller repo when `repositoryCount` is 0' , ( ) => {
97+ const repoLabel = buildRepoLabel ( remoteQueryHistoryItem ) ;
98+ const expectedRepoLabel = `${ remoteQueryHistoryItem . remoteQuery . controllerRepository . owner } /${ remoteQueryHistoryItem . remoteQuery . controllerRepository . name } ` ;
99+
100+ expect ( repoLabel ) . to . equal ( expectedRepoLabel ) ;
101+ } ) ;
102+ it ( 'should return number of repositories when `repositoryCount` is non-zero' , ( ) => {
103+ const remoteQueryHistoryItem2 = createMockRemoteQueryHistoryItem ( { repositoryCount : 3 } ) ;
104+ const repoLabel2 = buildRepoLabel ( remoteQueryHistoryItem2 ) ;
105+ const expectedRepoLabel2 = '3 repositories' ;
106+
107+ expect ( repoLabel2 ) . to . equal ( expectedRepoLabel2 ) ;
108+ } ) ;
106109 } ) ;
107- it ( 'should build the repo label for variant analysis history items' , ( ) => {
108- const repoLabel = buildRepoLabel ( variantAnalysisHistoryItem ) ;
109-
110- expect ( repoLabel ) . to . equal ( '2/4 repositories' ) ;
110+ describe ( 'repo label for variant analysis history items' , ( ) => {
111+ it ( 'should return label when `totalScannedRepositoryCount` is 0' , ( ) => {
112+ const variantAnalysisHistoryItem0 : VariantAnalysisHistoryItem = {
113+ t : 'variant-analysis' ,
114+ status : QueryStatus . InProgress ,
115+ completed : false ,
116+ historyItemId : 'abc123' ,
117+ variantAnalysis : createMockVariantAnalysis (
118+ VariantAnalysisStatus . InProgress ,
119+ createMockScannedRepos ( [ ] )
120+ ) ,
121+ } ;
122+ const repoLabel0 = buildRepoLabel ( variantAnalysisHistoryItem0 ) ;
123+
124+ expect ( repoLabel0 ) . to . equal ( '0/0 repositories' ) ;
125+ } ) ;
126+ it ( 'should return label when `totalScannedRepositoryCount` is 1' , ( ) => {
127+ const variantAnalysisHistoryItem1 : VariantAnalysisHistoryItem = {
128+ t : 'variant-analysis' ,
129+ status : QueryStatus . InProgress ,
130+ completed : false ,
131+ historyItemId : 'abc123' ,
132+ variantAnalysis : createMockVariantAnalysis (
133+ VariantAnalysisStatus . InProgress ,
134+ createMockScannedRepos ( [
135+ VariantAnalysisRepoStatus . Pending ,
136+ ] )
137+ ) ,
138+ } ;
139+
140+ const repoLabel1 = buildRepoLabel ( variantAnalysisHistoryItem1 ) ;
141+ expect ( repoLabel1 ) . to . equal ( '0/1 repository' ) ;
142+ } ) ;
143+ it ( 'should return label when `totalScannedRepositoryCount` is greater than 1' , ( ) => {
144+ const repoLabel = buildRepoLabel ( variantAnalysisHistoryItem ) ;
145+
146+ expect ( repoLabel ) . to . equal ( '2/4 repositories' ) ;
147+ } ) ;
111148 } ) ;
112149 } ) ;
113150} ) ;
0 commit comments