@@ -784,3 +784,65 @@ t.test('TrustCommand - logOptions with fromPackageJson and urls', async t => {
784784 t . ok ( output . includes ( 'from package.json' ) , 'shows fromPackageJson indicator' )
785785 t . match ( output , / h t t p s : \/ \/ g i t h u b \. c o m \/ n p m \/ c l i \b / , 'shows URL' )
786786} )
787+
788+ t . test ( 'TrustCommand - logOptions with no urls' , async t => {
789+ const { npm, joinedOutput } = await loadMockNpm ( t , {
790+ config : {
791+ '//registry.npmjs.org/:_authToken' : 'test-auth-token' ,
792+ } ,
793+ } )
794+
795+ class TestTrustCmd extends TrustCommand {
796+ static name = 'test'
797+ static description = 'Test command'
798+ }
799+
800+ const cmd = new TestTrustCmd ( npm )
801+
802+ // Call logOptions without urls object
803+ cmd . logOptions ( {
804+ values : {
805+ type : 'github' ,
806+ id : 'test-id' ,
807+ repository : 'npm/cli' ,
808+ file : 'workflow.yml' ,
809+ } ,
810+ } )
811+ const output = joinedOutput ( )
812+ t . ok ( output . includes ( 'repository' ) , 'shows repository field' )
813+ t . ok ( output . includes ( 'file' ) , 'shows file field' )
814+ t . notOk ( output . includes ( 'Links to verify manually' ) , 'does not show links header when no urls' )
815+ } )
816+
817+ t . test ( 'TrustCommand - logOptions with urls but all values are null' , async t => {
818+ const { npm, joinedOutput } = await loadMockNpm ( t , {
819+ config : {
820+ '//registry.npmjs.org/:_authToken' : 'test-auth-token' ,
821+ } ,
822+ } )
823+
824+ class TestTrustCmd extends TrustCommand {
825+ static name = 'test'
826+ static description = 'Test command'
827+ }
828+
829+ const cmd = new TestTrustCmd ( npm )
830+
831+ // Call logOptions with urls object but all values are null/undefined
832+ cmd . logOptions ( {
833+ values : {
834+ type : 'github' ,
835+ id : 'test-id' ,
836+ repository : 'npm/cli' ,
837+ file : 'workflow.yml' ,
838+ } ,
839+ urls : {
840+ repository : null ,
841+ file : undefined ,
842+ } ,
843+ } )
844+ const output = joinedOutput ( )
845+ t . ok ( output . includes ( 'repository' ) , 'shows repository field' )
846+ t . ok ( output . includes ( 'file' ) , 'shows file field' )
847+ t . notOk ( output . includes ( 'Links to verify manually' ) , 'does not show links header when all urls are null' )
848+ } )
0 commit comments