mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 21:57:06 +01:00
27cfb6aa51
The Selenium webdriver is difficult to use, and easy to misuse. To help use the driver and make it easier to maintain our e2e tests, all driver interactions are now performed via a `driver` module. This is basically a wrapper class around the `selenium-webdriver` that exposes only the methods we want to use directly, along with all of our helper methods.
44 lines
1.7 KiB
JavaScript
44 lines
1.7 KiB
JavaScript
const reactTriggerChange = require('../../lib/react-trigger-change')
|
|
const {
|
|
timeout,
|
|
queryAsync,
|
|
findAsync,
|
|
} = require('../../lib/util')
|
|
const fetchMockResponses = require('../../data/fetch-mocks.json')
|
|
|
|
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) {
|
|
console.log('*** start runCurrencyLocalizationTest')
|
|
const selectState = await queryAsync($, 'select')
|
|
selectState.val('currency localization')
|
|
|
|
const realFetch = window.fetch.bind(window)
|
|
global.fetch = (...args) => {
|
|
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/)) {
|
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
|
}
|
|
return realFetch.fetch(...args)
|
|
}
|
|
|
|
await timeout(1000)
|
|
reactTriggerChange(selectState[0])
|
|
await timeout(1000)
|
|
const txView = await queryAsync($, '.transaction-view')
|
|
const heroBalance = await findAsync($(txView), '.transaction-view-balance__balance')
|
|
const fiatAmount = await findAsync($(heroBalance), '.transaction-view-balance__secondary-balance')
|
|
assert.equal(fiatAmount[0].textContent, '₱102,707.97PHP')
|
|
}
|