@@ -17,6 +17,7 @@ describe(VariantAnalysisStats.name, () => {
1717 variantAnalysisStatus = { VariantAnalysisStatus . InProgress }
1818 totalRepositoryCount = { 10 }
1919 onViewLogsClick = { onViewLogsClick }
20+ createdAt = { new Date ( ) }
2021 { ...props }
2122 />
2223 ) ;
@@ -31,6 +32,7 @@ describe(VariantAnalysisStats.name, () => {
3132 render ( { resultCount : 123456 } ) ;
3233
3334 expect ( screen . getByText ( '123,456' ) ) . toBeInTheDocument ( ) ;
35+ expect ( screen . queryAllByText ( '-' ) . length ) . toBe ( 1 ) ;
3436 } ) ;
3537
3638 it ( 'renders the number of repositories as a formatted number' , ( ) => {
@@ -100,4 +102,30 @@ describe(VariantAnalysisStats.name, () => {
100102 expect ( screen . getByText ( 'Succeeded' ) ) . toBeInTheDocument ( ) ;
101103 expect ( screen . queryByText ( 'Succeeded warnings' ) ) . not . toBeInTheDocument ( ) ;
102104 } ) ;
105+
106+ it ( 'does not render the duration when the completedAt is not set' , ( ) => {
107+ render ( { createdAt : new Date ( '2021-05-01T00:00:00Z' ) } ) ;
108+
109+ expect ( screen . queryAllByText ( '-' ) . length ) . toBe ( 2 ) ;
110+ expect ( screen . queryByText ( 'Less than a second' ) ) . not . toBeInTheDocument ( ) ;
111+ } ) ;
112+
113+ it ( 'renders the duration when it is less than a second' , ( ) => {
114+ render ( { createdAt : new Date ( '2021-05-01T00:00:00Z' ) , completedAt : new Date ( '2021-05-01T00:00:00Z' ) } ) ;
115+
116+ expect ( screen . getByText ( 'Less than a second' ) ) . toBeInTheDocument ( ) ;
117+ expect ( screen . queryAllByText ( '-' ) . length ) . toBe ( 1 ) ;
118+ } ) ;
119+
120+ it ( 'renders the duration when it is less than a minute' , ( ) => {
121+ render ( { createdAt : new Date ( '2021-05-01T00:00:00Z' ) , completedAt : new Date ( '2021-05-01T00:00:34Z' ) } ) ;
122+
123+ expect ( screen . getByText ( '34 seconds' ) ) . toBeInTheDocument ( ) ;
124+ } ) ;
125+
126+ it ( 'renders the duration when it is more than a minute' , ( ) => {
127+ render ( { createdAt : new Date ( '2021-05-01T00:00:00Z' ) , completedAt : new Date ( '2021-05-01T00:10:22Z' ) } ) ;
128+
129+ expect ( screen . getByText ( '10 minutes' ) ) . toBeInTheDocument ( ) ;
130+ } ) ;
103131} ) ;
0 commit comments