@@ -591,4 +591,56 @@ Code (hidden, use --include code)
591591
592592Payload (hidden, use --include payload)` , output .OkEmoji ()), "\n " ), result .String ())
593593 })
594+
595+ t .Run ("Block explorer link for mainnet" , func (t * testing.T ) {
596+ result := transactionResult {tx : tx , result : txResult , network : "mainnet" }
597+
598+ output := result .String ()
599+ assert .Contains (t , output , "🔗 View on Block Explorer" )
600+ assert .Contains (t , output , "https://www.flowscan.io/tx/e913d1f3e431c7df49c99845bea9ebff9db11bbf25d507b9ad0fad45652d515f" )
601+
602+ jsonResult := result .JSON ()
603+ jsonMap , ok := jsonResult .(map [string ]any )
604+ assert .True (t , ok )
605+ assert .Contains (t , jsonMap , "view_on_block_explorer" )
606+ assert .Equal (t , "https://www.flowscan.io/tx/e913d1f3e431c7df49c99845bea9ebff9db11bbf25d507b9ad0fad45652d515f" , jsonMap ["view_on_block_explorer" ])
607+ })
608+
609+ t .Run ("Block explorer link for testnet" , func (t * testing.T ) {
610+ result := transactionResult {tx : tx , result : txResult , network : "testnet" }
611+
612+ output := result .String ()
613+ assert .Contains (t , output , "🔗 View on Block Explorer" )
614+ assert .Contains (t , output , "https://testnet.flowscan.io/tx/e913d1f3e431c7df49c99845bea9ebff9db11bbf25d507b9ad0fad45652d515f" )
615+
616+ jsonResult := result .JSON ()
617+ jsonMap , ok := jsonResult .(map [string ]any )
618+ assert .True (t , ok )
619+ assert .Contains (t , jsonMap , "view_on_block_explorer" )
620+ assert .Equal (t , "https://testnet.flowscan.io/tx/e913d1f3e431c7df49c99845bea9ebff9db11bbf25d507b9ad0fad45652d515f" , jsonMap ["view_on_block_explorer" ])
621+ })
622+
623+ t .Run ("No block explorer link for emulator" , func (t * testing.T ) {
624+ result := transactionResult {tx : tx , result : txResult , network : "emulator" }
625+
626+ output := result .String ()
627+ assert .NotContains (t , output , "🔗 View on Block Explorer" )
628+
629+ jsonResult := result .JSON ()
630+ jsonMap , ok := jsonResult .(map [string ]any )
631+ assert .True (t , ok )
632+ assert .NotContains (t , jsonMap , "view_on_block_explorer" )
633+ })
634+
635+ t .Run ("No block explorer link for empty network" , func (t * testing.T ) {
636+ result := transactionResult {tx : tx , result : txResult , network : "" }
637+
638+ output := result .String ()
639+ assert .NotContains (t , output , "🔗 View on Block Explorer" )
640+
641+ jsonResult := result .JSON ()
642+ jsonMap , ok := jsonResult .(map [string ]any )
643+ assert .True (t , ok )
644+ assert .NotContains (t , jsonMap , "view_on_block_explorer" )
645+ })
594646}
0 commit comments