@@ -12,6 +12,7 @@ import PrepareSecurityRelease, {
1212import UpdateSecurityRelease from '../../lib/update_security_release.js' ;
1313import {
1414 getAffectedVersionLines ,
15+ getDependencyUpdates ,
1516 getHighestSeverityAnnouncement
1617} from '../../lib/security-release/security-release.js' ;
1718
@@ -909,8 +910,76 @@ describe('security_blog: getDependencyUpdatesTemplate', () => {
909910 assert . match ( template , / - u n d i c i \( 8 \. 5 \. 0 \) o n 2 2 \. x , 2 4 \. x / ) ;
910911 } ) ;
911912
913+ it ( 'does not repeat a version listed once per release line' , ( ) => {
914+ const blog = new SecurityBlog ( ) ;
915+ const template = blog . getDependencyUpdatesTemplate ( {
916+ llhttp : {
917+ versions : [
918+ { version : '9.4.3' , affectedVersions : [ 'main' ] } ,
919+ { version : '9.4.3' , affectedVersions : [ '26.x' ] } ,
920+ { version : '9.4.3' , affectedVersions : [ '24.x' ] }
921+ ] ,
922+ affectedVersions : {
923+ main : 'https://github.com/nodejs-private/node-private/pull/935' ,
924+ '26.x' : 'https://github.com/nodejs-private/node-private/pull/935' ,
925+ '24.x' : 'https://github.com/nodejs-private/node-private/pull/935'
926+ }
927+ }
928+ } ) ;
929+
930+ assert . match ( template , / - l l h t t p \( 9 \. 4 \. 3 \) o n 2 6 \. x , 2 4 \. x / ) ;
931+ } ) ;
932+
933+ it ( 'renders a dependency holding a list of updates' , ( ) => {
934+ const blog = new SecurityBlog ( ) ;
935+ const template = blog . getDependencyUpdatesTemplate ( {
936+ nghttp2 : [
937+ {
938+ title : 'deps: update nghttp2 to 1.68.0' ,
939+ affectedVersions : [ '24.x' ]
940+ } ,
941+ {
942+ name : 'nghttp2' ,
943+ versions : [ '1.67.1' ] ,
944+ affectedVersions : [ '22.x' ]
945+ }
946+ ]
947+ } ) ;
948+
949+ assert . match ( template , / - u p d a t e n g h t t p 2 t o 1 \. 6 8 \. 0 o n 2 4 \. x / ) ;
950+ assert . match ( template , / - n g h t t p 2 \( 1 \. 6 7 \. 1 \) o n 2 2 \. x / ) ;
951+ } ) ;
952+
912953 it ( 'returns an empty string when there are no dependency updates' , ( ) => {
913954 const blog = new SecurityBlog ( ) ;
914955 assert . strictEqual ( blog . getDependencyUpdatesTemplate ( { } ) , '' ) ;
956+ assert . strictEqual ( blog . getDependencyUpdatesTemplate ( undefined ) , '' ) ;
957+ } ) ;
958+ } ) ;
959+
960+ describe ( 'security_release: getDependencyUpdates' , ( ) => {
961+ it ( 'names the updates of a map keyed by dependency' , ( ) => {
962+ assert . deepStrictEqual (
963+ getDependencyUpdates ( { undici : { versions : [ '8.9.0' ] } } ) ,
964+ [ { versions : [ '8.9.0' ] , name : 'undici' } ] ) ;
965+ } ) ;
966+
967+ it ( 'flattens a dependency holding a list of updates' , ( ) => {
968+ assert . deepStrictEqual (
969+ getDependencyUpdates ( {
970+ nghttp2 : [
971+ { affectedVersions : [ '24.x' ] } ,
972+ { name : 'nghttp2' , affectedVersions : [ '22.x' ] }
973+ ]
974+ } ) ,
975+ [
976+ { affectedVersions : [ '24.x' ] , name : 'nghttp2' } ,
977+ { affectedVersions : [ '22.x' ] , name : 'nghttp2' }
978+ ] ) ;
979+ } ) ;
980+
981+ it ( 'returns an empty list when there are no dependency updates' , ( ) => {
982+ assert . deepStrictEqual ( getDependencyUpdates ( undefined ) , [ ] ) ;
983+ assert . deepStrictEqual ( getDependencyUpdates ( { } ) , [ ] ) ;
915984 } ) ;
916985} ) ;
0 commit comments