Resolve "BCMR Adapter: Create BaseBCMR and HTTP implementation"
This commit is contained in:
committed by
Emergent Reasons
parent
6d0a36248d
commit
e4020a996c
@@ -0,0 +1,46 @@
|
||||
import { test, expect, describe } from 'vitest';
|
||||
|
||||
import { BCMRComposite } from '../../src/bcmr/bcmr-composite.js';
|
||||
import { BCMRHttp } from '../../src/index.js';
|
||||
|
||||
// musd-v1
|
||||
const categoryId =
|
||||
'b38a33f750f84c5c169a6f23cb873e6e79605021585d4f3408789689ed87f366';
|
||||
const musdTokenField = {
|
||||
x: 'https://x.com/MoriaMoney/',
|
||||
web: 'https://moria.money',
|
||||
icon: 'https://meta.moria.money/m1.png',
|
||||
telegram: 'https://t.me/moriamoney',
|
||||
};
|
||||
|
||||
describe('BCMRComposite', () => {
|
||||
const bcmrComposite = new BCMRComposite([
|
||||
new BCMRHttp({ indexerUri: 'https://bcmr.paytaca.com/api/tokens/' }),
|
||||
new BCMRHttp({
|
||||
indexerUri: 'https://bcmr.flowee.cash/',
|
||||
endpointEndsWithDotJson: true,
|
||||
}),
|
||||
]);
|
||||
|
||||
test('should return token metadata', async () => {
|
||||
const metadata = await bcmrComposite.getTokenData(categoryId);
|
||||
|
||||
expect(metadata).toBeDefined();
|
||||
expect(metadata?.token.symbol).toBeDefined();
|
||||
expect(metadata?.token.symbol).toBe('MUSD');
|
||||
});
|
||||
|
||||
test('metadata should have a uris field that matches', async () => {
|
||||
const matches = await bcmrComposite.searchField(categoryId, 'uris');
|
||||
|
||||
expect(Array.isArray(matches)).toBeTruthy();
|
||||
expect((matches as Array<unknown>).length).toBeGreaterThan(0);
|
||||
expect((matches as Array<unknown>)[0]).toMatchObject(musdTokenField);
|
||||
});
|
||||
|
||||
test('should fail if cantegoryId is not a registered entry', async () => {
|
||||
const invalidCategoryId = 'asd123';
|
||||
|
||||
await expect(bcmrComposite.getTokenData(invalidCategoryId)).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user