Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/__tests__/chronik.test.js
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | for (let i = 0; i < mockChronikTxDetailsResponses.length; i += 1) { | ||||
when(chronik.tx) | when(chronik.tx) | ||||
.calledWith(mockChronikTxDetailsResponses[i].txid) | .calledWith(mockChronikTxDetailsResponses[i].txid) | ||||
.mockResolvedValue(mockChronikTxDetailsResponses[i]); | .mockResolvedValue(mockChronikTxDetailsResponses[i]); | ||||
} | } | ||||
expect( | expect( | ||||
await finalizeTokensArray(chronik, mockPreliminaryTokensArray), | await finalizeTokensArray(chronik, mockPreliminaryTokensArray), | ||||
).toStrictEqual({ | ).toStrictEqual({ | ||||
finalTokenArray: mockFinalTokenArray, | tokens: mockFinalTokenArray, | ||||
updatedTokenInfoById: mockFinalCachedTokenInfo, | updatedTokenInfoById: mockFinalCachedTokenInfo, | ||||
newTokensToCache: true, | newTokensToCache: true, | ||||
}); | }); | ||||
}); | }); | ||||
it(`finalizeTokensArray successfully returns finalTokenArray and cachedTokenInfoById when called with all token info in cache`, async () => { | it(`finalizeTokensArray successfully returns finalTokenArray and cachedTokenInfoById when called with all token info in cache`, async () => { | ||||
// Initialize chronik | // Initialize chronik | ||||
const chronik = new ChronikClient( | const chronik = new ChronikClient( | ||||
'https://FakeChronikUrlToEnsureMocksOnly.com', | 'https://FakeChronikUrlToEnsureMocksOnly.com', | ||||
); | ); | ||||
expect( | expect( | ||||
await finalizeTokensArray( | await finalizeTokensArray( | ||||
chronik, | chronik, | ||||
mockPreliminaryTokensArrayClone, | mockPreliminaryTokensArrayClone, | ||||
mockFinalCachedTokenInfo, | mockFinalCachedTokenInfo, | ||||
), | ), | ||||
).toStrictEqual({ | ).toStrictEqual({ | ||||
finalTokenArray: mockFinalTokenArray, | tokens: mockFinalTokenArray, | ||||
updatedTokenInfoById: mockFinalCachedTokenInfo, | updatedTokenInfoById: mockFinalCachedTokenInfo, | ||||
newTokensToCache: false, | newTokensToCache: false, | ||||
}); | }); | ||||
}); | }); | ||||
it(`updateCachedTokenInfoAndFinalizeTokensArray successfully returns finalTokenArray and cachedTokenInfoById when called with some token info in cache`, async () => { | it(`updateCachedTokenInfoAndFinalizeTokensArray successfully returns finalTokenArray and cachedTokenInfoById when called with some token info in cache`, async () => { | ||||
// Initialize chronik | // Initialize chronik | ||||
const chronik = new ChronikClient( | const chronik = new ChronikClient( | ||||
Show All 12 Lines | it(`updateCachedTokenInfoAndFinalizeTokensArray successfully returns finalTokenArray and cachedTokenInfoById when called with some token info in cache`, async () => { | ||||
expect( | expect( | ||||
await finalizeTokensArray( | await finalizeTokensArray( | ||||
chronik, | chronik, | ||||
mockPreliminaryTokensArrayCloneClone, | mockPreliminaryTokensArrayCloneClone, | ||||
mockPartialCachedTokenInfo, | mockPartialCachedTokenInfo, | ||||
), | ), | ||||
).toStrictEqual({ | ).toStrictEqual({ | ||||
finalTokenArray: mockFinalTokenArray, | tokens: mockFinalTokenArray, | ||||
updatedTokenInfoById: mockFinalCachedTokenInfo, | updatedTokenInfoById: mockFinalCachedTokenInfo, | ||||
newTokensToCache: true, | newTokensToCache: true, | ||||
}); | }); | ||||
}); | }); | ||||
it(`finalizeSlpUtxos successfully adds token quantity adjusted for token decimals to preliminarySlpUtxos`, async () => { | it(`finalizeSlpUtxos successfully adds token quantity adjusted for token decimals to preliminarySlpUtxos`, async () => { | ||||
expect( | expect( | ||||
await finalizeSlpUtxos(mockPreliminarySlpUtxos, mockTokenInfoById), | await finalizeSlpUtxos(mockPreliminarySlpUtxos, mockTokenInfoById), | ||||
▲ Show 20 Lines • Show All 649 Lines • Show Last 20 Lines |