diff options
author | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-04-18 04:46:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-18 04:46:24 +0800 |
commit | 2ce33a3eee5383681b638ef6c426c46b65c6fa79 (patch) | |
tree | 096c6a8f7e12c5ece8bb64af1466bb2d94b6e5d3 /test | |
parent | 7b70804aa0d74120098a4bcb2c375d29080e8368 (diff) | |
parent | 6ee57dcad70057b1f71b9abe53d9d4965cbbe3e8 (diff) | |
download | tangerine-wallet-browser-2ce33a3eee5383681b638ef6c426c46b65c6fa79.tar tangerine-wallet-browser-2ce33a3eee5383681b638ef6c426c46b65c6fa79.tar.gz tangerine-wallet-browser-2ce33a3eee5383681b638ef6c426c46b65c6fa79.tar.bz2 tangerine-wallet-browser-2ce33a3eee5383681b638ef6c426c46b65c6fa79.tar.lz tangerine-wallet-browser-2ce33a3eee5383681b638ef6c426c46b65c6fa79.tar.xz tangerine-wallet-browser-2ce33a3eee5383681b638ef6c426c46b65c6fa79.tar.zst tangerine-wallet-browser-2ce33a3eee5383681b638ef6c426c46b65c6fa79.zip |
Merge pull request #3853 from MetaMask/i3580-InternationalizeCurrency
Internationalize currency
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/lib/currency-localization.js | 28 | ||||
-rw-r--r-- | test/integration/lib/send-new-ui.js | 8 | ||||
-rw-r--r-- | test/unit/balance-formatter-test.js | 27 |
3 files changed, 59 insertions, 4 deletions
diff --git a/test/integration/lib/currency-localization.js b/test/integration/lib/currency-localization.js new file mode 100644 index 000000000..7705c9720 --- /dev/null +++ b/test/integration/lib/currency-localization.js @@ -0,0 +1,28 @@ +const reactTriggerChange = require('../../lib/react-trigger-change') +const { + timeout, + queryAsync, + findAsync, +} = require('../../lib/util') + +QUnit.module('currency localization') + +QUnit.test('renders localized currency', (assert) => { + const done = assert.async() + runCurrencyLocalizationTest(assert).then(done).catch((err) => { + assert.notOk(err, `Error was thrown: ${err.stack}`) + done() + }) +}) + +async function runCurrencyLocalizationTest(assert, done) { + console.log('*** start runCurrencyLocalizationTest') + const selectState = await queryAsync($, 'select') + selectState.val('currency localization') + reactTriggerChange(selectState[0]) + await timeout(1000) + const txView = await queryAsync($, '.tx-view') + const heroBalance = await findAsync($(txView), '.hero-balance') + const fiatAmount = await findAsync($(heroBalance), '.fiat-amount') + assert.equal(fiatAmount[0].textContent, '₱102,707.97') +} diff --git a/test/integration/lib/send-new-ui.js b/test/integration/lib/send-new-ui.js index 4731117d7..09a074750 100644 --- a/test/integration/lib/send-new-ui.js +++ b/test/integration/lib/send-new-ui.js @@ -91,7 +91,7 @@ async function runSendFlowTest(assert, done) { ) assert.equal( sendGasField.find('.currency-display__converted-value')[0].textContent, - '0.24 USD', + '$0.24 USD', 'send gas field should show estimated gas total converted to USD' ) @@ -118,7 +118,7 @@ async function runSendFlowTest(assert, done) { ) assert.equal( (await findAsync(sendGasField, '.currency-display__converted-value'))[0].textContent, - '3.60 USD', + '$3.60 USD', 'send gas field should show customized gas total converted to USD' ) @@ -138,9 +138,9 @@ async function runSendFlowTest(assert, done) { const confirmScreenRows = await queryAsync($, '.confirm-screen-rows') const confirmScreenGas = confirmScreenRows.find('.currency-display__converted-value')[0] - assert.equal(confirmScreenGas.textContent, '3.60 USD', 'confirm screen should show correct gas') + assert.equal(confirmScreenGas.textContent, '$3.60 USD', 'confirm screen should show correct gas') const confirmScreenTotal = confirmScreenRows.find('.confirm-screen-row-info')[2] - assert.equal(confirmScreenTotal.textContent, '2405.36 USD', 'confirm screen should show correct total') + assert.equal(confirmScreenTotal.textContent, '$2,405.36 USD', 'confirm screen should show correct total') const confirmScreenBackButton = await queryAsync($, '.page-container__back-button') confirmScreenBackButton[0].click() diff --git a/test/unit/balance-formatter-test.js b/test/unit/balance-formatter-test.js new file mode 100644 index 000000000..ab6daa19c --- /dev/null +++ b/test/unit/balance-formatter-test.js @@ -0,0 +1,27 @@ +const assert = require('assert') +const currencyFormatter = require('currency-formatter') +const infuraConversion = require('../../ui/app/infura-conversion.json') + +describe('currencyFormatting', function () { + it('be able to format any infura currency', function (done) { + const number = 10000 + + infuraConversion.objects.forEach((conversion) => { + const code = conversion.quote.code.toUpperCase() + const result = currencyFormatter.format(number, { code }) + + switch (code) { + case 'USD': + assert.equal(result, '$10,000.00') + break + case 'JPY': + assert.equal(result, '¥10,000') + break + default: + assert.ok(result, `Currency ${code} formatted as ${result}`) + } + }) + + done() + }) +}) |