@kinetiq-research/markets-assets
Version:
Asset metadata (descriptions, oracle references) for Kinetiq markets
43 lines (37 loc) • 1.78 kB
text/typescript
import { describe, expect, it } from 'vitest'
import { getAssetName } from './get-asset-name'
describe('getAssetName', () => {
// THIS SUITE PINS THE CONTRACT, NOT THE BUG — worth stating, because the
// comment that used to sit here claimed otherwise. The old implementation
// keyed through `toAssetKey`, which returns the bare key when no `dex` is
// passed, so every assertion below is green against it too. What actually
// fails on a revert is `build-ticker-universe.test.ts`, where the caller
// supplied the `dex` that made the lookup miss. Kept because the bare-key
// contract is the thing a future change would break silently.
it.each([
['NVDA', 'NVIDIA'],
['AAPL', 'Apple'],
['TSLA', 'Tesla'],
['USTECH', 'Top 100 US tech stocks'],
['US500', 'Top 500 stocks'],
])('names the HIP-3 listing %s', (symbol, expected) => {
expect(getAssetName({ symbol })).toBe(expected)
})
// Main-Hyperliquid perps always worked, because their keys happen to be bare.
// Pinned so a future key migration cannot fix the HIP-3 half by breaking this
// one.
it('still names a main-Hyperliquid perp', () => {
expect(getAssetName({ symbol: 'BTC' })).toBe('Bitcoin')
})
it('is case-insensitive on the symbol', () => {
expect(getAssetName({ symbol: 'nvda' })).toBe('NVIDIA')
})
it('returns undefined for a symbol with no metadata entry', () => {
expect(getAssetName({ symbol: 'NOT_A_REAL_TICKER' })).toBeUndefined()
})
// `Record<string, string>` types the read as a string, so a prototype key
// would return a FUNCTION that the caller's `?? symbol` happily passes on.
it('returns undefined for a prototype-chain key', () => {
expect(getAssetName({ symbol: 'constructor' })).toBeUndefined()
})
})