mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-02 18:34:09 +00:00
update tests
This commit is contained in:
parent
0099078e94
commit
eda616dc73
@ -2,6 +2,7 @@
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const sinon = require('sinon');
|
const sinon = require('sinon');
|
||||||
const AccountParser = require('../lib/contracts/accountParser');
|
const AccountParser = require('../lib/contracts/accountParser');
|
||||||
|
const utils = require('../lib/utils/utils');
|
||||||
let TestLogger = require('../lib/tests/test_logger.js');
|
let TestLogger = require('../lib/tests/test_logger.js');
|
||||||
const Web3 = require('web3');
|
const Web3 = require('web3');
|
||||||
const i18n = require('../lib/i18n/i18n.js');
|
const i18n = require('../lib/i18n/i18n.js');
|
||||||
@ -75,38 +76,38 @@ describe('embark.AccountParser', function () {
|
|||||||
|
|
||||||
describe('getHexBalance', () => {
|
describe('getHexBalance', () => {
|
||||||
it('should return default if no balance', () => {
|
it('should return default if no balance', () => {
|
||||||
const hexBalance = AccountParser.getHexBalance(null, Web3);
|
const hexBalance = utils.getHexBalanceFromString(null, Web3);
|
||||||
|
|
||||||
assert.strictEqual(hexBalance, 0xFFFFFFFFFFFFFFFFFF);
|
assert.strictEqual(hexBalance, 0xFFFFFFFFFFFFFFFFFF);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the balance string if already hexadecimal', () => {
|
it('should return the balance string if already hexadecimal', () => {
|
||||||
const hexBalance = AccountParser.getHexBalance('0xFFF', Web3);
|
const hexBalance = utils.getHexBalanceFromString('0xFFF', Web3);
|
||||||
|
|
||||||
assert.strictEqual(hexBalance, '0xFFF');
|
assert.strictEqual(hexBalance, '0xFFF');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should convert to hex when decimal', () => {
|
it('should convert to hex when decimal', () => {
|
||||||
const hexBalance = AccountParser.getHexBalance('500', Web3);
|
const hexBalance = utils.getHexBalanceFromString('500', Web3);
|
||||||
|
|
||||||
assert.strictEqual(hexBalance, '0x1f4');
|
assert.strictEqual(hexBalance, '0x1f4');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should convert to hex with eth string', () => {
|
it('should convert to hex with eth string', () => {
|
||||||
const hexBalance = AccountParser.getHexBalance('4ether', Web3);
|
const hexBalance = utils.getHexBalanceFromString('4ether', Web3);
|
||||||
|
|
||||||
assert.strictEqual(hexBalance, '0x3782dace9d900000');
|
assert.strictEqual(hexBalance, '0x3782dace9d900000');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should convert to hex with eth string with space', () => {
|
it('should convert to hex with eth string with space', () => {
|
||||||
const hexBalance = AccountParser.getHexBalance('673 shannon', Web3);
|
const hexBalance = utils.getHexBalanceFromString('673 shannon', Web3);
|
||||||
|
|
||||||
assert.strictEqual(hexBalance, '0x9cb1ed0a00');
|
assert.strictEqual(hexBalance, '0x9cb1ed0a00');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when string is not good', () => {
|
it('should fail when string is not good', () => {
|
||||||
try {
|
try {
|
||||||
AccountParser.getHexBalance('nogood', Web3);
|
utils.getHexBalanceFromString('nogood', Web3);
|
||||||
assert.fail('Should have failed at getHexBalance');
|
assert.fail('Should have failed at getHexBalance');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Ok
|
// Ok
|
||||||
|
Loading…
x
Reference in New Issue
Block a user