Files
Chris Troutner e978516a0f Refactor like result modal and share the block explorer link
Deduplicate the new like-result acceptance steps behind one render helper,
and extract the bch.loping.net transaction link shared by the New Post result
modal, the post options menu, and the like/tip result into a block-explorer
service. Cover the LikeTipPage open/parse/handler failure branches and add
property tests for the explorer URL, the LikeResult markup, and the result
modal state machine.

CRAP is at or below 5 with full coverage on the changed services; every
changed/new plain source file scans at 21 or fewer mutation sites. The
existing mutation manifests are left for the mutation tool to refresh.

By refactorer.
2026-09-16 12:03:41 -07:00

36 lines
1.0 KiB
JavaScript

/*
Unit tests for the shared block explorer link.
The New Post result modal, the post options menu, and the like/tip broadcast
result all use this module so the explorer base URL and link shape stay in
one place.
*/
'use strict'
const test = require('node:test')
const assert = require('node:assert/strict')
const {
BLOCK_EXPLORER_TX_BASE,
blockExplorerTxUrl
} = require('../../src/services/block-explorer')
const SAMPLE_TXID = '1111111111111111111111111111111111111111111111111111111111111111'
test('the block explorer base points at bch.loping.net', () => {
assert.equal(BLOCK_EXPLORER_TX_BASE, 'https://bch.loping.net/tx')
})
test('blockExplorerTxUrl builds a transaction link', () => {
assert.equal(
blockExplorerTxUrl(SAMPLE_TXID),
`${BLOCK_EXPLORER_TX_BASE}/${SAMPLE_TXID}`
)
})
test('blockExplorerTxUrl returns an empty string without a txid', () => {
assert.equal(blockExplorerTxUrl(''), '')
assert.equal(blockExplorerTxUrl(null), '')
assert.equal(blockExplorerTxUrl(undefined), '')
})