diff --git a/test/alexSDK.mock-externals.test.ts b/test/alexSDK.mock-externals.test.ts index 59df16d..768c34c 100644 --- a/test/alexSDK.mock-externals.test.ts +++ b/test/alexSDK.mock-externals.test.ts @@ -26,7 +26,7 @@ const stxAddress = 'SM2MARAVW6BEJCD13YV2RHGYHQWT7TDDNMNRB1MVT'; describe('AlexSDK - mock externals', () => { beforeEach(() => { - fetchMock.get('https://alex-sdk-api.alexlab.co', 500); + fetchMock.get(configs.SDK_API_HOST, 500); }); afterEach(() => { fetchMock.restore(); @@ -34,24 +34,24 @@ describe('AlexSDK - mock externals', () => { it('Attempt to Get Latest Prices with incorrect Alex SDK Data', async () => { await expect(sdk.getLatestPrices()).rejects.toThrow( - 'Failed to fetch token mappings', + 'Failed to fetch token mappings' ); }, 10000); it('Attempt to Get Fee with incorrect Alex SDK Data', async () => { await expect(sdk.getFeeRate(tokenAlex, Currency.STX)).rejects.toThrow( - 'Failed to fetch token mappings', + 'Failed to fetch token mappings' ); }, 10000); it('Attempt to Get Router with incorrect Alex SDK Data', async () => { await expect(sdk.getRouter(tokenAlex, Currency.STX)).rejects.toThrow( - 'Failed to fetch token mappings', + 'Failed to fetch token mappings' ); }, 10000); it('Attempt to Get Amount with incorrect Alex SDK Data', async () => { await expect( - sdk.getAmountTo(Currency.STX, BigInt(2) * BigInt(1e8), tokenWUSDA), + sdk.getAmountTo(Currency.STX, BigInt(2) * BigInt(1e8), tokenWUSDA) ).rejects.toThrow('Failed to fetch token mappings'); }, 10000); @@ -62,34 +62,34 @@ describe('AlexSDK - mock externals', () => { tokenAlex, tokenWUSDA, BigInt(2) * BigInt(1e8), - BigInt(0), - ), + BigInt(0) + ) ).rejects.toThrow('Failed to fetch token mappings'); }, 10000); it('Attempt to Get Latest Prices with incorrect Alex SDK Data', async () => { await expect(sdk.getLatestPrices()).rejects.toThrow( - 'Failed to fetch token mappings', + 'Failed to fetch token mappings' ); }, 10000); it('Attempt to Get Balances with incorrect Alex SDK Data', async () => { const stxAddress = 'SM2MARAVW6BEJCD13YV2RHGYHQWT7TDDNMNRB1MVT'; await expect(sdk.getBalances(stxAddress)).rejects.toThrow( - 'Failed to fetch token mappings', + 'Failed to fetch token mappings' ); }, 10000); it('Attempt to Fetch Swappable Currency with incorrect Alex SDK Data', async () => { await expect(sdk.fetchSwappableCurrency()).rejects.toThrow( - 'Failed to fetch token mappings', + 'Failed to fetch token mappings' ); }, 10000); }); -describe('AlexSDK - mock externals - API_HOST', () => { +describe('AlexSDK - mock externals - BACKEND_API_HOST', () => { beforeEach(() => { - fetchMock.get(`${configs.API_HOST}/v2/public/token-prices`, { + fetchMock.get(`${configs.BACKEND_API_HOST}/v2/public/token-prices`, { status: 500, body: 'Internal Server Error', }); @@ -100,24 +100,34 @@ describe('AlexSDK - mock externals - API_HOST', () => { }); it('Attempt to get token prices with incorrect data', async () => { - await expect(getPrices(tokenMappings)).rejects.toThrow('Failed to fetch token mappings'); - expect(fetchMock.calls(`${configs.API_HOST}/v2/public/token-prices`).length).toBe(1); + await expect(getPrices(tokenMappings)).rejects.toThrow( + 'Failed to fetch token mappings' + ); + expect( + fetchMock.calls(`${configs.BACKEND_API_HOST}/v2/public/token-prices`) + .length + ).toBe(1); }, 10000); }); describe('Transfer Factory', () => { it('Throws error in Transfer Factory', () => { const transfer = transferFactory(tokenMappings); - expect(() => transfer(stxAddress, tokenAlex, BigInt(1000))).toThrow('Token mapping not found'); + expect(() => transfer(stxAddress, tokenAlex, BigInt(1000))).toThrow( + 'Token mapping not found' + ); }); }); describe('AlexSDK - mock externals - STACKS_API_HOST', () => { beforeEach(() => { - fetchMock.get(`${configs.STACKS_API_HOST}/extended/v1/address/${stxAddress}/balances`, { - status: 500, - body: 'Internal Server Error', - }); + fetchMock.get( + `${configs.STACKS_API_HOST}/extended/v1/address/${stxAddress}/balances`, + { + status: 500, + body: 'Internal Server Error', + } + ); }); afterEach(() => { @@ -125,8 +135,12 @@ describe('AlexSDK - mock externals - STACKS_API_HOST', () => { }); it('Attempt to Get Balances with incorrect data', async () => { - await expect(fetchBalanceForAccount(stxAddress, tokenMappings)).rejects. - toThrow(new - SyntaxError('Unexpected token \'I\', "Internal S"... is not valid JSON')); + await expect( + fetchBalanceForAccount(stxAddress, tokenMappings) + ).rejects.toThrow( + new SyntaxError( + 'Unexpected token \'I\', "Internal S"... is not valid JSON' + ) + ); }, 10000); }); diff --git a/test/alexSDK.test.ts b/test/alexSDK.test.ts index edfc4c8..7299230 100644 --- a/test/alexSDK.test.ts +++ b/test/alexSDK.test.ts @@ -52,7 +52,7 @@ describe('AlexSDK', () => { }, 10000); it('Verify response of getFeeRate function (custom route)', async () => { - const customRoute = await sdk.getRoute(tokenAlex, Currency.STX); + const customRoute = await sdk.getRoute(tokenAlex, Currency.STX); const result = await sdk.getFeeRate(tokenAlex, Currency.STX, customRoute); expect(typeof result).toBe('bigint'); expect(result >= BigInt(0)).toBeTruthy(); @@ -235,10 +235,8 @@ describe('AlexSDK', () => { expect(balances).toBeDefined(); expect(typeof balances).toBe('object'); Object.keys(balances).forEach((currency) => { - - expect(typeof balances[currency as Currency]).toBe('bigint'); - } - ); + expect(typeof balances[currency as Currency]).toBe('bigint'); + }); }); it('Attempt to get balances with invalid address', async () => {