@@ -15,6 +15,9 @@ function baseRow(
1515 vulnerabilityReportingUrl : null ,
1616 bugBountyUrl : null ,
1717 pvrEnabled : true ,
18+ declaredRepositoryUrl : 'https://github.com/lodash/lodash.git' ,
19+ resolvedRepositoryUrl : 'https://github.com/lodash/lodash' ,
20+ repoMappingConfidence : 0.9 ,
1821 securityContacts : [
1922 {
2023 channel : 'email' ,
@@ -107,4 +110,31 @@ describe('toAkritesExternalContactDetail', () => {
107110 expect ( result . vulnerabilityReportingUrl ) . toBe ( 'https://example.org/report' )
108111 expect ( result . pvrEnabled ) . toBe ( false )
109112 } )
113+
114+ it ( 'passes through the repo provenance fields when present' , ( ) => {
115+ const result = toAkritesExternalContactDetail ( baseRow ( ) )
116+ expect ( result . declaredRepositoryUrl ) . toBe ( 'https://github.com/lodash/lodash.git' )
117+ expect ( result . resolvedRepositoryUrl ) . toBe ( 'https://github.com/lodash/lodash' )
118+ expect ( result . repoMappingConfidence ) . toBe ( 0.9 )
119+ } )
120+
121+ it ( 'casts repoMappingConfidence from a numeric string (pg-promise numeric type)' , ( ) => {
122+ const result = toAkritesExternalContactDetail (
123+ baseRow ( { repoMappingConfidence : '0.9' as unknown as number } ) ,
124+ )
125+ expect ( result . repoMappingConfidence ) . toBe ( 0.9 )
126+ } )
127+
128+ it ( 'returns resolvedRepositoryUrl and repoMappingConfidence as null when there is no repo link' , ( ) => {
129+ const result = toAkritesExternalContactDetail (
130+ baseRow ( { resolvedRepositoryUrl : null , repoMappingConfidence : null } ) ,
131+ )
132+ expect ( result . resolvedRepositoryUrl ) . toBeNull ( )
133+ expect ( result . repoMappingConfidence ) . toBeNull ( )
134+ } )
135+
136+ it ( 'returns declaredRepositoryUrl as null when the package has no declared repository' , ( ) => {
137+ const result = toAkritesExternalContactDetail ( baseRow ( { declaredRepositoryUrl : null } ) )
138+ expect ( result . declaredRepositoryUrl ) . toBeNull ( )
139+ } )
110140} )
0 commit comments