forked from CredenceOrg/Credence-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexplorerUrl.test.ts
More file actions
31 lines (25 loc) · 1.04 KB
/
Copy pathexplorerUrl.test.ts
File metadata and controls
31 lines (25 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { describe, it, expect } from 'vitest'
import { explorerUrl } from './explorerUrl'
const HASH = 'abc123def456'
describe('explorerUrl', () => {
it('uses the public network base URL by default', () => {
const url = explorerUrl('public', HASH)
expect(url).toBe(`https://stellar.expert/explorer/public/tx/${HASH}`)
})
it('uses the testnet base URL when network is testnet', () => {
const url = explorerUrl('testnet', HASH)
expect(url).toBe(`https://stellar.expert/explorer/testnet/tx/${HASH}`)
})
it('falls back to public for an unknown network value', () => {
const url = explorerUrl('staging', HASH)
expect(url).toBe(`https://stellar.expert/explorer/public/tx/${HASH}`)
})
it('percent-encodes special characters in the hash', () => {
const url = explorerUrl('public', 'hash with spaces')
expect(url).toContain('hash%20with%20spaces')
})
it('handles an empty hash gracefully', () => {
const url = explorerUrl('public', '')
expect(url).toBe('https://stellar.expert/explorer/public/tx/')
})
})