You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.5 KiB
43 lines
1.5 KiB
4 years ago
|
import { ETH } from '../constants/common';
|
||
|
import * as utils from './conversions.util';
|
||
4 years ago
|
|
||
4 years ago
|
describe('conversion utils', () => {
|
||
|
describe('getWeiHexFromDecimalValue', () => {
|
||
|
it('should correctly convert 0 in ETH', () => {
|
||
4 years ago
|
const weiValue = utils.getWeiHexFromDecimalValue({
|
||
|
value: '0',
|
||
|
fromCurrency: ETH,
|
||
|
fromDenomination: ETH,
|
||
4 years ago
|
});
|
||
4 years ago
|
expect(weiValue).toStrictEqual('0');
|
||
4 years ago
|
});
|
||
|
});
|
||
4 years ago
|
|
||
4 years ago
|
describe('decETHToDecWEI', () => {
|
||
|
it('should correctly convert 1 ETH to WEI', () => {
|
||
4 years ago
|
const weiValue = utils.decETHToDecWEI('1');
|
||
4 years ago
|
expect(weiValue).toStrictEqual('1000000000000000000');
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
4 years ago
|
it('should correctly convert 0.000000000000000001 ETH to WEI', () => {
|
||
4 years ago
|
const weiValue = utils.decETHToDecWEI('0.000000000000000001');
|
||
4 years ago
|
expect(weiValue).toStrictEqual('1');
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
4 years ago
|
it('should correctly convert 1000000.000000000000000001 ETH to WEI', () => {
|
||
4 years ago
|
const weiValue = utils.decETHToDecWEI('1000000.000000000000000001');
|
||
4 years ago
|
expect(weiValue).toStrictEqual('1000000000000000000000001');
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
4 years ago
|
it('should correctly convert 9876.543210 ETH to WEI', () => {
|
||
4 years ago
|
const weiValue = utils.decETHToDecWEI('9876.543210');
|
||
4 years ago
|
expect(weiValue).toStrictEqual('9876543210000000000000');
|
||
4 years ago
|
});
|
||
4 years ago
|
|
||
4 years ago
|
it('should correctly convert 1.0000000000000000 ETH to WEI', () => {
|
||
4 years ago
|
const weiValue = utils.decETHToDecWEI('1.0000000000000000');
|
||
4 years ago
|
expect(weiValue).toStrictEqual('1000000000000000000');
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|