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.
28 lines
791 B
28 lines
791 B
4 years ago
|
import assert from 'assert';
|
||
|
import currencyFormatter from 'currency-formatter';
|
||
|
import availableCurrencies from '../../ui/app/helpers/constants/available-conversions.json';
|
||
7 years ago
|
|
||
7 years ago
|
describe('currencyFormatting', function () {
|
||
7 years ago
|
it('be able to format any infura currency', function (done) {
|
||
4 years ago
|
const number = 10000;
|
||
7 years ago
|
|
||
5 years ago
|
availableCurrencies.forEach((conversion) => {
|
||
4 years ago
|
const code = conversion.code.toUpperCase();
|
||
|
const result = currencyFormatter.format(number, { code });
|
||
7 years ago
|
|
||
|
switch (code) {
|
||
|
case 'USD':
|
||
4 years ago
|
assert.equal(result, '$10,000.00');
|
||
|
break;
|
||
7 years ago
|
case 'JPY':
|
||
4 years ago
|
assert.equal(result, '¥10,000');
|
||
|
break;
|
||
7 years ago
|
default:
|
||
4 years ago
|
assert.ok(result, `Currency ${code} formatted as ${result}`);
|
||
7 years ago
|
}
|
||
4 years ago
|
});
|
||
7 years ago
|
|
||
4 years ago
|
done();
|
||
|
});
|
||
|
});
|