2018-04-10 02:01:27 +02:00
|
|
|
const reactTriggerChange = require('../../lib/react-trigger-change')
|
|
|
|
const {
|
|
|
|
timeout,
|
|
|
|
queryAsync,
|
|
|
|
findAsync,
|
|
|
|
} = require('../../lib/util')
|
2020-01-13 16:07:32 +01:00
|
|
|
const fetchMockResponses = require('../../data/fetch-mocks.json')
|
2018-04-10 02:01:27 +02:00
|
|
|
|
|
|
|
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()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-05-08 21:51:33 +02:00
|
|
|
async function runCurrencyLocalizationTest (assert) {
|
2018-04-10 02:01:27 +02:00
|
|
|
console.log('*** start runCurrencyLocalizationTest')
|
|
|
|
const selectState = await queryAsync($, 'select')
|
|
|
|
selectState.val('currency localization')
|
2019-03-05 16:45:01 +01:00
|
|
|
|
2019-05-07 19:52:02 +02:00
|
|
|
const realFetch = window.fetch.bind(window)
|
2020-04-15 19:23:27 +02:00
|
|
|
window.fetch = (...args) => {
|
2019-05-07 19:52:02 +02:00
|
|
|
if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
|
|
|
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
|
|
|
|
} else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') {
|
|
|
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) })
|
|
|
|
} else if (args[0].match(/chromeextensionmm/)) {
|
2019-03-05 16:45:01 +01:00
|
|
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
|
|
|
}
|
2019-05-07 19:52:02 +02:00
|
|
|
return realFetch.fetch(...args)
|
2019-03-05 16:45:01 +01:00
|
|
|
}
|
|
|
|
|
2018-07-11 18:07:26 +02:00
|
|
|
await timeout(1000)
|
2018-04-10 02:01:27 +02:00
|
|
|
reactTriggerChange(selectState[0])
|
|
|
|
await timeout(1000)
|
2020-02-28 22:46:01 +01:00
|
|
|
const txView = await queryAsync($, '.home__main-view')
|
2020-05-21 19:33:48 +02:00
|
|
|
const heroBalance = await findAsync($(txView), '.eth-overview__balance')
|
|
|
|
const fiatAmount = await findAsync($(heroBalance), '.eth-overview__secondary-balance')
|
2018-10-21 13:12:40 +02:00
|
|
|
assert.equal(fiatAmount[0].textContent, '₱102,707.97PHP')
|
2018-04-10 02:01:27 +02:00
|
|
|
}
|