TST: fix some tests failing due to: 1) timers 2) linux locale differences

This commit is contained in:
Overtorment 2020-07-28 16:02:05 +01:00
parent 68c79f995b
commit 110c801dde
3 changed files with 12 additions and 8 deletions

View file

@ -20,11 +20,11 @@ it('bip38 decodes', async () => {
});
it('bip38 decodes slow', async () => {
if (process.env.USER === 'burn' || process.env.USER === 'igor' || process.env.USER === 'overtorment') {
// run only on circleCI
if (!(process.env.CI || process.env.TRAVIS)) {
// run only on CI
return;
}
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000;
const bip38 = require('../../blue_modules/bip38');
const wif = require('wif');

View file

@ -29,6 +29,9 @@ describe('currency', () => {
currency._setPreferredFiatCurrency(FiatUnit.JPY);
currency._setExchangeRate('BTC_JPY', 1043740.8614);
assert.strictEqual(currency.satoshiToLocalCurrency(1), '¥0.01');
assert.ok(
currency.satoshiToLocalCurrency(1) === '¥0.01' || currency.satoshiToLocalCurrency(1) === '¥0.01',
'Unexpected: ' + currency.satoshiToLocalCurrency(1),
);
});
});

View file

@ -1,9 +1,10 @@
/* global it, describe */
/* global it, describe, jest */
import { BitcoinUnit } from '../../models/bitcoinUnits';
import { FiatUnit } from '../../models/fiatUnit';
import { _leaveNumbersAndDots, formatBalanceWithoutSuffix, formatBalancePlain, formatBalance } from '../../loc';
const assert = require('assert');
const currency = require('../../blue_modules/currency');
jest.useFakeTimers();
describe('Localization', () => {
it('internal formatter', () => {
@ -16,17 +17,17 @@ describe('Localization', () => {
currency._setExchangeRate('BTC_RUB', 660180.143);
currency._setPreferredFiatCurrency(FiatUnit.RUB);
let newInputValue = formatBalanceWithoutSuffix(152, BitcoinUnit.LOCAL_CURRENCY, false);
assert.strictEqual(newInputValue, 'RUB 1.00');
assert.ok(newInputValue === 'RUB 1.00' || newInputValue === '1,00 ₽', 'Unexpected: ' + newInputValue);
newInputValue = formatBalancePlain(152, BitcoinUnit.LOCAL_CURRENCY, false);
assert.strictEqual(newInputValue, '1');
newInputValue = formatBalanceWithoutSuffix(1515, BitcoinUnit.LOCAL_CURRENCY, false);
assert.strictEqual(newInputValue, 'RUB 10.00');
assert.ok(newInputValue === 'RUB 10.00' || newInputValue === '10,00 ₽', 'Unexpected: ' + newInputValue);
newInputValue = formatBalancePlain(1515, BitcoinUnit.LOCAL_CURRENCY, false);
assert.strictEqual(newInputValue, '10');
newInputValue = formatBalanceWithoutSuffix(16793829, BitcoinUnit.LOCAL_CURRENCY, false);
assert.strictEqual(newInputValue, 'RUB 110,869.52');
assert.ok(newInputValue === 'RUB 110,869.52' || newInputValue === '110 869,52 ₽', 'Unexpected: ' + newInputValue);
newInputValue = formatBalancePlain(16793829, BitcoinUnit.LOCAL_CURRENCY, false);
assert.strictEqual(newInputValue, '110869.52');