MyCrypto/common/api/shapeshift.spec.ts
Connor Bryan f3bcc99603 Grey out disabled swap options (#2026)
* Adjust emailTo to desired email addresses

* Prettierize SupportFooter

* Add monero swap support

* Adjust styling and wording for the PaymentInfo screen for XMR

* Only show warning on XMR swaps (duh)

* Replicate comment

* Fix styling for rates and payment info

* Add a Monero donation address and use it as the placeholder for the ReceivingAddress Input

* Add a public method for the ShapeShift service to add unavailable coins to coin list

* Show unavailable swap options in a sorted manner.

* Test implementation
2018-07-06 13:56:54 -05:00

126 lines
3.0 KiB
TypeScript

import shapeshift, { SHAPESHIFT_BASE_URL } from './shapeshift';
describe('ShapeShift service', () => {
beforeEach(() => {
(global as any).fetch = jest.fn().mockImplementation(
(url: string) =>
new Promise(resolve => {
const returnValues = {
[`${SHAPESHIFT_BASE_URL}/marketinfo`]: {
status: 200,
json: () => [
{
limit: 1,
maxLimit: 2,
min: 1,
minerFee: 2,
pair: 'BTC_ETH',
rate: '1.0'
},
{
limit: 1,
maxLimit: 2,
min: 1,
minerFee: 2,
pair: 'ETH_BTC',
rate: '1.0'
}
]
},
[`${SHAPESHIFT_BASE_URL}/getcoins`]: {
status: 200,
json: () => ({
BTC: {
name: 'Bitcoin',
symbol: 'BTC',
image: '',
imageSmall: '',
status: 'available',
minerFee: 1
},
ETH: {
name: 'Ethereum',
symbol: 'ETH',
image: '',
imageSmall: '',
status: 'available',
minerFee: 1
},
XMR: {
name: 'Monero',
symbol: 'XMR',
image: '',
imageSmall: '',
status: 'unavailable',
minerFee: 1
}
})
}
};
resolve(returnValues[url]);
})
);
});
it('provides a collection of all available and unavailable coins and tokens', async done => {
const rates = await shapeshift.getAllRates();
expect(rates).toEqual({
BTCETH: {
id: 'BTCETH',
rate: '1.0',
limit: 1,
min: 1,
options: [
{
id: 'BTC',
image: '',
name: 'Bitcoin',
status: 'available'
},
{
id: 'ETH',
image: '',
name: 'Ethereum',
status: 'available'
}
]
},
ETHBTC: {
id: 'ETHBTC',
rate: '1.0',
limit: 1,
min: 1,
options: [
{
id: 'ETH',
image: '',
name: 'Ethereum',
status: 'available'
},
{
id: 'BTC',
image: '',
name: 'Bitcoin',
status: 'available'
}
]
},
__XMR: {
id: '__XMR',
limit: 0,
min: 0,
options: [
{
id: 'XMR',
image: '',
name: 'Monero',
status: 'unavailable'
}
]
}
});
done();
});
});