mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Update ESLint rules for test suite (#8023)
* Use @metamask/eslint-config@1.1.0 * Use eslint-plugin-mocha@6.2.2 * Mark root ESLint config as root * Update Mocha ESLint rules with shared ESLint config
This commit is contained in:
parent
3bbbe13311
commit
4f3fc95d50
@ -1,4 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
|
root: true,
|
||||||
parser: 'babel-eslint',
|
parser: 'babel-eslint',
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
'sourceType': 'module',
|
'sourceType': 'module',
|
||||||
@ -20,17 +21,16 @@ module.exports = {
|
|||||||
extends: [
|
extends: [
|
||||||
'@metamask/eslint-config',
|
'@metamask/eslint-config',
|
||||||
'@metamask/eslint-config/config/nodejs',
|
'@metamask/eslint-config/config/nodejs',
|
||||||
|
'@metamask/eslint-config/config/mocha',
|
||||||
'plugin:react/recommended',
|
'plugin:react/recommended',
|
||||||
],
|
],
|
||||||
|
|
||||||
env: {
|
env: {
|
||||||
'browser': true,
|
'browser': true,
|
||||||
'mocha': true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
'babel',
|
'babel',
|
||||||
'mocha',
|
|
||||||
'chai',
|
'chai',
|
||||||
'react',
|
'react',
|
||||||
'json',
|
'json',
|
||||||
@ -90,6 +90,6 @@ module.exports = {
|
|||||||
'prop': 'parens-new-line',
|
'prop': 'parens-new-line',
|
||||||
}],
|
}],
|
||||||
'babel/semi': ['error', 'never'],
|
'babel/semi': ['error', 'never'],
|
||||||
'mocha/no-exclusive-tests': 'error',
|
'mocha/no-setup-in-describe': 'off',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@
|
|||||||
"@babel/preset-env": "^7.5.5",
|
"@babel/preset-env": "^7.5.5",
|
||||||
"@babel/preset-react": "^7.0.0",
|
"@babel/preset-react": "^7.0.0",
|
||||||
"@babel/register": "^7.5.5",
|
"@babel/register": "^7.5.5",
|
||||||
"@metamask/eslint-config": "^1.0.0",
|
"@metamask/eslint-config": "^1.1.0",
|
||||||
"@metamask/forwarder": "^1.1.0",
|
"@metamask/forwarder": "^1.1.0",
|
||||||
"@metamask/onboarding": "^0.2.0",
|
"@metamask/onboarding": "^0.2.0",
|
||||||
"@sentry/cli": "^1.49.0",
|
"@sentry/cli": "^1.49.0",
|
||||||
@ -208,7 +208,7 @@
|
|||||||
"eslint-plugin-chai": "0.0.1",
|
"eslint-plugin-chai": "0.0.1",
|
||||||
"eslint-plugin-import": "^2.19.1",
|
"eslint-plugin-import": "^2.19.1",
|
||||||
"eslint-plugin-json": "^1.2.0",
|
"eslint-plugin-json": "^1.2.0",
|
||||||
"eslint-plugin-mocha": "^5.0.0",
|
"eslint-plugin-mocha": "^6.2.2",
|
||||||
"eslint-plugin-react": "^7.4.0",
|
"eslint-plugin-react": "^7.4.0",
|
||||||
"fancy-log": "^1.3.3",
|
"fancy-log": "^1.3.3",
|
||||||
"fetch-mock": "^6.5.2",
|
"fetch-mock": "^6.5.2",
|
||||||
|
5
test/e2e/.eslintrc.js
Normal file
5
test/e2e/.eslintrc.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
rules: {
|
||||||
|
'mocha/no-hooks-for-single-case': 'off',
|
||||||
|
},
|
||||||
|
}
|
@ -52,24 +52,24 @@ describe('MetaMask', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Going through the first time flow', () => {
|
describe('Going through the first time flow', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver.findElement(By.css('.welcome-page__header'))
|
await driver.findElement(By.css('.welcome-page__header'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Create New Wallet" option', async () => {
|
it('clicks the "Create New Wallet" option', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "No thanks" option on the metametrics opt-in screen', async () => {
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
||||||
await driver.clickElement(By.css('.btn-default'))
|
await driver.clickElement(By.css('.btn-default'))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('accepts a secure password', async () => {
|
it('accepts a secure password', async function () {
|
||||||
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
||||||
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
let seedPhrase
|
let seedPhrase
|
||||||
|
|
||||||
it('reveals the seed phrase', async () => {
|
it('reveals the seed phrase', async function () {
|
||||||
const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button')
|
const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button')
|
||||||
await driver.clickElement(byRevealButton)
|
await driver.clickElement(byRevealButton)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -102,7 +102,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(tinyDelayMs)
|
await driver.delay(tinyDelayMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
it('can retype the seed phrase', async () => {
|
it('can retype the seed phrase', async function () {
|
||||||
const words = seedPhrase.split(' ')
|
const words = seedPhrase.split(' ')
|
||||||
|
|
||||||
for (const word of words) {
|
for (const word of words) {
|
||||||
@ -113,15 +113,15 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks through the success screen', async () => {
|
it('clicks through the success screen', async function () {
|
||||||
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Import seed phrase', () => {
|
describe('Import seed phrase', function () {
|
||||||
it('logs out of the vault', async () => {
|
it('logs out of the vault', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('imports seed phrase', async () => {
|
it('imports seed phrase', async function () {
|
||||||
const restoreSeedLink = await driver.findClickableElement(By.css('.unlock-page__link--import'))
|
const restoreSeedLink = await driver.findClickableElement(By.css('.unlock-page__link--import'))
|
||||||
assert.equal(await restoreSeedLink.getText(), 'Import using account seed phrase')
|
assert.equal(await restoreSeedLink.getText(), 'Import using account seed phrase')
|
||||||
await restoreSeedLink.click()
|
await restoreSeedLink.click()
|
||||||
@ -150,14 +150,14 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('balance renders', async () => {
|
it('balance renders', async function () {
|
||||||
const balance = await driver.findElement(By.css('.balance-display .token-amount'))
|
const balance = await driver.findElement(By.css('.balance-display .token-amount'))
|
||||||
await driver.wait(until.elementTextMatches(balance, /25\s*ETH/))
|
await driver.wait(until.elementTextMatches(balance, /25\s*ETH/))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Adds an entry to the address book and sends eth to that address', () => {
|
describe('Adds an entry to the address book and sends eth to that address', function () {
|
||||||
it('starts a send transaction', async function () {
|
it('starts a send transaction', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -205,7 +205,7 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Sends to an address book entry', () => {
|
describe('Sends to an address book entry', function () {
|
||||||
it('starts a send transaction by clicking address book entry', async function () {
|
it('starts a send transaction by clicking address book entry', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
@ -51,24 +51,24 @@ describe('MetaMask', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Going through the first time flow, but skipping the seed phrase challenge', () => {
|
describe('Going through the first time flow, but skipping the seed phrase challenge', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver.findElement(By.css('.welcome-page__header'))
|
await driver.findElement(By.css('.welcome-page__header'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Create New Wallet" option', async () => {
|
it('clicks the "Create New Wallet" option', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "No thanks" option on the metametrics opt-in screen', async () => {
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
||||||
await driver.clickElement(By.css('.btn-default'))
|
await driver.clickElement(By.css('.btn-default'))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('accepts a secure password', async () => {
|
it('accepts a secure password', async function () {
|
||||||
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
||||||
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('skips the seed phrase challenge', async () => {
|
it('skips the seed phrase challenge', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.remindMeLater.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.remindMeLater.message}')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('gets the current accounts address', async () => {
|
it('gets the current accounts address', async function () {
|
||||||
const addressInput = await driver.findElement(By.css('.qr-ellip-address'))
|
const addressInput = await driver.findElement(By.css('.qr-ellip-address'))
|
||||||
publicAddress = await addressInput.getAttribute('value')
|
publicAddress = await addressInput.getAttribute('value')
|
||||||
const accountModal = await driver.findElement(By.css('span .modal'))
|
const accountModal = await driver.findElement(By.css('span .modal'))
|
||||||
@ -101,12 +101,12 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('provider listening for events', () => {
|
describe('provider listening for events', function () {
|
||||||
let extension
|
let extension
|
||||||
let popup
|
let popup
|
||||||
let dapp
|
let dapp
|
||||||
|
|
||||||
it('connects to the dapp', async () => {
|
it('connects to the dapp', async function () {
|
||||||
await driver.openNewPage('http://127.0.0.1:8080/')
|
await driver.openNewPage('http://127.0.0.1:8080/')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -134,13 +134,13 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has the ganache network id within the dapp', async () => {
|
it('has the ganache network id within the dapp', async function () {
|
||||||
const networkDiv = await driver.findElement(By.css('#network'))
|
const networkDiv = await driver.findElement(By.css('#network'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
assert.equal(await networkDiv.getText(), '5777')
|
assert.equal(await networkDiv.getText(), '5777')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('changes the network', async () => {
|
it('changes the network', async function () {
|
||||||
await driver.switchToWindow(extension)
|
await driver.switchToWindow(extension)
|
||||||
|
|
||||||
await driver.clickElement(By.css('.network-name'))
|
await driver.clickElement(By.css('.network-name'))
|
||||||
@ -150,19 +150,19 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets the network div within the dapp', async () => {
|
it('sets the network div within the dapp', async function () {
|
||||||
await driver.switchToWindow(dapp)
|
await driver.switchToWindow(dapp)
|
||||||
const networkDiv = await driver.findElement(By.css('#network'))
|
const networkDiv = await driver.findElement(By.css('#network'))
|
||||||
assert.equal(await networkDiv.getText(), '3')
|
assert.equal(await networkDiv.getText(), '3')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets the chainId div within the dapp', async () => {
|
it('sets the chainId div within the dapp', async function () {
|
||||||
await driver.switchToWindow(dapp)
|
await driver.switchToWindow(dapp)
|
||||||
const chainIdDiv = await driver.findElement(By.css('#chainId'))
|
const chainIdDiv = await driver.findElement(By.css('#chainId'))
|
||||||
assert.equal(await chainIdDiv.getText(), '0x3')
|
assert.equal(await chainIdDiv.getText(), '0x3')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets the account div within the dapp', async () => {
|
it('sets the account div within the dapp', async function () {
|
||||||
await driver.switchToWindow(dapp)
|
await driver.switchToWindow(dapp)
|
||||||
const accountsDiv = await driver.findElement(By.css('#accounts'))
|
const accountsDiv = await driver.findElement(By.css('#accounts'))
|
||||||
assert.equal(await accountsDiv.getText(), publicAddress.toLowerCase())
|
assert.equal(await accountsDiv.getText(), publicAddress.toLowerCase())
|
||||||
|
@ -56,24 +56,24 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('First time flow starting from an existing seed phrase', () => {
|
describe('First time flow starting from an existing seed phrase', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver.findElement(By.css('.welcome-page__header'))
|
await driver.findElement(By.css('.welcome-page__header'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Import Wallet" option', async () => {
|
it('clicks the "Import Wallet" option', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Import Wallet')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Import Wallet')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "No thanks" option on the metametrics opt-in screen', async () => {
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
||||||
await driver.clickElement(By.css('.btn-default'))
|
await driver.clickElement(By.css('.btn-default'))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('imports a seed phrase', async () => {
|
it('imports a seed phrase', async function () {
|
||||||
const [seedTextArea] = await driver.findElements(By.css('textarea.first-time-flow__textarea'))
|
const [seedTextArea] = await driver.findElements(By.css('textarea.first-time-flow__textarea'))
|
||||||
await seedTextArea.sendKeys(testSeedPhrase)
|
await seedTextArea.sendKeys(testSeedPhrase)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -89,15 +89,15 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks through the success screen', async () => {
|
it('clicks through the success screen', async function () {
|
||||||
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Show account information', () => {
|
describe('Show account information', function () {
|
||||||
it('shows the correct account address', async () => {
|
it('shows the correct account address', async function () {
|
||||||
await driver.clickElement(By.css('.account-details__details-button'))
|
await driver.clickElement(By.css('.account-details__details-button'))
|
||||||
await driver.findVisibleElement(By.css('.qr-wrapper'))
|
await driver.findVisibleElement(By.css('.qr-wrapper'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -109,7 +109,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows a QR code for the account', async () => {
|
it('shows a QR code for the account', async function () {
|
||||||
await driver.clickElement(By.css('.account-details__details-button'))
|
await driver.clickElement(By.css('.account-details__details-button'))
|
||||||
await driver.findVisibleElement(By.css('.qr-wrapper'))
|
await driver.findVisibleElement(By.css('.qr-wrapper'))
|
||||||
const detailModal = await driver.findElement(By.css('span .modal'))
|
const detailModal = await driver.findElement(By.css('span .modal'))
|
||||||
@ -121,8 +121,8 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Lock and unlock', () => {
|
describe('Lock and unlock', function () {
|
||||||
it('logs out of the account', async () => {
|
it('logs out of the account', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon .identicon'))
|
await driver.clickElement(By.css('.account-menu__icon .identicon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('accepts the account password after lock', async () => {
|
it('accepts the account password after lock', async function () {
|
||||||
const passwordField = await driver.findElement(By.id('password'))
|
const passwordField = await driver.findElement(By.id('password'))
|
||||||
await passwordField.sendKeys('correct horse battery staple')
|
await passwordField.sendKeys('correct horse battery staple')
|
||||||
await passwordField.sendKeys(Key.ENTER)
|
await passwordField.sendKeys(Key.ENTER)
|
||||||
@ -140,8 +140,8 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Add an account', () => {
|
describe('Add an account', function () {
|
||||||
it('switches to localhost', async () => {
|
it('switches to localhost', async function () {
|
||||||
await driver.clickElement(By.css('.network-name'))
|
await driver.clickElement(By.css('.network-name'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('choose Create Account from the account menu', async () => {
|
it('choose Create Account from the account menu', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('set account name', async () => {
|
it('set account name', async function () {
|
||||||
const [accountName] = await driver.findElements(By.css('.new-account-create-form input'))
|
const [accountName] = await driver.findElements(By.css('.new-account-create-form input'))
|
||||||
await accountName.sendKeys('2nd account')
|
await accountName.sendKeys('2nd account')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -166,15 +166,15 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should show the correct account name', async () => {
|
it('should show the correct account name', async function () {
|
||||||
const [accountName] = await driver.findElements(By.css('.account-details__account-name'))
|
const [accountName] = await driver.findElements(By.css('.account-details__account-name'))
|
||||||
assert.equal(await accountName.getText(), '2nd account')
|
assert.equal(await accountName.getText(), '2nd account')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Switch back to original account', () => {
|
describe('Switch back to original account', function () {
|
||||||
it('chooses the original account from the account menu', async () => {
|
it('chooses the original account from the account menu', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Send ETH from inside MetaMask', () => {
|
describe('Send ETH from inside MetaMask', function () {
|
||||||
it('starts a send transaction', async function () {
|
it('starts a send transaction', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -225,8 +225,8 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Imports an account with private key', () => {
|
describe('Imports an account with private key', function () {
|
||||||
it('choose Create Account from the account menu', async () => {
|
it('choose Create Account from the account menu', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('enter private key', async () => {
|
it('enter private key', async function () {
|
||||||
const privateKeyInput = await driver.findElement(By.css('#private-key-box'))
|
const privateKeyInput = await driver.findElement(By.css('#private-key-box'))
|
||||||
await privateKeyInput.sendKeys(testPrivateKey2)
|
await privateKeyInput.sendKeys(testPrivateKey2)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -242,21 +242,21 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should show the correct account name', async () => {
|
it('should show the correct account name', async function () {
|
||||||
const [accountName] = await driver.findElements(By.css('.account-details__account-name'))
|
const [accountName] = await driver.findElements(By.css('.account-details__account-name'))
|
||||||
assert.equal(await accountName.getText(), 'Account 4')
|
assert.equal(await accountName.getText(), 'Account 4')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should show the imported label', async () => {
|
it('should show the imported label', async function () {
|
||||||
const [importedLabel] = await driver.findElements(By.css('.account-details__keyring-label'))
|
const [importedLabel] = await driver.findElements(By.css('.account-details__keyring-label'))
|
||||||
assert.equal(await importedLabel.getText(), 'IMPORTED')
|
assert.equal(await importedLabel.getText(), 'IMPORTED')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Imports and removes an account', () => {
|
describe('Imports and removes an account', function () {
|
||||||
it('choose Create Account from the account menu', async () => {
|
it('choose Create Account from the account menu', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('enter private key', async () => {
|
it('enter private key', async function () {
|
||||||
const privateKeyInput = await driver.findElement(By.css('#private-key-box'))
|
const privateKeyInput = await driver.findElement(By.css('#private-key-box'))
|
||||||
await privateKeyInput.sendKeys(testPrivateKey3)
|
await privateKeyInput.sendKeys(testPrivateKey3)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -272,7 +272,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should open the remove account modal', async () => {
|
it('should open the remove account modal', async function () {
|
||||||
const [accountName] = await driver.findElements(By.css('.account-details__account-name'))
|
const [accountName] = await driver.findElements(By.css('.account-details__account-name'))
|
||||||
assert.equal(await accountName.getText(), 'Account 5')
|
assert.equal(await accountName.getText(), 'Account 5')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -289,7 +289,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.findElement(By.css('.confirm-remove-account__account'))
|
await driver.findElement(By.css('.confirm-remove-account__account'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should remove the account', async () => {
|
it('should remove the account', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Remove')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Remove')]`))
|
||||||
|
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -303,13 +303,13 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Connects to a Hardware wallet', () => {
|
describe('Connects to a Hardware wallet', function () {
|
||||||
it('choose Connect Hardware Wallet from the account menu', async () => {
|
it('choose Connect Hardware Wallet from the account menu', async function () {
|
||||||
await driver.clickElement(By.xpath(`//div[contains(text(), 'Connect Hardware Wallet')]`))
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Connect Hardware Wallet')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should open the TREZOR Connect popup', async () => {
|
it('should open the TREZOR Connect popup', async function () {
|
||||||
await driver.clickElement(By.css('.hw-connect__btn:nth-of-type(2)'))
|
await driver.clickElement(By.css('.hw-connect__btn:nth-of-type(2)'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Connect')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Connect')]`))
|
||||||
|
@ -56,24 +56,24 @@ describe('MetaMask', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Going through the first time flow, but skipping the seed phrase challenge', () => {
|
describe('Going through the first time flow, but skipping the seed phrase challenge', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver.findElement(By.css('.welcome-page__header'))
|
await driver.findElement(By.css('.welcome-page__header'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Create New Wallet" option', async () => {
|
it('clicks the "Create New Wallet" option', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "No thanks" option on the metametrics opt-in screen', async () => {
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
||||||
await driver.clickElement(By.css('.btn-default'))
|
await driver.clickElement(By.css('.btn-default'))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('accepts a secure password', async () => {
|
it('accepts a secure password', async function () {
|
||||||
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
||||||
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('skips the seed phrase challenge', async () => {
|
it('skips the seed phrase challenge', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.remindMeLater.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.remindMeLater.message}')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('gets the current accounts address', async () => {
|
it('gets the current accounts address', async function () {
|
||||||
const addressInput = await driver.findElement(By.css('.qr-ellip-address'))
|
const addressInput = await driver.findElement(By.css('.qr-ellip-address'))
|
||||||
publicAddress = await addressInput.getAttribute('value')
|
publicAddress = await addressInput.getAttribute('value')
|
||||||
|
|
||||||
@ -108,10 +108,10 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('send to current account from dapp with different provider', () => {
|
describe('send to current account from dapp with different provider', function () {
|
||||||
let extension
|
let extension
|
||||||
|
|
||||||
it('switches to dapp screen', async () => {
|
it('switches to dapp screen', async function () {
|
||||||
const windowHandles = await driver.getAllWindowHandles()
|
const windowHandles = await driver.getAllWindowHandles()
|
||||||
extension = windowHandles[0]
|
extension = windowHandles[0]
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sends eth to the current account', async () => {
|
it('sends eth to the current account', async function () {
|
||||||
const addressInput = await driver.findElement(By.css('#address'))
|
const addressInput = await driver.findElement(By.css('#address'))
|
||||||
await addressInput.sendKeys(publicAddress)
|
await addressInput.sendKeys(publicAddress)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -130,11 +130,11 @@ describe('MetaMask', function () {
|
|||||||
await driver.wait(until.elementTextMatches(txStatus, /Success/), 15000)
|
await driver.wait(until.elementTextMatches(txStatus, /Success/), 15000)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('switches back to MetaMask', async () => {
|
it('switches back to MetaMask', async function () {
|
||||||
await driver.switchToWindow(extension)
|
await driver.switchToWindow(extension)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should have the correct amount of eth', async () => {
|
it('should have the correct amount of eth', async function () {
|
||||||
const balances = await driver.findElements(By.css('.currency-display-component__text'))
|
const balances = await driver.findElements(By.css('.currency-display-component__text'))
|
||||||
await driver.wait(until.elementTextMatches(balances[0], /1/), 15000)
|
await driver.wait(until.elementTextMatches(balances[0], /1/), 15000)
|
||||||
const balance = await balances[0].getText()
|
const balance = await balances[0].getText()
|
||||||
@ -143,20 +143,20 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('backs up the seed phrase', () => {
|
describe('backs up the seed phrase', function () {
|
||||||
it('should show a backup reminder', async () => {
|
it('should show a backup reminder', async function () {
|
||||||
const backupReminder = await driver.findElements(By.xpath("//div[contains(@class, 'home-notification__text') and contains(text(), 'Backup your Secret Recovery code to keep your wallet and funds secure')]"))
|
const backupReminder = await driver.findElements(By.xpath("//div[contains(@class, 'home-notification__text') and contains(text(), 'Backup your Secret Recovery code to keep your wallet and funds secure')]"))
|
||||||
assert.equal(backupReminder.length, 1)
|
assert.equal(backupReminder.length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should take the user to the seedphrase backup screen', async () => {
|
it('should take the user to the seedphrase backup screen', async function () {
|
||||||
await driver.clickElement(By.css('.home-notification__accept-button'))
|
await driver.clickElement(By.css('.home-notification__accept-button'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
let seedPhrase
|
let seedPhrase
|
||||||
|
|
||||||
it('reveals the seed phrase', async () => {
|
it('reveals the seed phrase', async function () {
|
||||||
const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button')
|
const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button')
|
||||||
await driver.clickElement(byRevealButton)
|
await driver.clickElement(byRevealButton)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -175,7 +175,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(tinyDelayMs)
|
await driver.delay(tinyDelayMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
it('can retype the seed phrase', async () => {
|
it('can retype the seed phrase', async function () {
|
||||||
const words = seedPhrase.split(' ')
|
const words = seedPhrase.split(' ')
|
||||||
|
|
||||||
for (const word of words) {
|
for (const word of words) {
|
||||||
@ -186,12 +186,12 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can click through the success screen', async () => {
|
it('can click through the success screen', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'All Done')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'All Done')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should have the correct amount of eth', async () => {
|
it('should have the correct amount of eth', async function () {
|
||||||
const balances = await driver.findElements(By.css('.currency-display-component__text'))
|
const balances = await driver.findElements(By.css('.currency-display-component__text'))
|
||||||
await driver.wait(until.elementTextMatches(balances[0], /1/), 15000)
|
await driver.wait(until.elementTextMatches(balances[0], /1/), 15000)
|
||||||
const balance = await balances[0].getText()
|
const balance = await balances[0].getText()
|
||||||
@ -199,7 +199,7 @@ describe('MetaMask', function () {
|
|||||||
assert.equal(balance, '1')
|
assert.equal(balance, '1')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not show a backup reminder', async () => {
|
it('should not show a backup reminder', async function () {
|
||||||
await driver.assertElementNotPresent(By.css('.backup-notification'))
|
await driver.assertElementNotPresent(By.css('.backup-notification'))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -46,24 +46,24 @@ describe('MetaMask', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Going through the first time flow', () => {
|
describe('Going through the first time flow', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver.findElement(By.css('.welcome-page__header'))
|
await driver.findElement(By.css('.welcome-page__header'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Create New Wallet" option', async () => {
|
it('clicks the "Create New Wallet" option', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "I agree" option on the metametrics opt-in screen', async () => {
|
it('clicks the "I agree" option on the metametrics opt-in screen', async function () {
|
||||||
await driver.clickElement(By.css('.btn-primary'))
|
await driver.clickElement(By.css('.btn-primary'))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('accepts a secure password', async () => {
|
it('accepts a secure password', async function () {
|
||||||
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
||||||
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
let seedPhrase
|
let seedPhrase
|
||||||
|
|
||||||
it('reveals the seed phrase', async () => {
|
it('reveals the seed phrase', async function () {
|
||||||
const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button')
|
const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button')
|
||||||
await driver.clickElement(byRevealButton)
|
await driver.clickElement(byRevealButton)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -97,7 +97,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(tinyDelayMs)
|
await driver.delay(tinyDelayMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
it('can retype the seed phrase', async () => {
|
it('can retype the seed phrase', async function () {
|
||||||
const words = seedPhrase.split(' ')
|
const words = seedPhrase.split(' ')
|
||||||
|
|
||||||
for (const word of words) {
|
for (const word of words) {
|
||||||
@ -108,15 +108,15 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks through the success screen', async () => {
|
it('clicks through the success screen', async function () {
|
||||||
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Show account information', () => {
|
describe('Show account information', function () {
|
||||||
it('show account details dropdown menu', async () => {
|
it('show account details dropdown menu', async function () {
|
||||||
await driver.clickElement(By.css('div.menu-bar__open-in-browser'))
|
await driver.clickElement(By.css('div.menu-bar__open-in-browser'))
|
||||||
const options = await driver.findElements(By.css('div.menu.account-details-dropdown div.menu__item'))
|
const options = await driver.findElements(By.css('div.menu.account-details-dropdown div.menu__item'))
|
||||||
assert.equal(options.length, 4) // HD Wallet type does not have to show the Remove Account option
|
assert.equal(options.length, 4) // HD Wallet type does not have to show the Remove Account option
|
||||||
@ -124,8 +124,8 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Import seed phrase', () => {
|
describe('Import seed phrase', function () {
|
||||||
it('logs out of the vault', async () => {
|
it('logs out of the vault', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('imports seed phrase', async () => {
|
it('imports seed phrase', async function () {
|
||||||
const restoreSeedLink = await driver.findClickableElement(By.css('.unlock-page__link--import'))
|
const restoreSeedLink = await driver.findClickableElement(By.css('.unlock-page__link--import'))
|
||||||
assert.equal(await restoreSeedLink.getText(), 'Import using account seed phrase')
|
assert.equal(await restoreSeedLink.getText(), 'Import using account seed phrase')
|
||||||
await restoreSeedLink.click()
|
await restoreSeedLink.click()
|
||||||
@ -154,7 +154,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('switches to localhost', async () => {
|
it('switches to localhost', async function () {
|
||||||
await driver.clickElement(By.css('.network-name'))
|
await driver.clickElement(By.css('.network-name'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -162,14 +162,14 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs * 2)
|
await driver.delay(largeDelayMs * 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('balance renders', async () => {
|
it('balance renders', async function () {
|
||||||
const balance = await driver.findElement(By.css('.transaction-view-balance__primary-balance'))
|
const balance = await driver.findElement(By.css('.transaction-view-balance__primary-balance'))
|
||||||
await driver.wait(until.elementTextMatches(balance, /100\s*ETH/))
|
await driver.wait(until.elementTextMatches(balance, /100\s*ETH/))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Send ETH from inside MetaMask', () => {
|
describe('Send ETH from inside MetaMask', function () {
|
||||||
it('starts to send a transaction', async function () {
|
it('starts to send a transaction', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
@ -47,24 +47,24 @@ describe('MetaMask', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Going through the first time flow', () => {
|
describe('Going through the first time flow', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver.findElement(By.css('.welcome-page__header'))
|
await driver.findElement(By.css('.welcome-page__header'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Create New Wallet" option', async () => {
|
it('clicks the "Create New Wallet" option', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "No thanks" option on the metametrics opt-in screen', async () => {
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
||||||
await driver.clickElement(By.css('.btn-default'))
|
await driver.clickElement(By.css('.btn-default'))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('accepts a secure password', async () => {
|
it('accepts a secure password', async function () {
|
||||||
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
||||||
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
let seedPhrase
|
let seedPhrase
|
||||||
|
|
||||||
it('reveals the seed phrase', async () => {
|
it('reveals the seed phrase', async function () {
|
||||||
const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button')
|
const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button')
|
||||||
await driver.findElement(byRevealButton)
|
await driver.findElement(byRevealButton)
|
||||||
await driver.clickElement(byRevealButton)
|
await driver.clickElement(byRevealButton)
|
||||||
@ -99,7 +99,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(tinyDelayMs)
|
await driver.delay(tinyDelayMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
it('can retype the seed phrase', async () => {
|
it('can retype the seed phrase', async function () {
|
||||||
const words = seedPhrase.split(' ')
|
const words = seedPhrase.split(' ')
|
||||||
|
|
||||||
for (const word of words) {
|
for (const word of words) {
|
||||||
@ -110,15 +110,15 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks through the success screen', async () => {
|
it('clicks through the success screen', async function () {
|
||||||
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Show account information', () => {
|
describe('Show account information', function () {
|
||||||
it('shows the QR code for the account', async () => {
|
it('shows the QR code for the account', async function () {
|
||||||
await driver.clickElement(By.css('.account-details__details-button'))
|
await driver.clickElement(By.css('.account-details__details-button'))
|
||||||
await driver.findVisibleElement(By.css('.qr-wrapper'))
|
await driver.findVisibleElement(By.css('.qr-wrapper'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -131,8 +131,8 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Lock an unlock', () => {
|
describe('Lock an unlock', function () {
|
||||||
it('logs out of the account', async () => {
|
it('logs out of the account', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('accepts the account password after lock', async () => {
|
it('accepts the account password after lock', async function () {
|
||||||
const passwordField = await driver.findElement(By.id('password'))
|
const passwordField = await driver.findElement(By.id('password'))
|
||||||
await passwordField.sendKeys('correct horse battery staple')
|
await passwordField.sendKeys('correct horse battery staple')
|
||||||
await passwordField.sendKeys(Key.ENTER)
|
await passwordField.sendKeys(Key.ENTER)
|
||||||
@ -150,8 +150,8 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Add account', () => {
|
describe('Add account', function () {
|
||||||
it('choose Create Account from the account menu', async () => {
|
it('choose Create Account from the account menu', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('set account name', async () => {
|
it('set account name', async function () {
|
||||||
const accountName = await driver.findElement(By.css('.new-account-create-form input'))
|
const accountName = await driver.findElement(By.css('.new-account-create-form input'))
|
||||||
await accountName.sendKeys('2nd account')
|
await accountName.sendKeys('2nd account')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -168,15 +168,15 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should display correct account name', async () => {
|
it('should display correct account name', async function () {
|
||||||
const accountName = await driver.findElement(By.css('.account-details__account-name'))
|
const accountName = await driver.findElement(By.css('.account-details__account-name'))
|
||||||
assert.equal(await accountName.getText(), '2nd account')
|
assert.equal(await accountName.getText(), '2nd account')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Import seed phrase', () => {
|
describe('Import seed phrase', function () {
|
||||||
it('logs out of the vault', async () => {
|
it('logs out of the vault', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('imports seed phrase', async () => {
|
it('imports seed phrase', async function () {
|
||||||
const restoreSeedLink = await driver.findClickableElement(By.css('.unlock-page__link--import'))
|
const restoreSeedLink = await driver.findClickableElement(By.css('.unlock-page__link--import'))
|
||||||
assert.equal(await restoreSeedLink.getText(), 'Import using account seed phrase')
|
assert.equal(await restoreSeedLink.getText(), 'Import using account seed phrase')
|
||||||
await restoreSeedLink.click()
|
await restoreSeedLink.click()
|
||||||
@ -205,14 +205,14 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('balance renders', async () => {
|
it('balance renders', async function () {
|
||||||
const balance = await driver.findElement(By.css('.balance-display .token-amount'))
|
const balance = await driver.findElement(By.css('.balance-display .token-amount'))
|
||||||
await driver.wait(until.elementTextMatches(balance, /100\s*ETH/))
|
await driver.wait(until.elementTextMatches(balance, /100\s*ETH/))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Send ETH from inside MetaMask using default gas', () => {
|
describe('Send ETH from inside MetaMask using default gas', function () {
|
||||||
it('starts a send transaction', async function () {
|
it('starts a send transaction', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -275,7 +275,7 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Send ETH from inside MetaMask using fast gas option', () => {
|
describe('Send ETH from inside MetaMask using fast gas option', function () {
|
||||||
it('starts a send transaction', async function () {
|
it('starts a send transaction', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -314,7 +314,7 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Send ETH from inside MetaMask using advanced gas modal', () => {
|
describe('Send ETH from inside MetaMask using advanced gas modal', function () {
|
||||||
it('starts a send transaction', async function () {
|
it('starts a send transaction', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -362,13 +362,13 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Send ETH from dapp using advanced gas controls', () => {
|
describe('Send ETH from dapp using advanced gas controls', function () {
|
||||||
let windowHandles
|
let windowHandles
|
||||||
let extension
|
let extension
|
||||||
let popup
|
let popup
|
||||||
let dapp
|
let dapp
|
||||||
|
|
||||||
it('goes to the settings screen', async () => {
|
it('goes to the settings screen', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -394,7 +394,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('connects the dapp', async () => {
|
it('connects the dapp', async function () {
|
||||||
await driver.openNewPage('http://127.0.0.1:8080/')
|
await driver.openNewPage('http://127.0.0.1:8080/')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('initiates a send from the dapp', async () => {
|
it('initiates a send from the dapp', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`), 10000)
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`), 10000)
|
||||||
await driver.delay(2000)
|
await driver.delay(2000)
|
||||||
|
|
||||||
@ -478,8 +478,8 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Navigate transactions', () => {
|
describe('Navigate transactions', function () {
|
||||||
it('adds multiple transactions', async () => {
|
it('adds multiple transactions', async function () {
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
await driver.waitUntilXWindowHandles(2)
|
await driver.waitUntilXWindowHandles(2)
|
||||||
@ -510,7 +510,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('navigates the transactions', async () => {
|
it('navigates the transactions', async function () {
|
||||||
await driver.clickElement(By.css('[data-testid="next-page"]'))
|
await driver.clickElement(By.css('[data-testid="next-page"]'))
|
||||||
let navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
let navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
||||||
let navigationText = await navigationElement.getText()
|
let navigationText = await navigationElement.getText()
|
||||||
@ -547,7 +547,7 @@ describe('MetaMask', function () {
|
|||||||
assert.equal(navigationText.includes('2'), true, 'changed transaction left')
|
assert.equal(navigationText.includes('2'), true, 'changed transaction left')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('adds a transaction while confirm screen is in focus', async () => {
|
it('adds a transaction while confirm screen is in focus', async function () {
|
||||||
let navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
let navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
||||||
let navigationText = await navigationElement.getText()
|
let navigationText = await navigationElement.getText()
|
||||||
assert.equal(navigationText.includes('2'), true, 'second transaction in focus')
|
assert.equal(navigationText.includes('2'), true, 'second transaction in focus')
|
||||||
@ -570,7 +570,7 @@ describe('MetaMask', function () {
|
|||||||
assert.equal(navigationText.includes('2'), true, 'correct (same) transaction in focus')
|
assert.equal(navigationText.includes('2'), true, 'correct (same) transaction in focus')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('rejects a transaction', async () => {
|
it('rejects a transaction', async function () {
|
||||||
await driver.delay(tinyDelayMs)
|
await driver.delay(tinyDelayMs)
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Reject')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Reject')]`))
|
||||||
await driver.delay(largeDelayMs * 2)
|
await driver.delay(largeDelayMs * 2)
|
||||||
@ -581,7 +581,7 @@ describe('MetaMask', function () {
|
|||||||
assert.equal(navigationText.includes('4'), true, 'transaction rejected')
|
assert.equal(navigationText.includes('4'), true, 'transaction rejected')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('confirms a transaction', async () => {
|
it('confirms a transaction', async function () {
|
||||||
await driver.delay(tinyDelayMs / 2)
|
await driver.delay(tinyDelayMs / 2)
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -593,7 +593,7 @@ describe('MetaMask', function () {
|
|||||||
assert.equal(navigationText.includes('3'), true, 'transaction confirmed')
|
assert.equal(navigationText.includes('3'), true, 'transaction confirmed')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('rejects the rest of the transactions', async () => {
|
it('rejects the rest of the transactions', async function () {
|
||||||
await driver.clickElement(By.xpath(`//a[contains(text(), 'Reject 3')]`))
|
await driver.clickElement(By.xpath(`//a[contains(text(), 'Reject 3')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -605,10 +605,10 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Deploy contract and call contract methods', () => {
|
describe('Deploy contract and call contract methods', function () {
|
||||||
let extension
|
let extension
|
||||||
let dapp
|
let dapp
|
||||||
it('creates a deploy contract transaction', async () => {
|
it('creates a deploy contract transaction', async function () {
|
||||||
const windowHandles = await driver.getAllWindowHandles()
|
const windowHandles = await driver.getAllWindowHandles()
|
||||||
extension = windowHandles[0]
|
extension = windowHandles[0]
|
||||||
dapp = windowHandles[1]
|
dapp = windowHandles[1]
|
||||||
@ -627,7 +627,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('displays the contract creation data', async () => {
|
it('displays the contract creation data', async function () {
|
||||||
await driver.clickElement(By.xpath(`//li[contains(text(), 'Data')]`))
|
await driver.clickElement(By.xpath(`//li[contains(text(), 'Data')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -641,7 +641,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('confirms a deploy contract transaction', async () => {
|
it('confirms a deploy contract transaction', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
|
|
||||||
@ -655,7 +655,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls and confirms a contract method where ETH is sent', async () => {
|
it('calls and confirms a contract method where ETH is sent', async function () {
|
||||||
await driver.switchToWindow(dapp)
|
await driver.switchToWindow(dapp)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -721,7 +721,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.wait(until.elementTextMatches(txValues[0], /-4\s*ETH/), 10000)
|
await driver.wait(until.elementTextMatches(txValues[0], /-4\s*ETH/), 10000)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls and confirms a contract method where ETH is received', async () => {
|
it('calls and confirms a contract method where ETH is received', async function () {
|
||||||
await driver.switchToWindow(dapp)
|
await driver.switchToWindow(dapp)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -749,7 +749,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.switchToWindow(extension)
|
await driver.switchToWindow(extension)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the correct ETH balance', async () => {
|
it('renders the correct ETH balance', async function () {
|
||||||
const balance = await driver.findElement(By.css('.transaction-view-balance__primary-balance'))
|
const balance = await driver.findElement(By.css('.transaction-view-balance__primary-balance'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
await driver.wait(until.elementTextMatches(balance, /^87.*\s*ETH.*$/), 10000)
|
await driver.wait(until.elementTextMatches(balance, /^87.*\s*ETH.*$/), 10000)
|
||||||
@ -759,8 +759,8 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Add a custom token from a dapp', () => {
|
describe('Add a custom token from a dapp', function () {
|
||||||
it('creates a new token', async () => {
|
it('creates a new token', async function () {
|
||||||
let windowHandles = await driver.getAllWindowHandles()
|
let windowHandles = await driver.getAllWindowHandles()
|
||||||
const extension = windowHandles[0]
|
const extension = windowHandles[0]
|
||||||
const dapp = windowHandles[1]
|
const dapp = windowHandles[1]
|
||||||
@ -807,12 +807,12 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks on the Add Token button', async () => {
|
it('clicks on the Add Token button', async function () {
|
||||||
await driver.clickElement(By.xpath(`//div[contains(text(), 'Add Token')]`))
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Add Token')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('picks the newly created Test token', async () => {
|
it('picks the newly created Test token', async function () {
|
||||||
await driver.clickElement(By.xpath("//li[contains(text(), 'Custom Token')]"))
|
await driver.clickElement(By.xpath("//li[contains(text(), 'Custom Token')]"))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -827,7 +827,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the balance for the new token', async () => {
|
it('renders the balance for the new token', async function () {
|
||||||
const balance = await driver.findElement(By.css('.transaction-view-balance .transaction-view-balance__primary-balance'))
|
const balance = await driver.findElement(By.css('.transaction-view-balance .transaction-view-balance__primary-balance'))
|
||||||
await driver.wait(until.elementTextMatches(balance, /^10.000\s*TST\s*$/))
|
await driver.wait(until.elementTextMatches(balance, /^10.000\s*TST\s*$/))
|
||||||
const tokenAmount = await balance.getText()
|
const tokenAmount = await balance.getText()
|
||||||
@ -836,7 +836,7 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Send token from inside MetaMask', () => {
|
describe('Send token from inside MetaMask', function () {
|
||||||
let gasModal
|
let gasModal
|
||||||
it('starts to send a transaction', async function () {
|
it('starts to send a transaction', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
@ -856,13 +856,13 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens customize gas modal', async () => {
|
it('opens customize gas modal', async function () {
|
||||||
await driver.findElement(By.css('.page-container__title'))
|
await driver.findElement(By.css('.page-container__title'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Save')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Save')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('transitions to the confirm screen', async () => {
|
it('transitions to the confirm screen', async function () {
|
||||||
await driver.wait(until.stalenessOf(gasModal))
|
await driver.wait(until.stalenessOf(gasModal))
|
||||||
|
|
||||||
// Continue to next screen
|
// Continue to next screen
|
||||||
@ -870,7 +870,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('displays the token transfer data', async () => {
|
it('displays the token transfer data', async function () {
|
||||||
await driver.clickElement(By.xpath(`//li[contains(text(), 'Data')]`))
|
await driver.clickElement(By.xpath(`//li[contains(text(), 'Data')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -912,9 +912,9 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Send a custom token from dapp', () => {
|
describe('Send a custom token from dapp', function () {
|
||||||
let gasModal
|
let gasModal
|
||||||
it('sends an already created token', async () => {
|
it('sends an already created token', async function () {
|
||||||
const windowHandles = await driver.getAllWindowHandles()
|
const windowHandles = await driver.getAllWindowHandles()
|
||||||
const extension = windowHandles[0]
|
const extension = windowHandles[0]
|
||||||
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
||||||
@ -945,7 +945,7 @@ describe('MetaMask', function () {
|
|||||||
gasModal = await driver.findElement(By.css('span .modal'))
|
gasModal = await driver.findElement(By.css('span .modal'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('customizes gas', async () => {
|
it('customizes gas', async function () {
|
||||||
await driver.clickElement(By.css('.page-container__tab:nth-of-type(2)'))
|
await driver.clickElement(By.css('.page-container__tab:nth-of-type(2)'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -1003,9 +1003,9 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Approves a custom token from dapp', () => {
|
describe('Approves a custom token from dapp', function () {
|
||||||
let gasModal
|
let gasModal
|
||||||
it('approves an already created token', async () => {
|
it('approves an already created token', async function () {
|
||||||
const windowHandles = await driver.getAllWindowHandles()
|
const windowHandles = await driver.getAllWindowHandles()
|
||||||
const extension = windowHandles[0]
|
const extension = windowHandles[0]
|
||||||
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
||||||
@ -1031,7 +1031,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('displays the token approval data', async () => {
|
it('displays the token approval data', async function () {
|
||||||
await driver.clickElement(By.css('.confirm-approve-content__view-full-tx-button'))
|
await driver.clickElement(By.css('.confirm-approve-content__view-full-tx-button'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -1044,14 +1044,14 @@ describe('MetaMask', function () {
|
|||||||
assert(confirmDataText.match(/0x095ea7b30000000000000000000000009bc5baf874d2da8d216ae9f137804184ee5afef4/))
|
assert(confirmDataText.match(/0x095ea7b30000000000000000000000009bc5baf874d2da8d216ae9f137804184ee5afef4/))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens the gas edit modal', async () => {
|
it('opens the gas edit modal', async function () {
|
||||||
await driver.clickElement(By.css('.confirm-approve-content__small-blue-text.cursor-pointer'))
|
await driver.clickElement(By.css('.confirm-approve-content__small-blue-text.cursor-pointer'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
gasModal = await driver.findElement(By.css('span .modal'))
|
gasModal = await driver.findElement(By.css('span .modal'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('customizes gas', async () => {
|
it('customizes gas', async function () {
|
||||||
await driver.clickElement(By.css('.page-container__tab:nth-of-type(2)'))
|
await driver.clickElement(By.css('.page-container__tab:nth-of-type(2)'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -1078,7 +1078,7 @@ describe('MetaMask', function () {
|
|||||||
assert.equal(await gasFeeInEth.getText(), '0.0006 ETH')
|
assert.equal(await gasFeeInEth.getText(), '0.0006 ETH')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('edits the permission', async () => {
|
it('edits the permission', async function () {
|
||||||
const editButtons = await driver.findClickableElements(By.css('.confirm-approve-content__small-blue-text.cursor-pointer'))
|
const editButtons = await driver.findClickableElements(By.css('.confirm-approve-content__small-blue-text.cursor-pointer'))
|
||||||
await editButtons[1].click()
|
await editButtons[1].click()
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -1121,8 +1121,8 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Tranfers a custom token from dapp when no gas value is specified', () => {
|
describe('Tranfers a custom token from dapp when no gas value is specified', function () {
|
||||||
it('transfers an already created token, without specifying gas', async () => {
|
it('transfers an already created token, without specifying gas', async function () {
|
||||||
const windowHandles = await driver.getAllWindowHandles()
|
const windowHandles = await driver.getAllWindowHandles()
|
||||||
const extension = windowHandles[0]
|
const extension = windowHandles[0]
|
||||||
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
||||||
@ -1166,8 +1166,8 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Approves a custom token from dapp when no gas value is specified', () => {
|
describe('Approves a custom token from dapp when no gas value is specified', function () {
|
||||||
it('approves an already created token', async () => {
|
it('approves an already created token', async function () {
|
||||||
const windowHandles = await driver.getAllWindowHandles()
|
const windowHandles = await driver.getAllWindowHandles()
|
||||||
const extension = windowHandles[0]
|
const extension = windowHandles[0]
|
||||||
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
||||||
@ -1221,8 +1221,8 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Hide token', () => {
|
describe('Hide token', function () {
|
||||||
it('hides the token when clicked', async () => {
|
it('hides the token when clicked', async function () {
|
||||||
await driver.clickElement(By.css('.token-list-item__ellipsis'))
|
await driver.clickElement(By.css('.token-list-item__ellipsis'))
|
||||||
|
|
||||||
const byTokenMenuDropdownOption = By.css('.menu__item--clickable')
|
const byTokenMenuDropdownOption = By.css('.menu__item--clickable')
|
||||||
@ -1237,13 +1237,13 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Add existing token using search', () => {
|
describe('Add existing token using search', function () {
|
||||||
it('clicks on the Add Token button', async () => {
|
it('clicks on the Add Token button', async function () {
|
||||||
await driver.clickElement(By.xpath(`//div[contains(text(), 'Add Token')]`))
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Add Token')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can pick a token from the existing options', async () => {
|
it('can pick a token from the existing options', async function () {
|
||||||
const tokenSearch = await driver.findElement(By.css('#search-tokens'))
|
const tokenSearch = await driver.findElement(By.css('#search-tokens'))
|
||||||
await tokenSearch.sendKeys('BAT')
|
await tokenSearch.sendKeys('BAT')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -1258,14 +1258,14 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the balance for the chosen token', async () => {
|
it('renders the balance for the chosen token', async function () {
|
||||||
const balance = await driver.findElement(By.css('.transaction-view-balance__primary-balance'))
|
const balance = await driver.findElement(By.css('.transaction-view-balance__primary-balance'))
|
||||||
await driver.wait(until.elementTextMatches(balance, /0\s*BAT/))
|
await driver.wait(until.elementTextMatches(balance, /0\s*BAT/))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Stores custom RPC history', () => {
|
describe('Stores custom RPC history', function () {
|
||||||
const customRpcUrls = [
|
const customRpcUrls = [
|
||||||
'http://127.0.0.1:8545/1',
|
'http://127.0.0.1:8545/1',
|
||||||
'http://127.0.0.1:8545/2',
|
'http://127.0.0.1:8545/2',
|
||||||
@ -1274,7 +1274,7 @@ describe('MetaMask', function () {
|
|||||||
]
|
]
|
||||||
|
|
||||||
customRpcUrls.forEach(customRpcUrl => {
|
customRpcUrls.forEach(customRpcUrl => {
|
||||||
it(`creates custom RPC: ${customRpcUrl}`, async () => {
|
it(`creates custom RPC: ${customRpcUrl}`, async function () {
|
||||||
await driver.clickElement(By.css('.network-name'))
|
await driver.clickElement(By.css('.network-name'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -1293,7 +1293,7 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('selects another provider', async () => {
|
it('selects another provider', async function () {
|
||||||
await driver.clickElement(By.css('.network-name'))
|
await driver.clickElement(By.css('.network-name'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -1301,7 +1301,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs * 2)
|
await driver.delay(largeDelayMs * 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds all recent RPCs in history', async () => {
|
it('finds all recent RPCs in history', async function () {
|
||||||
await driver.clickElement(By.css('.network-name'))
|
await driver.clickElement(By.css('.network-name'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -1311,7 +1311,7 @@ describe('MetaMask', function () {
|
|||||||
assert.equal(customRpcs.length, customRpcUrls.length)
|
assert.equal(customRpcs.length, customRpcUrls.length)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('deletes a custom RPC', async () => {
|
it('deletes a custom RPC', async function () {
|
||||||
const networkListItems = await driver.findClickableElements(By.css('.networks-tab__networks-list-name'))
|
const networkListItems = await driver.findClickableElements(By.css('.networks-tab__networks-list-name'))
|
||||||
const lastNetworkListItem = networkListItems[networkListItems.length - 1]
|
const lastNetworkListItem = networkListItems[networkListItems.length - 1]
|
||||||
await lastNetworkListItem.click()
|
await lastNetworkListItem.click()
|
||||||
|
@ -51,24 +51,24 @@ describe('MetaMask', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Going through the first time flow, but skipping the seed phrase challenge', () => {
|
describe('Going through the first time flow, but skipping the seed phrase challenge', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver.findElement(By.css('.welcome-page__header'))
|
await driver.findElement(By.css('.welcome-page__header'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Create New Wallet" option', async () => {
|
it('clicks the "Create New Wallet" option', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "No thanks" option on the metametrics opt-in screen', async () => {
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
||||||
await driver.clickElement(By.css('.btn-default'))
|
await driver.clickElement(By.css('.btn-default'))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('accepts a secure password', async () => {
|
it('accepts a secure password', async function () {
|
||||||
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
||||||
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('skips the seed phrase challenge', async () => {
|
it('skips the seed phrase challenge', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.remindMeLater.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.remindMeLater.message}')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('gets the current accounts address', async () => {
|
it('gets the current accounts address', async function () {
|
||||||
const addressInput = await driver.findElement(By.css('.qr-ellip-address'))
|
const addressInput = await driver.findElement(By.css('.qr-ellip-address'))
|
||||||
publicAddress = await addressInput.getAttribute('value')
|
publicAddress = await addressInput.getAttribute('value')
|
||||||
const accountModal = await driver.findElement(By.css('span .modal'))
|
const accountModal = await driver.findElement(By.css('span .modal'))
|
||||||
@ -101,12 +101,12 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('sets permissions', () => {
|
describe('sets permissions', function () {
|
||||||
let extension
|
let extension
|
||||||
let popup
|
let popup
|
||||||
let dapp
|
let dapp
|
||||||
|
|
||||||
it('connects to the dapp', async () => {
|
it('connects to the dapp', async function () {
|
||||||
await driver.openNewPage('http://127.0.0.1:8080/')
|
await driver.openNewPage('http://127.0.0.1:8080/')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows connected sites', async () => {
|
it('shows connected sites', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Connected Sites')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Connected Sites')]`))
|
||||||
|
|
||||||
await driver.findElement(By.css('.connected-sites__title'))
|
await driver.findElement(By.css('.connected-sites__title'))
|
||||||
@ -149,7 +149,7 @@ describe('MetaMask', function () {
|
|||||||
assert.equal(await permissionDescription.getText(), 'View the address of the selected account')
|
assert.equal(await permissionDescription.getText(), 'View the address of the selected account')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can get accounts within the dapp', async () => {
|
it('can get accounts within the dapp', async function () {
|
||||||
await driver.switchToWindow(dapp)
|
await driver.switchToWindow(dapp)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ describe('MetaMask', function () {
|
|||||||
assert.equal((await getAccountsResult.getText()).toLowerCase(), publicAddress.toLowerCase())
|
assert.equal((await getAccountsResult.getText()).toLowerCase(), publicAddress.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can disconnect all accounts', async () => {
|
it('can disconnect all accounts', async function () {
|
||||||
await driver.switchToWindow(extension)
|
await driver.switchToWindow(extension)
|
||||||
|
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Disconnect All')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Disconnect All')]`))
|
||||||
@ -172,7 +172,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can no longer get accounts within the dapp', async () => {
|
it('can no longer get accounts within the dapp', async function () {
|
||||||
await driver.switchToWindow(dapp)
|
await driver.switchToWindow(dapp)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
|
@ -53,24 +53,24 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('First time flow starting from an existing seed phrase', () => {
|
describe('First time flow starting from an existing seed phrase', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver.findElement(By.css('.welcome-page__header'))
|
await driver.findElement(By.css('.welcome-page__header'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Import Wallet" option', async () => {
|
it('clicks the "Import Wallet" option', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Import Wallet')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Import Wallet')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "No thanks" option on the metametrics opt-in screen', async () => {
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
||||||
await driver.clickElement(By.css('.btn-default'))
|
await driver.clickElement(By.css('.btn-default'))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('imports a seed phrase', async () => {
|
it('imports a seed phrase', async function () {
|
||||||
const [seedTextArea] = await driver.findElements(By.css('textarea.first-time-flow__textarea'))
|
const [seedTextArea] = await driver.findElements(By.css('textarea.first-time-flow__textarea'))
|
||||||
await seedTextArea.sendKeys(testSeedPhrase)
|
await seedTextArea.sendKeys(testSeedPhrase)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -86,14 +86,14 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks through the success screen', async () => {
|
it('clicks through the success screen', async function () {
|
||||||
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Send ETH from inside MetaMask', () => {
|
describe('Send ETH from inside MetaMask', function () {
|
||||||
it('starts a send transaction', async function () {
|
it('starts a send transaction', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
@ -51,13 +51,13 @@ describe('MetaMask', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('successfuly signs typed data', () => {
|
describe('successfuly signs typed data', function () {
|
||||||
let extension
|
let extension
|
||||||
let popup
|
let popup
|
||||||
let dapp
|
let dapp
|
||||||
let windowHandles
|
let windowHandles
|
||||||
|
|
||||||
it('accepts the account password after lock', async () => {
|
it('accepts the account password after lock', async function () {
|
||||||
await driver.delay(1000)
|
await driver.delay(1000)
|
||||||
const passwordField = await driver.findElement(By.id('password'))
|
const passwordField = await driver.findElement(By.id('password'))
|
||||||
await passwordField.sendKeys('correct horse battery staple')
|
await passwordField.sendKeys('correct horse battery staple')
|
||||||
@ -65,7 +65,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(largeDelayMs * 4)
|
await driver.delay(largeDelayMs * 4)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('connects to the dapp', async () => {
|
it('connects to the dapp', async function () {
|
||||||
await driver.openNewPage('http://127.0.0.1:8080/')
|
await driver.openNewPage('http://127.0.0.1:8080/')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.switchToWindow(dapp)
|
await driver.switchToWindow(dapp)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates a sign typed data signature request', async () => {
|
it('creates a sign typed data signature request', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Sign')]`), 10000)
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Sign')]`), 10000)
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ describe('MetaMask', function () {
|
|||||||
assert.equal(await address.getText(), publicAddress.slice(0, 8) + '...' + publicAddress.slice(publicAddress.length - 8))
|
assert.equal(await address.getText(), publicAddress.slice(0, 8) + '...' + publicAddress.slice(publicAddress.length - 8))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('signs the transaction', async () => {
|
it('signs the transaction', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Sign')]`), 10000)
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Sign')]`), 10000)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ describe('MetaMask', function () {
|
|||||||
await driver.switchToWindow(extension)
|
await driver.switchToWindow(extension)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('gets the current accounts address', async () => {
|
it('gets the current accounts address', async function () {
|
||||||
await driver.clickElement(By.css('.account-details__details-button'))
|
await driver.clickElement(By.css('.account-details__details-button'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ const { By, Key } = require('selenium-webdriver')
|
|||||||
const { withFixtures } = require('../helpers')
|
const { withFixtures } = require('../helpers')
|
||||||
|
|
||||||
describe('MetaMask Browser Extension', function () {
|
describe('MetaMask Browser Extension', function () {
|
||||||
it('can send a simple transaction from one account to another', async () => {
|
it('can send a simple transaction from one account to another', async function () {
|
||||||
const ganacheOptions = {
|
const ganacheOptions = {
|
||||||
accounts: [
|
accounts: [
|
||||||
{
|
{
|
||||||
|
@ -54,26 +54,26 @@ describe('MetaMask', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('set up data to be restored by 3box', () => {
|
describe('set up data to be restored by 3box', function () {
|
||||||
|
|
||||||
describe('First time flow starting from an existing seed phrase', () => {
|
describe('First time flow starting from an existing seed phrase', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver.findElement(By.css('.welcome-page__header'))
|
await driver.findElement(By.css('.welcome-page__header'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Import Wallet" option', async () => {
|
it('clicks the "Import Wallet" option', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Import Wallet')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Import Wallet')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "No thanks" option on the metametrics opt-in screen', async () => {
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
||||||
await driver.clickElement(By.css('.btn-default'))
|
await driver.clickElement(By.css('.btn-default'))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('imports a seed phrase', async () => {
|
it('imports a seed phrase', async function () {
|
||||||
const [seedTextArea] = await driver.findElements(By.css('textarea.first-time-flow__textarea'))
|
const [seedTextArea] = await driver.findElements(By.css('textarea.first-time-flow__textarea'))
|
||||||
await seedTextArea.sendKeys(testSeedPhrase)
|
await seedTextArea.sendKeys(testSeedPhrase)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -89,44 +89,44 @@ describe('MetaMask', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks through the success screen', async () => {
|
it('clicks through the success screen', async function () {
|
||||||
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('balance renders', async () => {
|
it('balance renders', async function () {
|
||||||
const balance = await driver.findElement(By.css('.balance-display .token-amount'))
|
const balance = await driver.findElement(By.css('.balance-display .token-amount'))
|
||||||
await driver.wait(until.elementTextMatches(balance, /25\s*ETH/))
|
await driver.wait(until.elementTextMatches(balance, /25\s*ETH/))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('turns on threebox syncing', () => {
|
describe('turns on threebox syncing', function () {
|
||||||
it('goes to the settings screen', async () => {
|
it('goes to the settings screen', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
await driver.clickElement(By.xpath(`//div[contains(text(), 'Settings')]`))
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Settings')]`))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('turns on threebox syncing', async () => {
|
it('turns on threebox syncing', async function () {
|
||||||
await driver.clickElement(By.xpath(`//div[contains(text(), 'Advanced')]`))
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Advanced')]`))
|
||||||
await driver.clickElement(By.css('[data-testid="advanced-setting-3box"] .toggle-button div'))
|
await driver.clickElement(By.css('[data-testid="advanced-setting-3box"] .toggle-button div'))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('updates settings and address book', () => {
|
describe('updates settings and address book', function () {
|
||||||
it('adds an address to the contact list', async () => {
|
it('navigates to General settings', async function () {
|
||||||
await driver.clickElement(By.xpath(`//div[contains(text(), 'General')]`))
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'General')]`))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('turns on use of blockies', async () => {
|
it('turns on use of blockies', async function () {
|
||||||
await driver.clickElement(By.css('.toggle-button > div'))
|
await driver.clickElement(By.css('.toggle-button > div'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('adds an address to the contact list', async () => {
|
it('adds an address to the contact list', async function () {
|
||||||
await driver.clickElement(By.xpath(`//div[contains(text(), 'Contacts')]`))
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Contacts')]`))
|
||||||
|
|
||||||
await driver.clickElement(By.css('.address-book-add-button__button'))
|
await driver.clickElement(By.css('.address-book-add-button__button'))
|
||||||
@ -150,7 +150,7 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('restoration from 3box', () => {
|
describe('restoration from 3box', function () {
|
||||||
let driver2
|
let driver2
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
@ -162,24 +162,24 @@ describe('MetaMask', function () {
|
|||||||
await driver2.quit()
|
await driver2.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('First time flow starting from an existing seed phrase', () => {
|
describe('First time flow starting from an existing seed phrase', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver2.findElement(By.css('.welcome-page__header'))
|
await driver2.findElement(By.css('.welcome-page__header'))
|
||||||
await driver2.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver2.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver2.delay(largeDelayMs)
|
await driver2.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Import Wallet" option', async () => {
|
it('clicks the "Import Wallet" option', async function () {
|
||||||
await driver2.clickElement(By.xpath(`//button[contains(text(), 'Import Wallet')]`))
|
await driver2.clickElement(By.xpath(`//button[contains(text(), 'Import Wallet')]`))
|
||||||
await driver2.delay(largeDelayMs)
|
await driver2.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "No thanks" option on the metametrics opt-in screen', async () => {
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
||||||
await driver2.clickElement(By.css('.btn-default'))
|
await driver2.clickElement(By.css('.btn-default'))
|
||||||
await driver2.delay(largeDelayMs)
|
await driver2.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('imports a seed phrase', async () => {
|
it('imports a seed phrase', async function () {
|
||||||
const [seedTextArea] = await driver2.findElements(By.css('textarea.first-time-flow__textarea'))
|
const [seedTextArea] = await driver2.findElements(By.css('textarea.first-time-flow__textarea'))
|
||||||
await seedTextArea.sendKeys(testSeedPhrase)
|
await seedTextArea.sendKeys(testSeedPhrase)
|
||||||
await driver2.delay(regularDelayMs)
|
await driver2.delay(regularDelayMs)
|
||||||
@ -195,40 +195,40 @@ describe('MetaMask', function () {
|
|||||||
await driver2.delay(regularDelayMs)
|
await driver2.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks through the success screen', async () => {
|
it('clicks through the success screen', async function () {
|
||||||
await driver2.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
await driver2.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
||||||
await driver2.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
await driver2.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
||||||
await driver2.delay(regularDelayMs)
|
await driver2.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('balance renders', async () => {
|
it('balance renders', async function () {
|
||||||
const balance = await driver2.findElement(By.css('.balance-display .token-amount'))
|
const balance = await driver2.findElement(By.css('.balance-display .token-amount'))
|
||||||
await driver2.wait(until.elementTextMatches(balance, /25\s*ETH/))
|
await driver2.wait(until.elementTextMatches(balance, /25\s*ETH/))
|
||||||
await driver2.delay(regularDelayMs)
|
await driver2.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('restores 3box data', () => {
|
describe('restores 3box data', function () {
|
||||||
it('confirms the 3box restore notification', async () => {
|
it('confirms the 3box restore notification', async function () {
|
||||||
await driver2.clickElement(By.css('.home-notification__accept-button'))
|
await driver2.clickElement(By.css('.home-notification__accept-button'))
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: Fix tests from here forward; they're using the wrong driver
|
// TODO: Fix tests from here forward; they're using the wrong driver
|
||||||
it('goes to the settings screen', async () => {
|
it('goes to the settings screen', async function () {
|
||||||
await driver.clickElement(By.css('.account-menu__icon'))
|
await driver.clickElement(By.css('.account-menu__icon'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
await driver.clickElement(By.xpath(`//div[contains(text(), 'Settings')]`))
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Settings')]`))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds the blockies toggle turned on', async () => {
|
it('finds the blockies toggle turned on', async function () {
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
const toggleLabel = await driver.findElement(By.css('.toggle-button__status-label'))
|
const toggleLabel = await driver.findElement(By.css('.toggle-button__status-label'))
|
||||||
const toggleLabelText = await toggleLabel.getText()
|
const toggleLabelText = await toggleLabel.getText()
|
||||||
assert.equal(toggleLabelText, 'ON')
|
assert.equal(toggleLabelText, 'ON')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds the restored address in the contact list', async () => {
|
it('finds the restored address in the contact list', async function () {
|
||||||
await driver.clickElement(By.xpath(`//div[contains(text(), 'Contacts')]`))
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Contacts')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
|
@ -52,24 +52,24 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.quit()
|
await driver.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('First time flow starting from an existing seed phrase', () => {
|
describe('First time flow starting from an existing seed phrase', function () {
|
||||||
it('clicks the continue button on the welcome screen', async () => {
|
it('clicks the continue button on the welcome screen', async function () {
|
||||||
await driver.findElement(By.css('.welcome-page__header'))
|
await driver.findElement(By.css('.welcome-page__header'))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "Import Wallet" option', async () => {
|
it('clicks the "Import Wallet" option', async function () {
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), 'Import Wallet')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Import Wallet')]`))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks the "No thanks" option on the metametrics opt-in screen', async () => {
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
||||||
await driver.clickElement(By.css('.btn-default'))
|
await driver.clickElement(By.css('.btn-default'))
|
||||||
await driver.delay(largeDelayMs)
|
await driver.delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('imports a seed phrase', async () => {
|
it('imports a seed phrase', async function () {
|
||||||
const [seedTextArea] = await driver.findElements(By.css('textarea.first-time-flow__textarea'))
|
const [seedTextArea] = await driver.findElements(By.css('textarea.first-time-flow__textarea'))
|
||||||
await seedTextArea.sendKeys(testSeedPhrase)
|
await seedTextArea.sendKeys(testSeedPhrase)
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -85,7 +85,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks through the success screen', async () => {
|
it('clicks through the success screen', async function () {
|
||||||
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
||||||
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
@ -93,9 +93,9 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
describe('opens dapp', () => {
|
describe('opens dapp', function () {
|
||||||
|
|
||||||
it('switches to mainnet', async () => {
|
it('switches to mainnet', async function () {
|
||||||
await driver.clickElement(By.css('.network-name'))
|
await driver.clickElement(By.css('.network-name'))
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.delay(largeDelayMs * 2)
|
await driver.delay(largeDelayMs * 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('connects to dapp', async () => {
|
it('connects to dapp', async function () {
|
||||||
await driver.openNewPage('http://127.0.0.1:8080/')
|
await driver.openNewPage('http://127.0.0.1:8080/')
|
||||||
await driver.delay(regularDelayMs)
|
await driver.delay(regularDelayMs)
|
||||||
|
|
||||||
@ -126,10 +126,10 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('testing web3 methods', async () => {
|
describe('testing web3 methods', function () {
|
||||||
|
|
||||||
|
|
||||||
it('testing hexa methods', async () => {
|
it('testing hexa methods', async function () {
|
||||||
|
|
||||||
|
|
||||||
const List = await driver.findClickableElements(By.className('hexaNumberMethods'))
|
const List = await driver.findClickableElements(By.className('hexaNumberMethods'))
|
||||||
@ -151,7 +151,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('testing booleanMethods', async () => {
|
it('testing booleanMethods', async function () {
|
||||||
|
|
||||||
const List = await driver.findClickableElement(By.className('booleanMethods'))
|
const List = await driver.findClickableElement(By.className('booleanMethods'))
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('testing transactionMethods', async () => {
|
it('testing transactionMethods', async function () {
|
||||||
|
|
||||||
const List = await driver.findClickableElement(By.className('transactionMethods'))
|
const List = await driver.findClickableElement(By.className('transactionMethods'))
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('testing blockMethods', async () => {
|
it('testing blockMethods', async function () {
|
||||||
|
|
||||||
const List = await driver.findClickableElement(By.className('blockMethods'))
|
const List = await driver.findClickableElement(By.className('blockMethods'))
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('testing methods', async () => {
|
it('testing methods', async function () {
|
||||||
|
|
||||||
const List = await driver.findClickableElement(By.className('methods'))
|
const List = await driver.findClickableElement(By.className('methods'))
|
||||||
let parsedData
|
let parsedData
|
||||||
|
@ -6,9 +6,9 @@ import '../../app/scripts/lib/freezeGlobals'
|
|||||||
|
|
||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
|
|
||||||
describe('Promise global is immutable', () => {
|
describe('Promise global is immutable', function () {
|
||||||
|
|
||||||
it('throws when reassinging promise (syntax 1)', () => {
|
it('throws when reassinging promise (syntax 1)', function () {
|
||||||
try {
|
try {
|
||||||
Promise = {}
|
Promise = {}
|
||||||
assert.fail('did not throw error')
|
assert.fail('did not throw error')
|
||||||
@ -17,7 +17,7 @@ describe('Promise global is immutable', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws when reassinging promise (syntax 2)', () => {
|
it('throws when reassinging promise (syntax 2)', function () {
|
||||||
try {
|
try {
|
||||||
global.Promise = {}
|
global.Promise = {}
|
||||||
assert.fail('did not throw error')
|
assert.fail('did not throw error')
|
||||||
@ -26,7 +26,7 @@ describe('Promise global is immutable', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws when mutating existing Promise property', () => {
|
it('throws when mutating existing Promise property', function () {
|
||||||
try {
|
try {
|
||||||
Promise.all = () => {}
|
Promise.all = () => {}
|
||||||
assert.fail('did not throw error')
|
assert.fail('did not throw error')
|
||||||
@ -35,7 +35,7 @@ describe('Promise global is immutable', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws when adding new Promise property', () => {
|
it('throws when adding new Promise property', function () {
|
||||||
try {
|
try {
|
||||||
Promise.foo = 'bar'
|
Promise.foo = 'bar'
|
||||||
assert.fail('did not throw error')
|
assert.fail('did not throw error')
|
||||||
@ -44,7 +44,7 @@ describe('Promise global is immutable', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws when deleting Promise from global', () => {
|
it('throws when deleting Promise from global', function () {
|
||||||
try {
|
try {
|
||||||
delete global.Promise
|
delete global.Promise
|
||||||
assert.fail('did not throw error')
|
assert.fail('did not throw error')
|
||||||
|
@ -25,7 +25,7 @@ describe('tx confirmation screen', function () {
|
|||||||
const store = mockStore(initialState)
|
const store = mockStore(initialState)
|
||||||
|
|
||||||
describe('cancelTx', function () {
|
describe('cancelTx', function () {
|
||||||
before(function (done) {
|
it('creates COMPLETED_TX with the cancelled transaction ID', async function () {
|
||||||
actions._setBackgroundConnection({
|
actions._setBackgroundConnection({
|
||||||
approveTransaction (_, cb) {
|
approveTransaction (_, cb) {
|
||||||
cb('An error!')
|
cb('An error!')
|
||||||
@ -37,10 +37,7 @@ describe('tx confirmation screen', function () {
|
|||||||
cb()
|
cb()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
done()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('creates COMPLETED_TX with the cancelled transaction ID', async function () {
|
|
||||||
await store.dispatch(actions.cancelTx({ id: txId }))
|
await store.dispatch(actions.cancelTx({ id: txId }))
|
||||||
const storeActions = store.getActions()
|
const storeActions = store.getActions()
|
||||||
const completedTxAction = storeActions.find(({ type }) => type === actions.actionConstants.COMPLETED_TX)
|
const completedTxAction = storeActions.find(({ type }) => type === actions.actionConstants.COMPLETED_TX)
|
||||||
|
@ -2,20 +2,20 @@ import assert from 'assert'
|
|||||||
import ComposableObservableStore from '../../../app/scripts/lib/ComposableObservableStore'
|
import ComposableObservableStore from '../../../app/scripts/lib/ComposableObservableStore'
|
||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
|
|
||||||
describe('ComposableObservableStore', () => {
|
describe('ComposableObservableStore', function () {
|
||||||
it('should register initial state', () => {
|
it('should register initial state', function () {
|
||||||
const store = new ComposableObservableStore('state')
|
const store = new ComposableObservableStore('state')
|
||||||
assert.strictEqual(store.getState(), 'state')
|
assert.strictEqual(store.getState(), 'state')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should register initial structure', () => {
|
it('should register initial structure', function () {
|
||||||
const testStore = new ObservableStore()
|
const testStore = new ObservableStore()
|
||||||
const store = new ComposableObservableStore(null, { TestStore: testStore })
|
const store = new ComposableObservableStore(null, { TestStore: testStore })
|
||||||
testStore.putState('state')
|
testStore.putState('state')
|
||||||
assert.deepEqual(store.getState(), { TestStore: 'state' })
|
assert.deepEqual(store.getState(), { TestStore: 'state' })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should update structure', () => {
|
it('should update structure', function () {
|
||||||
const testStore = new ObservableStore()
|
const testStore = new ObservableStore()
|
||||||
const store = new ComposableObservableStore()
|
const store = new ComposableObservableStore()
|
||||||
store.updateStructure({ TestStore: testStore })
|
store.updateStructure({ TestStore: testStore })
|
||||||
@ -23,7 +23,7 @@ describe('ComposableObservableStore', () => {
|
|||||||
assert.deepEqual(store.getState(), { TestStore: 'state' })
|
assert.deepEqual(store.getState(), { TestStore: 'state' })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return flattened state', () => {
|
it('should return flattened state', function () {
|
||||||
const fooStore = new ObservableStore({ foo: 'foo' })
|
const fooStore = new ObservableStore({ foo: 'foo' })
|
||||||
const barStore = new ObservableStore({ bar: 'bar' })
|
const barStore = new ObservableStore({ bar: 'bar' })
|
||||||
const store = new ComposableObservableStore(null, {
|
const store = new ComposableObservableStore(null, {
|
||||||
|
@ -12,26 +12,24 @@ describe('Account Import Strategies', function () {
|
|||||||
assert.equal(importPrivKey, ethUtil.stripHexPrefix(privkey))
|
assert.equal(importPrivKey, ethUtil.stripHexPrefix(privkey))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error for empty string private key', async () => {
|
it('throws an error for empty string private key', async function () {
|
||||||
return assert.rejects(async function () {
|
await assert.rejects(async () => {
|
||||||
await accountImporter.importAccount('Private Key', [ '' ])
|
await accountImporter.importAccount('Private Key', [ '' ])
|
||||||
}, Error, 'no empty strings')
|
}, Error, 'no empty strings')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error for undefined string private key', async () => {
|
it('throws an error for undefined string private key', async function () {
|
||||||
return assert.rejects(async function () {
|
await assert.rejects(async () => {
|
||||||
await accountImporter.importAccount('Private Key', [ undefined ])
|
await accountImporter.importAccount('Private Key', [ undefined ])
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
it('throws an error for undefined string private key', async () => {
|
await assert.rejects(async () => {
|
||||||
return assert.rejects(async function () {
|
|
||||||
await accountImporter.importAccount('Private Key', [])
|
await accountImporter.importAccount('Private Key', [])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error for invalid private key', async () => {
|
it('throws an error for invalid private key', async function () {
|
||||||
return assert.rejects(async function () {
|
await assert.rejects(async () => {
|
||||||
await accountImporter.importAccount('Private Key', [ 'popcorn' ])
|
await accountImporter.importAccount('Private Key', [ 'popcorn' ])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import cleanErrorStack from '../../../app/scripts/lib/cleanErrorStack'
|
import cleanErrorStack from '../../../app/scripts/lib/cleanErrorStack'
|
||||||
|
|
||||||
describe('Clean Error Stack', () => {
|
describe('Clean Error Stack', function () {
|
||||||
|
|
||||||
const testMessage = 'Test Message'
|
const testMessage = 'Test Message'
|
||||||
const testError = new Error(testMessage)
|
const testError = new Error(testMessage)
|
||||||
@ -9,24 +9,24 @@ describe('Clean Error Stack', () => {
|
|||||||
const blankErrorName = new Error(testMessage)
|
const blankErrorName = new Error(testMessage)
|
||||||
const blankMsgError = new Error()
|
const blankMsgError = new Error()
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
undefinedErrorName.name = undefined
|
undefinedErrorName.name = undefined
|
||||||
blankErrorName.name = ''
|
blankErrorName.name = ''
|
||||||
})
|
})
|
||||||
|
|
||||||
it('tests error with message', () => {
|
it('tests error with message', function () {
|
||||||
assert.equal(cleanErrorStack(testError), 'Error: Test Message')
|
assert.equal(cleanErrorStack(testError), 'Error: Test Message')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('tests error with undefined name', () => {
|
it('tests error with undefined name', function () {
|
||||||
assert.equal(cleanErrorStack(undefinedErrorName).toString(), 'Error: Test Message')
|
assert.equal(cleanErrorStack(undefinedErrorName).toString(), 'Error: Test Message')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('tests error with blank name', () => {
|
it('tests error with blank name', function () {
|
||||||
assert.equal(cleanErrorStack(blankErrorName).toString(), 'Test Message')
|
assert.equal(cleanErrorStack(blankErrorName).toString(), 'Test Message')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('tests error with blank message', () => {
|
it('tests error with blank message', function () {
|
||||||
assert.equal(cleanErrorStack(blankMsgError), 'Error')
|
assert.equal(cleanErrorStack(blankMsgError), 'Error')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ const accounts = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Balance Controller', () => {
|
describe('Balance Controller', function () {
|
||||||
|
|
||||||
let balanceController
|
let balanceController
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ describe('Balance Controller', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
balanceController = new BalanceController({
|
balanceController = new BalanceController({
|
||||||
address: TEST_ADDRESS,
|
address: TEST_ADDRESS,
|
||||||
accountTracker: new AccountTracker({
|
accountTracker: new AccountTracker({
|
||||||
|
@ -2,9 +2,9 @@ import assert from 'assert'
|
|||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
import CachedBalancesController from '../../../../app/scripts/controllers/cached-balances'
|
import CachedBalancesController from '../../../../app/scripts/controllers/cached-balances'
|
||||||
|
|
||||||
describe('CachedBalancesController', () => {
|
describe('CachedBalancesController', function () {
|
||||||
describe('updateCachedBalances', () => {
|
describe('updateCachedBalances', function () {
|
||||||
it('should update the cached balances', async () => {
|
it('should update the cached balances', async function () {
|
||||||
const controller = new CachedBalancesController({
|
const controller = new CachedBalancesController({
|
||||||
getNetwork: () => Promise.resolve(17),
|
getNetwork: () => Promise.resolve(17),
|
||||||
accountTracker: {
|
accountTracker: {
|
||||||
@ -27,8 +27,8 @@ describe('CachedBalancesController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('_generateBalancesToCache', () => {
|
describe('_generateBalancesToCache', function () {
|
||||||
it('should generate updated account balances where the current network was updated', () => {
|
it('should generate updated account balances where the current network was updated', function () {
|
||||||
const controller = new CachedBalancesController({
|
const controller = new CachedBalancesController({
|
||||||
accountTracker: {
|
accountTracker: {
|
||||||
store: {
|
store: {
|
||||||
@ -71,7 +71,7 @@ describe('CachedBalancesController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should generate updated account balances where the a new network was selected', () => {
|
it('should generate updated account balances where the a new network was selected', function () {
|
||||||
const controller = new CachedBalancesController({
|
const controller = new CachedBalancesController({
|
||||||
accountTracker: {
|
accountTracker: {
|
||||||
store: {
|
store: {
|
||||||
@ -109,8 +109,8 @@ describe('CachedBalancesController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('_registerUpdates', () => {
|
describe('_registerUpdates', function () {
|
||||||
it('should subscribe to the account tracker with the updateCachedBalances method', async () => {
|
it('should subscribe to the account tracker with the updateCachedBalances method', async function () {
|
||||||
const subscribeSpy = sinon.spy()
|
const subscribeSpy = sinon.spy()
|
||||||
const controller = new CachedBalancesController({
|
const controller = new CachedBalancesController({
|
||||||
getNetwork: () => Promise.resolve(17),
|
getNetwork: () => Promise.resolve(17),
|
||||||
|
@ -6,7 +6,7 @@ import DetectTokensController from '../../../../app/scripts/controllers/detect-t
|
|||||||
import NetworkController from '../../../../app/scripts/controllers/network/network'
|
import NetworkController from '../../../../app/scripts/controllers/network/network'
|
||||||
import PreferencesController from '../../../../app/scripts/controllers/preferences'
|
import PreferencesController from '../../../../app/scripts/controllers/preferences'
|
||||||
|
|
||||||
describe('DetectTokensController', () => {
|
describe('DetectTokensController', function () {
|
||||||
const sandbox = sinon.createSandbox()
|
const sandbox = sinon.createSandbox()
|
||||||
let clock, keyringMemStore, network, preferences, controller
|
let clock, keyringMemStore, network, preferences, controller
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ describe('DetectTokensController', () => {
|
|||||||
getAccounts: noop,
|
getAccounts: noop,
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async function () {
|
||||||
|
|
||||||
|
|
||||||
nock('https://api.infura.io')
|
nock('https://api.infura.io')
|
||||||
@ -32,19 +32,19 @@ describe('DetectTokensController', () => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
after(() => {
|
after(function () {
|
||||||
sandbox.restore()
|
sandbox.restore()
|
||||||
nock.cleanAll()
|
nock.cleanAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should poll on correct interval', async () => {
|
it('should poll on correct interval', async function () {
|
||||||
const stub = sinon.stub(global, 'setInterval')
|
const stub = sinon.stub(global, 'setInterval')
|
||||||
new DetectTokensController({ interval: 1337 }) // eslint-disable-line no-new
|
new DetectTokensController({ interval: 1337 }) // eslint-disable-line no-new
|
||||||
assert.strictEqual(stub.getCall(0).args[1], 1337)
|
assert.strictEqual(stub.getCall(0).args[1], 1337)
|
||||||
stub.restore()
|
stub.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should be called on every polling period', async () => {
|
it('should be called on every polling period', async function () {
|
||||||
clock = sandbox.useFakeTimers()
|
clock = sandbox.useFakeTimers()
|
||||||
const network = new NetworkController()
|
const network = new NetworkController()
|
||||||
network.initializeProvider(networkControllerProviderConfig)
|
network.initializeProvider(networkControllerProviderConfig)
|
||||||
@ -66,7 +66,7 @@ describe('DetectTokensController', () => {
|
|||||||
sandbox.assert.calledThrice(stub)
|
sandbox.assert.calledThrice(stub)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not check tokens while in test network', async () => {
|
it('should not check tokens while in test network', async function () {
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.isUnlocked = true
|
controller.isUnlocked = true
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ describe('DetectTokensController', () => {
|
|||||||
sandbox.assert.notCalled(stub)
|
sandbox.assert.notCalled(stub)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should only check and add tokens while in main network', async () => {
|
it('should only check and add tokens while in main network', async function () {
|
||||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.isUnlocked = true
|
controller.isUnlocked = true
|
||||||
@ -94,7 +94,7 @@ describe('DetectTokensController', () => {
|
|||||||
{ address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK' }])
|
{ address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK' }])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not detect same token while in main network', async () => {
|
it('should not detect same token while in main network', async function () {
|
||||||
preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8)
|
preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8)
|
||||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
@ -111,7 +111,7 @@ describe('DetectTokensController', () => {
|
|||||||
{ address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK' }])
|
{ address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK' }])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should trigger detect new tokens when change address', async () => {
|
it('should trigger detect new tokens when change address', async function () {
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.isUnlocked = true
|
controller.isUnlocked = true
|
||||||
const stub = sandbox.stub(controller, 'detectNewTokens')
|
const stub = sandbox.stub(controller, 'detectNewTokens')
|
||||||
@ -119,7 +119,7 @@ describe('DetectTokensController', () => {
|
|||||||
sandbox.assert.called(stub)
|
sandbox.assert.called(stub)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should trigger detect new tokens when submit password', async () => {
|
it('should trigger detect new tokens when submit password', async function () {
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.selectedAddress = '0x0'
|
controller.selectedAddress = '0x0'
|
||||||
const stub = sandbox.stub(controller, 'detectNewTokens')
|
const stub = sandbox.stub(controller, 'detectNewTokens')
|
||||||
@ -127,7 +127,7 @@ describe('DetectTokensController', () => {
|
|||||||
sandbox.assert.called(stub)
|
sandbox.assert.called(stub)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not trigger detect new tokens when not open or not unlocked', async () => {
|
it('should not trigger detect new tokens when not open or not unlocked', async function () {
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.isUnlocked = false
|
controller.isUnlocked = false
|
||||||
const stub = sandbox.stub(controller, 'detectTokenBalance')
|
const stub = sandbox.stub(controller, 'detectTokenBalance')
|
||||||
|
@ -9,7 +9,7 @@ const ZERO_X_ERROR_ADDRESS = '0x'
|
|||||||
|
|
||||||
describe('EnsController', function () {
|
describe('EnsController', function () {
|
||||||
describe('#constructor', function () {
|
describe('#constructor', function () {
|
||||||
it('should construct the controller given a provider and a network', async () => {
|
it('should construct the controller given a provider and a network', async function () {
|
||||||
const provider = new HttpProvider('https://ropsten.infura.io')
|
const provider = new HttpProvider('https://ropsten.infura.io')
|
||||||
const currentNetworkId = '3'
|
const currentNetworkId = '3'
|
||||||
const networkStore = new ObservableStore(currentNetworkId)
|
const networkStore = new ObservableStore(currentNetworkId)
|
||||||
@ -21,7 +21,7 @@ describe('EnsController', function () {
|
|||||||
assert.ok(ens._ens)
|
assert.ok(ens._ens)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should construct the controller given an existing ENS instance', async () => {
|
it('should construct the controller given an existing ENS instance', async function () {
|
||||||
const networkStore = {
|
const networkStore = {
|
||||||
subscribe: sinon.spy(),
|
subscribe: sinon.spy(),
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ describe('EnsController', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#reverseResolveName', function () {
|
describe('#reverseResolveName', function () {
|
||||||
it('should resolve to an ENS name', async () => {
|
it('should resolve to an ENS name', async function () {
|
||||||
const address = '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
|
const address = '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
|
||||||
const networkStore = {
|
const networkStore = {
|
||||||
subscribe: sinon.spy(),
|
subscribe: sinon.spy(),
|
||||||
@ -52,7 +52,7 @@ describe('EnsController', function () {
|
|||||||
assert.equal(name, 'peaksignal.eth')
|
assert.equal(name, 'peaksignal.eth')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should only resolve an ENS name once', async () => {
|
it('should only resolve an ENS name once', async function () {
|
||||||
const address = '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
|
const address = '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
|
||||||
const reverse = sinon.stub().withArgs(address).returns('peaksignal.eth')
|
const reverse = sinon.stub().withArgs(address).returns('peaksignal.eth')
|
||||||
const lookup = sinon.stub().withArgs('peaksignal.eth').returns(address)
|
const lookup = sinon.stub().withArgs('peaksignal.eth').returns(address)
|
||||||
@ -73,7 +73,7 @@ describe('EnsController', function () {
|
|||||||
assert.ok(reverse.calledOnce)
|
assert.ok(reverse.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should fail if the name is registered to a different address than the reverse-resolved', async () => {
|
it('should fail if the name is registered to a different address than the reverse-resolved', async function () {
|
||||||
const address = '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
|
const address = '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
|
||||||
const networkStore = {
|
const networkStore = {
|
||||||
subscribe: sinon.spy(),
|
subscribe: sinon.spy(),
|
||||||
@ -90,7 +90,7 @@ describe('EnsController', function () {
|
|||||||
assert.strictEqual(name, undefined)
|
assert.strictEqual(name, undefined)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw an error when the lookup resolves to the zero address', async () => {
|
it('should throw an error when the lookup resolves to the zero address', async function () {
|
||||||
const address = '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
|
const address = '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
|
||||||
const networkStore = {
|
const networkStore = {
|
||||||
subscribe: sinon.spy(),
|
subscribe: sinon.spy(),
|
||||||
@ -111,7 +111,7 @@ describe('EnsController', function () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw an error the lookup resolves to the zero x address', async () => {
|
it('should throw an error the lookup resolves to the zero x address', async function () {
|
||||||
const address = '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
|
const address = '0x8e5d75d60224ea0c33d0041e75de68b1c3cb6dd5'
|
||||||
const networkStore = {
|
const networkStore = {
|
||||||
subscribe: sinon.spy(),
|
subscribe: sinon.spy(),
|
||||||
|
@ -8,7 +8,7 @@ const IncomingTransactionsController = proxyquire('../../../../app/scripts/contr
|
|||||||
|
|
||||||
import { ROPSTEN, RINKEBY, KOVAN, GOERLI, MAINNET } from '../../../../app/scripts/controllers/network/enums'
|
import { ROPSTEN, RINKEBY, KOVAN, GOERLI, MAINNET } from '../../../../app/scripts/controllers/network/enums'
|
||||||
|
|
||||||
describe('IncomingTransactionsController', () => {
|
describe('IncomingTransactionsController', function () {
|
||||||
const EMPTY_INIT_STATE = {
|
const EMPTY_INIT_STATE = {
|
||||||
incomingTransactions: {},
|
incomingTransactions: {},
|
||||||
incomingTxLastFetchedBlocksByNetwork: {
|
incomingTxLastFetchedBlocksByNetwork: {
|
||||||
@ -71,8 +71,8 @@ describe('IncomingTransactionsController', () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('constructor', () => {
|
describe('constructor', function () {
|
||||||
it('should set up correct store, listeners and properties in the constructor', () => {
|
it('should set up correct store, listeners and properties in the constructor', function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -102,7 +102,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
incomingTransactionsController._update.resetHistory()
|
incomingTransactionsController._update.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should set the store to a provided initial state', () => {
|
it('should set the store to a provided initial state', function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -114,8 +114,8 @@ describe('IncomingTransactionsController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#start', () => {
|
describe('#start', function () {
|
||||||
it('should set up a listener for the latest block', () => {
|
it('should set up a listener for the latest block', function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -139,8 +139,8 @@ describe('IncomingTransactionsController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('_getDataForUpdate', () => {
|
describe('_getDataForUpdate', function () {
|
||||||
it('should call fetchAll with the correct params when passed a new block number and the current network has no stored block', async () => {
|
it('should call fetchAll with the correct params when passed a new block number and the current network has no stored block', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -158,7 +158,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call fetchAll with the correct params when passed a new block number but the current network has a stored block', async () => {
|
it('should call fetchAll with the correct params when passed a new block number but the current network has a stored block', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -176,7 +176,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call fetchAll with the correct params when passed a new network type but no block info exists', async () => {
|
it('should call fetchAll with the correct params when passed a new network type but no block info exists', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -197,25 +197,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call fetchAll with the correct params when passed a new block number but the current network has a stored block', async () => {
|
it('should return the expected data', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
|
||||||
preferencesController: MOCK_PREFERENCES_CONTROLLER,
|
|
||||||
initState: NON_EMPTY_INIT_STATE_WITH_FAKE_NETWORK_STATE,
|
|
||||||
})
|
|
||||||
incomingTransactionsController._fetchAll = sinon.stub().returns({})
|
|
||||||
|
|
||||||
await incomingTransactionsController._getDataForUpdate({ address: 'fakeAddress', newBlockNumberDec: 999 })
|
|
||||||
|
|
||||||
assert(incomingTransactionsController._fetchAll.calledOnce)
|
|
||||||
|
|
||||||
assert.deepEqual(incomingTransactionsController._fetchAll.getCall(0).args, [
|
|
||||||
'fakeAddress', 1111, 'FAKE_NETWORK',
|
|
||||||
])
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should return the expected data', async () => {
|
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -252,7 +234,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('_updateStateWithNewTxData', () => {
|
describe('_updateStateWithNewTxData', function () {
|
||||||
const MOCK_INPUT_WITHOUT_LASTEST = {
|
const MOCK_INPUT_WITHOUT_LASTEST = {
|
||||||
newTxs: [{ id: 555, hash: '0xfff' }],
|
newTxs: [{ id: 555, hash: '0xfff' }],
|
||||||
currentIncomingTxs: {
|
currentIncomingTxs: {
|
||||||
@ -275,7 +257,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
latestIncomingTxBlockNumber: 444,
|
latestIncomingTxBlockNumber: 444,
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should update state with correct blockhash and transactions when passed a truthy latestIncomingTxBlockNumber', async () => {
|
it('should update state with correct blockhash and transactions when passed a truthy latestIncomingTxBlockNumber', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -300,7 +282,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should update state with correct blockhash and transactions when passed a falsy latestIncomingTxBlockNumber', async () => {
|
it('should update state with correct blockhash and transactions when passed a falsy latestIncomingTxBlockNumber', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -326,22 +308,22 @@ describe('IncomingTransactionsController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('_fetchTxs', () => {
|
describe('_fetchTxs', function () {
|
||||||
const mockFetch = sinon.stub().returns(Promise.resolve({
|
const mockFetch = sinon.stub().returns(Promise.resolve({
|
||||||
json: () => Promise.resolve({ someKey: 'someValue' }),
|
json: () => Promise.resolve({ someKey: 'someValue' }),
|
||||||
}))
|
}))
|
||||||
let tempFetch
|
let tempFetch
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
tempFetch = global.fetch
|
tempFetch = global.fetch
|
||||||
global.fetch = mockFetch
|
global.fetch = mockFetch
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
global.fetch = tempFetch
|
global.fetch = tempFetch
|
||||||
mockFetch.resetHistory()
|
mockFetch.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call fetch with the expected url when passed an address, block number and supported network', async () => {
|
it('should call fetch with the expected url when passed an address, block number and supported network', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -355,7 +337,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
assert.equal(mockFetch.getCall(0).args[0], `https://api-${ROPSTEN}.etherscan.io/api?module=account&action=txlist&address=0xfakeaddress&tag=latest&page=1&startBlock=789`)
|
assert.equal(mockFetch.getCall(0).args[0], `https://api-${ROPSTEN}.etherscan.io/api?module=account&action=txlist&address=0xfakeaddress&tag=latest&page=1&startBlock=789`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call fetch with the expected url when passed an address, block number and MAINNET', async () => {
|
it('should call fetch with the expected url when passed an address, block number and MAINNET', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -369,7 +351,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
assert.equal(mockFetch.getCall(0).args[0], `https://api.etherscan.io/api?module=account&action=txlist&address=0xfakeaddress&tag=latest&page=1&startBlock=789`)
|
assert.equal(mockFetch.getCall(0).args[0], `https://api.etherscan.io/api?module=account&action=txlist&address=0xfakeaddress&tag=latest&page=1&startBlock=789`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call fetch with the expected url when passed an address and supported network, but a falsy block number', async () => {
|
it('should call fetch with the expected url when passed an address and supported network, but a falsy block number', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -383,7 +365,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
assert.equal(mockFetch.getCall(0).args[0], `https://api-${ROPSTEN}.etherscan.io/api?module=account&action=txlist&address=0xfakeaddress&tag=latest&page=1`)
|
assert.equal(mockFetch.getCall(0).args[0], `https://api-${ROPSTEN}.etherscan.io/api?module=account&action=txlist&address=0xfakeaddress&tag=latest&page=1`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not fetch and return an empty object when passed an unsported network', async () => {
|
it('should not fetch and return an empty object when passed an unsported network', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -397,7 +379,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
assert.deepEqual(result, {})
|
assert.deepEqual(result, {})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return the results from the fetch call, plus the address and currentNetworkID, when passed an address, block number and supported network', async () => {
|
it('should return the results from the fetch call, plus the address and currentNetworkID, when passed an address, block number and supported network', async function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -416,8 +398,8 @@ describe('IncomingTransactionsController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('_processTxFetchResponse', () => {
|
describe('_processTxFetchResponse', function () {
|
||||||
it('should return a null block number and empty tx array if status is 0', () => {
|
it('should return a null block number and empty tx array if status is 0', function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -437,7 +419,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return a null block number and empty tx array if the passed result array is empty', () => {
|
it('should return a null block number and empty tx array if the passed result array is empty', function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -457,7 +439,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return the expected block number and tx list when passed data from a successful fetch', () => {
|
it('should return the expected block number and tx list when passed data from a successful fetch', function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -575,8 +557,8 @@ describe('IncomingTransactionsController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('_normalizeTxFromEtherscan', () => {
|
describe('_normalizeTxFromEtherscan', function () {
|
||||||
it('should return the expected data when the tx is in error', () => {
|
it('should return the expected data when the tx is in error', function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
@ -616,7 +598,7 @@ describe('IncomingTransactionsController', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return the expected data when the tx is not in error', () => {
|
it('should return the expected data when the tx is not in error', function () {
|
||||||
const incomingTransactionsController = new IncomingTransactionsController({
|
const incomingTransactionsController = new IncomingTransactionsController({
|
||||||
blockTracker: MOCK_BLOCKTRACKER,
|
blockTracker: MOCK_BLOCKTRACKER,
|
||||||
networkController: MOCK_NETWORK_CONTROLLER,
|
networkController: MOCK_NETWORK_CONTROLLER,
|
||||||
|
@ -6,6 +6,7 @@ describe('infura-controller', function () {
|
|||||||
let infuraController, sandbox, networkStatus
|
let infuraController, sandbox, networkStatus
|
||||||
const response = { 'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down', 'goerli': 'ok' }
|
const response = { 'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down', 'goerli': 'ok' }
|
||||||
|
|
||||||
|
describe('Network status queries', function () {
|
||||||
before(async function () {
|
before(async function () {
|
||||||
infuraController = new InfuraController()
|
infuraController = new InfuraController()
|
||||||
sandbox = sinon.createSandbox()
|
sandbox = sinon.createSandbox()
|
||||||
@ -17,8 +18,6 @@ describe('infura-controller', function () {
|
|||||||
sandbox.restore()
|
sandbox.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Network status queries', function () {
|
|
||||||
|
|
||||||
describe('Mainnet', function () {
|
describe('Mainnet', function () {
|
||||||
it('should have Mainnet', function () {
|
it('should have Mainnet', function () {
|
||||||
assert.equal(Object.keys(networkStatus)[0], 'mainnet')
|
assert.equal(Object.keys(networkStatus)[0], 'mainnet')
|
||||||
|
@ -110,14 +110,10 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#getAccounts', function () {
|
describe('#getAccounts', function () {
|
||||||
|
it('returns first address when dapp calls web3.eth.getAccounts', async function () {
|
||||||
beforeEach(async function () {
|
|
||||||
const password = 'a-fake-password'
|
const password = 'a-fake-password'
|
||||||
|
|
||||||
await metamaskController.createNewVaultAndRestore(password, TEST_SEED)
|
await metamaskController.createNewVaultAndRestore(password, TEST_SEED)
|
||||||
})
|
|
||||||
|
|
||||||
it('returns first address when dapp calls web3.eth.getAccounts', function () {
|
|
||||||
metamaskController.networkController._baseProviderParams.getAccounts((err, res) => {
|
metamaskController.networkController._baseProviderParams.getAccounts((err, res) => {
|
||||||
assert.ifError(err)
|
assert.ifError(err)
|
||||||
assert.equal(res.length, 1)
|
assert.equal(res.length, 1)
|
||||||
@ -127,12 +123,10 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#importAccountWithStrategy', function () {
|
describe('#importAccountWithStrategy', function () {
|
||||||
|
|
||||||
const importPrivkey = '4cfd3e90fc78b0f86bf7524722150bb8da9c60cd532564d7ff43f5716514f553'
|
const importPrivkey = '4cfd3e90fc78b0f86bf7524722150bb8da9c60cd532564d7ff43f5716514f553'
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
const password = 'a-fake-password'
|
const password = 'a-fake-password'
|
||||||
|
|
||||||
await metamaskController.createNewVaultAndRestore(password, TEST_SEED)
|
await metamaskController.createNewVaultAndRestore(password, TEST_SEED)
|
||||||
await metamaskController.importAccountWithStrategy('Private Key', [ importPrivkey ])
|
await metamaskController.importAccountWithStrategy('Private Key', [ importPrivkey ])
|
||||||
})
|
})
|
||||||
@ -148,7 +142,7 @@ describe('MetaMaskController', function () {
|
|||||||
assert.equal(pubKey, '0xe18035bf8712672935fdb4e5e431b1a0183d2dfc')
|
assert.equal(pubKey, '0xe18035bf8712672935fdb4e5e431b1a0183d2dfc')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('adds private key to keyrings in KeyringController', async function () {
|
it('adds 1 account', async function () {
|
||||||
const keyringAccounts = await metamaskController.keyringController.getAccounts()
|
const keyringAccounts = await metamaskController.keyringController.getAccounts()
|
||||||
assert.equal(keyringAccounts[keyringAccounts.length - 1], '0xe18035bf8712672935fdb4e5e431b1a0183d2dfc')
|
assert.equal(keyringAccounts[keyringAccounts.length - 1], '0xe18035bf8712672935fdb4e5e431b1a0183d2dfc')
|
||||||
})
|
})
|
||||||
@ -180,7 +174,7 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('gets the address from threebox and creates a new 3box instance', async () => {
|
it('gets the address from threebox and creates a new 3box instance', async function () {
|
||||||
await metamaskController.submitPassword(password)
|
await metamaskController.submitPassword(password)
|
||||||
assert(threeBoxSpies.init.calledOnce)
|
assert(threeBoxSpies.init.calledOnce)
|
||||||
assert(threeBoxSpies.turnThreeBoxSyncingOn.calledOnce)
|
assert(threeBoxSpies.turnThreeBoxSyncingOn.calledOnce)
|
||||||
@ -242,7 +236,7 @@ describe('MetaMaskController', function () {
|
|||||||
assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice)
|
assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should clear previous identities after vault restoration', async () => {
|
it('should clear previous identities after vault restoration', async function () {
|
||||||
sandbox.stub(metamaskController, 'getBalance')
|
sandbox.stub(metamaskController, 'getBalance')
|
||||||
metamaskController.getBalance.callsFake(() => {
|
metamaskController.getBalance.callsFake(() => {
|
||||||
return Promise.resolve('0x0')
|
return Promise.resolve('0x0')
|
||||||
@ -264,7 +258,7 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should restore any consecutive accounts with balances', async () => {
|
it('should restore any consecutive accounts with balances', async function () {
|
||||||
sandbox.stub(metamaskController, 'getBalance')
|
sandbox.stub(metamaskController, 'getBalance')
|
||||||
metamaskController.getBalance.withArgs(TEST_ADDRESS).callsFake(() => {
|
metamaskController.getBalance.withArgs(TEST_ADDRESS).callsFake(() => {
|
||||||
return Promise.resolve('0x14ced5122ce0a000')
|
return Promise.resolve('0x14ced5122ce0a000')
|
||||||
@ -284,8 +278,8 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#getBalance', () => {
|
describe('#getBalance', function () {
|
||||||
it('should return the balance known by accountTracker', async () => {
|
it('should return the balance known by accountTracker', async function () {
|
||||||
const accounts = {}
|
const accounts = {}
|
||||||
const balance = '0x14ced5122ce0a000'
|
const balance = '0x14ced5122ce0a000'
|
||||||
accounts[TEST_ADDRESS] = { balance: balance }
|
accounts[TEST_ADDRESS] = { balance: balance }
|
||||||
@ -297,7 +291,7 @@ describe('MetaMaskController', function () {
|
|||||||
assert.equal(balance, gotten)
|
assert.equal(balance, gotten)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should ask the network for a balance when not known by accountTracker', async () => {
|
it('should ask the network for a balance when not known by accountTracker', async function () {
|
||||||
const accounts = {}
|
const accounts = {}
|
||||||
const balance = '0x14ced5122ce0a000'
|
const balance = '0x14ced5122ce0a000'
|
||||||
const ethQuery = new EthQuery()
|
const ethQuery = new EthQuery()
|
||||||
@ -314,13 +308,9 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#getApi', function () {
|
describe('#getApi', function () {
|
||||||
let getApi, state
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
getApi = metamaskController.getApi()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('getState', function (done) {
|
it('getState', function (done) {
|
||||||
|
let state
|
||||||
|
const getApi = metamaskController.getApi()
|
||||||
getApi.getState((err, res) => {
|
getApi.getState((err, res) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
done(err)
|
done(err)
|
||||||
@ -331,7 +321,6 @@ describe('MetaMaskController', function () {
|
|||||||
assert.deepEqual(state, metamaskController.getState())
|
assert.deepEqual(state, metamaskController.getState())
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('preferencesController', function () {
|
describe('preferencesController', function () {
|
||||||
@ -549,16 +538,12 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#addNewAccount', function () {
|
describe('#addNewAccount', function () {
|
||||||
let addNewAccount
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
addNewAccount = metamaskController.addNewAccount()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('errors when an primary keyring is does not exist', async function () {
|
it('errors when an primary keyring is does not exist', async function () {
|
||||||
|
const addNewAccount = metamaskController.addNewAccount()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await addNewAccount
|
await addNewAccount
|
||||||
assert.equal(1 === 0)
|
assert.fail('should throw')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assert.equal(e.message, 'MetamaskController - No HD Key Tree found')
|
assert.equal(e.message, 'MetamaskController - No HD Key Tree found')
|
||||||
}
|
}
|
||||||
@ -586,8 +571,7 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#resetAccount', function () {
|
describe('#resetAccount', function () {
|
||||||
|
it('wipes transactions from only the correct network id and with the selected address', async function () {
|
||||||
beforeEach(function () {
|
|
||||||
const selectedAddressStub = sinon.stub(metamaskController.preferencesController, 'getSelectedAddress')
|
const selectedAddressStub = sinon.stub(metamaskController.preferencesController, 'getSelectedAddress')
|
||||||
const getNetworkstub = sinon.stub(metamaskController.txController.txStateManager, 'getNetwork')
|
const getNetworkstub = sinon.stub(metamaskController.txController.txStateManager, 'getNetwork')
|
||||||
|
|
||||||
@ -600,9 +584,7 @@ describe('MetaMaskController', function () {
|
|||||||
createTxMeta({ id: 2, status: 'rejected', metamaskNetworkId: 32 }),
|
createTxMeta({ id: 2, status: 'rejected', metamaskNetworkId: 32 }),
|
||||||
createTxMeta({ id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: { from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4' } }),
|
createTxMeta({ id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: { from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4' } }),
|
||||||
])
|
])
|
||||||
})
|
|
||||||
|
|
||||||
it('wipes transactions from only the correct network id and with the selected address', async function () {
|
|
||||||
await metamaskController.resetAccount()
|
await metamaskController.resetAccount()
|
||||||
assert.equal(metamaskController.txController.txStateManager.getTx(1), undefined)
|
assert.equal(metamaskController.txController.txStateManager.getTx(1), undefined)
|
||||||
})
|
})
|
||||||
@ -656,14 +638,14 @@ describe('MetaMaskController', function () {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#newUnsignedMessage', () => {
|
describe('#newUnsignedMessage', function () {
|
||||||
|
|
||||||
let msgParams, metamaskMsgs, messages, msgId
|
let msgParams, metamaskMsgs, messages, msgId
|
||||||
|
|
||||||
const address = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
|
const address = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
|
||||||
const data = '0x43727970746f6b697474696573'
|
const data = '0x43727970746f6b697474696573'
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async function () {
|
||||||
sandbox.stub(metamaskController, 'getBalance')
|
sandbox.stub(metamaskController, 'getBalance')
|
||||||
metamaskController.getBalance.callsFake(() => {
|
metamaskController.getBalance.callsFake(() => {
|
||||||
return Promise.resolve('0x0')
|
return Promise.resolve('0x0')
|
||||||
@ -746,7 +728,7 @@ describe('MetaMaskController', function () {
|
|||||||
personalMessages[0].msgParams.metamaskId = parseInt(msgId)
|
personalMessages[0].msgParams.metamaskId = parseInt(msgId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('errors with no from in msgParams', async () => {
|
it('errors with no from in msgParams', async function () {
|
||||||
const msgParams = {
|
const msgParams = {
|
||||||
'data': data,
|
'data': data,
|
||||||
}
|
}
|
||||||
@ -788,23 +770,15 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#setupUntrustedCommunication', function () {
|
describe('#setupUntrustedCommunication', function () {
|
||||||
let streamTest
|
it('sets up phishing stream for untrusted communication ', async function () {
|
||||||
|
|
||||||
const phishingMessageSender = {
|
const phishingMessageSender = {
|
||||||
url: 'http://myethereumwalletntw.com',
|
url: 'http://myethereumwalletntw.com',
|
||||||
tab: {},
|
tab: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
streamTest.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('sets up phishing stream for untrusted communication ', async () => {
|
|
||||||
await metamaskController.phishingController.updatePhishingLists()
|
await metamaskController.phishingController.updatePhishingLists()
|
||||||
|
|
||||||
const { promise, resolve } = deferredPromise()
|
const { promise, resolve } = deferredPromise()
|
||||||
|
const streamTest = createThoughStream((chunk, _, cb) => {
|
||||||
streamTest = createThoughStream((chunk, _, cb) => {
|
|
||||||
if (chunk.name !== 'phishing') {
|
if (chunk.name !== 'phishing') {
|
||||||
return cb()
|
return cb()
|
||||||
}
|
}
|
||||||
@ -812,31 +786,29 @@ describe('MetaMaskController', function () {
|
|||||||
resolve()
|
resolve()
|
||||||
cb()
|
cb()
|
||||||
})
|
})
|
||||||
metamaskController.setupUntrustedCommunication(streamTest, phishingMessageSender)
|
|
||||||
|
|
||||||
|
metamaskController.setupUntrustedCommunication(streamTest, phishingMessageSender)
|
||||||
await promise
|
await promise
|
||||||
|
streamTest.end()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#setupTrustedCommunication', function () {
|
describe('#setupTrustedCommunication', function () {
|
||||||
let streamTest
|
it('sets up controller dnode api for trusted communication', async function () {
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
streamTest.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('sets up controller dnode api for trusted communication', function (done) {
|
|
||||||
const messageSender = {
|
const messageSender = {
|
||||||
url: 'http://mycrypto.com',
|
url: 'http://mycrypto.com',
|
||||||
tab: {},
|
tab: {},
|
||||||
}
|
}
|
||||||
streamTest = createThoughStream((chunk, _, cb) => {
|
const { promise, resolve } = deferredPromise()
|
||||||
|
const streamTest = createThoughStream((chunk, _, cb) => {
|
||||||
assert.equal(chunk.name, 'controller')
|
assert.equal(chunk.name, 'controller')
|
||||||
|
resolve()
|
||||||
cb()
|
cb()
|
||||||
done()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
metamaskController.setupTrustedCommunication(streamTest, messageSender)
|
metamaskController.setupTrustedCommunication(streamTest, messageSender)
|
||||||
|
await promise
|
||||||
|
streamTest.end()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@ import nock from 'nock'
|
|||||||
import NetworkController from '../../../../../app/scripts/controllers/network'
|
import NetworkController from '../../../../../app/scripts/controllers/network'
|
||||||
import { getNetworkDisplayName } from '../../../../../app/scripts/controllers/network/util'
|
import { getNetworkDisplayName } from '../../../../../app/scripts/controllers/network/util'
|
||||||
|
|
||||||
describe('# Network Controller', function () {
|
describe('NetworkController', function () {
|
||||||
|
describe('controller', function () {
|
||||||
let networkController
|
let networkController
|
||||||
const noop = () => {}
|
const noop = () => {}
|
||||||
const networkControllerProviderConfig = {
|
const networkControllerProviderConfig = {
|
||||||
@ -11,14 +12,12 @@ describe('# Network Controller', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
nock('https://rinkeby.infura.io')
|
nock('https://rinkeby.infura.io')
|
||||||
.persist()
|
.persist()
|
||||||
.post('/metamask')
|
.post('/metamask')
|
||||||
.reply(200)
|
.reply(200)
|
||||||
|
|
||||||
networkController = new NetworkController()
|
networkController = new NetworkController()
|
||||||
|
|
||||||
networkController.initializeProvider(networkControllerProviderConfig)
|
networkController.initializeProvider(networkControllerProviderConfig)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -26,7 +25,6 @@ describe('# Network Controller', function () {
|
|||||||
nock.cleanAll()
|
nock.cleanAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('network', function () {
|
|
||||||
describe('#provider', function () {
|
describe('#provider', function () {
|
||||||
it('provider should be updatable without reassignment', function () {
|
it('provider should be updatable without reassignment', function () {
|
||||||
networkController.initializeProvider(networkControllerProviderConfig)
|
networkController.initializeProvider(networkControllerProviderConfig)
|
||||||
@ -64,10 +62,9 @@ describe('# Network Controller', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
describe('Network utils', () => {
|
describe('utils', function () {
|
||||||
it('getNetworkDisplayName should return the correct network name', () => {
|
it('getNetworkDisplayName should return the correct network name', function () {
|
||||||
const tests = [
|
const tests = [
|
||||||
{
|
{
|
||||||
input: 3,
|
input: 3,
|
||||||
@ -99,3 +96,4 @@ describe('Network utils', () => {
|
|||||||
tests.forEach(({ input, expected }) => assert.equal(getNetworkDisplayName(input), expected))
|
tests.forEach(({ input, expected }) => assert.equal(getNetworkDisplayName(input), expected))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
@ -2,22 +2,23 @@ import assert from 'assert'
|
|||||||
import { createPendingNonceMiddleware, createPendingTxMiddleware } from '../../../../../app/scripts/controllers/network/middleware/pending'
|
import { createPendingNonceMiddleware, createPendingTxMiddleware } from '../../../../../app/scripts/controllers/network/middleware/pending'
|
||||||
import { txMetaStub } from './stubs'
|
import { txMetaStub } from './stubs'
|
||||||
|
|
||||||
|
describe('PendingNonceMiddleware', function () {
|
||||||
describe('#createPendingNonceMiddleware', function () {
|
describe('#createPendingNonceMiddleware', function () {
|
||||||
const getPendingNonce = async () => '0x2'
|
const getPendingNonce = async () => '0x2'
|
||||||
const address = '0xF231D46dD78806E1DD93442cf33C7671f8538748'
|
const address = '0xF231D46dD78806E1DD93442cf33C7671f8538748'
|
||||||
const pendingNonceMiddleware = createPendingNonceMiddleware({ getPendingNonce })
|
const pendingNonceMiddleware = createPendingNonceMiddleware({ getPendingNonce })
|
||||||
|
|
||||||
it('should call next if not a eth_getTransactionCount request', (done) => {
|
it('should call next if not a eth_getTransactionCount request', function (done) {
|
||||||
const req = { method: 'eth_getBlockByNumber' }
|
const req = { method: 'eth_getBlockByNumber' }
|
||||||
const res = {}
|
const res = {}
|
||||||
pendingNonceMiddleware(req, res, () => done())
|
pendingNonceMiddleware(req, res, () => done())
|
||||||
})
|
})
|
||||||
it('should call next if not a "pending" block request', (done) => {
|
it('should call next if not a "pending" block request', function (done) {
|
||||||
const req = { method: 'eth_getTransactionCount', params: [address] }
|
const req = { method: 'eth_getTransactionCount', params: [address] }
|
||||||
const res = {}
|
const res = {}
|
||||||
pendingNonceMiddleware(req, res, () => done())
|
pendingNonceMiddleware(req, res, () => done())
|
||||||
})
|
})
|
||||||
it('should fill the result with a the "pending" nonce', (done) => {
|
it('should fill the result with a the "pending" nonce', function (done) {
|
||||||
const req = { method: 'eth_getTransactionCount', params: [address, 'pending'] }
|
const req = { method: 'eth_getTransactionCount', params: [address, 'pending'] }
|
||||||
const res = {}
|
const res = {}
|
||||||
pendingNonceMiddleware(req, res, () => {
|
pendingNonceMiddleware(req, res, () => {
|
||||||
@ -50,37 +51,28 @@ describe('#createPendingTxMiddleware', function () {
|
|||||||
'r': '0x5f973e540f2d3c2f06d3725a626b75247593cb36477187ae07ecfe0a4db3cf57',
|
'r': '0x5f973e540f2d3c2f06d3725a626b75247593cb36477187ae07ecfe0a4db3cf57',
|
||||||
's': '0x0259b52ee8c58baaa385fb05c3f96116e58de89bcc165cb3bfdfc708672fed8a',
|
's': '0x0259b52ee8c58baaa385fb05c3f96116e58de89bcc165cb3bfdfc708672fed8a',
|
||||||
}
|
}
|
||||||
it('should call next if not a eth_getTransactionByHash request', (done) => {
|
it('should call next if not a eth_getTransactionByHash request', function (done) {
|
||||||
const req = { method: 'eth_getBlockByNumber' }
|
const req = { method: 'eth_getBlockByNumber' }
|
||||||
const res = {}
|
const res = {}
|
||||||
pendingTxMiddleware(req, res, () => done())
|
pendingTxMiddleware(req, res, () => done())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call next if no pending txMeta is in history', (done) => {
|
it('should call next if no pending txMeta is in history', function (done) {
|
||||||
const req = { method: 'eth_getTransactionByHash', params: [address] }
|
const req = { method: 'eth_getTransactionByHash', params: [address] }
|
||||||
const res = {}
|
const res = {}
|
||||||
pendingTxMiddleware(req, res, () => done())
|
pendingTxMiddleware(req, res, () => done())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should fill the result with a the "pending" tx the result should match the rpc spec', (done) => {
|
it('should fill the result with a the "pending" tx the result should match the rpc spec', function (done) {
|
||||||
returnUndefined = false
|
returnUndefined = false
|
||||||
const req = { method: 'eth_getTransactionByHash', params: [address, 'pending'] }
|
const req = { method: 'eth_getTransactionByHash', params: [address, 'pending'] }
|
||||||
const res = {}
|
const res = {}
|
||||||
pendingTxMiddleware(req, res, () => {
|
pendingTxMiddleware(req, res, () => {
|
||||||
done(new Error('should not have called next'))
|
done(new Error('should not have called next'))
|
||||||
}, () => {
|
}, () => {
|
||||||
/*
|
|
||||||
// uncomment this section for debugging help with non matching keys
|
|
||||||
const coppy = {...res.result}
|
|
||||||
Object.keys(spec).forEach((key) => {
|
|
||||||
console.log(coppy[key], '===', spec[key], coppy[key] === spec[key], key)
|
|
||||||
delete coppy[key]
|
|
||||||
})
|
|
||||||
console.log(coppy)
|
|
||||||
*/
|
|
||||||
assert.deepStrictEqual(res.result, spec, new Error('result does not match the spec object'))
|
assert.deepStrictEqual(res.result, spec, new Error('result does not match the spec object'))
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -8,7 +8,7 @@ describe('preferences controller', function () {
|
|||||||
let preferencesController
|
let preferencesController
|
||||||
let network
|
let network
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
network = { providerStore: new ObservableStore({ type: 'mainnet' }) }
|
network = { providerStore: new ObservableStore({ type: 'mainnet' }) }
|
||||||
preferencesController = new PreferencesController({ network })
|
preferencesController = new PreferencesController({ network })
|
||||||
})
|
})
|
||||||
@ -346,7 +346,7 @@ describe('preferences controller', function () {
|
|||||||
let stubNext, stubEnd, stubHandleWatchAssetERC20, asy, req, res
|
let stubNext, stubEnd, stubHandleWatchAssetERC20, asy, req, res
|
||||||
const sandbox = sinon.createSandbox()
|
const sandbox = sinon.createSandbox()
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
req = { params: {} }
|
req = { params: {} }
|
||||||
res = {}
|
res = {}
|
||||||
asy = { next: () => {}, end: () => {} }
|
asy = { next: () => {}, end: () => {} }
|
||||||
@ -354,7 +354,7 @@ describe('preferences controller', function () {
|
|||||||
stubEnd = sandbox.stub(asy, 'end').returns(0)
|
stubEnd = sandbox.stub(asy, 'end').returns(0)
|
||||||
stubHandleWatchAssetERC20 = sandbox.stub(preferencesController, '_handleWatchAssetERC20')
|
stubHandleWatchAssetERC20 = sandbox.stub(preferencesController, '_handleWatchAssetERC20')
|
||||||
})
|
})
|
||||||
after(() => {
|
after(function () {
|
||||||
sandbox.restore()
|
sandbox.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -404,10 +404,10 @@ describe('preferences controller', function () {
|
|||||||
let req
|
let req
|
||||||
|
|
||||||
const sandbox = sinon.createSandbox()
|
const sandbox = sinon.createSandbox()
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
req = { params: { type: 'ERC20' } }
|
req = { params: { type: 'ERC20' } }
|
||||||
})
|
})
|
||||||
after(() => {
|
after(function () {
|
||||||
sandbox.restore()
|
sandbox.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -514,7 +514,7 @@ describe('preferences controller', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#updateRpc', function () {
|
describe('#updateRpc', function () {
|
||||||
it('should update the rpcDetails properly', () => {
|
it('should update the rpcDetails properly', function () {
|
||||||
preferencesController.store.updateState({ frequentRpcListDetail: [{}, { rpcUrl: 'test' }, {}] })
|
preferencesController.store.updateState({ frequentRpcListDetail: [{}, { rpcUrl: 'test' }, {}] })
|
||||||
preferencesController.updateRpc({ rpcUrl: 'test', chainId: 1 })
|
preferencesController.updateRpc({ rpcUrl: 'test', chainId: 1 })
|
||||||
preferencesController.updateRpc({ rpcUrl: 'test/1', chainId: 1 })
|
preferencesController.updateRpc({ rpcUrl: 'test/1', chainId: 1 })
|
||||||
|
@ -3,15 +3,15 @@ import sinon from 'sinon'
|
|||||||
import TokenRatesController from '../../../../app/scripts/controllers/token-rates'
|
import TokenRatesController from '../../../../app/scripts/controllers/token-rates'
|
||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
|
|
||||||
describe('TokenRatesController', () => {
|
describe('TokenRatesController', function () {
|
||||||
it('should listen for preferences store updates', () => {
|
it('should listen for preferences store updates', function () {
|
||||||
const preferences = new ObservableStore({ tokens: [] })
|
const preferences = new ObservableStore({ tokens: [] })
|
||||||
const controller = new TokenRatesController({ preferences })
|
const controller = new TokenRatesController({ preferences })
|
||||||
preferences.putState({ tokens: ['foo'] })
|
preferences.putState({ tokens: ['foo'] })
|
||||||
assert.deepEqual(controller._tokens, ['foo'])
|
assert.deepEqual(controller._tokens, ['foo'])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should poll on correct interval', async () => {
|
it('should poll on correct interval', async function () {
|
||||||
const stub = sinon.stub(global, 'setInterval')
|
const stub = sinon.stub(global, 'setInterval')
|
||||||
new TokenRatesController({ interval: 1337 }) // eslint-disable-line no-new
|
new TokenRatesController({ interval: 1337 }) // eslint-disable-line no-new
|
||||||
assert.strictEqual(stub.getCall(0).args[1], 1337)
|
assert.strictEqual(stub.getCall(0).args[1], 1337)
|
||||||
|
@ -56,17 +56,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('_checkPendingTx state management', function () {
|
describe('_checkPendingTx state management', function () {
|
||||||
let stub
|
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
if (stub) {
|
|
||||||
stub.restore()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should emit dropped if another tx with the same nonce succeeds', async function () {
|
it('should emit dropped if another tx with the same nonce succeeds', async function () {
|
||||||
|
|
||||||
// SETUP
|
|
||||||
const txGen = new MockTxGen()
|
const txGen = new MockTxGen()
|
||||||
|
|
||||||
txGen.generate({
|
txGen.generate({
|
||||||
@ -83,21 +73,19 @@ describe('PendingTransactionTracker', function () {
|
|||||||
status: 'submitted',
|
status: 'submitted',
|
||||||
}, { count: 1, fromNonce: '0x01' })[0]
|
}, { count: 1, fromNonce: '0x01' })[0]
|
||||||
|
|
||||||
stub = sinon.stub(pendingTxTracker, 'getCompletedTransactions')
|
const stub = sinon.stub(pendingTxTracker, 'getCompletedTransactions')
|
||||||
.returns(txGen.txs)
|
.returns(txGen.txs)
|
||||||
|
|
||||||
// THE EXPECTATION
|
|
||||||
const spy = sinon.spy()
|
const spy = sinon.spy()
|
||||||
pendingTxTracker.on('tx:dropped', (txId) => {
|
pendingTxTracker.on('tx:dropped', (txId) => {
|
||||||
assert.equal(txId, pending.id, 'should fail the pending tx')
|
assert.equal(txId, pending.id, 'should fail the pending tx')
|
||||||
spy(txId)
|
spy(txId)
|
||||||
})
|
})
|
||||||
|
|
||||||
// THE METHOD
|
|
||||||
await pendingTxTracker._checkPendingTx(pending)
|
await pendingTxTracker._checkPendingTx(pending)
|
||||||
|
|
||||||
// THE ASSERTION
|
|
||||||
assert.ok(spy.calledWith(pending.id), 'tx dropped should be emitted')
|
assert.ok(spy.calledWith(pending.id), 'tx dropped should be emitted')
|
||||||
|
stub.restore()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -161,7 +149,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#_checkPendingTxs', function () {
|
describe('#_checkPendingTxs', function () {
|
||||||
beforeEach(function () {
|
it('should warp all txMeta\'s in #updatePendingTxs', function (done) {
|
||||||
const txMeta2 = txMeta3 = txMeta
|
const txMeta2 = txMeta3 = txMeta
|
||||||
txMeta2.id = 2
|
txMeta2.id = 2
|
||||||
txMeta3.id = 3
|
txMeta3.id = 3
|
||||||
@ -171,9 +159,6 @@ describe('PendingTransactionTracker', function () {
|
|||||||
})
|
})
|
||||||
return tx
|
return tx
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
it('should warp all txMeta\'s in #updatePendingTxs', function (done) {
|
|
||||||
pendingTxTracker.getPendingTransactions = () => txList
|
pendingTxTracker.getPendingTransactions = () => txList
|
||||||
pendingTxTracker._checkPendingTx = (tx) => {
|
pendingTxTracker._checkPendingTx = (tx) => {
|
||||||
tx.resolve(tx)
|
tx.resolve(tx)
|
||||||
@ -263,7 +248,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
const mockFirstRetryBlockNumber = '0x1'
|
const mockFirstRetryBlockNumber = '0x1'
|
||||||
let txMetaToTestExponentialBackoff, enoughBalance
|
let txMetaToTestExponentialBackoff, enoughBalance
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
pendingTxTracker.getBalance = (address) => {
|
pendingTxTracker.getBalance = (address) => {
|
||||||
assert.equal(address, txMeta.txParams.from, 'Should pass the address')
|
assert.equal(address, txMeta.txParams.from, 'Should pass the address')
|
||||||
return enoughBalance
|
return enoughBalance
|
||||||
@ -280,7 +265,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
pendingTxTracker.publishTransaction.restore()
|
pendingTxTracker.publishTransaction.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -327,7 +312,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
assert.equal(pendingTxTracker.publishTransaction.callCount, 1, 'Should call publish transaction')
|
assert.equal(pendingTxTracker.publishTransaction.callCount, 1, 'Should call publish transaction')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call opts.approveTransaction with the id if the tx is not signed', async () => {
|
it('should call opts.approveTransaction with the id if the tx is not signed', async function () {
|
||||||
const stubTx = {
|
const stubTx = {
|
||||||
id: 40,
|
id: 40,
|
||||||
}
|
}
|
||||||
@ -340,7 +325,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#_checkIftxWasDropped', () => {
|
describe('#_checkIftxWasDropped', function () {
|
||||||
const txMeta = {
|
const txMeta = {
|
||||||
id: 1,
|
id: 1,
|
||||||
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
@ -352,7 +337,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
},
|
},
|
||||||
rawTx: '0xf86c808504a817c800827b0d940c62bb85faa3311a998d3aba8098c1235c564966880de0b6b3a7640000802aa08ff665feb887a25d4099e40e11f0fef93ee9608f404bd3f853dd9e84ed3317a6a02ec9d3d1d6e176d4d2593dd760e74ccac753e6a0ea0d00cc9789d0d7ff1f471d',
|
rawTx: '0xf86c808504a817c800827b0d940c62bb85faa3311a998d3aba8098c1235c564966880de0b6b3a7640000802aa08ff665feb887a25d4099e40e11f0fef93ee9608f404bd3f853dd9e84ed3317a6a02ec9d3d1d6e176d4d2593dd760e74ccac753e6a0ea0d00cc9789d0d7ff1f471d',
|
||||||
}
|
}
|
||||||
it('should return false when the nonce is the suggested network nonce', (done) => {
|
it('should return false when the nonce is the suggested network nonce', function (done) {
|
||||||
providerResultStub['eth_getTransactionCount'] = '0x01'
|
providerResultStub['eth_getTransactionCount'] = '0x01'
|
||||||
providerResultStub['eth_getTransactionReceipt'] = {}
|
providerResultStub['eth_getTransactionReceipt'] = {}
|
||||||
pendingTxTracker._checkIftxWasDropped(txMeta, {}).then((dropped) => {
|
pendingTxTracker._checkIftxWasDropped(txMeta, {}).then((dropped) => {
|
||||||
|
@ -4,7 +4,7 @@ import { ROPSTEN_CODE, RINKEBY_CODE, KOVAN_CODE, GOERLI_CODE } from '../../../..
|
|||||||
import KeyringController from 'eth-keyring-controller'
|
import KeyringController from 'eth-keyring-controller'
|
||||||
|
|
||||||
describe('Recipient Blacklist Checker', function () {
|
describe('Recipient Blacklist Checker', function () {
|
||||||
|
describe('#checkAccount', function () {
|
||||||
let publicAccounts
|
let publicAccounts
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
@ -19,7 +19,6 @@ describe('Recipient Blacklist Checker', function () {
|
|||||||
publicAccounts = await keyring.getAccounts()
|
publicAccounts = await keyring.getAccounts()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#checkAccount', function () {
|
|
||||||
it('does not fail on test networks', function () {
|
it('does not fail on test networks', function () {
|
||||||
let callCount = 0
|
let callCount = 0
|
||||||
const networks = [ROPSTEN_CODE, RINKEBY_CODE, KOVAN_CODE, GOERLI_CODE]
|
const networks = [ROPSTEN_CODE, RINKEBY_CODE, KOVAN_CODE, GOERLI_CODE]
|
||||||
|
@ -87,9 +87,8 @@ describe('Transaction Controller', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#getConfirmedTransactions', function () {
|
describe('#getConfirmedTransactions', function () {
|
||||||
let address
|
it('should return the number of confirmed txs', function () {
|
||||||
beforeEach(function () {
|
const address = '0xc684832530fcbddae4b4230a47e991ddcec2831d'
|
||||||
address = '0xc684832530fcbddae4b4230a47e991ddcec2831d'
|
|
||||||
const txParams = {
|
const txParams = {
|
||||||
'from': address,
|
'from': address,
|
||||||
'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||||
@ -105,9 +104,6 @@ describe('Transaction Controller', function () {
|
|||||||
{ id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [{}] },
|
{ id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [{}] },
|
||||||
{ id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] },
|
{ id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams, history: [{}] },
|
||||||
])
|
])
|
||||||
})
|
|
||||||
|
|
||||||
it('should return the number of confirmed txs', function () {
|
|
||||||
assert.equal(txController.nonceTracker.getConfirmedTransactions(address).length, 3)
|
assert.equal(txController.nonceTracker.getConfirmedTransactions(address).length, 3)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -132,12 +128,12 @@ describe('Transaction Controller', function () {
|
|||||||
txController.emit('newUnapprovedTx', txMeta)
|
txController.emit('newUnapprovedTx', txMeta)
|
||||||
return Promise.resolve(txController.txStateManager.addTx(txMeta))
|
return Promise.resolve(txController.txStateManager.addTx(txMeta))
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
txController.txStateManager._saveTxList([])
|
txController.txStateManager._saveTxList([])
|
||||||
stub.restore()
|
stub.restore()
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
it('should resolve when finished and status is submitted and resolve with the hash', function (done) {
|
it('should resolve when finished and status is submitted and resolve with the hash', function (done) {
|
||||||
txController.once('newUnapprovedTx', (txMetaFromEmit) => {
|
txController.once('newUnapprovedTx', (txMetaFromEmit) => {
|
||||||
@ -226,11 +222,11 @@ describe('Transaction Controller', function () {
|
|||||||
|
|
||||||
it('should fail if the from address isn\'t the selected address', function (done) {
|
it('should fail if the from address isn\'t the selected address', function (done) {
|
||||||
txController.addUnapprovedTransaction({ from: '0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2' })
|
txController.addUnapprovedTransaction({ from: '0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2' })
|
||||||
.then(function () {
|
.then(() => {
|
||||||
assert.fail('transaction should not have been added')
|
assert.fail('transaction should not have been added')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
.catch(function () {
|
.catch(() => {
|
||||||
assert.ok('pass')
|
assert.ok('pass')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
@ -259,7 +255,7 @@ describe('Transaction Controller', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#addTxGasDefaults', function () {
|
describe('#addTxGasDefaults', function () {
|
||||||
it('should add the tx defaults if their are none', async () => {
|
it('should add the tx defaults if their are none', async function () {
|
||||||
const txMeta = {
|
const txMeta = {
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||||
@ -307,11 +303,9 @@ describe('Transaction Controller', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#approveTransaction', function () {
|
describe('#approveTransaction', function () {
|
||||||
let txMeta, originalValue
|
it('does not overwrite set values', function (done) {
|
||||||
|
const originalValue = '0x01'
|
||||||
beforeEach(function () {
|
const txMeta = {
|
||||||
originalValue = '0x01'
|
|
||||||
txMeta = {
|
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
@ -321,10 +315,6 @@ describe('Transaction Controller', function () {
|
|||||||
gasPrice: originalValue,
|
gasPrice: originalValue,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
it('does not overwrite set values', function (done) {
|
|
||||||
this.timeout(15000)
|
this.timeout(15000)
|
||||||
const wrongValue = '0x05'
|
const wrongValue = '0x05'
|
||||||
|
|
||||||
@ -366,9 +356,8 @@ describe('Transaction Controller', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#updateAndApproveTransaction', function () {
|
describe('#updateAndApproveTransaction', function () {
|
||||||
let txMeta
|
it('should update and approve transactions', async function () {
|
||||||
beforeEach(() => {
|
const txMeta = {
|
||||||
txMeta = {
|
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
txParams: {
|
txParams: {
|
||||||
@ -380,8 +369,6 @@ describe('Transaction Controller', function () {
|
|||||||
},
|
},
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
}
|
}
|
||||||
})
|
|
||||||
it('should update and approve transactions', async () => {
|
|
||||||
txController.txStateManager.addTx(txMeta)
|
txController.txStateManager.addTx(txMeta)
|
||||||
const approvalPromise = txController.updateAndApproveTransaction(txMeta)
|
const approvalPromise = txController.updateAndApproveTransaction(txMeta)
|
||||||
const tx = txController.txStateManager.getTx(1)
|
const tx = txController.txStateManager.getTx(1)
|
||||||
@ -398,7 +385,7 @@ describe('Transaction Controller', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#cancelTransaction', function () {
|
describe('#cancelTransaction', function () {
|
||||||
beforeEach(function () {
|
it('should emit a status change to rejected', function (done) {
|
||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{ id: 0, status: 'unapproved', txParams: {}, metamaskNetworkId: currentNetworkId, history: [{}] },
|
{ id: 0, status: 'unapproved', txParams: {}, metamaskNetworkId: currentNetworkId, history: [{}] },
|
||||||
{ id: 1, status: 'rejected', txParams: {}, metamaskNetworkId: currentNetworkId, history: [{}] },
|
{ id: 1, status: 'rejected', txParams: {}, metamaskNetworkId: currentNetworkId, history: [{}] },
|
||||||
@ -408,9 +395,7 @@ describe('Transaction Controller', function () {
|
|||||||
{ id: 5, status: 'confirmed', txParams: {}, metamaskNetworkId: currentNetworkId, history: [{}] },
|
{ id: 5, status: 'confirmed', txParams: {}, metamaskNetworkId: currentNetworkId, history: [{}] },
|
||||||
{ id: 6, status: 'failed', txParams: {}, metamaskNetworkId: currentNetworkId, history: [{}] },
|
{ id: 6, status: 'failed', txParams: {}, metamaskNetworkId: currentNetworkId, history: [{}] },
|
||||||
])
|
])
|
||||||
})
|
|
||||||
|
|
||||||
it('should emit a status change to rejected', function (done) {
|
|
||||||
txController.once('tx:status-update', (txId, status) => {
|
txController.once('tx:status-update', (txId, status) => {
|
||||||
try {
|
try {
|
||||||
assert.equal(status, 'rejected', 'status should e rejected')
|
assert.equal(status, 'rejected', 'status should e rejected')
|
||||||
@ -426,13 +411,13 @@ describe('Transaction Controller', function () {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#createSpeedUpTransaction', () => {
|
describe('#createSpeedUpTransaction', function () {
|
||||||
let addTxSpy
|
let addTxSpy
|
||||||
let approveTransactionSpy
|
let approveTransactionSpy
|
||||||
let txParams
|
let txParams
|
||||||
let expectedTxParams
|
let expectedTxParams
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
addTxSpy = sinon.spy(txController, 'addTx')
|
addTxSpy = sinon.spy(txController, 'addTx')
|
||||||
approveTransactionSpy = sinon.spy(txController, 'approveTransaction')
|
approveTransactionSpy = sinon.spy(txController, 'approveTransaction')
|
||||||
|
|
||||||
@ -450,12 +435,12 @@ describe('Transaction Controller', function () {
|
|||||||
expectedTxParams = Object.assign({}, txParams, { gasPrice: '0xb' })
|
expectedTxParams = Object.assign({}, txParams, { gasPrice: '0xb' })
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
addTxSpy.restore()
|
addTxSpy.restore()
|
||||||
approveTransactionSpy.restore()
|
approveTransactionSpy.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call this.addTx and this.approveTransaction with the expected args', async () => {
|
it('should call this.addTx and this.approveTransaction with the expected args', async function () {
|
||||||
await txController.createSpeedUpTransaction(1)
|
await txController.createSpeedUpTransaction(1)
|
||||||
assert.equal(addTxSpy.callCount, 1)
|
assert.equal(addTxSpy.callCount, 1)
|
||||||
|
|
||||||
@ -469,7 +454,7 @@ describe('Transaction Controller', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call this.approveTransaction with the id of the returned tx', async () => {
|
it('should call this.approveTransaction with the id of the returned tx', async function () {
|
||||||
const result = await txController.createSpeedUpTransaction(1)
|
const result = await txController.createSpeedUpTransaction(1)
|
||||||
assert.equal(approveTransactionSpy.callCount, 1)
|
assert.equal(approveTransactionSpy.callCount, 1)
|
||||||
|
|
||||||
@ -477,7 +462,7 @@ describe('Transaction Controller', function () {
|
|||||||
assert.equal(result.id, approveTransactionArg)
|
assert.equal(result.id, approveTransactionArg)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return the expected txMeta', async () => {
|
it('should return the expected txMeta', async function () {
|
||||||
const result = await txController.createSpeedUpTransaction(1)
|
const result = await txController.createSpeedUpTransaction(1)
|
||||||
|
|
||||||
assert.deepEqual(result.txParams, expectedTxParams)
|
assert.deepEqual(result.txParams, expectedTxParams)
|
||||||
@ -686,7 +671,7 @@ describe('Transaction Controller', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('#getPendingTransactions', function () {
|
describe('#getPendingTransactions', function () {
|
||||||
beforeEach(function () {
|
it('should show only submitted and approved transactions as pending transasction', function () {
|
||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{ id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
|
{ id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
|
||||||
{ id: 2, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] },
|
{ id: 2, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] },
|
||||||
@ -696,8 +681,7 @@ describe('Transaction Controller', function () {
|
|||||||
{ id: 6, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] },
|
{ id: 6, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] },
|
||||||
{ id: 7, status: 'failed', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] },
|
{ id: 7, status: 'failed', metamaskNetworkId: currentNetworkId, txParams: {}, history: [{}] },
|
||||||
])
|
])
|
||||||
})
|
|
||||||
it('should show only submitted and approved transactions as pending transasction', function () {
|
|
||||||
assert(txController.pendingTxTracker.getPendingTransactions().length, 2)
|
assert(txController.pendingTxTracker.getPendingTransactions().length, 2)
|
||||||
const states = txController.pendingTxTracker.getPendingTransactions().map(tx => tx.status)
|
const states = txController.pendingTxTracker.getPendingTransactions().map(tx => tx.status)
|
||||||
assert(states.includes('approved'), 'includes approved')
|
assert(states.includes('approved'), 'includes approved')
|
||||||
|
@ -30,7 +30,7 @@ describe('TransactionStateManager', function () {
|
|||||||
assert.equal(result[0].status, 'signed')
|
assert.equal(result[0].status, 'signed')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should emit a signed event to signal the exciton of callback', (done) => {
|
it('should emit a signed event to signal the exciton of callback', function (done) {
|
||||||
const tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }
|
const tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }
|
||||||
const noop = function () {
|
const noop = function () {
|
||||||
assert(true, 'event listener has been triggered and noop executed')
|
assert(true, 'event listener has been triggered and noop executed')
|
||||||
@ -53,7 +53,7 @@ describe('TransactionStateManager', function () {
|
|||||||
assert.equal(result.length, 0)
|
assert.equal(result.length, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should emit a rejected event to signal the exciton of callback', (done) => {
|
it('should emit a rejected event to signal the exciton of callback', function (done) {
|
||||||
const tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }
|
const tx = { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }
|
||||||
txStateManager.addTx(tx)
|
txStateManager.addTx(tx)
|
||||||
const noop = () => {
|
const noop = () => {
|
||||||
@ -303,7 +303,6 @@ describe('TransactionStateManager', function () {
|
|||||||
assert.equal(txStateManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
assert.equal(txStateManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
||||||
filterParams = { status: (status) => status !== 'confirmed' }
|
filterParams = { status: (status) => status !== 'confirmed' }
|
||||||
assert.equal(txStateManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
assert.equal(txStateManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -346,18 +345,17 @@ describe('TransactionStateManager', function () {
|
|||||||
|
|
||||||
assert.equal(txsFromCurrentNetworkAndAddress.length, 0)
|
assert.equal(txsFromCurrentNetworkAndAddress.length, 0)
|
||||||
assert.equal(txFromOtherNetworks.length, 2)
|
assert.equal(txFromOtherNetworks.length, 2)
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#_removeTx', function () {
|
describe('#_removeTx', function () {
|
||||||
it('should remove the transaction from the storage', () => {
|
it('should remove the transaction from the storage', function () {
|
||||||
txStateManager._saveTxList([ { id: 1 } ])
|
txStateManager._saveTxList([ { id: 1 } ])
|
||||||
txStateManager._removeTx(1)
|
txStateManager._removeTx(1)
|
||||||
assert(!txStateManager.getFullTxList().length, 'txList should be empty')
|
assert(!txStateManager.getFullTxList().length, 'txList should be empty')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should only remove the transaction with ID 1 from the storage', () => {
|
it('should only remove the transaction with ID 1 from the storage', function () {
|
||||||
txStateManager._saveTxList([ { id: 1 }, { id: 2 } ])
|
txStateManager._saveTxList([ { id: 1 }, { id: 2 } ])
|
||||||
txStateManager._removeTx(1)
|
txStateManager._removeTx(1)
|
||||||
assert.equal(txStateManager.getFullTxList()[0].id, 2, 'txList should have a id of 2')
|
assert.equal(txStateManager.getFullTxList()[0].id, 2, 'txList should have a id of 2')
|
||||||
|
@ -25,8 +25,8 @@ describe('txUtils', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#normalizeTxParams', () => {
|
describe('#normalizeTxParams', function () {
|
||||||
it('should normalize txParams', () => {
|
it('should normalize txParams', function () {
|
||||||
const txParams = {
|
const txParams = {
|
||||||
chainId: '0x1',
|
chainId: '0x1',
|
||||||
from: 'a7df1beDBF813f57096dF77FCd515f0B3900e402',
|
from: 'a7df1beDBF813f57096dF77FCd515f0B3900e402',
|
||||||
@ -50,7 +50,7 @@ describe('txUtils', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#validateRecipient', () => {
|
describe('#validateRecipient', function () {
|
||||||
it('removes recipient for txParams with 0x when contract data is provided', function () {
|
it('removes recipient for txParams with 0x when contract data is provided', function () {
|
||||||
const zeroRecipientandDataTxParams = {
|
const zeroRecipientandDataTxParams = {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
@ -73,7 +73,7 @@ describe('txUtils', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
describe('#validateFrom', () => {
|
describe('#validateFrom', function () {
|
||||||
it('should error when from is not a hex string', function () {
|
it('should error when from is not a hex string', function () {
|
||||||
|
|
||||||
// where from is undefined
|
// where from is undefined
|
||||||
|
@ -3,8 +3,8 @@ import nock from 'nock'
|
|||||||
|
|
||||||
import fetchWithTimeout from '../../../app/scripts/lib/fetch-with-timeout'
|
import fetchWithTimeout from '../../../app/scripts/lib/fetch-with-timeout'
|
||||||
|
|
||||||
describe('fetchWithTimeout', () => {
|
describe('fetchWithTimeout', function () {
|
||||||
it('fetches a url', async () => {
|
it('fetches a url', async function () {
|
||||||
nock('https://api.infura.io')
|
nock('https://api.infura.io')
|
||||||
.get('/money')
|
.get('/money')
|
||||||
.reply(200, '{"hodl": false}')
|
.reply(200, '{"hodl": false}')
|
||||||
@ -16,7 +16,7 @@ describe('fetchWithTimeout', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws when the request hits a custom timeout', async () => {
|
it('throws when the request hits a custom timeout', async function () {
|
||||||
nock('https://api.infura.io')
|
nock('https://api.infura.io')
|
||||||
.get('/moon')
|
.get('/moon')
|
||||||
.delay(2000)
|
.delay(2000)
|
||||||
@ -34,7 +34,7 @@ describe('fetchWithTimeout', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should abort the request when the custom timeout is hit', async () => {
|
it('should abort the request when the custom timeout is hit', async function () {
|
||||||
nock('https://api.infura.io')
|
nock('https://api.infura.io')
|
||||||
.get('/moon')
|
.get('/moon')
|
||||||
.delay(2000)
|
.delay(2000)
|
||||||
|
@ -12,7 +12,7 @@ describe('nodeify', function () {
|
|||||||
|
|
||||||
it('should retain original context', function (done) {
|
it('should retain original context', function (done) {
|
||||||
const nodified = nodeify(obj.promiseFunc, obj)
|
const nodified = nodeify(obj.promiseFunc, obj)
|
||||||
nodified('baz', function (err, res) {
|
nodified('baz', (err, res) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
assert.equal(res, 'barbaz')
|
assert.equal(res, 'barbaz')
|
||||||
done()
|
done()
|
||||||
@ -36,7 +36,7 @@ describe('nodeify', function () {
|
|||||||
const nodified = nodeify(async () => {
|
const nodified = nodeify(async () => {
|
||||||
throw new Error('boom!')
|
throw new Error('boom!')
|
||||||
}, obj)
|
}, obj)
|
||||||
process.prependOnceListener('uncaughtException', function (err) {
|
process.prependOnceListener('uncaughtException', (err) => {
|
||||||
assert.ok(err, 'got expected error')
|
assert.ok(err, 'got expected error')
|
||||||
assert.ok(err.message.includes('boom!'), 'got expected error message')
|
assert.ok(err.message.includes('boom!'), 'got expected error message')
|
||||||
done()
|
done()
|
||||||
|
@ -45,19 +45,15 @@ describe('PendingBalanceCalculator', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('if you have no pending txs and one ether', function () {
|
describe('if you have no pending txs and one ether', function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
balanceCalculator = generateBalanceCalcWith([], etherBn)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns the network balance', async function () {
|
it('returns the network balance', async function () {
|
||||||
|
balanceCalculator = generateBalanceCalcWith([], etherBn)
|
||||||
const result = await balanceCalculator.getBalance()
|
const result = await balanceCalculator.getBalance()
|
||||||
assert.equal(result, ether, `gave ${result} needed ${ether}`)
|
assert.equal(result, ether, `gave ${result} needed ${ether}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('if you have a one ether pending tx and one ether', function () {
|
describe('if you have a one ether pending tx and one ether', function () {
|
||||||
beforeEach(function () {
|
it('returns the subtracted result', async function () {
|
||||||
const txGen = new MockTxGen()
|
const txGen = new MockTxGen()
|
||||||
pendingTxs = txGen.generate({
|
pendingTxs = txGen.generate({
|
||||||
status: 'submitted',
|
status: 'submitted',
|
||||||
@ -69,14 +65,11 @@ describe('PendingBalanceCalculator', function () {
|
|||||||
}, { count: 1 })
|
}, { count: 1 })
|
||||||
|
|
||||||
balanceCalculator = generateBalanceCalcWith(pendingTxs, etherBn)
|
balanceCalculator = generateBalanceCalcWith(pendingTxs, etherBn)
|
||||||
})
|
|
||||||
|
|
||||||
it('returns the subtracted result', async function () {
|
|
||||||
const result = await balanceCalculator.getBalance()
|
const result = await balanceCalculator.getBalance()
|
||||||
assert.equal(result, '0x0', `gave ${result} needed '0x0'`)
|
assert.equal(result, '0x0', `gave ${result} needed '0x0'`)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -3,14 +3,14 @@ import sinon from 'sinon'
|
|||||||
import NetworkController from '../../../app/scripts/controllers/network/index'
|
import NetworkController from '../../../app/scripts/controllers/network/index'
|
||||||
import TypedMessageManager from '../../../app/scripts/lib/typed-message-manager'
|
import TypedMessageManager from '../../../app/scripts/lib/typed-message-manager'
|
||||||
|
|
||||||
describe('Typed Message Manager', () => {
|
describe('Typed Message Manager', function () {
|
||||||
let typedMessageManager, msgParamsV1, msgParamsV3, typedMsgs, messages, msgId, numberMsgId
|
let typedMessageManager, msgParamsV1, msgParamsV3, typedMsgs, messages, msgId, numberMsgId
|
||||||
|
|
||||||
const address = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
|
const address = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
|
||||||
const networkController = new NetworkController()
|
const networkController = new NetworkController()
|
||||||
sinon.stub(networkController, 'getNetworkState').returns('1')
|
sinon.stub(networkController, 'getNetworkState').returns('1')
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
typedMessageManager = new TypedMessageManager({
|
typedMessageManager = new TypedMessageManager({
|
||||||
networkController,
|
networkController,
|
||||||
})
|
})
|
||||||
@ -72,7 +72,7 @@ describe('Typed Message Manager', () => {
|
|||||||
numberMsgId = parseInt(msgId)
|
numberMsgId = parseInt(msgId)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports version 1 of signedTypedData', () => {
|
it('supports version 1 of signedTypedData', function () {
|
||||||
typedMessageManager.addUnapprovedMessage(msgParamsV1, null, 'V1')
|
typedMessageManager.addUnapprovedMessage(msgParamsV1, null, 'V1')
|
||||||
assert.equal(messages[messages.length - 1].msgParams.data, msgParamsV1.data)
|
assert.equal(messages[messages.length - 1].msgParams.data, msgParamsV1.data)
|
||||||
})
|
})
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
ENVIRONMENT_TYPE_BACKGROUND,
|
ENVIRONMENT_TYPE_BACKGROUND,
|
||||||
} from '../../../app/scripts/lib/enums'
|
} from '../../../app/scripts/lib/enums'
|
||||||
|
|
||||||
|
describe('app utils', function () {
|
||||||
describe('getEnvironmentType', function () {
|
describe('getEnvironmentType', function () {
|
||||||
it('should return popup type', function () {
|
it('should return popup type', function () {
|
||||||
const environmentType = getEnvironmentType('http://extension-id/popup.html')
|
const environmentType = getEnvironmentType('http://extension-id/popup.html')
|
||||||
@ -87,3 +88,4 @@ describe('SufficientBalance', function () {
|
|||||||
assert.ok(!result, 'insufficient balance found.')
|
assert.ok(!result, 'insufficient balance found.')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
@ -2,8 +2,8 @@ import assert from 'assert'
|
|||||||
import wallet2 from '../../lib/migrations/002.json'
|
import wallet2 from '../../lib/migrations/002.json'
|
||||||
import migration21 from '../../../app/scripts/migrations/021'
|
import migration21 from '../../../app/scripts/migrations/021'
|
||||||
|
|
||||||
describe('wallet2 is migrated successfully with out the BlacklistController', () => {
|
describe('wallet2 is migrated successfully with out the BlacklistController', function () {
|
||||||
it('should delete BlacklistController key', (done) => {
|
it('should delete BlacklistController key', function (done) {
|
||||||
migration21.migrate(wallet2)
|
migration21.migrate(wallet2)
|
||||||
.then((migratedData) => {
|
.then((migratedData) => {
|
||||||
assert.equal(migratedData.meta.version, 21)
|
assert.equal(migratedData.meta.version, 21)
|
||||||
|
@ -15,8 +15,8 @@ const storage = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => {
|
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', function () {
|
||||||
it('should add submittedTime key on the txMeta if appropriate', (done) => {
|
it('should add submittedTime key on the txMeta if appropriate', function (done) {
|
||||||
migration22.migrate(storage)
|
migration22.migrate(storage)
|
||||||
.then((migratedData) => {
|
.then((migratedData) => {
|
||||||
const [txMeta1, txMeta2, txMeta3] = migratedData.data.TransactionController.transactions
|
const [txMeta1, txMeta2, txMeta3] = migratedData.data.TransactionController.transactions
|
||||||
|
@ -57,8 +57,8 @@ while (transactions20.length < 20) {
|
|||||||
|
|
||||||
storage.data.TransactionController.transactions = transactions
|
storage.data.TransactionController.transactions = transactions
|
||||||
|
|
||||||
describe('storage is migrated successfully and the proper transactions are remove from state', () => {
|
describe('storage is migrated successfully and the proper transactions are remove from state', function () {
|
||||||
it('should remove transactions that are unneeded', (done) => {
|
it('should remove transactions that are unneeded', function (done) {
|
||||||
migration23.migrate(storage)
|
migration23.migrate(storage)
|
||||||
.then((migratedData) => {
|
.then((migratedData) => {
|
||||||
let leftoverNonDeletableTxCount = 0
|
let leftoverNonDeletableTxCount = 0
|
||||||
@ -74,7 +74,7 @@ describe('storage is migrated successfully and the proper transactions are remov
|
|||||||
}).catch(done)
|
}).catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not remove any transactions because 40 is the expectable limit', (done) => {
|
it('should not remove any transactions because 40 is the expectable limit', function (done) {
|
||||||
storage.meta.version = 22
|
storage.meta.version = 22
|
||||||
storage.data.TransactionController.transactions = transactions40
|
storage.data.TransactionController.transactions = transactions40
|
||||||
migration23.migrate(storage)
|
migration23.migrate(storage)
|
||||||
@ -86,7 +86,7 @@ describe('storage is migrated successfully and the proper transactions are remov
|
|||||||
}).catch(done)
|
}).catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not remove any transactions because 20 txs is under the expectable limit', (done) => {
|
it('should not remove any transactions because 20 txs is under the expectable limit', function (done) {
|
||||||
storage.meta.version = 22
|
storage.meta.version = 22
|
||||||
storage.data.TransactionController.transactions = transactions20
|
storage.data.TransactionController.transactions = transactions20
|
||||||
migration23.migrate(storage)
|
migration23.migrate(storage)
|
||||||
|
@ -27,8 +27,8 @@ while (transactions.length <= 10) {
|
|||||||
|
|
||||||
storage.data.TransactionController.transactions = transactions
|
storage.data.TransactionController.transactions = transactions
|
||||||
|
|
||||||
describe('storage is migrated successfully and the txParams.from are lowercase', () => {
|
describe('storage is migrated successfully and the txParams.from are lowercase', function () {
|
||||||
it('should lowercase the from for unapproved txs', (done) => {
|
it('should lowercase the from for unapproved txs', function (done) {
|
||||||
migration24.migrate(storage)
|
migration24.migrate(storage)
|
||||||
.then((migratedData) => {
|
.then((migratedData) => {
|
||||||
const migratedTransactions = migratedData.data.TransactionController.transactions
|
const migratedTransactions = migratedData.data.TransactionController.transactions
|
||||||
@ -43,7 +43,7 @@ describe('storage is migrated successfully and the txParams.from are lowercase',
|
|||||||
}).catch(done)
|
}).catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should migrate first time state', (done) => {
|
it('should migrate first time state', function (done) {
|
||||||
migration24.migrate(firstTimeState)
|
migration24.migrate(firstTimeState)
|
||||||
.then((migratedData) => {
|
.then((migratedData) => {
|
||||||
assert.equal(migratedData.meta.version, 24)
|
assert.equal(migratedData.meta.version, 24)
|
||||||
|
@ -28,8 +28,8 @@ while (transactions.length <= 10) {
|
|||||||
|
|
||||||
storage.data.TransactionController.transactions = transactions
|
storage.data.TransactionController.transactions = transactions
|
||||||
|
|
||||||
describe('storage is migrated successfully and the txParams.from are lowercase', () => {
|
describe('storage is migrated successfully and the txParams.from are lowercase', function () {
|
||||||
it('should lowercase the from for unapproved txs', (done) => {
|
it('should lowercase the from for unapproved txs', function (done) {
|
||||||
migration25.migrate(storage)
|
migration25.migrate(storage)
|
||||||
.then((migratedData) => {
|
.then((migratedData) => {
|
||||||
const migratedTransactions = migratedData.data.TransactionController.transactions
|
const migratedTransactions = migratedData.data.TransactionController.transactions
|
||||||
@ -45,7 +45,7 @@ describe('storage is migrated successfully and the txParams.from are lowercase',
|
|||||||
}).catch(done)
|
}).catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should migrate first time state', (done) => {
|
it('should migrate first time state', function (done) {
|
||||||
migration25.migrate(firstTimeState)
|
migration25.migrate(firstTimeState)
|
||||||
.then((migratedData) => {
|
.then((migratedData) => {
|
||||||
assert.equal(migratedData.meta.version, 25)
|
assert.equal(migratedData.meta.version, 25)
|
||||||
|
@ -14,8 +14,8 @@ const oldStorage = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('migration #26', () => {
|
describe('migration #26', function () {
|
||||||
it('should move the identities from KeyringController', (done) => {
|
it('should move the identities from KeyringController', function (done) {
|
||||||
migration26.migrate(oldStorage)
|
migration26.migrate(oldStorage)
|
||||||
.then((newStorage) => {
|
.then((newStorage) => {
|
||||||
const identities = newStorage.data.PreferencesController.identities
|
const identities = newStorage.data.PreferencesController.identities
|
||||||
@ -29,7 +29,7 @@ describe('migration #26', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should successfully migrate first time state', (done) => {
|
it('should successfully migrate first time state', function (done) {
|
||||||
migration26.migrate({
|
migration26.migrate({
|
||||||
meta: {},
|
meta: {},
|
||||||
data: require('../../../app/scripts/first-time-state'),
|
data: require('../../../app/scripts/first-time-state'),
|
||||||
|
@ -23,8 +23,8 @@ while (transactions.length < 9) {
|
|||||||
|
|
||||||
oldStorage.data.TransactionController.transactions = transactions
|
oldStorage.data.TransactionController.transactions = transactions
|
||||||
|
|
||||||
describe('migration #27', () => {
|
describe('migration #27', function () {
|
||||||
it('should remove rejected transactions', (done) => {
|
it('should remove rejected transactions', function (done) {
|
||||||
migration27.migrate(oldStorage)
|
migration27.migrate(oldStorage)
|
||||||
.then((newStorage) => {
|
.then((newStorage) => {
|
||||||
const newTransactions = newStorage.data.TransactionController.transactions
|
const newTransactions = newStorage.data.TransactionController.transactions
|
||||||
@ -39,7 +39,7 @@ describe('migration #27', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should successfully migrate first time state', (done) => {
|
it('should successfully migrate first time state', function (done) {
|
||||||
migration27.migrate({
|
migration27.migrate({
|
||||||
meta: {},
|
meta: {},
|
||||||
data: require('../../../app/scripts/first-time-state'),
|
data: require('../../../app/scripts/first-time-state'),
|
||||||
|
@ -14,8 +14,8 @@ const oldStorage = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('migration #28', () => {
|
describe('migration #28', function () {
|
||||||
it('should add corresponding tokens to accountTokens', (done) => {
|
it('should add corresponding tokens to accountTokens', function (done) {
|
||||||
migration28.migrate(oldStorage)
|
migration28.migrate(oldStorage)
|
||||||
.then((newStorage) => {
|
.then((newStorage) => {
|
||||||
const newTokens = newStorage.data.PreferencesController.tokens
|
const newTokens = newStorage.data.PreferencesController.tokens
|
||||||
@ -33,7 +33,7 @@ describe('migration #28', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should successfully migrate first time state', (done) => {
|
it('should successfully migrate first time state', function (done) {
|
||||||
migration28.migrate({
|
migration28.migrate({
|
||||||
meta: {},
|
meta: {},
|
||||||
data: require('../../../app/scripts/first-time-state'),
|
data: require('../../../app/scripts/first-time-state'),
|
||||||
|
@ -17,8 +17,8 @@ const storage = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => {
|
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', function () {
|
||||||
it('should auto fail transactions more than 12 hours old', (done) => {
|
it('should auto fail transactions more than 12 hours old', function (done) {
|
||||||
migration29.migrate(storage)
|
migration29.migrate(storage)
|
||||||
.then((migratedData) => {
|
.then((migratedData) => {
|
||||||
const txs = migratedData.data.TransactionController.transactions
|
const txs = migratedData.data.TransactionController.transactions
|
||||||
|
@ -23,8 +23,8 @@ const storage = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('storage is migrated successfully', () => {
|
describe('storage is migrated successfully', function () {
|
||||||
it('should work', (done) => {
|
it('should work', function (done) {
|
||||||
migrationTemplate.migrate(storage)
|
migrationTemplate.migrate(storage)
|
||||||
.then((migratedData) => {
|
.then((migratedData) => {
|
||||||
assert.equal(migratedData.meta.version, 30)
|
assert.equal(migratedData.meta.version, 30)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration31 from '../../../app/scripts/migrations/031'
|
import migration31 from '../../../app/scripts/migrations/031'
|
||||||
|
|
||||||
describe('migration #31', () => {
|
describe('migration #31', function () {
|
||||||
it('should set completedOnboarding to true if vault exists', done => {
|
it('should set completedOnboarding to true if vault exists', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -31,7 +31,7 @@ describe('migration #31', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should set completedOnboarding to false if vault does not exist', done => {
|
it('should set completedOnboarding to false if vault does not exist', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration33 from '../../../app/scripts/migrations/033'
|
import migration33 from '../../../app/scripts/migrations/033'
|
||||||
|
|
||||||
describe('Migration to delete notice controller', () => {
|
describe('Migration to delete notice controller', function () {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -31,7 +31,7 @@ describe('Migration to delete notice controller', () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
it('removes notice controller from state', () => {
|
it('removes notice controller from state', function () {
|
||||||
migration33.migrate(oldStorage)
|
migration33.migrate(oldStorage)
|
||||||
.then(newStorage => {
|
.then(newStorage => {
|
||||||
assert.equal(newStorage.data.NoticeController, undefined)
|
assert.equal(newStorage.data.NoticeController, undefined)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration34 from '../../../app/scripts/migrations/034'
|
import migration34 from '../../../app/scripts/migrations/034'
|
||||||
|
|
||||||
describe('migration #34', () => {
|
describe('migration #34', function () {
|
||||||
it('should update the version metadata', (done) => {
|
it('should update the version metadata', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {
|
'meta': {
|
||||||
'version': 33,
|
'version': 33,
|
||||||
@ -20,7 +20,7 @@ describe('migration #34', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should set migratedPrivacyMode & privacyMode if featureFlags.privacyMode was false', (done) => {
|
it('should set migratedPrivacyMode & privacyMode if featureFlags.privacyMode was false', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -45,7 +45,7 @@ describe('migration #34', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if migratedPrivacyMode is already set to true', (done) => {
|
it('should NOT change any state if migratedPrivacyMode is already set to true', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -66,7 +66,7 @@ describe('migration #34', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if migratedPrivacyMode is already set to false', (done) => {
|
it('should NOT change any state if migratedPrivacyMode is already set to false', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -87,7 +87,7 @@ describe('migration #34', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if PreferencesController is missing', (done) => {
|
it('should NOT change any state if PreferencesController is missing', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {},
|
'data': {},
|
||||||
@ -101,7 +101,7 @@ describe('migration #34', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if featureFlags.privacyMode is already true', (done) => {
|
it('should NOT change any state if featureFlags.privacyMode is already true', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration35 from '../../../app/scripts/migrations/035'
|
import migration35 from '../../../app/scripts/migrations/035'
|
||||||
|
|
||||||
describe('migration #35', () => {
|
describe('migration #35', function () {
|
||||||
it('should update the version metadata', (done) => {
|
it('should update the version metadata', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
meta: {
|
meta: {
|
||||||
version: 34,
|
version: 34,
|
||||||
@ -20,7 +20,7 @@ describe('migration #35', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should delete seedWords', (done) => {
|
it('should delete seedWords', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
meta: {},
|
meta: {},
|
||||||
data: {
|
data: {
|
||||||
@ -38,7 +38,7 @@ describe('migration #35', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should delete falsy seedWords', (done) => {
|
it('should delete falsy seedWords', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
meta: {},
|
meta: {},
|
||||||
data: {
|
data: {
|
||||||
@ -56,7 +56,7 @@ describe('migration #35', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should leave state without seedWords unchanged', (done) => {
|
it('should leave state without seedWords unchanged', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
meta: {},
|
meta: {},
|
||||||
data: {
|
data: {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration36 from '../../../app/scripts/migrations/036'
|
import migration36 from '../../../app/scripts/migrations/036'
|
||||||
|
|
||||||
describe('migration #36', () => {
|
describe('migration #36', function () {
|
||||||
it('should update the version metadata', (done) => {
|
it('should update the version metadata', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {
|
'meta': {
|
||||||
'version': 35,
|
'version': 35,
|
||||||
@ -20,7 +20,7 @@ describe('migration #36', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should remove privacyMode if featureFlags.privacyMode was false', (done) => {
|
it('should remove privacyMode if featureFlags.privacyMode was false', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -43,7 +43,7 @@ describe('migration #36', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should remove privacyMode if featureFlags.privacyMode was true', (done) => {
|
it('should remove privacyMode if featureFlags.privacyMode was true', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -66,7 +66,7 @@ describe('migration #36', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if privacyMode does not exist', (done) => {
|
it('should NOT change any state if privacyMode does not exist', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -86,7 +86,7 @@ describe('migration #36', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if PreferencesController is missing', (done) => {
|
it('should NOT change any state if PreferencesController is missing', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {},
|
'data': {},
|
||||||
@ -100,7 +100,7 @@ describe('migration #36', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if featureFlags is missing', (done) => {
|
it('should NOT change any state if featureFlags is missing', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration37 from '../../../app/scripts/migrations/037'
|
import migration37 from '../../../app/scripts/migrations/037'
|
||||||
|
|
||||||
describe('migration #37', () => {
|
describe('migration #37', function () {
|
||||||
it('should update the version metadata', (done) => {
|
it('should update the version metadata', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {
|
'meta': {
|
||||||
'version': 36,
|
'version': 36,
|
||||||
@ -20,7 +20,7 @@ describe('migration #37', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should transform old state to new format', (done) => {
|
it('should transform old state to new format', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -84,7 +84,7 @@ describe('migration #37', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('ens validation test', (done) => {
|
it('ens validation test', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration38 from '../../../app/scripts/migrations/038'
|
import migration38 from '../../../app/scripts/migrations/038'
|
||||||
|
|
||||||
describe('migration #38', () => {
|
describe('migration #38', function () {
|
||||||
it('should update the version metadata', (done) => {
|
it('should update the version metadata', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {
|
'meta': {
|
||||||
'version': 37,
|
'version': 37,
|
||||||
@ -20,7 +20,7 @@ describe('migration #38', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should add a fullScreenVsPopup property set to either "control" or "fullScreen"', (done) => {
|
it('should add a fullScreenVsPopup property set to either "control" or "fullScreen"', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {},
|
'data': {},
|
||||||
@ -34,7 +34,7 @@ describe('migration #38', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should leave the fullScreenVsPopup property unchanged if it exists', (done) => {
|
it('should leave the fullScreenVsPopup property unchanged if it exists', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration39 from '../../../app/scripts/migrations/039'
|
import migration39 from '../../../app/scripts/migrations/039'
|
||||||
|
|
||||||
describe('migration #39', () => {
|
describe('migration #39', function () {
|
||||||
it('should update the version metadata', (done) => {
|
it('should update the version metadata', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {
|
'meta': {
|
||||||
'version': 38,
|
'version': 38,
|
||||||
@ -20,7 +20,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should update old DAI token symbol to SAI in tokens', (done) => {
|
it('should update old DAI token symbol to SAI in tokens', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -64,7 +64,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should update old DAI token symbol to SAI in accountTokens', (done) => {
|
it('should update old DAI token symbol to SAI in accountTokens', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -152,7 +152,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if accountTokens is not an object', (done) => {
|
it('should NOT change any state if accountTokens is not an object', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -170,7 +170,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if accountTokens is an object with invalid values', (done) => {
|
it('should NOT change any state if accountTokens is an object with invalid values', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -206,7 +206,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if accountTokens includes the new DAI token', (done) => {
|
it('should NOT change any state if accountTokens includes the new DAI token', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -258,7 +258,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if tokens includes the new DAI token', (done) => {
|
it('should NOT change any state if tokens includes the new DAI token', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -284,7 +284,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if tokens does not include DAI', (done) => {
|
it('should NOT change any state if tokens does not include DAI', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -310,7 +310,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if a tokens property has invalid entries', (done) => {
|
it('should NOT change any state if a tokens property has invalid entries', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -333,7 +333,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if a tokens property is not an array', (done) => {
|
it('should NOT change any state if a tokens property is not an array', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -351,7 +351,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if a tokens property is null', (done) => {
|
it('should NOT change any state if a tokens property is null', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -369,7 +369,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if a tokens property is missing', (done) => {
|
it('should NOT change any state if a tokens property is missing', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -386,7 +386,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if a accountTokens property is missing', (done) => {
|
it('should NOT change any state if a accountTokens property is missing', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {
|
'data': {
|
||||||
@ -403,7 +403,7 @@ describe('migration #39', () => {
|
|||||||
.catch(done)
|
.catch(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should NOT change any state if PreferencesController is missing', (done) => {
|
it('should NOT change any state if PreferencesController is missing', function (done) {
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
'meta': {},
|
'meta': {},
|
||||||
'data': {},
|
'data': {},
|
||||||
|
@ -19,8 +19,8 @@ let vault5, vault6, vault7, vault8, vault9 // vault10, vault11
|
|||||||
const oldTestRpc = 'https://rawtestrpc.metamask.io/'
|
const oldTestRpc = 'https://rawtestrpc.metamask.io/'
|
||||||
const newTestRpc = 'https://testrpc.metamask.io/'
|
const newTestRpc = 'https://testrpc.metamask.io/'
|
||||||
|
|
||||||
describe('wallet1 is migrated successfully', () => {
|
describe('wallet1 is migrated successfully', function () {
|
||||||
it('should convert providers', () => {
|
it('should convert providers', function () {
|
||||||
wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null }
|
wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null }
|
||||||
|
|
||||||
return migration2.migrate(wallet1)
|
return migration2.migrate(wallet1)
|
||||||
|
@ -40,8 +40,10 @@ const firstTimeState = {
|
|||||||
meta: { version: 0 },
|
meta: { version: 0 },
|
||||||
data,
|
data,
|
||||||
}
|
}
|
||||||
describe('liveMigrations require list', () => {
|
|
||||||
it('should include all the migrations', async () => {
|
describe('migrations', function () {
|
||||||
|
describe('liveMigrations require list', function () {
|
||||||
|
it('should include all the migrations', async function () {
|
||||||
const fileNames = await pify(cb => fs.readdir('./app/scripts/migrations/', cb))()
|
const fileNames = await pify(cb => fs.readdir('./app/scripts/migrations/', cb))()
|
||||||
const migrationNumbers = fileNames.reduce((agg, filename) => {
|
const migrationNumbers = fileNames.reduce((agg, filename) => {
|
||||||
const name = filename.split('.')[0]
|
const name = filename.split('.')[0]
|
||||||
@ -58,21 +60,21 @@ describe('liveMigrations require list', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Migrator', () => {
|
describe('Migrator', function () {
|
||||||
const migrator = new Migrator({ migrations: stubMigrations })
|
const migrator = new Migrator({ migrations: stubMigrations })
|
||||||
it('migratedData version should be version 3', async () => {
|
it('migratedData version should be version 3', async function () {
|
||||||
const migratedData = await migrator.migrateData(versionedData)
|
const migratedData = await migrator.migrateData(versionedData)
|
||||||
assert.equal(migratedData.meta.version, stubMigrations[2].version)
|
assert.equal(migratedData.meta.version, stubMigrations[2].version)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should match the last version in live migrations', async () => {
|
it('should match the last version in live migrations', async function () {
|
||||||
const migrator = new Migrator({ migrations: liveMigrations })
|
const migrator = new Migrator({ migrations: liveMigrations })
|
||||||
const migratedData = await migrator.migrateData(firstTimeState)
|
const migratedData = await migrator.migrateData(firstTimeState)
|
||||||
const last = liveMigrations.length - 1
|
const last = liveMigrations.length - 1
|
||||||
assert.equal(migratedData.meta.version, liveMigrations[last].version)
|
assert.equal(migratedData.meta.version, liveMigrations[last].version)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should emit an error', async () => {
|
it('should emit an error', async function () {
|
||||||
const migrator = new Migrator({
|
const migrator = new Migrator({
|
||||||
migrations: [{
|
migrations: [{
|
||||||
version: 1,
|
version: 1,
|
||||||
@ -84,3 +86,4 @@ describe('Migrator', () => {
|
|||||||
await assert.rejects(migrator.migrateData({ meta: { version: 0 } }))
|
await assert.rejects(migrator.migrateData({ meta: { version: 0 } }))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
@ -6,8 +6,8 @@ const storage = {
|
|||||||
data: {},
|
data: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('storage is migrated successfully', () => {
|
describe('storage is migrated successfully', function () {
|
||||||
it('should work', (done) => {
|
it('should work', function (done) {
|
||||||
migrationTemplate.migrate(storage)
|
migrationTemplate.migrate(storage)
|
||||||
.then((migratedData) => {
|
.then((migratedData) => {
|
||||||
assert.equal(migratedData.meta.version, 0)
|
assert.equal(migratedData.meta.version, 0)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@ import { mount } from 'enzyme'
|
|||||||
import TokenCell from '../../../../../ui/app/components/app/token-cell'
|
import TokenCell from '../../../../../ui/app/components/app/token-cell'
|
||||||
import Identicon from '../../../../../ui/app/components/ui/identicon'
|
import Identicon from '../../../../../ui/app/components/ui/identicon'
|
||||||
|
|
||||||
describe('Token Cell', () => {
|
describe('Token Cell', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
@ -33,7 +33,7 @@ describe('Token Cell', () => {
|
|||||||
const mockStore = configureMockStore(middlewares)
|
const mockStore = configureMockStore(middlewares)
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = mount(
|
wrapper = mount(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<TokenCell
|
<TokenCell
|
||||||
@ -48,21 +48,21 @@ describe('Token Cell', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders Identicon with props from token cell', () => {
|
it('renders Identicon with props from token cell', function () {
|
||||||
assert.equal(wrapper.find(Identicon).prop('address'), '0xAnotherToken')
|
assert.equal(wrapper.find(Identicon).prop('address'), '0xAnotherToken')
|
||||||
assert.equal(wrapper.find(Identicon).prop('network'), 'test')
|
assert.equal(wrapper.find(Identicon).prop('network'), 'test')
|
||||||
assert.equal(wrapper.find(Identicon).prop('image'), './test-image')
|
assert.equal(wrapper.find(Identicon).prop('image'), './test-image')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders token balance', () => {
|
it('renders token balance', function () {
|
||||||
assert.equal(wrapper.find('.token-list-item__token-balance').text(), '5.000')
|
assert.equal(wrapper.find('.token-list-item__token-balance').text(), '5.000')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders token symbol', () => {
|
it('renders token symbol', function () {
|
||||||
assert.equal(wrapper.find('.token-list-item__token-symbol').text(), 'TEST')
|
assert.equal(wrapper.find('.token-list-item__token-symbol').text(), 'TEST')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders converted fiat amount', () => {
|
it('renders converted fiat amount', function () {
|
||||||
assert.equal(wrapper.find('.token-list-item__fiat-amount').text(), '0.52 USD')
|
assert.equal(wrapper.find('.token-list-item__fiat-amount').text(), '0.52 USD')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { actionConstants } from '../../../../../ui/app/store/actions'
|
|||||||
|
|
||||||
const actions = actionConstants
|
const actions = actionConstants
|
||||||
|
|
||||||
describe('App State', () => {
|
describe('App State', function () {
|
||||||
|
|
||||||
const metamaskState = {
|
const metamaskState = {
|
||||||
selectedAddress: '0xAddress',
|
selectedAddress: '0xAddress',
|
||||||
@ -16,13 +16,13 @@ describe('App State', () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
it('App init state', () => {
|
it('App init state', function () {
|
||||||
const initState = reduceApp(metamaskState, {})
|
const initState = reduceApp(metamaskState, {})
|
||||||
|
|
||||||
assert(initState)
|
assert(initState)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets networkDropdownOpen dropdown to true', () => {
|
it('sets networkDropdownOpen dropdown to true', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.NETWORK_DROPDOWN_OPEN,
|
type: actions.NETWORK_DROPDOWN_OPEN,
|
||||||
})
|
})
|
||||||
@ -30,7 +30,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.networkDropdownOpen, true)
|
assert.equal(state.networkDropdownOpen, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets networkDropdownOpen dropdown to false', () => {
|
it('sets networkDropdownOpen dropdown to false', function () {
|
||||||
const dropdown = { networkDropdowopen: true }
|
const dropdown = { networkDropdowopen: true }
|
||||||
const state = { ...metamaskState, ...dropdown }
|
const state = { ...metamaskState, ...dropdown }
|
||||||
const newState = reduceApp(state, {
|
const newState = reduceApp(state, {
|
||||||
@ -40,7 +40,7 @@ describe('App State', () => {
|
|||||||
assert.equal(newState.networkDropdownOpen, false)
|
assert.equal(newState.networkDropdownOpen, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens sidebar', () => {
|
it('opens sidebar', function () {
|
||||||
const value = {
|
const value = {
|
||||||
'transitionName': 'sidebar-right',
|
'transitionName': 'sidebar-right',
|
||||||
'type': 'wallet-view',
|
'type': 'wallet-view',
|
||||||
@ -54,7 +54,7 @@ describe('App State', () => {
|
|||||||
assert.deepEqual(state.sidebar, value)
|
assert.deepEqual(state.sidebar, value)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('closes sidebar', () => {
|
it('closes sidebar', function () {
|
||||||
const openSidebar = { sidebar: { isOpen: true } }
|
const openSidebar = { sidebar: { isOpen: true } }
|
||||||
const state = { ...metamaskState, ...openSidebar }
|
const state = { ...metamaskState, ...openSidebar }
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ describe('App State', () => {
|
|||||||
assert.equal(newState.sidebar.isOpen, false)
|
assert.equal(newState.sidebar.isOpen, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens alert', () => {
|
it('opens alert', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.ALERT_OPEN,
|
type: actions.ALERT_OPEN,
|
||||||
value: 'test message',
|
value: 'test message',
|
||||||
@ -75,7 +75,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.alertMessage, 'test message')
|
assert.equal(state.alertMessage, 'test message')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('closes alert', () => {
|
it('closes alert', function () {
|
||||||
const alert = { alertOpen: true, alertMessage: 'test message' }
|
const alert = { alertOpen: true, alertMessage: 'test message' }
|
||||||
const state = { ...metamaskState, ...alert }
|
const state = { ...metamaskState, ...alert }
|
||||||
const newState = reduceApp(state, {
|
const newState = reduceApp(state, {
|
||||||
@ -86,7 +86,7 @@ describe('App State', () => {
|
|||||||
assert.equal(newState.alertMessage, null)
|
assert.equal(newState.alertMessage, null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('detects qr code data', () => {
|
it('detects qr code data', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.QR_CODE_DETECTED,
|
type: actions.QR_CODE_DETECTED,
|
||||||
value: 'qr data',
|
value: 'qr data',
|
||||||
@ -95,7 +95,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.qrCodeData, 'qr data')
|
assert.equal(state.qrCodeData, 'qr data')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens modal', () => {
|
it('opens modal', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.MODAL_OPEN,
|
type: actions.MODAL_OPEN,
|
||||||
payload: {
|
payload: {
|
||||||
@ -107,7 +107,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.modal.modalState.name, 'test')
|
assert.equal(state.modal.modalState.name, 'test')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('closes modal, but moves open modal state to previous modal state', () => {
|
it('closes modal, but moves open modal state to previous modal state', function () {
|
||||||
const opensModal = {
|
const opensModal = {
|
||||||
modal: {
|
modal: {
|
||||||
open: true,
|
open: true,
|
||||||
@ -127,7 +127,7 @@ describe('App State', () => {
|
|||||||
assert.equal(newState.modal.modalState.name, null)
|
assert.equal(newState.modal.modalState.name, null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('transitions forwards', () => {
|
it('transitions forwards', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.TRANSITION_FORWARD,
|
type: actions.TRANSITION_FORWARD,
|
||||||
})
|
})
|
||||||
@ -135,7 +135,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.transForward, true)
|
assert.equal(state.transForward, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows send token page', () => {
|
it('shows send token page', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.SHOW_SEND_TOKEN_PAGE,
|
type: actions.SHOW_SEND_TOKEN_PAGE,
|
||||||
})
|
})
|
||||||
@ -144,7 +144,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.warning, null)
|
assert.equal(state.warning, null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('unlocks Metamask', () => {
|
it('unlocks Metamask', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.UNLOCK_METAMASK,
|
type: actions.UNLOCK_METAMASK,
|
||||||
})
|
})
|
||||||
@ -155,7 +155,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.warning, null)
|
assert.equal(state.warning, null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('locks Metamask', () => {
|
it('locks Metamask', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.LOCK_METAMASK,
|
type: actions.LOCK_METAMASK,
|
||||||
})
|
})
|
||||||
@ -164,7 +164,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.warning, null)
|
assert.equal(state.warning, null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('goes home', () => {
|
it('goes home', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.GO_HOME,
|
type: actions.GO_HOME,
|
||||||
})
|
})
|
||||||
@ -177,7 +177,7 @@ describe('App State', () => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows account detail', () => {
|
it('shows account detail', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.SHOW_ACCOUNT_DETAIL,
|
type: actions.SHOW_ACCOUNT_DETAIL,
|
||||||
value: 'context address',
|
value: 'context address',
|
||||||
@ -190,7 +190,7 @@ describe('App State', () => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shoes account page', () => {
|
it('shoes account page', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.SHOW_ACCOUNTS_PAGE,
|
type: actions.SHOW_ACCOUNTS_PAGE,
|
||||||
})
|
})
|
||||||
@ -202,7 +202,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.forgottenPassword, false)
|
assert.equal(state.forgottenPassword, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows confirm tx page', () => {
|
it('shows confirm tx page', function () {
|
||||||
const txs = {
|
const txs = {
|
||||||
unapprovedTxs: {
|
unapprovedTxs: {
|
||||||
1: {
|
1: {
|
||||||
@ -227,7 +227,7 @@ describe('App State', () => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('completes tx continues to show pending txs current view context', () => {
|
it('completes tx continues to show pending txs current view context', function () {
|
||||||
const txs = {
|
const txs = {
|
||||||
unapprovedTxs: {
|
unapprovedTxs: {
|
||||||
1: {
|
1: {
|
||||||
@ -253,7 +253,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.warning, null)
|
assert.equal(state.warning, null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns to account detail page when no unconf actions completed tx', () => {
|
it('returns to account detail page when no unconf actions completed tx', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.COMPLETED_TX,
|
type: actions.COMPLETED_TX,
|
||||||
value: {
|
value: {
|
||||||
@ -264,10 +264,9 @@ describe('App State', () => {
|
|||||||
assert.equal(state.transForward, false)
|
assert.equal(state.transForward, false)
|
||||||
assert.equal(state.warning, null)
|
assert.equal(state.warning, null)
|
||||||
assert.equal(state.accountDetail.subview, 'transactions')
|
assert.equal(state.accountDetail.subview, 'transactions')
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets default warning when unlock fails', () => {
|
it('sets default warning when unlock fails', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.UNLOCK_FAILED,
|
type: actions.UNLOCK_FAILED,
|
||||||
})
|
})
|
||||||
@ -275,7 +274,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.warning, 'Incorrect password. Try again.')
|
assert.equal(state.warning, 'Incorrect password. Try again.')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets default warning when unlock fails', () => {
|
it('sets errors when unlock fails', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.UNLOCK_FAILED,
|
type: actions.UNLOCK_FAILED,
|
||||||
value: 'errors',
|
value: 'errors',
|
||||||
@ -284,7 +283,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.warning, 'errors')
|
assert.equal(state.warning, 'errors')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets warning to empty string when unlock succeeds', () => {
|
it('sets warning to empty string when unlock succeeds', function () {
|
||||||
const errorState = { warning: 'errors' }
|
const errorState = { warning: 'errors' }
|
||||||
const oldState = { ...metamaskState, ...errorState }
|
const oldState = { ...metamaskState, ...errorState }
|
||||||
const state = reduceApp(oldState, {
|
const state = reduceApp(oldState, {
|
||||||
@ -294,7 +293,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.warning, '')
|
assert.equal(state.warning, '')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets hardware wallet default hd path', () => {
|
it('sets hardware wallet default hd path', function () {
|
||||||
const hdPaths = {
|
const hdPaths = {
|
||||||
trezor: "m/44'/60'/0'/0",
|
trezor: "m/44'/60'/0'/0",
|
||||||
ledger: "m/44'/60'/0'",
|
ledger: "m/44'/60'/0'",
|
||||||
@ -310,7 +309,7 @@ describe('App State', () => {
|
|||||||
assert.deepEqual(state.defaultHdPaths, hdPaths)
|
assert.deepEqual(state.defaultHdPaths, hdPaths)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows loading message', () => {
|
it('shows loading message', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.SHOW_LOADING,
|
type: actions.SHOW_LOADING,
|
||||||
value: 'loading',
|
value: 'loading',
|
||||||
@ -320,7 +319,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.loadingMessage, 'loading')
|
assert.equal(state.loadingMessage, 'loading')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('hides loading message', () => {
|
it('hides loading message', function () {
|
||||||
const loadingState = { isLoading: true }
|
const loadingState = { isLoading: true }
|
||||||
const oldState = { ...metamaskState, ...loadingState }
|
const oldState = { ...metamaskState, ...loadingState }
|
||||||
|
|
||||||
@ -331,7 +330,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.isLoading, false)
|
assert.equal(state.isLoading, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows sub loading indicator', () => {
|
it('shows sub loading indicator', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.SHOW_SUB_LOADING_INDICATION,
|
type: actions.SHOW_SUB_LOADING_INDICATION,
|
||||||
})
|
})
|
||||||
@ -339,7 +338,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.isSubLoading, true)
|
assert.equal(state.isSubLoading, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('hides sub loading indicator', () => {
|
it('hides sub loading indicator', function () {
|
||||||
const oldState = { ...metamaskState, isSubLoading: true }
|
const oldState = { ...metamaskState, isSubLoading: true }
|
||||||
const state = reduceApp(oldState, {
|
const state = reduceApp(oldState, {
|
||||||
type: actions.HIDE_SUB_LOADING_INDICATION,
|
type: actions.HIDE_SUB_LOADING_INDICATION,
|
||||||
@ -348,7 +347,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.isSubLoading, false)
|
assert.equal(state.isSubLoading, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('displays warning', () => {
|
it('displays warning', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.DISPLAY_WARNING,
|
type: actions.DISPLAY_WARNING,
|
||||||
value: 'warning',
|
value: 'warning',
|
||||||
@ -358,7 +357,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.warning, 'warning')
|
assert.equal(state.warning, 'warning')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('hides warning', () => {
|
it('hides warning', function () {
|
||||||
const displayWarningState = { warning: 'warning' }
|
const displayWarningState = { warning: 'warning' }
|
||||||
const oldState = { ...metamaskState, ...displayWarningState }
|
const oldState = { ...metamaskState, ...displayWarningState }
|
||||||
const state = reduceApp(oldState, {
|
const state = reduceApp(oldState, {
|
||||||
@ -368,7 +367,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.warning, undefined)
|
assert.equal(state.warning, undefined)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows private key', () => {
|
it('shows private key', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.SHOW_PRIVATE_KEY,
|
type: actions.SHOW_PRIVATE_KEY,
|
||||||
value: 'private key',
|
value: 'private key',
|
||||||
@ -379,7 +378,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.accountDetail.privateKey, 'private key')
|
assert.equal(state.accountDetail.privateKey, 'private key')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates pair', () => {
|
it('updates pair', function () {
|
||||||
const coinOptions = {
|
const coinOptions = {
|
||||||
BTC: {
|
BTC: {
|
||||||
symbol: 'BTC',
|
symbol: 'BTC',
|
||||||
@ -427,7 +426,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.buyView.amount, '12.00')
|
assert.equal(state.buyView.amount, '12.00')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows QR', () => {
|
it('shows QR', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.SHOW_QR,
|
type: actions.SHOW_QR,
|
||||||
value: {
|
value: {
|
||||||
@ -442,7 +441,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.Qr.data, 'data')
|
assert.equal(state.Qr.data, 'data')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows qr view', () => {
|
it('shows qr view', function () {
|
||||||
const appState = {
|
const appState = {
|
||||||
currentView: {
|
currentView: {
|
||||||
context: 'accounts',
|
context: 'accounts',
|
||||||
@ -463,7 +462,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.Qr.data, 'data')
|
assert.equal(state.Qr.data, 'data')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('set mouse user state', () => {
|
it('set mouse user state', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.SET_MOUSE_USER_STATE,
|
type: actions.SET_MOUSE_USER_STATE,
|
||||||
value: true,
|
value: true,
|
||||||
@ -472,7 +471,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.isMouseUser, true)
|
assert.equal(state.isMouseUser, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets gas loading', () => {
|
it('sets gas loading', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.GAS_LOADING_STARTED,
|
type: actions.GAS_LOADING_STARTED,
|
||||||
})
|
})
|
||||||
@ -480,7 +479,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.gasIsLoading, true)
|
assert.equal(state.gasIsLoading, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('unsets gas loading', () => {
|
it('unsets gas loading', function () {
|
||||||
const gasLoadingState = { gasIsLoading: true }
|
const gasLoadingState = { gasIsLoading: true }
|
||||||
const oldState = { ...metamaskState, ...gasLoadingState }
|
const oldState = { ...metamaskState, ...gasLoadingState }
|
||||||
const state = reduceApp(oldState, {
|
const state = reduceApp(oldState, {
|
||||||
@ -490,7 +489,7 @@ describe('App State', () => {
|
|||||||
assert.equal(state.gasIsLoading, false)
|
assert.equal(state.gasIsLoading, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets network nonce', () => {
|
it('sets network nonce', function () {
|
||||||
const state = reduceApp(metamaskState, {
|
const state = reduceApp(metamaskState, {
|
||||||
type: actions.SET_NETWORK_NONCE,
|
type: actions.SET_NETWORK_NONCE,
|
||||||
value: '33',
|
value: '33',
|
||||||
|
@ -2,14 +2,14 @@ import assert from 'assert'
|
|||||||
import reduceMetamask from '../../../../../ui/app/ducks/metamask/metamask'
|
import reduceMetamask from '../../../../../ui/app/ducks/metamask/metamask'
|
||||||
import { actionConstants as actions } from '../../../../../ui/app/store/actions'
|
import { actionConstants as actions } from '../../../../../ui/app/store/actions'
|
||||||
|
|
||||||
describe('MetaMask Reducers', () => {
|
describe('MetaMask Reducers', function () {
|
||||||
|
|
||||||
it('init state', () => {
|
it('init state', function () {
|
||||||
const initState = reduceMetamask(undefined, {})
|
const initState = reduceMetamask(undefined, {})
|
||||||
assert(initState)
|
assert(initState)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('unlocks MetaMask', () => {
|
it('unlocks MetaMask', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UNLOCK_METAMASK,
|
type: actions.UNLOCK_METAMASK,
|
||||||
value: 'test address',
|
value: 'test address',
|
||||||
@ -20,7 +20,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.selectedAddress, 'test address')
|
assert.equal(state.selectedAddress, 'test address')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('locks MetaMask', () => {
|
it('locks MetaMask', function () {
|
||||||
const unlockMetaMaskState = {
|
const unlockMetaMaskState = {
|
||||||
isUnlocked: true,
|
isUnlocked: true,
|
||||||
isInitialzed: false,
|
isInitialzed: false,
|
||||||
@ -33,7 +33,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(lockMetaMask.isUnlocked, false)
|
assert.equal(lockMetaMask.isUnlocked, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets rpc target', () => {
|
it('sets rpc target', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_RPC_TARGET,
|
type: actions.SET_RPC_TARGET,
|
||||||
value: 'https://custom.rpc',
|
value: 'https://custom.rpc',
|
||||||
@ -42,7 +42,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.provider.rpcTarget, 'https://custom.rpc')
|
assert.equal(state.provider.rpcTarget, 'https://custom.rpc')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets provider type', () => {
|
it('sets provider type', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_PROVIDER_TYPE,
|
type: actions.SET_PROVIDER_TYPE,
|
||||||
value: 'provider type',
|
value: 'provider type',
|
||||||
@ -51,7 +51,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.provider.type, 'provider type')
|
assert.equal(state.provider.type, 'provider type')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows account detail', () => {
|
it('shows account detail', function () {
|
||||||
|
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SHOW_ACCOUNT_DETAIL,
|
type: actions.SHOW_ACCOUNT_DETAIL,
|
||||||
@ -63,7 +63,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.selectedAddress, 'test address')
|
assert.equal(state.selectedAddress, 'test address')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets select ', () => {
|
it('sets select ', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_SELECTED_TOKEN,
|
type: actions.SET_SELECTED_TOKEN,
|
||||||
value: 'test token',
|
value: 'test token',
|
||||||
@ -72,7 +72,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.selectedTokenAddress, 'test token')
|
assert.equal(state.selectedTokenAddress, 'test token')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets account label', () => {
|
it('sets account label', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_ACCOUNT_LABEL,
|
type: actions.SET_ACCOUNT_LABEL,
|
||||||
value: {
|
value: {
|
||||||
@ -84,7 +84,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.deepEqual(state.identities, { 'test account': { name: 'test label' } })
|
assert.deepEqual(state.identities, { 'test account': { name: 'test label' } })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets current fiat', () => {
|
it('sets current fiat', function () {
|
||||||
const value = {
|
const value = {
|
||||||
currentCurrency: 'yen',
|
currentCurrency: 'yen',
|
||||||
conversionRate: 3.14,
|
conversionRate: 3.14,
|
||||||
@ -101,7 +101,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.conversionDate, value.conversionDate)
|
assert.equal(state.conversionDate, value.conversionDate)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates tokens', () => {
|
it('updates tokens', function () {
|
||||||
const newTokens = {
|
const newTokens = {
|
||||||
'address': '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
'address': '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
||||||
'decimals': 18,
|
'decimals': 18,
|
||||||
@ -116,7 +116,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.deepEqual(state.tokens, newTokens)
|
assert.deepEqual(state.tokens, newTokens)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates send gas limit', () => {
|
it('updates send gas limit', function () {
|
||||||
|
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_GAS_LIMIT,
|
type: actions.UPDATE_GAS_LIMIT,
|
||||||
@ -126,7 +126,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.send.gasLimit, '0xGasLimit')
|
assert.equal(state.send.gasLimit, '0xGasLimit')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates send gas price', () => {
|
it('updates send gas price', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_GAS_PRICE,
|
type: actions.UPDATE_GAS_PRICE,
|
||||||
value: '0xGasPrice',
|
value: '0xGasPrice',
|
||||||
@ -135,7 +135,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.send.gasPrice, '0xGasPrice')
|
assert.equal(state.send.gasPrice, '0xGasPrice')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('toggles account menu ', () => {
|
it('toggles account menu ', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.TOGGLE_ACCOUNT_MENU,
|
type: actions.TOGGLE_ACCOUNT_MENU,
|
||||||
})
|
})
|
||||||
@ -143,7 +143,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.isAccountMenuOpen, true)
|
assert.equal(state.isAccountMenuOpen, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates gas total', () => {
|
it('updates gas total', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_GAS_TOTAL,
|
type: actions.UPDATE_GAS_TOTAL,
|
||||||
value: '0xGasTotal',
|
value: '0xGasTotal',
|
||||||
@ -152,7 +152,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.send.gasTotal, '0xGasTotal')
|
assert.equal(state.send.gasTotal, '0xGasTotal')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates send token balance', () => {
|
it('updates send token balance', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_TOKEN_BALANCE,
|
type: actions.UPDATE_SEND_TOKEN_BALANCE,
|
||||||
value: '0xTokenBalance',
|
value: '0xTokenBalance',
|
||||||
@ -161,7 +161,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.send.tokenBalance, '0xTokenBalance')
|
assert.equal(state.send.tokenBalance, '0xTokenBalance')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates data', () => {
|
it('updates data', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_HEX_DATA,
|
type: actions.UPDATE_SEND_HEX_DATA,
|
||||||
value: '0xData',
|
value: '0xData',
|
||||||
@ -170,7 +170,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.send.data, '0xData')
|
assert.equal(state.send.data, '0xData')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates send to', () => {
|
it('updates send to', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_TO,
|
type: actions.UPDATE_SEND_TO,
|
||||||
value: {
|
value: {
|
||||||
@ -183,7 +183,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.send.toNickname, 'nickname')
|
assert.equal(state.send.toNickname, 'nickname')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('update send amount', () => {
|
it('update send amount', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_AMOUNT,
|
type: actions.UPDATE_SEND_AMOUNT,
|
||||||
value: '0xAmount',
|
value: '0xAmount',
|
||||||
@ -192,7 +192,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.send.amount, '0xAmount')
|
assert.equal(state.send.amount, '0xAmount')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates max mode', () => {
|
it('updates max mode', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_MAX_MODE,
|
type: actions.UPDATE_MAX_MODE,
|
||||||
value: true,
|
value: true,
|
||||||
@ -201,7 +201,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.send.maxModeOn, true)
|
assert.equal(state.send.maxModeOn, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('update send', () => {
|
it('update send', function () {
|
||||||
const value = {
|
const value = {
|
||||||
gasLimit: '0xGasLimit',
|
gasLimit: '0xGasLimit',
|
||||||
gasPrice: '0xGasPrice',
|
gasPrice: '0xGasPrice',
|
||||||
@ -228,7 +228,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.deepEqual(sendState.send, value)
|
assert.deepEqual(sendState.send, value)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clears send', () => {
|
it('clears send', function () {
|
||||||
const initStateSend = {
|
const initStateSend = {
|
||||||
send:
|
send:
|
||||||
{ gasLimit: null,
|
{ gasLimit: null,
|
||||||
@ -272,7 +272,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.deepEqual(state.send, initStateSend.send)
|
assert.deepEqual(state.send, initStateSend.send)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates value of tx by id', () => {
|
it('updates value of tx by id', function () {
|
||||||
const oldState = {
|
const oldState = {
|
||||||
selectedAddressTxList: [
|
selectedAddressTxList: [
|
||||||
{
|
{
|
||||||
@ -291,7 +291,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.selectedAddressTxList[0].txParams, 'bar')
|
assert.equal(state.selectedAddressTxList[0].txParams, 'bar')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates pair for shapeshift', () => {
|
it('updates pair for shapeshift', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.PAIR_UPDATE,
|
type: actions.PAIR_UPDATE,
|
||||||
value: {
|
value: {
|
||||||
@ -304,7 +304,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.tokenExchangeRates['test pair'].pair, 'test pair')
|
assert.equal(state.tokenExchangeRates['test pair'].pair, 'test pair')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets blockies', () => {
|
it('sets blockies', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_USE_BLOCKIE,
|
type: actions.SET_USE_BLOCKIE,
|
||||||
value: true,
|
value: true,
|
||||||
@ -313,7 +313,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.useBlockie, true)
|
assert.equal(state.useBlockie, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates an arbitrary feature flag', () => {
|
it('updates an arbitrary feature flag', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_FEATURE_FLAGS,
|
type: actions.UPDATE_FEATURE_FLAGS,
|
||||||
value: {
|
value: {
|
||||||
@ -324,7 +324,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.featureFlags.foo, true)
|
assert.equal(state.featureFlags.foo, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('close welcome screen', () => {
|
it('close welcome screen', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.CLOSE_WELCOME_SCREEN,
|
type: actions.CLOSE_WELCOME_SCREEN,
|
||||||
})
|
})
|
||||||
@ -332,7 +332,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.welcomeScreenSeen, true)
|
assert.equal(state.welcomeScreenSeen, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets current locale', () => {
|
it('sets current locale', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.SET_CURRENT_LOCALE,
|
type: actions.SET_CURRENT_LOCALE,
|
||||||
value: { locale: 'ge' },
|
value: { locale: 'ge' },
|
||||||
@ -341,7 +341,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.equal(state.currentLocale, 'ge')
|
assert.equal(state.currentLocale, 'ge')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets pending tokens ', () => {
|
it('sets pending tokens ', function () {
|
||||||
const payload = {
|
const payload = {
|
||||||
'address': '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
'address': '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
||||||
'decimals': 18,
|
'decimals': 18,
|
||||||
@ -356,7 +356,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.deepEqual(pendingTokensState.pendingTokens, payload)
|
assert.deepEqual(pendingTokensState.pendingTokens, payload)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clears pending tokens', () => {
|
it('clears pending tokens', function () {
|
||||||
const payload = {
|
const payload = {
|
||||||
'address': '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
'address': '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
|
||||||
'decimals': 18,
|
'decimals': 18,
|
||||||
@ -374,7 +374,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.deepEqual(state.pendingTokens, {})
|
assert.deepEqual(state.pendingTokens, {})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('update ensResolution', () => {
|
it('update ensResolution', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_ENS_RESOLUTION,
|
type: actions.UPDATE_SEND_ENS_RESOLUTION,
|
||||||
payload: '0x1337',
|
payload: '0x1337',
|
||||||
@ -384,7 +384,7 @@ describe('MetaMask Reducers', () => {
|
|||||||
assert.deepEqual(state.send.ensResolutionError, '')
|
assert.deepEqual(state.send.ensResolutionError, '')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('update ensResolutionError', () => {
|
it('update ensResolutionError', function () {
|
||||||
const state = reduceMetamask({}, {
|
const state = reduceMetamask({}, {
|
||||||
type: actions.UPDATE_SEND_ENS_RESOLUTION_ERROR,
|
type: actions.UPDATE_SEND_ENS_RESOLUTION_ERROR,
|
||||||
payload: 'ens name not found',
|
payload: 'ens name not found',
|
||||||
|
@ -109,50 +109,50 @@ describe('Selectors', function () {
|
|||||||
assert.equal(currentAccountwithSendEther.name, 'Test Account')
|
assert.equal(currentAccountwithSendEther.name, 'Test Account')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getGasIsLoading', () => {
|
it('#getGasIsLoading', function () {
|
||||||
const gasIsLoading = selectors.getGasIsLoading(mockState)
|
const gasIsLoading = selectors.getGasIsLoading(mockState)
|
||||||
assert.equal(gasIsLoading, false)
|
assert.equal(gasIsLoading, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Send From', () => {
|
describe('Send From', function () {
|
||||||
it('#getSendFrom', () => {
|
it('#getSendFrom', function () {
|
||||||
const sendFrom = selectors.getSendFrom(mockState)
|
const sendFrom = selectors.getSendFrom(mockState)
|
||||||
assert.equal(sendFrom, '0xc42edfcc21ed14dda456aa0756c153f7985d8813')
|
assert.equal(sendFrom, '0xc42edfcc21ed14dda456aa0756c153f7985d8813')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getForceGasMin', () => {
|
it('#getForceGasMin', function () {
|
||||||
const forceGasMin = selectors.getForceGasMin(mockState)
|
const forceGasMin = selectors.getForceGasMin(mockState)
|
||||||
assert.equal(forceGasMin, null)
|
assert.equal(forceGasMin, null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getSendAmount', () => {
|
it('#getSendAmount', function () {
|
||||||
const sendAmount = selectors.getSendAmount(mockState)
|
const sendAmount = selectors.getSendAmount(mockState)
|
||||||
assert.equal(sendAmount, '1bc16d674ec80000')
|
assert.equal(sendAmount, '1bc16d674ec80000')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getSendMaxModeState', () => {
|
it('#getSendMaxModeState', function () {
|
||||||
const sendMaxModeState = selectors.getSendMaxModeState(mockState)
|
const sendMaxModeState = selectors.getSendMaxModeState(mockState)
|
||||||
assert.equal(sendMaxModeState, false)
|
assert.equal(sendMaxModeState, false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getCurrentCurrency', () => {
|
it('#getCurrentCurrency', function () {
|
||||||
const currentCurrency = selectors.getCurrentCurrency(mockState)
|
const currentCurrency = selectors.getCurrentCurrency(mockState)
|
||||||
assert.equal(currentCurrency, 'usd')
|
assert.equal(currentCurrency, 'usd')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getSelectedTokenToFiatRate', () => {
|
it('#getSelectedTokenToFiatRate', function () {
|
||||||
const selectedTokenToFiatRate = selectors.getSelectedTokenToFiatRate(mockState)
|
const selectedTokenToFiatRate = selectors.getSelectedTokenToFiatRate(mockState)
|
||||||
assert.equal(selectedTokenToFiatRate, '0.21880988420033492152')
|
assert.equal(selectedTokenToFiatRate, '0.21880988420033492152')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getSelectedTokenContract', () => {
|
it('#getSelectedTokenContract', function () {
|
||||||
global.eth = new Eth(provider)
|
global.eth = new Eth(provider)
|
||||||
const selectedTokenContract = selectors.getSelectedTokenContract(mockState)
|
const selectedTokenContract = selectors.getSelectedTokenContract(mockState)
|
||||||
assert(selectedTokenContract.abi)
|
assert(selectedTokenContract.abi)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getTotalUnapprovedCount', () => {
|
it('#getTotalUnapprovedCount', function () {
|
||||||
const totalUnapprovedCount = selectors.getTotalUnapprovedCount(mockState)
|
const totalUnapprovedCount = selectors.getTotalUnapprovedCount(mockState)
|
||||||
assert.equal(totalUnapprovedCount, 1)
|
assert.equal(totalUnapprovedCount, 1)
|
||||||
})
|
})
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import etherscanNetworkPrefix from '../../../ui/lib/etherscan-prefix-for-network'
|
import etherscanNetworkPrefix from '../../../ui/lib/etherscan-prefix-for-network'
|
||||||
|
|
||||||
describe('Etherscan Network Prefix', () => {
|
describe('Etherscan Network Prefix', function () {
|
||||||
|
|
||||||
it('returns empy string as default value', () => {
|
it('returns empy string as default value', function () {
|
||||||
assert.equal(etherscanNetworkPrefix(), '')
|
assert.equal(etherscanNetworkPrefix(), '')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns empty string as a prefix for networkId of 1', () => {
|
it('returns empty string as a prefix for networkId of 1', function () {
|
||||||
assert.equal(etherscanNetworkPrefix(1), '')
|
assert.equal(etherscanNetworkPrefix(1), '')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns ropsten as prefix for networkId of 3', () => {
|
it('returns ropsten as prefix for networkId of 3', function () {
|
||||||
assert.equal(etherscanNetworkPrefix(3), 'ropsten.')
|
assert.equal(etherscanNetworkPrefix(3), 'ropsten.')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns rinkeby as prefix for networkId of 4', () => {
|
it('returns rinkeby as prefix for networkId of 4', function () {
|
||||||
assert.equal(etherscanNetworkPrefix(4), 'rinkeby.')
|
assert.equal(etherscanNetworkPrefix(4), 'rinkeby.')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returs kovan as prefix for networkId of 42', () => {
|
it('returs kovan as prefix for networkId of 42', function () {
|
||||||
assert.equal(etherscanNetworkPrefix(42), 'kovan.')
|
assert.equal(etherscanNetworkPrefix(42), 'kovan.')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returs goerli as prefix for networkId of 5', () => {
|
it('returs goerli as prefix for networkId of 5', function () {
|
||||||
assert.equal(etherscanNetworkPrefix(5), 'goerli.')
|
assert.equal(etherscanNetworkPrefix(5), 'goerli.')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -12,12 +12,12 @@ web3.currentProvider.enable().then(() => {
|
|||||||
Object.keys(methodGroup).forEach(methodKey => {
|
Object.keys(methodGroup).forEach(methodKey => {
|
||||||
|
|
||||||
const methodButton = document.getElementById(methodKey)
|
const methodButton = document.getElementById(methodKey)
|
||||||
methodButton.addEventListener('click', function () {
|
methodButton.addEventListener('click', () => {
|
||||||
|
|
||||||
window.ethereum.sendAsync({
|
window.ethereum.sendAsync({
|
||||||
method: methodKey,
|
method: methodKey,
|
||||||
params: methodGroup[methodKey][1],
|
params: methodGroup[methodKey][1],
|
||||||
}, function (err, result) {
|
}, (err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
console.log(methodKey)
|
console.log(methodKey)
|
||||||
|
@ -6,7 +6,7 @@ import { mountWithRouter } from '../../../../../../test/lib/render-helpers'
|
|||||||
import AccountMenu from '../index'
|
import AccountMenu from '../index'
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
|
|
||||||
describe('Account Menu', async () => {
|
describe('Account Menu', function () {
|
||||||
|
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ describe('Account Menu', async () => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
before(() => {
|
before(function () {
|
||||||
wrapper = mountWithRouter(
|
wrapper = mountWithRouter(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<AccountMenu.WrappedComponent {...props} />
|
<AccountMenu.WrappedComponent {...props} />
|
||||||
@ -71,23 +71,23 @@ describe('Account Menu', async () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
props.toggleAccountMenu.resetHistory()
|
props.toggleAccountMenu.resetHistory()
|
||||||
props.history.push.resetHistory()
|
props.history.push.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Render Content', () => {
|
describe('Render Content', function () {
|
||||||
it('returns account name from identities', () => {
|
it('returns account name from identities', function () {
|
||||||
const accountName = wrapper.find('.account-menu__name')
|
const accountName = wrapper.find('.account-menu__name')
|
||||||
assert.equal(accountName.length, 2)
|
assert.equal(accountName.length, 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders user preference currency display balance from account balance', () => {
|
it('renders user preference currency display balance from account balance', function () {
|
||||||
const accountBalance = wrapper.find('.currency-display-component.account-menu__balance')
|
const accountBalance = wrapper.find('.currency-display-component.account-menu__balance')
|
||||||
assert.equal(accountBalance.length, 2)
|
assert.equal(accountBalance.length, 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('simulate click', () => {
|
it('simulate click', function () {
|
||||||
const click = wrapper.find('.account-menu__account.menu__item--clickable')
|
const click = wrapper.find('.account-menu__account.menu__item--clickable')
|
||||||
click.first().simulate('click')
|
click.first().simulate('click')
|
||||||
|
|
||||||
@ -95,12 +95,12 @@ describe('Account Menu', async () => {
|
|||||||
assert.equal(props.showAccountDetail.getCall(0).args[0], '0xAddress')
|
assert.equal(props.showAccountDetail.getCall(0).args[0], '0xAddress')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('render imported account label', () => {
|
it('render imported account label', function () {
|
||||||
const importedAccount = wrapper.find('.keyring-label.allcaps')
|
const importedAccount = wrapper.find('.keyring-label.allcaps')
|
||||||
assert.equal(importedAccount.text(), 'imported')
|
assert.equal(importedAccount.text(), 'imported')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('remove account', () => {
|
it('remove account', function () {
|
||||||
const removeAccount = wrapper.find('.remove-account-icon')
|
const removeAccount = wrapper.find('.remove-account-icon')
|
||||||
removeAccount.simulate('click', {
|
removeAccount.simulate('click', {
|
||||||
preventDefault: () => {},
|
preventDefault: () => {},
|
||||||
@ -114,93 +114,93 @@ describe('Account Menu', async () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Log Out', () => {
|
describe('Log Out', function () {
|
||||||
let logout
|
let logout
|
||||||
|
|
||||||
it('logout', () => {
|
it('logout', function () {
|
||||||
logout = wrapper.find('.account-menu__lock-button')
|
logout = wrapper.find('.account-menu__lock-button')
|
||||||
assert.equal(logout.length, 1)
|
assert.equal(logout.length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('simulate click', () => {
|
it('simulate click', function () {
|
||||||
logout.simulate('click')
|
logout.simulate('click')
|
||||||
assert(props.lockMetamask.calledOnce)
|
assert(props.lockMetamask.calledOnce)
|
||||||
assert.equal(props.history.push.getCall(0).args[0], '/')
|
assert.equal(props.history.push.getCall(0).args[0], '/')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Create Account', () => {
|
describe('Create Account', function () {
|
||||||
let createAccount
|
let createAccount
|
||||||
|
|
||||||
it('renders create account item', () => {
|
it('renders create account item', function () {
|
||||||
createAccount = wrapper.find({ text: 'createAccount' })
|
createAccount = wrapper.find({ text: 'createAccount' })
|
||||||
assert.equal(createAccount.length, 1)
|
assert.equal(createAccount.length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls toggle menu and push new-account route to history', () => {
|
it('calls toggle menu and push new-account route to history', function () {
|
||||||
createAccount.simulate('click')
|
createAccount.simulate('click')
|
||||||
assert(props.toggleAccountMenu.calledOnce)
|
assert(props.toggleAccountMenu.calledOnce)
|
||||||
assert.equal(props.history.push.getCall(0).args[0], '/new-account')
|
assert.equal(props.history.push.getCall(0).args[0], '/new-account')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Import Account', () => {
|
describe('Import Account', function () {
|
||||||
let importAccount
|
let importAccount
|
||||||
|
|
||||||
it('renders import account item', () => {
|
it('renders import account item', function () {
|
||||||
importAccount = wrapper.find({ text: 'importAccount' })
|
importAccount = wrapper.find({ text: 'importAccount' })
|
||||||
assert.equal(importAccount.length, 1)
|
assert.equal(importAccount.length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls toggle menu and push /new-account/import route to history', () => {
|
it('calls toggle menu and push /new-account/import route to history', function () {
|
||||||
importAccount.simulate('click')
|
importAccount.simulate('click')
|
||||||
assert(props.toggleAccountMenu.calledOnce)
|
assert(props.toggleAccountMenu.calledOnce)
|
||||||
assert(props.history.push.getCall(0).args[0], '/new-account/import')
|
assert(props.history.push.getCall(0).args[0], '/new-account/import')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Connect Hardware Wallet', () => {
|
describe('Connect Hardware Wallet', function () {
|
||||||
|
|
||||||
let connectHardwareWallet
|
let connectHardwareWallet
|
||||||
|
|
||||||
it('renders import account item', () => {
|
it('renders import account item', function () {
|
||||||
connectHardwareWallet = wrapper.find({ text: 'connectHardwareWallet' })
|
connectHardwareWallet = wrapper.find({ text: 'connectHardwareWallet' })
|
||||||
assert.equal(connectHardwareWallet.length, 1)
|
assert.equal(connectHardwareWallet.length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls toggle menu and push /new-account/connect route to history', () => {
|
it('calls toggle menu and push /new-account/connect route to history', function () {
|
||||||
connectHardwareWallet.simulate('click')
|
connectHardwareWallet.simulate('click')
|
||||||
assert(props.toggleAccountMenu.calledOnce)
|
assert(props.toggleAccountMenu.calledOnce)
|
||||||
assert.equal(props.history.push.getCall(0).args[0], '/new-account/connect')
|
assert.equal(props.history.push.getCall(0).args[0], '/new-account/connect')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Info & Help', () => {
|
describe('Info & Help', function () {
|
||||||
|
|
||||||
let infoHelp
|
let infoHelp
|
||||||
|
|
||||||
it('renders import account item', () => {
|
it('renders import account item', function () {
|
||||||
infoHelp = wrapper.find({ text: 'infoHelp' })
|
infoHelp = wrapper.find({ text: 'infoHelp' })
|
||||||
assert.equal(infoHelp.length, 1)
|
assert.equal(infoHelp.length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls toggle menu and push /new-account/connect route to history', () => {
|
it('calls toggle menu and push /new-account/connect route to history', function () {
|
||||||
infoHelp.simulate('click')
|
infoHelp.simulate('click')
|
||||||
assert(props.toggleAccountMenu.calledOnce)
|
assert(props.toggleAccountMenu.calledOnce)
|
||||||
assert.equal(props.history.push.getCall(0).args[0], '/settings/about-us')
|
assert.equal(props.history.push.getCall(0).args[0], '/settings/about-us')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Settings', () => {
|
describe('Settings', function () {
|
||||||
|
|
||||||
let settings
|
let settings
|
||||||
|
|
||||||
it('renders import account item', () => {
|
it('renders import account item', function () {
|
||||||
settings = wrapper.find({ text: 'settings' })
|
settings = wrapper.find({ text: 'settings' })
|
||||||
assert.equal(settings.length, 1)
|
assert.equal(settings.length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls toggle menu and push /new-account/connect route to history', () => {
|
it('calls toggle menu and push /new-account/connect route to history', function () {
|
||||||
settings.simulate('click')
|
settings.simulate('click')
|
||||||
assert(props.toggleAccountMenu.calledOnce)
|
assert(props.toggleAccountMenu.calledOnce)
|
||||||
assert.equal(props.history.push.getCall(0).args[0], '/settings')
|
assert.equal(props.history.push.getCall(0).args[0], '/settings')
|
||||||
|
@ -5,7 +5,7 @@ import { shallow } from 'enzyme'
|
|||||||
import MetaFoxLogo from '../../../ui/metafox-logo'
|
import MetaFoxLogo from '../../../ui/metafox-logo'
|
||||||
import AppHeader from '../index'
|
import AppHeader from '../index'
|
||||||
|
|
||||||
describe('App Header', () => {
|
describe('App Header', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
@ -25,7 +25,7 @@ describe('App Header', () => {
|
|||||||
isUnlocked: true,
|
isUnlocked: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<AppHeader.WrappedComponent {...props} />, {
|
<AppHeader.WrappedComponent {...props} />, {
|
||||||
context: {
|
context: {
|
||||||
@ -36,12 +36,12 @@ describe('App Header', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
props.toggleAccountMenu.resetHistory()
|
props.toggleAccountMenu.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('App Header Logo', () => {
|
describe('App Header Logo', function () {
|
||||||
it('routes to default route when logo is clicked', () => {
|
it('routes to default route when logo is clicked', function () {
|
||||||
const appLogo = wrapper.find(MetaFoxLogo)
|
const appLogo = wrapper.find(MetaFoxLogo)
|
||||||
appLogo.simulate('click')
|
appLogo.simulate('click')
|
||||||
assert(props.history.push.calledOnce)
|
assert(props.history.push.calledOnce)
|
||||||
@ -49,8 +49,8 @@ describe('App Header', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Network', () => {
|
describe('Network', function () {
|
||||||
it('shows network dropdown when networkDropdownOpen is false', () => {
|
it('shows network dropdown when networkDropdownOpen is false', function () {
|
||||||
const network = wrapper.find({ network: 'test' })
|
const network = wrapper.find({ network: 'test' })
|
||||||
|
|
||||||
network.simulate('click', {
|
network.simulate('click', {
|
||||||
@ -61,7 +61,7 @@ describe('App Header', () => {
|
|||||||
assert(props.showNetworkDropdown.calledOnce)
|
assert(props.showNetworkDropdown.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('hides network dropdown when networkDropdownOpen is true', () => {
|
it('hides network dropdown when networkDropdownOpen is true', function () {
|
||||||
wrapper.setProps({ networkDropdownOpen: true })
|
wrapper.setProps({ networkDropdownOpen: true })
|
||||||
const network = wrapper.find({ network: 'test' })
|
const network = wrapper.find({ network: 'test' })
|
||||||
|
|
||||||
@ -73,22 +73,22 @@ describe('App Header', () => {
|
|||||||
assert(props.hideNetworkDropdown.calledOnce)
|
assert(props.hideNetworkDropdown.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('hides network indicator', () => {
|
it('hides network indicator', function () {
|
||||||
wrapper.setProps({ hideNetworkIndicator: true })
|
wrapper.setProps({ hideNetworkIndicator: true })
|
||||||
const network = wrapper.find({ network: 'test' })
|
const network = wrapper.find({ network: 'test' })
|
||||||
assert.equal(network.length, 0)
|
assert.equal(network.length, 0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Account Menu', () => {
|
describe('Account Menu', function () {
|
||||||
|
|
||||||
it('toggles account menu', () => {
|
it('toggles account menu', function () {
|
||||||
const accountMenu = wrapper.find('.account-menu__icon')
|
const accountMenu = wrapper.find('.account-menu__icon')
|
||||||
accountMenu.simulate('click')
|
accountMenu.simulate('click')
|
||||||
assert(props.toggleAccountMenu.calledOnce)
|
assert(props.toggleAccountMenu.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not toggle account menu when disabled', () => {
|
it('does not toggle account menu when disabled', function () {
|
||||||
wrapper.setProps({ disabled: true })
|
wrapper.setProps({ disabled: true })
|
||||||
const accountMenu = wrapper.find('.account-menu__icon')
|
const accountMenu = wrapper.find('.account-menu__icon')
|
||||||
accountMenu.simulate('click')
|
accountMenu.simulate('click')
|
||||||
|
@ -9,9 +9,10 @@ const propsMethodSpies = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('Confirm Detail Row Component', function () {
|
describe('Confirm Detail Row Component', function () {
|
||||||
|
describe('render', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<ConfirmDetailRow
|
<ConfirmDetailRow
|
||||||
errorType="mockErrorType"
|
errorType="mockErrorType"
|
||||||
@ -27,38 +28,37 @@ describe('Confirm Detail Row Component', function () {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('render', () => {
|
it('should render a div with a confirm-detail-row class', function () {
|
||||||
it('should render a div with a confirm-detail-row class', () => {
|
|
||||||
assert.equal(wrapper.find('div.confirm-detail-row').length, 1)
|
assert.equal(wrapper.find('div.confirm-detail-row').length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render the label as a child of the confirm-detail-row__label', () => {
|
it('should render the label as a child of the confirm-detail-row__label', function () {
|
||||||
assert.equal(wrapper.find('.confirm-detail-row > .confirm-detail-row__label').childAt(0).text(), 'mockLabel')
|
assert.equal(wrapper.find('.confirm-detail-row > .confirm-detail-row__label').childAt(0).text(), 'mockLabel')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render the headerText as a child of the confirm-detail-row__header-text', () => {
|
it('should render the headerText as a child of the confirm-detail-row__header-text', function () {
|
||||||
assert.equal(wrapper.find('.confirm-detail-row__details > .confirm-detail-row__header-text').childAt(0).text(), 'mockHeaderText')
|
assert.equal(wrapper.find('.confirm-detail-row__details > .confirm-detail-row__header-text').childAt(0).text(), 'mockHeaderText')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render the primaryText as a child of the confirm-detail-row__primary', () => {
|
it('should render the primaryText as a child of the confirm-detail-row__primary', function () {
|
||||||
assert.equal(wrapper.find('.confirm-detail-row__details > .confirm-detail-row__primary').childAt(0).text(), 'mockFiatText')
|
assert.equal(wrapper.find('.confirm-detail-row__details > .confirm-detail-row__primary').childAt(0).text(), 'mockFiatText')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render the ethText as a child of the confirm-detail-row__secondary', () => {
|
it('should render the ethText as a child of the confirm-detail-row__secondary', function () {
|
||||||
assert.equal(wrapper.find('.confirm-detail-row__details > .confirm-detail-row__secondary').childAt(0).text(), 'mockEthText')
|
assert.equal(wrapper.find('.confirm-detail-row__details > .confirm-detail-row__secondary').childAt(0).text(), 'mockEthText')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should set the fiatTextColor on confirm-detail-row__primary', () => {
|
it('should set the fiatTextColor on confirm-detail-row__primary', function () {
|
||||||
assert.equal(wrapper.find('.confirm-detail-row__primary').props().style.color, 'mockColor')
|
assert.equal(wrapper.find('.confirm-detail-row__primary').props().style.color, 'mockColor')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should assure the confirm-detail-row__header-text classname is correct', () => {
|
it('should assure the confirm-detail-row__header-text classname is correct', function () {
|
||||||
assert.equal(wrapper.find('.confirm-detail-row__header-text').props().className, 'confirm-detail-row__header-text mockHeaderClass')
|
assert.equal(wrapper.find('.confirm-detail-row__header-text').props().className, 'confirm-detail-row__header-text mockHeaderClass')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call onHeaderClick when headerText div gets clicked', () => {
|
it('should call onHeaderClick when headerText div gets clicked', function () {
|
||||||
wrapper.find('.confirm-detail-row__header-text').props().onClick()
|
wrapper.find('.confirm-detail-row__header-text').props().onClick()
|
||||||
assert.equal(assert.equal(propsMethodSpies.onHeaderClick.callCount, 1))
|
assert.ok(propsMethodSpies.onHeaderClick.calledOnce)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -4,12 +4,12 @@ import sinon from 'sinon'
|
|||||||
import { shallow } from 'enzyme'
|
import { shallow } from 'enzyme'
|
||||||
import { DropdownMenuItem } from '../components/dropdown.js'
|
import { DropdownMenuItem } from '../components/dropdown.js'
|
||||||
|
|
||||||
describe('Dropdown', () => {
|
describe('Dropdown', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
const onClickSpy = sinon.spy()
|
const onClickSpy = sinon.spy()
|
||||||
const closeMenuSpy = sinon.spy()
|
const closeMenuSpy = sinon.spy()
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={onClickSpy}
|
onClick={onClickSpy}
|
||||||
@ -20,15 +20,15 @@ describe('Dropdown', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders li with dropdown-menu-item class', () => {
|
it('renders li with dropdown-menu-item class', function () {
|
||||||
assert.equal(wrapper.find('li.dropdown-menu-item').length, 1)
|
assert.equal(wrapper.find('li.dropdown-menu-item').length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('adds style based on props passed', () => {
|
it('adds style based on props passed', function () {
|
||||||
assert.equal(wrapper.prop('style').test, 'style')
|
assert.equal(wrapper.prop('style').test, 'style')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('simulates click event and calls onClick and closeMenu', () => {
|
it('simulates click event and calls onClick and closeMenu', function () {
|
||||||
wrapper.prop('onClick')()
|
wrapper.prop('onClick')()
|
||||||
assert.equal(onClickSpy.callCount, 1)
|
assert.equal(onClickSpy.callCount, 1)
|
||||||
assert.equal(closeMenuSpy.callCount, 1)
|
assert.equal(closeMenuSpy.callCount, 1)
|
||||||
|
@ -4,29 +4,21 @@ import sinon from 'sinon'
|
|||||||
import { shallow } from 'enzyme'
|
import { shallow } from 'enzyme'
|
||||||
import { Menu, Item, Divider, CloseArea } from '../components/menu'
|
import { Menu, Item, Divider, CloseArea } from '../components/menu'
|
||||||
|
|
||||||
describe('Dropdown Menu Components', () => {
|
describe('Dropdown Menu Components', function () {
|
||||||
|
describe('Menu', function () {
|
||||||
describe('Menu', () => {
|
it('adds prop className to menu', function () {
|
||||||
let wrapper
|
const wrapper = shallow(
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
wrapper = shallow(
|
|
||||||
<Menu className="Test Class" isShowing />
|
<Menu className="Test Class" isShowing />
|
||||||
)
|
)
|
||||||
})
|
|
||||||
|
|
||||||
it('adds prop className to menu', () => {
|
|
||||||
assert.equal(wrapper.find('.menu').prop('className'), 'menu Test Class')
|
assert.equal(wrapper.find('.menu').prop('className'), 'menu Test Class')
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Item', () => {
|
describe('Item', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const onClickSpy = sinon.spy()
|
const onClickSpy = sinon.spy()
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<Item
|
<Item
|
||||||
icon="test icon"
|
icon="test icon"
|
||||||
@ -37,53 +29,41 @@ describe('Dropdown Menu Components', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('add className based on props', () => {
|
it('add className based on props', function () {
|
||||||
assert.equal(wrapper.find('.menu__item').prop('className'), 'menu__item test foo1 menu__item--clickable')
|
assert.equal(wrapper.find('.menu__item').prop('className'), 'menu__item test foo1 menu__item--clickable')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('simulates onClick called', () => {
|
it('simulates onClick called', function () {
|
||||||
wrapper.find('.menu__item').prop('onClick')()
|
wrapper.find('.menu__item').prop('onClick')()
|
||||||
assert.equal(onClickSpy.callCount, 1)
|
assert.equal(onClickSpy.callCount, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('adds icon based on icon props', () => {
|
it('adds icon based on icon props', function () {
|
||||||
assert.equal(wrapper.find('.menu__item__icon').text(), 'test icon')
|
assert.equal(wrapper.find('.menu__item__icon').text(), 'test icon')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('adds html text based on text props', () => {
|
it('adds html text based on text props', function () {
|
||||||
assert.equal(wrapper.find('.menu__item__text').text(), 'test text')
|
assert.equal(wrapper.find('.menu__item__text').text(), 'test text')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Divider', () => {
|
describe('Divider', function () {
|
||||||
let wrapper
|
it('renders menu divider', function () {
|
||||||
|
const wrapper = shallow(<Divider />)
|
||||||
before(() => {
|
|
||||||
wrapper = shallow(<Divider />)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('renders menu divider', () => {
|
|
||||||
assert.equal(wrapper.find('.menu__divider').length, 1)
|
assert.equal(wrapper.find('.menu__divider').length, 1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('CloseArea', () => {
|
describe('CloseArea', function () {
|
||||||
let wrapper
|
it('simulates click', function () {
|
||||||
|
|
||||||
const onClickSpy = sinon.spy()
|
const onClickSpy = sinon.spy()
|
||||||
|
const wrapper = shallow((
|
||||||
beforeEach(() => {
|
|
||||||
wrapper = shallow((
|
|
||||||
<CloseArea
|
<CloseArea
|
||||||
onClick={onClickSpy}
|
onClick={onClickSpy}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
})
|
|
||||||
|
|
||||||
it('simulates click', () => {
|
|
||||||
wrapper.prop('onClick')()
|
wrapper.prop('onClick')()
|
||||||
assert.equal(onClickSpy.callCount, 1)
|
assert.ok(onClickSpy.calledOnce)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -3,11 +3,9 @@ import assert from 'assert'
|
|||||||
import { shallow } from 'enzyme'
|
import { shallow } from 'enzyme'
|
||||||
import NetworkDropdownIcon from '../components/network-dropdown-icon'
|
import NetworkDropdownIcon from '../components/network-dropdown-icon'
|
||||||
|
|
||||||
describe('Network Dropdown Icon', () => {
|
describe('Network Dropdown Icon', function () {
|
||||||
let wrapper
|
it('adds style props based on props', function () {
|
||||||
|
const wrapper = shallow((
|
||||||
beforeEach(() => {
|
|
||||||
wrapper = shallow((
|
|
||||||
<NetworkDropdownIcon
|
<NetworkDropdownIcon
|
||||||
backgroundColor="red"
|
backgroundColor="red"
|
||||||
isSelected={false}
|
isSelected={false}
|
||||||
@ -15,9 +13,6 @@ describe('Network Dropdown Icon', () => {
|
|||||||
diameter="12"
|
diameter="12"
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
})
|
|
||||||
|
|
||||||
it('adds style props based on props', () => {
|
|
||||||
const styleProp = wrapper.find('.menu-icon-circle').children().prop('style')
|
const styleProp = wrapper.find('.menu-icon-circle').children().prop('style')
|
||||||
assert.equal(styleProp.background, 'red')
|
assert.equal(styleProp.background, 'red')
|
||||||
assert.equal(styleProp.border, 'none')
|
assert.equal(styleProp.border, 'none')
|
||||||
|
@ -6,10 +6,10 @@ import NetworkDropdown from '../network-dropdown'
|
|||||||
import { DropdownMenuItem } from '../components/dropdown'
|
import { DropdownMenuItem } from '../components/dropdown'
|
||||||
import NetworkDropdownIcon from '../components/network-dropdown-icon'
|
import NetworkDropdownIcon from '../components/network-dropdown-icon'
|
||||||
|
|
||||||
describe('Network Dropdown', () => {
|
describe('Network Dropdown', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
describe('NetworkDropdown in appState in false', () => {
|
describe('NetworkDropdown in appState in false', function () {
|
||||||
const mockState = {
|
const mockState = {
|
||||||
metamask: {
|
metamask: {
|
||||||
network: '1',
|
network: '1',
|
||||||
@ -24,23 +24,23 @@ describe('Network Dropdown', () => {
|
|||||||
|
|
||||||
const store = createMockStore(mockState)
|
const store = createMockStore(mockState)
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = mountWithRouter(
|
wrapper = mountWithRouter(
|
||||||
<NetworkDropdown store={store} />
|
<NetworkDropdown store={store} />
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checks for network droppo class', () => {
|
it('checks for network droppo class', function () {
|
||||||
assert.equal(wrapper.find('.network-droppo').length, 1)
|
assert.equal(wrapper.find('.network-droppo').length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders only one child when networkDropdown is false in state', () => {
|
it('renders only one child when networkDropdown is false in state', function () {
|
||||||
assert.equal(wrapper.children().length, 1)
|
assert.equal(wrapper.children().length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('NetworkDropdown in appState is true', () => {
|
describe('NetworkDropdown in appState is true', function () {
|
||||||
const mockState = {
|
const mockState = {
|
||||||
metamask: {
|
metamask: {
|
||||||
network: '1',
|
network: '1',
|
||||||
@ -57,45 +57,45 @@ describe('Network Dropdown', () => {
|
|||||||
}
|
}
|
||||||
const store = createMockStore(mockState)
|
const store = createMockStore(mockState)
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = mountWithRouter(
|
wrapper = mountWithRouter(
|
||||||
<NetworkDropdown store={store} />,
|
<NetworkDropdown store={store} />,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders 7 DropDownMenuItems ', () => {
|
it('renders 7 DropDownMenuItems ', function () {
|
||||||
assert.equal(wrapper.find(DropdownMenuItem).length, 8)
|
assert.equal(wrapper.find(DropdownMenuItem).length, 8)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checks background color for first NetworkDropdownIcon', () => {
|
it('checks background color for first NetworkDropdownIcon', function () {
|
||||||
assert.equal(wrapper.find(NetworkDropdownIcon).at(0).prop('backgroundColor'), '#29B6AF') // Main Ethereum Network Teal
|
assert.equal(wrapper.find(NetworkDropdownIcon).at(0).prop('backgroundColor'), '#29B6AF') // Main Ethereum Network Teal
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checks background color for second NetworkDropdownIcon', () => {
|
it('checks background color for second NetworkDropdownIcon', function () {
|
||||||
assert.equal(wrapper.find(NetworkDropdownIcon).at(1).prop('backgroundColor'), '#ff4a8d') // Ropsten Red
|
assert.equal(wrapper.find(NetworkDropdownIcon).at(1).prop('backgroundColor'), '#ff4a8d') // Ropsten Red
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checks background color for third NetworkDropdownIcon', () => {
|
it('checks background color for third NetworkDropdownIcon', function () {
|
||||||
assert.equal(wrapper.find(NetworkDropdownIcon).at(2).prop('backgroundColor'), '#7057ff') // Kovan Purple
|
assert.equal(wrapper.find(NetworkDropdownIcon).at(2).prop('backgroundColor'), '#7057ff') // Kovan Purple
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checks background color for fourth NetworkDropdownIcon', () => {
|
it('checks background color for fourth NetworkDropdownIcon', function () {
|
||||||
assert.equal(wrapper.find(NetworkDropdownIcon).at(3).prop('backgroundColor'), '#f6c343') // Rinkeby Yellow
|
assert.equal(wrapper.find(NetworkDropdownIcon).at(3).prop('backgroundColor'), '#f6c343') // Rinkeby Yellow
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checks background color for fifth NetworkDropdownIcon', () => {
|
it('checks background color for fifth NetworkDropdownIcon', function () {
|
||||||
assert.equal(wrapper.find(NetworkDropdownIcon).at(4).prop('backgroundColor'), '#3099f2') // Goerli Blue
|
assert.equal(wrapper.find(NetworkDropdownIcon).at(4).prop('backgroundColor'), '#3099f2') // Goerli Blue
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checks background color for sixth NetworkDropdownIcon', () => {
|
it('checks background color for sixth NetworkDropdownIcon', function () {
|
||||||
assert.equal(wrapper.find(NetworkDropdownIcon).at(5).prop('innerBorder'), '1px solid #9b9b9b')
|
assert.equal(wrapper.find(NetworkDropdownIcon).at(5).prop('innerBorder'), '1px solid #9b9b9b')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checks dropdown for frequestRPCList from state ', () => {
|
it('checks dropdown for frequestRPCList from state ', function () {
|
||||||
assert.equal(wrapper.find(DropdownMenuItem).at(6).text(), '✓http://localhost:7545')
|
assert.equal(wrapper.find(DropdownMenuItem).at(6).text(), '✓http://localhost:7545')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('checks background color for seventh NetworkDropdownIcon', () => {
|
it('checks background color for seventh NetworkDropdownIcon', function () {
|
||||||
assert.equal(wrapper.find(NetworkDropdownIcon).at(6).prop('innerBorder'), '1px solid #9b9b9b')
|
assert.equal(wrapper.find(NetworkDropdownIcon).at(6).prop('innerBorder'), '1px solid #9b9b9b')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import sinon from 'sinon'
|
|||||||
import { mount } from 'enzyme'
|
import { mount } from 'enzyme'
|
||||||
import AdvancedTabContent from '../index'
|
import AdvancedTabContent from '../index'
|
||||||
|
|
||||||
describe('Advanced Gas Inputs', () => {
|
describe('Advanced Gas Inputs', function () {
|
||||||
let wrapper, clock
|
let wrapper, clock
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
@ -19,7 +19,7 @@ describe('Advanced Gas Inputs', () => {
|
|||||||
isSpeedUp: false,
|
isSpeedUp: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
clock = sinon.useFakeTimers()
|
clock = sinon.useFakeTimers()
|
||||||
|
|
||||||
wrapper = mount(
|
wrapper = mount(
|
||||||
@ -32,11 +32,11 @@ describe('Advanced Gas Inputs', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
clock.restore()
|
clock.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('wont update gasPrice in props before debounce', () => {
|
it('wont update gasPrice in props before debounce', function () {
|
||||||
const event = { target: { value: 1 } }
|
const event = { target: { value: 1 } }
|
||||||
|
|
||||||
wrapper.find('input').at(0).simulate('change', event)
|
wrapper.find('input').at(0).simulate('change', event)
|
||||||
@ -45,7 +45,7 @@ describe('Advanced Gas Inputs', () => {
|
|||||||
assert.equal(props.updateCustomGasPrice.callCount, 0)
|
assert.equal(props.updateCustomGasPrice.callCount, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('simulates onChange on gas price after debounce', () => {
|
it('simulates onChange on gas price after debounce', function () {
|
||||||
const event = { target: { value: 1 } }
|
const event = { target: { value: 1 } }
|
||||||
|
|
||||||
wrapper.find('input').at(0).simulate('change', event)
|
wrapper.find('input').at(0).simulate('change', event)
|
||||||
@ -55,7 +55,7 @@ describe('Advanced Gas Inputs', () => {
|
|||||||
assert.equal(props.updateCustomGasPrice.calledWith(1), true)
|
assert.equal(props.updateCustomGasPrice.calledWith(1), true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('wont update gasLimit in props before debounce', () => {
|
it('wont update gasLimit in props before debounce', function () {
|
||||||
const event = { target: { value: 21000 } }
|
const event = { target: { value: 21000 } }
|
||||||
|
|
||||||
wrapper.find('input').at(1).simulate('change', event)
|
wrapper.find('input').at(1).simulate('change', event)
|
||||||
@ -64,7 +64,7 @@ describe('Advanced Gas Inputs', () => {
|
|||||||
assert.equal(props.updateCustomGasLimit.callCount, 0)
|
assert.equal(props.updateCustomGasLimit.callCount, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('simulates onChange on gas limit after debounce', () => {
|
it('simulates onChange on gas limit after debounce', function () {
|
||||||
const event = { target: { value: 21000 } }
|
const event = { target: { value: 21000 } }
|
||||||
|
|
||||||
wrapper.find('input').at(1).simulate('change', event)
|
wrapper.find('input').at(1).simulate('change', event)
|
||||||
@ -74,7 +74,7 @@ describe('Advanced Gas Inputs', () => {
|
|||||||
assert.equal(props.updateCustomGasLimit.calledWith(21000), true)
|
assert.equal(props.updateCustomGasLimit.calledWith(21000), true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('errors when insuffientBalance under gas price and gas limit', () => {
|
it('errors when insuffientBalance under gas price and gas limit', function () {
|
||||||
wrapper.setProps({ insufficientBalance: true })
|
wrapper.setProps({ insufficientBalance: true })
|
||||||
const renderError = wrapper.find('.advanced-gas-inputs__gas-edit-row__error-text')
|
const renderError = wrapper.find('.advanced-gas-inputs__gas-edit-row__error-text')
|
||||||
assert.equal(renderError.length, 2)
|
assert.equal(renderError.length, 2)
|
||||||
@ -83,7 +83,7 @@ describe('Advanced Gas Inputs', () => {
|
|||||||
assert.equal(renderError.at(1).text(), 'insufficientBalance')
|
assert.equal(renderError.at(1).text(), 'insufficientBalance')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('errors zero gas price / speed up', () => {
|
it('errors zero gas price / speed up', function () {
|
||||||
wrapper.setProps({ isSpeedUp: true })
|
wrapper.setProps({ isSpeedUp: true })
|
||||||
|
|
||||||
const renderError = wrapper.find('.advanced-gas-inputs__gas-edit-row__error-text')
|
const renderError = wrapper.find('.advanced-gas-inputs__gas-edit-row__error-text')
|
||||||
@ -93,7 +93,7 @@ describe('Advanced Gas Inputs', () => {
|
|||||||
assert.equal(renderError.at(1).text(), 'gasLimitTooLow')
|
assert.equal(renderError.at(1).text(), 'gasLimitTooLow')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('warns when custom gas price is too low', () => {
|
it('warns when custom gas price is too low', function () {
|
||||||
wrapper.setProps({ customPriceIsSafe: false })
|
wrapper.setProps({ customPriceIsSafe: false })
|
||||||
|
|
||||||
const renderWarning = wrapper.find('.advanced-gas-inputs__gas-edit-row__warning-text')
|
const renderWarning = wrapper.find('.advanced-gas-inputs__gas-edit-row__warning-text')
|
||||||
|
@ -17,7 +17,7 @@ sinon.spy(AdvancedTabContent.prototype, 'renderDataSummary')
|
|||||||
describe('AdvancedTabContent Component', function () {
|
describe('AdvancedTabContent Component', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow((
|
wrapper = shallow((
|
||||||
<AdvancedTabContent
|
<AdvancedTabContent
|
||||||
updateCustomGasPrice={propsMethodSpies.updateCustomGasPrice}
|
updateCustomGasPrice={propsMethodSpies.updateCustomGasPrice}
|
||||||
@ -34,18 +34,18 @@ describe('AdvancedTabContent Component', function () {
|
|||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
propsMethodSpies.updateCustomGasPrice.resetHistory()
|
propsMethodSpies.updateCustomGasPrice.resetHistory()
|
||||||
propsMethodSpies.updateCustomGasLimit.resetHistory()
|
propsMethodSpies.updateCustomGasLimit.resetHistory()
|
||||||
AdvancedTabContent.prototype.renderDataSummary.resetHistory()
|
AdvancedTabContent.prototype.renderDataSummary.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('render()', () => {
|
describe('render()', function () {
|
||||||
it('should render the advanced-tab root node', () => {
|
it('should render the advanced-tab root node', function () {
|
||||||
assert(wrapper.hasClass('advanced-tab'))
|
assert(wrapper.hasClass('advanced-tab'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render the expected four children of the advanced-tab div', () => {
|
it('should render the expected four children of the advanced-tab div', function () {
|
||||||
const advancedTabChildren = wrapper.children()
|
const advancedTabChildren = wrapper.children()
|
||||||
assert.equal(advancedTabChildren.length, 2)
|
assert.equal(advancedTabChildren.length, 2)
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ describe('AdvancedTabContent Component', function () {
|
|||||||
assert(feeChartDiv.childAt(1).childAt(2).hasClass('advanced-tab__fee-chart__speed-buttons'))
|
assert(feeChartDiv.childAt(1).childAt(2).hasClass('advanced-tab__fee-chart__speed-buttons'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a loading component instead of the chart if gasEstimatesLoading is true', () => {
|
it('should render a loading component instead of the chart if gasEstimatesLoading is true', function () {
|
||||||
wrapper.setProps({ gasEstimatesLoading: true })
|
wrapper.setProps({ gasEstimatesLoading: true })
|
||||||
const advancedTabChildren = wrapper.children()
|
const advancedTabChildren = wrapper.children()
|
||||||
assert.equal(advancedTabChildren.length, 2)
|
assert.equal(advancedTabChildren.length, 2)
|
||||||
@ -74,31 +74,31 @@ describe('AdvancedTabContent Component', function () {
|
|||||||
assert(feeChartDiv.childAt(1).childAt(2).hasClass('advanced-tab__fee-chart__speed-buttons'))
|
assert(feeChartDiv.childAt(1).childAt(2).hasClass('advanced-tab__fee-chart__speed-buttons'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call renderDataSummary with the expected params', () => {
|
it('should call renderDataSummary with the expected params', function () {
|
||||||
const renderDataSummaryArgs = AdvancedTabContent.prototype.renderDataSummary.getCall(0).args
|
const renderDataSummaryArgs = AdvancedTabContent.prototype.renderDataSummary.getCall(0).args
|
||||||
assert.deepEqual(renderDataSummaryArgs, ['$0.25', 21500])
|
assert.deepEqual(renderDataSummaryArgs, ['$0.25', 21500])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('renderDataSummary()', () => {
|
describe('renderDataSummary()', function () {
|
||||||
let dataSummary
|
let dataSummary
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
dataSummary = shallow(wrapper.instance().renderDataSummary('mockTotalFee', 'mockMsRemaining'))
|
dataSummary = shallow(wrapper.instance().renderDataSummary('mockTotalFee', 'mockMsRemaining'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render the transaction-data-summary root node', () => {
|
it('should render the transaction-data-summary root node', function () {
|
||||||
assert(dataSummary.hasClass('advanced-tab__transaction-data-summary'))
|
assert(dataSummary.hasClass('advanced-tab__transaction-data-summary'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render titles of the data', () => {
|
it('should render titles of the data', function () {
|
||||||
const titlesNode = dataSummary.children().at(0)
|
const titlesNode = dataSummary.children().at(0)
|
||||||
assert(titlesNode.hasClass('advanced-tab__transaction-data-summary__titles'))
|
assert(titlesNode.hasClass('advanced-tab__transaction-data-summary__titles'))
|
||||||
assert.equal(titlesNode.children().at(0).text(), 'newTransactionFee')
|
assert.equal(titlesNode.children().at(0).text(), 'newTransactionFee')
|
||||||
assert.equal(titlesNode.children().at(1).text(), '~transactionTime')
|
assert.equal(titlesNode.children().at(1).text(), '~transactionTime')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render the data', () => {
|
it('should render the data', function () {
|
||||||
const dataNode = dataSummary.children().at(1)
|
const dataNode = dataSummary.children().at(1)
|
||||||
assert(dataNode.hasClass('advanced-tab__transaction-data-summary__container'))
|
assert(dataNode.hasClass('advanced-tab__transaction-data-summary__container'))
|
||||||
assert.equal(dataNode.children().at(0).text(), 'mockTotalFee')
|
assert.equal(dataNode.children().at(0).text(), 'mockTotalFee')
|
||||||
|
@ -2,7 +2,6 @@ import React from 'react'
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import shallow from '../../../../../../../lib/shallow-with-context'
|
import shallow from '../../../../../../../lib/shallow-with-context'
|
||||||
import BasicTabContent from '../basic-tab-content.component'
|
import BasicTabContent from '../basic-tab-content.component'
|
||||||
|
|
||||||
import GasPriceButtonGroup from '../../../gas-price-button-group'
|
import GasPriceButtonGroup from '../../../gas-price-button-group'
|
||||||
import Loading from '../../../../../ui/loading-screen'
|
import Loading from '../../../../../ui/loading-screen'
|
||||||
import { GAS_ESTIMATE_TYPES } from '../../../../../../helpers/constants/common'
|
import { GAS_ESTIMATE_TYPES } from '../../../../../../helpers/constants/common'
|
||||||
@ -39,9 +38,10 @@ const mockGasPriceButtonGroupProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('BasicTabContent Component', function () {
|
describe('BasicTabContent Component', function () {
|
||||||
|
describe('render', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow((
|
wrapper = shallow((
|
||||||
<BasicTabContent
|
<BasicTabContent
|
||||||
gasPriceButtonGroupProps={mockGasPriceButtonGroupProps}
|
gasPriceButtonGroupProps={mockGasPriceButtonGroupProps}
|
||||||
@ -49,16 +49,15 @@ describe('BasicTabContent Component', function () {
|
|||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('render', () => {
|
it('should have a title', function () {
|
||||||
it('should have a title', () => {
|
|
||||||
assert(wrapper.find('.basic-tab-content').childAt(0).hasClass('basic-tab-content__title'))
|
assert(wrapper.find('.basic-tab-content').childAt(0).hasClass('basic-tab-content__title'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a GasPriceButtonGroup compenent', () => {
|
it('should render a GasPriceButtonGroup compenent', function () {
|
||||||
assert.equal(wrapper.find(GasPriceButtonGroup).length, 1)
|
assert.equal(wrapper.find(GasPriceButtonGroup).length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should pass correct props to GasPriceButtonGroup', () => {
|
it('should pass correct props to GasPriceButtonGroup', function () {
|
||||||
const {
|
const {
|
||||||
buttonDataLoading,
|
buttonDataLoading,
|
||||||
className,
|
className,
|
||||||
@ -76,7 +75,7 @@ describe('BasicTabContent Component', function () {
|
|||||||
assert.equal(JSON.stringify(handleGasPriceSelection), JSON.stringify(mockGasPriceButtonGroupProps.handleGasPriceSelection))
|
assert.equal(JSON.stringify(handleGasPriceSelection), JSON.stringify(mockGasPriceButtonGroupProps.handleGasPriceSelection))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a loading component instead of the GasPriceButtonGroup if gasPriceButtonGroupProps.loading is true', () => {
|
it('should render a loading component instead of the GasPriceButtonGroup if gasPriceButtonGroupProps.loading is true', function () {
|
||||||
wrapper.setProps({
|
wrapper.setProps({
|
||||||
gasPriceButtonGroupProps: { ...mockGasPriceButtonGroupProps, loading: true },
|
gasPriceButtonGroupProps: { ...mockGasPriceButtonGroupProps, loading: true },
|
||||||
})
|
})
|
||||||
|
@ -62,7 +62,7 @@ const GP = GasModalPageContainer.prototype
|
|||||||
describe('GasModalPageContainer Component', function () {
|
describe('GasModalPageContainer Component', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow((
|
wrapper = shallow((
|
||||||
<GasModalPageContainer
|
<GasModalPageContainer
|
||||||
cancelAndClose={propsMethodSpies.cancelAndClose}
|
cancelAndClose={propsMethodSpies.cancelAndClose}
|
||||||
@ -84,19 +84,19 @@ describe('GasModalPageContainer Component', function () {
|
|||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
propsMethodSpies.cancelAndClose.resetHistory()
|
propsMethodSpies.cancelAndClose.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('componentDidMount', () => {
|
describe('componentDidMount', function () {
|
||||||
it('should call props.fetchBasicGasAndTimeEstimates', () => {
|
it('should call props.fetchBasicGasAndTimeEstimates', function () {
|
||||||
propsMethodSpies.fetchBasicGasAndTimeEstimates.resetHistory()
|
propsMethodSpies.fetchBasicGasAndTimeEstimates.resetHistory()
|
||||||
assert.equal(propsMethodSpies.fetchBasicGasAndTimeEstimates.callCount, 0)
|
assert.equal(propsMethodSpies.fetchBasicGasAndTimeEstimates.callCount, 0)
|
||||||
wrapper.instance().componentDidMount()
|
wrapper.instance().componentDidMount()
|
||||||
assert.equal(propsMethodSpies.fetchBasicGasAndTimeEstimates.callCount, 1)
|
assert.equal(propsMethodSpies.fetchBasicGasAndTimeEstimates.callCount, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call props.fetchGasEstimates with the block time returned by fetchBasicGasAndTimeEstimates', async () => {
|
it('should call props.fetchGasEstimates with the block time returned by fetchBasicGasAndTimeEstimates', async function () {
|
||||||
propsMethodSpies.fetchGasEstimates.resetHistory()
|
propsMethodSpies.fetchGasEstimates.resetHistory()
|
||||||
assert.equal(propsMethodSpies.fetchGasEstimates.callCount, 0)
|
assert.equal(propsMethodSpies.fetchGasEstimates.callCount, 0)
|
||||||
wrapper.instance().componentDidMount()
|
wrapper.instance().componentDidMount()
|
||||||
@ -106,12 +106,12 @@ describe('GasModalPageContainer Component', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('render', () => {
|
describe('render', function () {
|
||||||
it('should render a PageContainer compenent', () => {
|
it('should render a PageContainer compenent', function () {
|
||||||
assert.equal(wrapper.find(PageContainer).length, 1)
|
assert.equal(wrapper.find(PageContainer).length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should pass correct props to PageContainer', () => {
|
it('should pass correct props to PageContainer', function () {
|
||||||
const {
|
const {
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
@ -122,7 +122,7 @@ describe('GasModalPageContainer Component', function () {
|
|||||||
assert.equal(disabled, false)
|
assert.equal(disabled, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should pass the correct onCancel and onClose methods to PageContainer', () => {
|
it('should pass the correct onCancel and onClose methods to PageContainer', function () {
|
||||||
const {
|
const {
|
||||||
onCancel,
|
onCancel,
|
||||||
onClose,
|
onClose,
|
||||||
@ -134,7 +134,7 @@ describe('GasModalPageContainer Component', function () {
|
|||||||
assert.equal(propsMethodSpies.cancelAndClose.callCount, 2)
|
assert.equal(propsMethodSpies.cancelAndClose.callCount, 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should pass the correct renderTabs property to PageContainer', () => {
|
it('should pass the correct renderTabs property to PageContainer', function () {
|
||||||
sinon.stub(GP, 'renderTabs').returns('mockTabs')
|
sinon.stub(GP, 'renderTabs').returns('mockTabs')
|
||||||
const renderTabsWrapperTester = shallow((
|
const renderTabsWrapperTester = shallow((
|
||||||
<GasModalPageContainer
|
<GasModalPageContainer
|
||||||
@ -148,20 +148,20 @@ describe('GasModalPageContainer Component', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('renderTabs', () => {
|
describe('renderTabs', function () {
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
sinon.spy(GP, 'renderBasicTabContent')
|
sinon.spy(GP, 'renderBasicTabContent')
|
||||||
sinon.spy(GP, 'renderAdvancedTabContent')
|
sinon.spy(GP, 'renderAdvancedTabContent')
|
||||||
sinon.spy(GP, 'renderInfoRows')
|
sinon.spy(GP, 'renderInfoRows')
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
GP.renderBasicTabContent.restore()
|
GP.renderBasicTabContent.restore()
|
||||||
GP.renderAdvancedTabContent.restore()
|
GP.renderAdvancedTabContent.restore()
|
||||||
GP.renderInfoRows.restore()
|
GP.renderInfoRows.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a Tabs component with "Basic" and "Advanced" tabs', () => {
|
it('should render a Tabs component with "Basic" and "Advanced" tabs', function () {
|
||||||
const renderTabsResult = wrapper.instance().renderTabs()
|
const renderTabsResult = wrapper.instance().renderTabs()
|
||||||
const renderedTabs = shallow(renderTabsResult)
|
const renderedTabs = shallow(renderTabsResult)
|
||||||
assert.equal(renderedTabs.props().className, 'tabs')
|
assert.equal(renderedTabs.props().className, 'tabs')
|
||||||
@ -176,7 +176,7 @@ describe('GasModalPageContainer Component', function () {
|
|||||||
assert.equal(tabs.at(1).childAt(0).props().className, 'gas-modal-content')
|
assert.equal(tabs.at(1).childAt(0).props().className, 'gas-modal-content')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call renderInfoRows with the expected props', () => {
|
it('should call renderInfoRows with the expected props', function () {
|
||||||
assert.equal(GP.renderInfoRows.callCount, 0)
|
assert.equal(GP.renderInfoRows.callCount, 0)
|
||||||
|
|
||||||
wrapper.instance().renderTabs()
|
wrapper.instance().renderTabs()
|
||||||
@ -187,7 +187,7 @@ describe('GasModalPageContainer Component', function () {
|
|||||||
assert.deepEqual(GP.renderInfoRows.getCall(1).args, ['mockNewTotalFiat', 'mockNewTotalEth', 'mockSendAmount', 'mockTransactionFee'])
|
assert.deepEqual(GP.renderInfoRows.getCall(1).args, ['mockNewTotalFiat', 'mockNewTotalEth', 'mockSendAmount', 'mockTransactionFee'])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not render the basic tab if hideBasic is true', () => {
|
it('should not render the basic tab if hideBasic is true', function () {
|
||||||
wrapper = shallow((
|
wrapper = shallow((
|
||||||
<GasModalPageContainer
|
<GasModalPageContainer
|
||||||
cancelAndClose={propsMethodSpies.cancelAndClose}
|
cancelAndClose={propsMethodSpies.cancelAndClose}
|
||||||
@ -217,8 +217,8 @@ describe('GasModalPageContainer Component', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('renderBasicTabContent', () => {
|
describe('renderBasicTabContent', function () {
|
||||||
it('should render', () => {
|
it('should render', function () {
|
||||||
const renderBasicTabContentResult = wrapper.instance().renderBasicTabContent(mockGasPriceButtonGroupProps)
|
const renderBasicTabContentResult = wrapper.instance().renderBasicTabContent(mockGasPriceButtonGroupProps)
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@ -228,8 +228,8 @@ describe('GasModalPageContainer Component', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('renderInfoRows', () => {
|
describe('renderInfoRows', function () {
|
||||||
it('should render the info rows with the passed data', () => {
|
it('should render the info rows with the passed data', function () {
|
||||||
const baseClassName = 'gas-modal-content__info-row'
|
const baseClassName = 'gas-modal-content__info-row'
|
||||||
const renderedInfoRowsContainer = shallow(wrapper.instance().renderInfoRows(
|
const renderedInfoRowsContainer = shallow(wrapper.instance().renderInfoRows(
|
||||||
'mockNewTotalFiat',
|
'mockNewTotalFiat',
|
||||||
|
@ -53,10 +53,10 @@ proxyquire('../gas-modal-page-container.container.js', {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('gas-modal-page-container container', () => {
|
describe('gas-modal-page-container container', function () {
|
||||||
|
|
||||||
describe('mapStateToProps()', () => {
|
describe('mapStateToProps()', function () {
|
||||||
it('should map the correct properties to props', () => {
|
it('should map the correct properties to props', function () {
|
||||||
const baseMockState = {
|
const baseMockState = {
|
||||||
appState: {
|
appState: {
|
||||||
modal: {
|
modal: {
|
||||||
@ -257,31 +257,31 @@ describe('gas-modal-page-container container', () => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('mapDispatchToProps()', () => {
|
describe('mapDispatchToProps()', function () {
|
||||||
let dispatchSpy
|
let dispatchSpy
|
||||||
let mapDispatchToPropsObject
|
let mapDispatchToPropsObject
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
dispatchSpy = sinon.spy()
|
dispatchSpy = sinon.spy()
|
||||||
mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy)
|
mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
actionSpies.hideModal.resetHistory()
|
actionSpies.hideModal.resetHistory()
|
||||||
gasActionSpies.setCustomGasPrice.resetHistory()
|
gasActionSpies.setCustomGasPrice.resetHistory()
|
||||||
gasActionSpies.setCustomGasLimit.resetHistory()
|
gasActionSpies.setCustomGasLimit.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('hideGasButtonGroup()', () => {
|
describe('hideGasButtonGroup()', function () {
|
||||||
it('should dispatch a hideGasButtonGroup action', () => {
|
it('should dispatch a hideGasButtonGroup action', function () {
|
||||||
mapDispatchToPropsObject.hideGasButtonGroup()
|
mapDispatchToPropsObject.hideGasButtonGroup()
|
||||||
assert(dispatchSpy.calledOnce)
|
assert(dispatchSpy.calledOnce)
|
||||||
assert(sendActionSpies.hideGasButtonGroup.calledOnce)
|
assert(sendActionSpies.hideGasButtonGroup.calledOnce)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('cancelAndClose()', () => {
|
describe('cancelAndClose()', function () {
|
||||||
it('should dispatch a hideModal action', () => {
|
it('should dispatch a hideModal action', function () {
|
||||||
mapDispatchToPropsObject.cancelAndClose()
|
mapDispatchToPropsObject.cancelAndClose()
|
||||||
assert(dispatchSpy.calledTwice)
|
assert(dispatchSpy.calledTwice)
|
||||||
assert(actionSpies.hideModal.calledOnce)
|
assert(actionSpies.hideModal.calledOnce)
|
||||||
@ -289,17 +289,15 @@ describe('gas-modal-page-container container', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('updateCustomGasPrice()', () => {
|
describe('updateCustomGasPrice()', function () {
|
||||||
it('should dispatch a setCustomGasPrice action with the arg passed to updateCustomGasPrice hex prefixed', () => {
|
it('should dispatch a setCustomGasPrice action with the arg passed to updateCustomGasPrice hex prefixed', function () {
|
||||||
mapDispatchToPropsObject.updateCustomGasPrice('ffff')
|
mapDispatchToPropsObject.updateCustomGasPrice('ffff')
|
||||||
assert(dispatchSpy.calledOnce)
|
assert(dispatchSpy.calledOnce)
|
||||||
assert(gasActionSpies.setCustomGasPrice.calledOnce)
|
assert(gasActionSpies.setCustomGasPrice.calledOnce)
|
||||||
assert.equal(gasActionSpies.setCustomGasPrice.getCall(0).args[0], '0xffff')
|
assert.equal(gasActionSpies.setCustomGasPrice.getCall(0).args[0], '0xffff')
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
describe('updateCustomGasPrice()', () => {
|
it('should dispatch a setCustomGasPrice action', function () {
|
||||||
it('should dispatch a setCustomGasPrice action', () => {
|
|
||||||
mapDispatchToPropsObject.updateCustomGasPrice('0xffff')
|
mapDispatchToPropsObject.updateCustomGasPrice('0xffff')
|
||||||
assert(dispatchSpy.calledOnce)
|
assert(dispatchSpy.calledOnce)
|
||||||
assert(gasActionSpies.setCustomGasPrice.calledOnce)
|
assert(gasActionSpies.setCustomGasPrice.calledOnce)
|
||||||
@ -307,9 +305,8 @@ describe('gas-modal-page-container container', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('updateCustomGasLimit()', function () {
|
||||||
describe('updateCustomGasLimit()', () => {
|
it('should dispatch a setCustomGasLimit action', function () {
|
||||||
it('should dispatch a setCustomGasLimit action', () => {
|
|
||||||
mapDispatchToPropsObject.updateCustomGasLimit('0x10')
|
mapDispatchToPropsObject.updateCustomGasLimit('0x10')
|
||||||
assert(dispatchSpy.calledOnce)
|
assert(dispatchSpy.calledOnce)
|
||||||
assert(gasActionSpies.setCustomGasLimit.calledOnce)
|
assert(gasActionSpies.setCustomGasLimit.calledOnce)
|
||||||
@ -317,8 +314,8 @@ describe('gas-modal-page-container container', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('setGasData()', () => {
|
describe('setGasData()', function () {
|
||||||
it('should dispatch a setGasPrice and setGasLimit action with the correct props', () => {
|
it('should dispatch a setGasPrice and setGasLimit action with the correct props', function () {
|
||||||
mapDispatchToPropsObject.setGasData('ffff', 'aaaa')
|
mapDispatchToPropsObject.setGasData('ffff', 'aaaa')
|
||||||
assert(dispatchSpy.calledTwice)
|
assert(dispatchSpy.calledTwice)
|
||||||
assert(actionSpies.setGasPrice.calledOnce)
|
assert(actionSpies.setGasPrice.calledOnce)
|
||||||
@ -328,8 +325,8 @@ describe('gas-modal-page-container container', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('updateConfirmTxGasAndCalculate()', () => {
|
describe('updateConfirmTxGasAndCalculate()', function () {
|
||||||
it('should dispatch a updateGasAndCalculate action with the correct props', () => {
|
it('should dispatch a updateGasAndCalculate action with the correct props', function () {
|
||||||
mapDispatchToPropsObject.updateConfirmTxGasAndCalculate('ffff', 'aaaa')
|
mapDispatchToPropsObject.updateConfirmTxGasAndCalculate('ffff', 'aaaa')
|
||||||
assert.equal(dispatchSpy.callCount, 3)
|
assert.equal(dispatchSpy.callCount, 3)
|
||||||
assert(actionSpies.setGasPrice.calledOnce)
|
assert(actionSpies.setGasPrice.calledOnce)
|
||||||
@ -341,12 +338,12 @@ describe('gas-modal-page-container container', () => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('mergeProps', () => {
|
describe('mergeProps', function () {
|
||||||
let stateProps
|
let stateProps
|
||||||
let dispatchProps
|
let dispatchProps
|
||||||
let ownProps
|
let ownProps
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
stateProps = {
|
stateProps = {
|
||||||
gasPriceButtonGroupProps: {
|
gasPriceButtonGroupProps: {
|
||||||
someGasPriceButtonGroupProp: 'foo',
|
someGasPriceButtonGroupProp: 'foo',
|
||||||
@ -370,7 +367,7 @@ describe('gas-modal-page-container container', () => {
|
|||||||
ownProps = { someOwnProp: 123 }
|
ownProps = { someOwnProp: 123 }
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
dispatchProps.updateCustomGasPrice.resetHistory()
|
dispatchProps.updateCustomGasPrice.resetHistory()
|
||||||
dispatchProps.hideGasButtonGroup.resetHistory()
|
dispatchProps.hideGasButtonGroup.resetHistory()
|
||||||
dispatchProps.setGasData.resetHistory()
|
dispatchProps.setGasData.resetHistory()
|
||||||
@ -380,7 +377,7 @@ describe('gas-modal-page-container container', () => {
|
|||||||
dispatchProps.hideSidebar.resetHistory()
|
dispatchProps.hideSidebar.resetHistory()
|
||||||
dispatchProps.hideModal.resetHistory()
|
dispatchProps.hideModal.resetHistory()
|
||||||
})
|
})
|
||||||
it('should return the expected props when isConfirm is true', () => {
|
it('should return the expected props when isConfirm is true', function () {
|
||||||
const result = mergeProps(stateProps, dispatchProps, ownProps)
|
const result = mergeProps(stateProps, dispatchProps, ownProps)
|
||||||
|
|
||||||
assert.equal(result.isConfirm, true)
|
assert.equal(result.isConfirm, true)
|
||||||
@ -410,7 +407,7 @@ describe('gas-modal-page-container container', () => {
|
|||||||
assert.equal(dispatchProps.someOtherDispatchProp.callCount, 1)
|
assert.equal(dispatchProps.someOtherDispatchProp.callCount, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return the expected props when isConfirm is false', () => {
|
it('should return the expected props when isConfirm is false', function () {
|
||||||
const result = mergeProps(Object.assign({}, stateProps, { isConfirm: false }), dispatchProps, ownProps)
|
const result = mergeProps(Object.assign({}, stateProps, { isConfirm: false }), dispatchProps, ownProps)
|
||||||
|
|
||||||
assert.equal(result.isConfirm, false)
|
assert.equal(result.isConfirm, false)
|
||||||
@ -441,7 +438,7 @@ describe('gas-modal-page-container container', () => {
|
|||||||
assert.equal(dispatchProps.someOtherDispatchProp.callCount, 1)
|
assert.equal(dispatchProps.someOtherDispatchProp.callCount, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should dispatch the expected actions from obSubmit when isConfirm is false and isSpeedUp is true', () => {
|
it('should dispatch the expected actions from obSubmit when isConfirm is false and isSpeedUp is true', function () {
|
||||||
const result = mergeProps(Object.assign({}, stateProps, { isSpeedUp: true, isConfirm: false }), dispatchProps, ownProps)
|
const result = mergeProps(Object.assign({}, stateProps, { isSpeedUp: true, isConfirm: false }), dispatchProps, ownProps)
|
||||||
|
|
||||||
result.onSubmit()
|
result.onSubmit()
|
||||||
|
@ -47,7 +47,7 @@ sinon.spy(GasPriceButtonGroup.prototype, 'renderButtonContent')
|
|||||||
describe('GasPriceButtonGroup Component', function () {
|
describe('GasPriceButtonGroup Component', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow((
|
wrapper = shallow((
|
||||||
<GasPriceButtonGroup
|
<GasPriceButtonGroup
|
||||||
{...mockGasPriceButtonGroupProps}
|
{...mockGasPriceButtonGroupProps}
|
||||||
@ -55,18 +55,18 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
GasPriceButtonGroup.prototype.renderButton.resetHistory()
|
GasPriceButtonGroup.prototype.renderButton.resetHistory()
|
||||||
GasPriceButtonGroup.prototype.renderButtonContent.resetHistory()
|
GasPriceButtonGroup.prototype.renderButtonContent.resetHistory()
|
||||||
mockGasPriceButtonGroupProps.handleGasPriceSelection.resetHistory()
|
mockGasPriceButtonGroupProps.handleGasPriceSelection.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('render', () => {
|
describe('render', function () {
|
||||||
it('should render a ButtonGroup', () => {
|
it('should render a ButtonGroup', function () {
|
||||||
assert(wrapper.is(ButtonGroup))
|
assert(wrapper.is(ButtonGroup))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render the correct props on the ButtonGroup', () => {
|
it('should render the correct props on the ButtonGroup', function () {
|
||||||
const {
|
const {
|
||||||
className,
|
className,
|
||||||
defaultActiveButtonIndex,
|
defaultActiveButtonIndex,
|
||||||
@ -88,14 +88,14 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should call this.renderButton 3 times, with the correct args', () => {
|
it('should call this.renderButton 3 times, with the correct args', function () {
|
||||||
assert.equal(GasPriceButtonGroup.prototype.renderButton.callCount, 3)
|
assert.equal(GasPriceButtonGroup.prototype.renderButton.callCount, 3)
|
||||||
renderButtonArgsTest(0, mockButtonPropsAndFlags)
|
renderButtonArgsTest(0, mockButtonPropsAndFlags)
|
||||||
renderButtonArgsTest(1, mockButtonPropsAndFlags)
|
renderButtonArgsTest(1, mockButtonPropsAndFlags)
|
||||||
renderButtonArgsTest(2, mockButtonPropsAndFlags)
|
renderButtonArgsTest(2, mockButtonPropsAndFlags)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should show loading if buttonDataLoading', () => {
|
it('should show loading if buttonDataLoading', function () {
|
||||||
wrapper.setProps({ buttonDataLoading: true })
|
wrapper.setProps({ buttonDataLoading: true })
|
||||||
assert(wrapper.is('div'))
|
assert(wrapper.is('div'))
|
||||||
assert(wrapper.hasClass('gas-price-button-group__loading-container'))
|
assert(wrapper.hasClass('gas-price-button-group__loading-container'))
|
||||||
@ -103,10 +103,10 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('renderButton', () => {
|
describe('renderButton', function () {
|
||||||
let wrappedRenderButtonResult
|
let wrappedRenderButtonResult
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
GasPriceButtonGroup.prototype.renderButtonContent.resetHistory()
|
GasPriceButtonGroup.prototype.renderButtonContent.resetHistory()
|
||||||
const renderButtonResult = GasPriceButtonGroup.prototype.renderButton(
|
const renderButtonResult = GasPriceButtonGroup.prototype.renderButton(
|
||||||
Object.assign({}, mockGasPriceButtonGroupProps.gasButtonInfo[0]),
|
Object.assign({}, mockGasPriceButtonGroupProps.gasButtonInfo[0]),
|
||||||
@ -115,11 +115,11 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
wrappedRenderButtonResult = shallow(renderButtonResult)
|
wrappedRenderButtonResult = shallow(renderButtonResult)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a button', () => {
|
it('should render a button', function () {
|
||||||
assert.equal(wrappedRenderButtonResult.type(), 'button')
|
assert.equal(wrappedRenderButtonResult.type(), 'button')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call the correct method when clicked', () => {
|
it('should call the correct method when clicked', function () {
|
||||||
assert.equal(mockGasPriceButtonGroupProps.handleGasPriceSelection.callCount, 0)
|
assert.equal(mockGasPriceButtonGroupProps.handleGasPriceSelection.callCount, 0)
|
||||||
wrappedRenderButtonResult.props().onClick()
|
wrappedRenderButtonResult.props().onClick()
|
||||||
assert.equal(mockGasPriceButtonGroupProps.handleGasPriceSelection.callCount, 1)
|
assert.equal(mockGasPriceButtonGroupProps.handleGasPriceSelection.callCount, 1)
|
||||||
@ -129,7 +129,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call this.renderButtonContent with the correct args', () => {
|
it('should call this.renderButtonContent with the correct args', function () {
|
||||||
assert.equal(GasPriceButtonGroup.prototype.renderButtonContent.callCount, 1)
|
assert.equal(GasPriceButtonGroup.prototype.renderButtonContent.callCount, 1)
|
||||||
const {
|
const {
|
||||||
feeInPrimaryCurrency,
|
feeInPrimaryCurrency,
|
||||||
@ -157,8 +157,8 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('renderButtonContent', () => {
|
describe('renderButtonContent', function () {
|
||||||
it('should render a label if passed a gasEstimateType', () => {
|
it('should render a label if passed a gasEstimateType', function () {
|
||||||
const renderButtonContentResult = wrapper.instance().renderButtonContent({
|
const renderButtonContentResult = wrapper.instance().renderButtonContent({
|
||||||
gasEstimateType: 'SLOW',
|
gasEstimateType: 'SLOW',
|
||||||
}, {
|
}, {
|
||||||
@ -169,7 +169,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
assert.equal(wrappedRenderButtonContentResult.find('.someClass__label').text(), 'slow')
|
assert.equal(wrappedRenderButtonContentResult.find('.someClass__label').text(), 'slow')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a feeInPrimaryCurrency if passed a feeInPrimaryCurrency', () => {
|
it('should render a feeInPrimaryCurrency if passed a feeInPrimaryCurrency', function () {
|
||||||
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent({
|
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent({
|
||||||
feeInPrimaryCurrency: 'mockFeeInPrimaryCurrency',
|
feeInPrimaryCurrency: 'mockFeeInPrimaryCurrency',
|
||||||
}, {
|
}, {
|
||||||
@ -180,7 +180,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
assert.equal(wrappedRenderButtonContentResult.find('.someClass__primary-currency').text(), 'mockFeeInPrimaryCurrency')
|
assert.equal(wrappedRenderButtonContentResult.find('.someClass__primary-currency').text(), 'mockFeeInPrimaryCurrency')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a feeInSecondaryCurrency if passed a feeInSecondaryCurrency', () => {
|
it('should render a feeInSecondaryCurrency if passed a feeInSecondaryCurrency', function () {
|
||||||
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent({
|
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent({
|
||||||
feeInSecondaryCurrency: 'mockFeeInSecondaryCurrency',
|
feeInSecondaryCurrency: 'mockFeeInSecondaryCurrency',
|
||||||
}, {
|
}, {
|
||||||
@ -191,7 +191,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
assert.equal(wrappedRenderButtonContentResult.find('.someClass__secondary-currency').text(), 'mockFeeInSecondaryCurrency')
|
assert.equal(wrappedRenderButtonContentResult.find('.someClass__secondary-currency').text(), 'mockFeeInSecondaryCurrency')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a timeEstimate if passed a timeEstimate', () => {
|
it('should render a timeEstimate if passed a timeEstimate', function () {
|
||||||
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent({
|
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent({
|
||||||
timeEstimate: 'mockTimeEstimate',
|
timeEstimate: 'mockTimeEstimate',
|
||||||
}, {
|
}, {
|
||||||
@ -202,7 +202,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
assert.equal(wrappedRenderButtonContentResult.find('.someClass__time-estimate').text(), 'mockTimeEstimate')
|
assert.equal(wrappedRenderButtonContentResult.find('.someClass__time-estimate').text(), 'mockTimeEstimate')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a check if showCheck is true', () => {
|
it('should render a check if showCheck is true', function () {
|
||||||
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent({}, {
|
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent({}, {
|
||||||
className: 'someClass',
|
className: 'someClass',
|
||||||
showCheck: true,
|
showCheck: true,
|
||||||
@ -211,7 +211,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
assert.equal(wrappedRenderButtonContentResult.find('.fa-check').length, 1)
|
assert.equal(wrappedRenderButtonContentResult.find('.fa-check').length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render all elements if all args passed', () => {
|
it('should render all elements if all args passed', function () {
|
||||||
const renderButtonContentResult = wrapper.instance().renderButtonContent({
|
const renderButtonContentResult = wrapper.instance().renderButtonContent({
|
||||||
gasEstimateType: 'SLOW',
|
gasEstimateType: 'SLOW',
|
||||||
feeInPrimaryCurrency: 'mockFeeInPrimaryCurrency',
|
feeInPrimaryCurrency: 'mockFeeInPrimaryCurrency',
|
||||||
@ -226,7 +226,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
it('should render no elements if all args passed', () => {
|
it('should render no elements if all args passed', function () {
|
||||||
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent({}, {})
|
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent({}, {})
|
||||||
const wrappedRenderButtonContentResult = shallow(renderButtonContentResult)
|
const wrappedRenderButtonContentResult = shallow(renderButtonContentResult)
|
||||||
assert.equal(wrappedRenderButtonContentResult.children().length, 0)
|
assert.equal(wrappedRenderButtonContentResult.children().length, 0)
|
||||||
|
@ -77,37 +77,37 @@ sinon.spy(GasPriceChart.prototype, 'renderChart')
|
|||||||
describe('GasPriceChart Component', function () {
|
describe('GasPriceChart Component', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow(<GasPriceChart {...testProps} />)
|
wrapper = shallow(<GasPriceChart {...testProps} />)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('render()', () => {
|
describe('render()', function () {
|
||||||
it('should render', () => {
|
it('should render', function () {
|
||||||
assert(wrapper.hasClass('gas-price-chart'))
|
assert(wrapper.hasClass('gas-price-chart'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render the chart div', () => {
|
it('should render the chart div', function () {
|
||||||
assert(wrapper.childAt(0).hasClass('gas-price-chart__root'))
|
assert(wrapper.childAt(0).hasClass('gas-price-chart__root'))
|
||||||
assert.equal(wrapper.childAt(0).props().id, 'chart')
|
assert.equal(wrapper.childAt(0).props().id, 'chart')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('componentDidMount', () => {
|
describe('componentDidMount', function () {
|
||||||
it('should call this.renderChart', () => {
|
it('should call this.renderChart', function () {
|
||||||
assert(GasPriceChart.prototype.renderChart.callCount, 1)
|
assert(GasPriceChart.prototype.renderChart.callCount, 1)
|
||||||
wrapper.instance().componentDidMount()
|
wrapper.instance().componentDidMount()
|
||||||
assert(GasPriceChart.prototype.renderChart.callCount, 2)
|
assert(GasPriceChart.prototype.renderChart.callCount, 2)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('componentDidUpdate', () => {
|
describe('componentDidUpdate', function () {
|
||||||
it('should call handleChartUpdate if props.currentPrice has changed', () => {
|
it('should call handleChartUpdate if props.currentPrice has changed', function () {
|
||||||
gasPriceChartUtilsSpies.handleChartUpdate.resetHistory()
|
gasPriceChartUtilsSpies.handleChartUpdate.resetHistory()
|
||||||
wrapper.instance().componentDidUpdate({ currentPrice: 7 })
|
wrapper.instance().componentDidUpdate({ currentPrice: 7 })
|
||||||
assert.equal(gasPriceChartUtilsSpies.handleChartUpdate.callCount, 1)
|
assert.equal(gasPriceChartUtilsSpies.handleChartUpdate.callCount, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call handleChartUpdate with the correct props', () => {
|
it('should call handleChartUpdate with the correct props', function () {
|
||||||
gasPriceChartUtilsSpies.handleChartUpdate.resetHistory()
|
gasPriceChartUtilsSpies.handleChartUpdate.resetHistory()
|
||||||
wrapper.instance().componentDidUpdate({ currentPrice: 7 })
|
wrapper.instance().componentDidUpdate({ currentPrice: 7 })
|
||||||
assert.deepEqual(gasPriceChartUtilsSpies.handleChartUpdate.getCall(0).args, [{
|
assert.deepEqual(gasPriceChartUtilsSpies.handleChartUpdate.getCall(0).args, [{
|
||||||
@ -118,15 +118,15 @@ describe('GasPriceChart Component', function () {
|
|||||||
}])
|
}])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not call handleChartUpdate if props.currentPrice has not changed', () => {
|
it('should not call handleChartUpdate if props.currentPrice has not changed', function () {
|
||||||
gasPriceChartUtilsSpies.handleChartUpdate.resetHistory()
|
gasPriceChartUtilsSpies.handleChartUpdate.resetHistory()
|
||||||
wrapper.instance().componentDidUpdate({ currentPrice: 6 })
|
wrapper.instance().componentDidUpdate({ currentPrice: 6 })
|
||||||
assert.equal(gasPriceChartUtilsSpies.handleChartUpdate.callCount, 0)
|
assert.equal(gasPriceChartUtilsSpies.handleChartUpdate.callCount, 0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('renderChart', () => {
|
describe('renderChart', function () {
|
||||||
it('should call setTickPosition 4 times, with the expected props', async () => {
|
it('should call setTickPosition 4 times, with the expected props', async function () {
|
||||||
await timeout(0)
|
await timeout(0)
|
||||||
gasPriceChartUtilsSpies.setTickPosition.resetHistory()
|
gasPriceChartUtilsSpies.setTickPosition.resetHistory()
|
||||||
assert.equal(gasPriceChartUtilsSpies.setTickPosition.callCount, 0)
|
assert.equal(gasPriceChartUtilsSpies.setTickPosition.callCount, 0)
|
||||||
@ -139,7 +139,7 @@ describe('GasPriceChart Component', function () {
|
|||||||
assert.deepEqual(gasPriceChartUtilsSpies.setTickPosition.getCall(3).args, ['x', 1, 3, -8])
|
assert.deepEqual(gasPriceChartUtilsSpies.setTickPosition.getCall(3).args, ['x', 1, 3, -8])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call handleChartUpdate with the correct props', async () => {
|
it('should call handleChartUpdate with the correct props', async function () {
|
||||||
await timeout(0)
|
await timeout(0)
|
||||||
gasPriceChartUtilsSpies.handleChartUpdate.resetHistory()
|
gasPriceChartUtilsSpies.handleChartUpdate.resetHistory()
|
||||||
wrapper.instance().renderChart(testProps)
|
wrapper.instance().renderChart(testProps)
|
||||||
@ -152,7 +152,7 @@ describe('GasPriceChart Component', function () {
|
|||||||
}])
|
}])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should add three events to the chart', async () => {
|
it('should add three events to the chart', async function () {
|
||||||
await timeout(0)
|
await timeout(0)
|
||||||
selectReturnSpies.on.resetHistory()
|
selectReturnSpies.on.resetHistory()
|
||||||
assert.equal(selectReturnSpies.on.callCount, 0)
|
assert.equal(selectReturnSpies.on.callCount, 0)
|
||||||
@ -168,7 +168,7 @@ describe('GasPriceChart Component', function () {
|
|||||||
assert.equal(thirdOnEventArgs[0], 'mousemove')
|
assert.equal(thirdOnEventArgs[0], 'mousemove')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should hide the data UI on mouseout', async () => {
|
it('should hide the data UI on mouseout', async function () {
|
||||||
await timeout(0)
|
await timeout(0)
|
||||||
selectReturnSpies.on.resetHistory()
|
selectReturnSpies.on.resetHistory()
|
||||||
wrapper.instance().renderChart(testProps)
|
wrapper.instance().renderChart(testProps)
|
||||||
@ -181,7 +181,7 @@ describe('GasPriceChart Component', function () {
|
|||||||
assert.deepEqual(gasPriceChartUtilsSpies.hideDataUI.getCall(0).args, [{ mockChart: true }, '#overlayed-circle'])
|
assert.deepEqual(gasPriceChartUtilsSpies.hideDataUI.getCall(0).args, [{ mockChart: true }, '#overlayed-circle'])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should updateCustomGasPrice on click', async () => {
|
it('should updateCustomGasPrice on click', async function () {
|
||||||
await timeout(0)
|
await timeout(0)
|
||||||
selectReturnSpies.on.resetHistory()
|
selectReturnSpies.on.resetHistory()
|
||||||
wrapper.instance().renderChart(testProps)
|
wrapper.instance().renderChart(testProps)
|
||||||
@ -194,7 +194,7 @@ describe('GasPriceChart Component', function () {
|
|||||||
assert.equal(propsMethodSpies.updateCustomGasPrice.getCall(0).args[0], 'mockX')
|
assert.equal(propsMethodSpies.updateCustomGasPrice.getCall(0).args[0], 'mockX')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should handle mousemove', async () => {
|
it('should handle mousemove', async function () {
|
||||||
await timeout(0)
|
await timeout(0)
|
||||||
selectReturnSpies.on.resetHistory()
|
selectReturnSpies.on.resetHistory()
|
||||||
wrapper.instance().renderChart(testProps)
|
wrapper.instance().renderChart(testProps)
|
||||||
|
@ -5,7 +5,7 @@ import { shallow } from 'enzyme'
|
|||||||
|
|
||||||
import InfoBox from '../index'
|
import InfoBox from '../index'
|
||||||
|
|
||||||
describe('InfoBox', () => {
|
describe('InfoBox', function () {
|
||||||
|
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
@ -15,21 +15,21 @@ describe('InfoBox', () => {
|
|||||||
onClose: sinon.spy(),
|
onClose: sinon.spy(),
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow(<InfoBox {...props} />)
|
wrapper = shallow(<InfoBox {...props} />)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders title from props', () => {
|
it('renders title from props', function () {
|
||||||
const title = wrapper.find('.info-box__title')
|
const title = wrapper.find('.info-box__title')
|
||||||
assert.equal(title.text(), props.title)
|
assert.equal(title.text(), props.title)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders description from props', () => {
|
it('renders description from props', function () {
|
||||||
const description = wrapper.find('.info-box__description')
|
const description = wrapper.find('.info-box__description')
|
||||||
assert.equal(description.text(), props.description)
|
assert.equal(description.text(), props.description)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('closes info box', () => {
|
it('closes info box', function () {
|
||||||
const close = wrapper.find('.info-box__close')
|
const close = wrapper.find('.info-box__close')
|
||||||
close.simulate('click')
|
close.simulate('click')
|
||||||
assert(props.onClose.calledOnce)
|
assert(props.onClose.calledOnce)
|
||||||
|
@ -6,7 +6,7 @@ import { mountWithRouter } from '../../../../../../test/lib/render-helpers'
|
|||||||
import MenuBar from '../index'
|
import MenuBar from '../index'
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
|
|
||||||
describe('MenuBar', () => {
|
describe('MenuBar', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const mockStore = {
|
const mockStore = {
|
||||||
@ -38,11 +38,11 @@ describe('MenuBar', () => {
|
|||||||
|
|
||||||
const store = configureStore()(mockStore)
|
const store = configureStore()(mockStore)
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
sinon.restore()
|
sinon.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows side bar when sidbarOpen is set to false', () => {
|
it('shows side bar when sidbarOpen is set to false', function () {
|
||||||
const props = {
|
const props = {
|
||||||
showSidebar: sinon.spy(),
|
showSidebar: sinon.spy(),
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ describe('MenuBar', () => {
|
|||||||
assert(props.showSidebar.calledOnce)
|
assert(props.showSidebar.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('hides side when sidebarOpen is set to true', () => {
|
it('hides side when sidebarOpen is set to true', function () {
|
||||||
const props = {
|
const props = {
|
||||||
showSidebar: sinon.spy(),
|
showSidebar: sinon.spy(),
|
||||||
hideSidebar: sinon.spy(),
|
hideSidebar: sinon.spy(),
|
||||||
@ -76,13 +76,13 @@ describe('MenuBar', () => {
|
|||||||
assert(props.hideSidebar.calledOnce)
|
assert(props.hideSidebar.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens account detail menu when account options is clicked', () => {
|
it('opens account detail menu when account options is clicked', function () {
|
||||||
const accountOptions = wrapper.find('.menu-bar__open-in-browser')
|
const accountOptions = wrapper.find('.menu-bar__open-in-browser')
|
||||||
accountOptions.simulate('click')
|
accountOptions.simulate('click')
|
||||||
assert.equal(wrapper.find('MenuBar').instance().state.accountDetailsMenuOpen, true)
|
assert.equal(wrapper.find('MenuBar').instance().state.accountDetailsMenuOpen, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets accountDetailsMenuOpen to false when closed', () => {
|
it('sets accountDetailsMenuOpen to false when closed', function () {
|
||||||
wrapper.find('MenuBar').instance().setState({ accountDetailsMenuOpen: true })
|
wrapper.find('MenuBar').instance().setState({ accountDetailsMenuOpen: true })
|
||||||
wrapper.update()
|
wrapper.update()
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ import assert from 'assert'
|
|||||||
import { shallow } from 'enzyme'
|
import { shallow } from 'enzyme'
|
||||||
import ModalContent from '../modal-content.component'
|
import ModalContent from '../modal-content.component'
|
||||||
|
|
||||||
describe('ModalContent Component', () => {
|
describe('ModalContent Component', function () {
|
||||||
it('should render a title', () => {
|
it('should render a title', function () {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title="Modal Title"
|
title="Modal Title"
|
||||||
@ -16,7 +16,7 @@ describe('ModalContent Component', () => {
|
|||||||
assert.equal(wrapper.find('.modal-content__description').length, 0)
|
assert.equal(wrapper.find('.modal-content__description').length, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a description', () => {
|
it('should render a description', function () {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ModalContent
|
<ModalContent
|
||||||
description="Modal Description"
|
description="Modal Description"
|
||||||
@ -28,7 +28,7 @@ describe('ModalContent Component', () => {
|
|||||||
assert.equal(wrapper.find('.modal-content__description').text(), 'Modal Description')
|
assert.equal(wrapper.find('.modal-content__description').text(), 'Modal Description')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render both a title and a description', () => {
|
it('should render both a title and a description', function () {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title="Modal Title"
|
title="Modal Title"
|
||||||
|
@ -5,8 +5,8 @@ import sinon from 'sinon'
|
|||||||
import Modal from '../modal.component'
|
import Modal from '../modal.component'
|
||||||
import Button from '../../../ui/button'
|
import Button from '../../../ui/button'
|
||||||
|
|
||||||
describe('Modal Component', () => {
|
describe('Modal Component', function () {
|
||||||
it('should render a modal with a submit button', () => {
|
it('should render a modal with a submit button', function () {
|
||||||
const wrapper = shallow(<Modal />)
|
const wrapper = shallow(<Modal />)
|
||||||
|
|
||||||
assert.equal(wrapper.find('.modal-container').length, 1)
|
assert.equal(wrapper.find('.modal-container').length, 1)
|
||||||
@ -15,7 +15,7 @@ describe('Modal Component', () => {
|
|||||||
assert.equal(buttons.at(0).props().type, 'secondary')
|
assert.equal(buttons.at(0).props().type, 'secondary')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a modal with a cancel and a submit button', () => {
|
it('should render a modal with a cancel and a submit button', function () {
|
||||||
const handleCancel = sinon.spy()
|
const handleCancel = sinon.spy()
|
||||||
const handleSubmit = sinon.spy()
|
const handleSubmit = sinon.spy()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
@ -45,7 +45,7 @@ describe('Modal Component', () => {
|
|||||||
assert.equal(handleSubmit.callCount, 1)
|
assert.equal(handleSubmit.callCount, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a modal with different button types', () => {
|
it('should render a modal with different button types', function () {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<Modal
|
<Modal
|
||||||
onCancel={() => {}}
|
onCancel={() => {}}
|
||||||
@ -63,7 +63,7 @@ describe('Modal Component', () => {
|
|||||||
assert.equal(buttons.at(1).props().type, 'confirm')
|
assert.equal(buttons.at(1).props().type, 'confirm')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a modal with children', () => {
|
it('should render a modal with children', function () {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<Modal
|
<Modal
|
||||||
onCancel={() => {}}
|
onCancel={() => {}}
|
||||||
@ -78,7 +78,7 @@ describe('Modal Component', () => {
|
|||||||
assert.ok(wrapper.find('.test-class'))
|
assert.ok(wrapper.find('.test-class'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a modal with a header', () => {
|
it('should render a modal with a header', function () {
|
||||||
const handleCancel = sinon.spy()
|
const handleCancel = sinon.spy()
|
||||||
const handleSubmit = sinon.spy()
|
const handleSubmit = sinon.spy()
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
@ -101,7 +101,7 @@ describe('Modal Component', () => {
|
|||||||
assert.equal(handleSubmit.callCount, 0)
|
assert.equal(handleSubmit.callCount, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should disable the submit button if submitDisabled is true', () => {
|
it('should disable the submit button if submitDisabled is true', function () {
|
||||||
const handleCancel = sinon.spy()
|
const handleCancel = sinon.spy()
|
||||||
const handleSubmit = sinon.spy()
|
const handleSubmit = sinon.spy()
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
|
@ -4,8 +4,8 @@ import { shallow } from 'enzyme'
|
|||||||
import CancelTransactionGasFee from '../cancel-transaction-gas-fee.component'
|
import CancelTransactionGasFee from '../cancel-transaction-gas-fee.component'
|
||||||
import UserPreferencedCurrencyDisplay from '../../../../user-preferenced-currency-display'
|
import UserPreferencedCurrencyDisplay from '../../../../user-preferenced-currency-display'
|
||||||
|
|
||||||
describe('CancelTransactionGasFee Component', () => {
|
describe('CancelTransactionGasFee Component', function () {
|
||||||
it('should render', () => {
|
it('should render', function () {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<CancelTransactionGasFee
|
<CancelTransactionGasFee
|
||||||
value="0x3b9aca00"
|
value="0x3b9aca00"
|
||||||
|
@ -6,10 +6,10 @@ import CancelTransaction from '../cancel-transaction.component'
|
|||||||
import CancelTransactionGasFee from '../cancel-transaction-gas-fee'
|
import CancelTransactionGasFee from '../cancel-transaction-gas-fee'
|
||||||
import Modal from '../../../modal'
|
import Modal from '../../../modal'
|
||||||
|
|
||||||
describe('CancelTransaction Component', () => {
|
describe('CancelTransaction Component', function () {
|
||||||
const t = key => key
|
const t = key => key
|
||||||
|
|
||||||
it('should render a CancelTransaction modal', () => {
|
it('should render a CancelTransaction modal', function () {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<CancelTransaction
|
<CancelTransaction
|
||||||
newGasFee="0x1319718a5000"
|
newGasFee="0x1319718a5000"
|
||||||
@ -25,7 +25,7 @@ describe('CancelTransaction Component', () => {
|
|||||||
assert.equal(wrapper.find('.cancel-transaction__description').text(), 'attemptToCancelDescription')
|
assert.equal(wrapper.find('.cancel-transaction__description').text(), 'attemptToCancelDescription')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should pass the correct props to the Modal component', async () => {
|
it('should pass the correct props to the Modal component', async function () {
|
||||||
const createCancelTransactionSpy = sinon.stub().callsFake(() => Promise.resolve())
|
const createCancelTransactionSpy = sinon.stub().callsFake(() => Promise.resolve())
|
||||||
const hideModalSpy = sinon.spy()
|
const hideModalSpy = sinon.spy()
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import sinon from 'sinon'
|
|||||||
import { mount } from 'enzyme'
|
import { mount } from 'enzyme'
|
||||||
import ConfirmDeleteNetwork from '../index'
|
import ConfirmDeleteNetwork from '../index'
|
||||||
|
|
||||||
describe('Confirm Delete Network', () => {
|
describe('Confirm Delete Network', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
@ -14,7 +14,7 @@ describe('Confirm Delete Network', () => {
|
|||||||
target: '',
|
target: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = mount(
|
wrapper = mount(
|
||||||
<ConfirmDeleteNetwork.WrappedComponent {...props} />, {
|
<ConfirmDeleteNetwork.WrappedComponent {...props} />, {
|
||||||
context: {
|
context: {
|
||||||
@ -24,18 +24,18 @@ describe('Confirm Delete Network', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
props.hideModal.resetHistory()
|
props.hideModal.resetHistory()
|
||||||
props.delRpcTarget.resetHistory()
|
props.delRpcTarget.resetHistory()
|
||||||
props.onConfirm.resetHistory()
|
props.onConfirm.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders delete network modal title', () => {
|
it('renders delete network modal title', function () {
|
||||||
const modalTitle = wrapper.find('.modal-content__title')
|
const modalTitle = wrapper.find('.modal-content__title')
|
||||||
assert.equal(modalTitle.text(), 'deleteNetwork')
|
assert.equal(modalTitle.text(), 'deleteNetwork')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks cancel to hide modal', () => {
|
it('clicks cancel to hide modal', function () {
|
||||||
const cancelButton = wrapper.find('.button.btn-default.modal-container__footer-button')
|
const cancelButton = wrapper.find('.button.btn-default.modal-container__footer-button')
|
||||||
cancelButton.simulate('click')
|
cancelButton.simulate('click')
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ describe('Confirm Delete Network', () => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks delete to delete the target and hides modal', () => {
|
it('clicks delete to delete the target and hides modal', function () {
|
||||||
const deleteButton = wrapper.find('.button.btn-danger.modal-container__footer-button')
|
const deleteButton = wrapper.find('.button.btn-danger.modal-container__footer-button')
|
||||||
|
|
||||||
deleteButton.simulate('click')
|
deleteButton.simulate('click')
|
||||||
|
@ -7,7 +7,7 @@ import configureStore from 'redux-mock-store'
|
|||||||
import { mount } from 'enzyme'
|
import { mount } from 'enzyme'
|
||||||
import ConfirmRemoveAccount from '../index'
|
import ConfirmRemoveAccount from '../index'
|
||||||
|
|
||||||
describe('Confirm Remove Account', () => {
|
describe('Confirm Remove Account', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
@ -30,7 +30,7 @@ describe('Confirm Remove Account', () => {
|
|||||||
const mockStore = configureStore()
|
const mockStore = configureStore()
|
||||||
const store = mockStore(state)
|
const store = mockStore(state)
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
|
|
||||||
wrapper = mount(
|
wrapper = mount(
|
||||||
<Provider store={store} >
|
<Provider store={store} >
|
||||||
@ -48,18 +48,18 @@ describe('Confirm Remove Account', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
props.hideModal.resetHistory()
|
props.hideModal.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('nevermind', () => {
|
it('nevermind', function () {
|
||||||
const nevermind = wrapper.find({ type: 'default' })
|
const nevermind = wrapper.find({ type: 'default' })
|
||||||
nevermind.simulate('click')
|
nevermind.simulate('click')
|
||||||
|
|
||||||
assert(props.hideModal.calledOnce)
|
assert(props.hideModal.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('remove', (done) => {
|
it('remove', function (done) {
|
||||||
const remove = wrapper.find({ type: 'secondary' })
|
const remove = wrapper.find({ type: 'secondary' })
|
||||||
remove.simulate('click')
|
remove.simulate('click')
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ describe('Confirm Remove Account', () => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('closes', () => {
|
it('closes', function () {
|
||||||
const close = wrapper.find('.modal-container__header-close')
|
const close = wrapper.find('.modal-container__header-close')
|
||||||
close.simulate('click')
|
close.simulate('click')
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import sinon from 'sinon'
|
|||||||
import { mount } from 'enzyme'
|
import { mount } from 'enzyme'
|
||||||
import ConfirmResetAccount from '../index'
|
import ConfirmResetAccount from '../index'
|
||||||
|
|
||||||
describe('Confirm Reset Account', () => {
|
describe('Confirm Reset Account', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
@ -12,7 +12,7 @@ describe('Confirm Reset Account', () => {
|
|||||||
resetAccount: sinon.stub().resolves(),
|
resetAccount: sinon.stub().resolves(),
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = mount(
|
wrapper = mount(
|
||||||
<ConfirmResetAccount.WrappedComponent {...props} />, {
|
<ConfirmResetAccount.WrappedComponent {...props} />, {
|
||||||
context: {
|
context: {
|
||||||
@ -22,18 +22,18 @@ describe('Confirm Reset Account', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
props.hideModal.resetHistory()
|
props.hideModal.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('hides modal when nevermind button is clicked', () => {
|
it('hides modal when nevermind button is clicked', function () {
|
||||||
const nevermind = wrapper.find('.btn-default.modal-container__footer-button')
|
const nevermind = wrapper.find('.btn-default.modal-container__footer-button')
|
||||||
nevermind.simulate('click')
|
nevermind.simulate('click')
|
||||||
|
|
||||||
assert(props.hideModal.calledOnce)
|
assert(props.hideModal.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('resets account and hidels modal when reset button is clicked', (done) => {
|
it('resets account and hidels modal when reset button is clicked', function (done) {
|
||||||
const reset = wrapper.find('.btn-danger.modal-container__footer-button')
|
const reset = wrapper.find('.btn-danger.modal-container__footer-button')
|
||||||
reset.simulate('click')
|
reset.simulate('click')
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import sinon from 'sinon'
|
|||||||
import { mount } from 'enzyme'
|
import { mount } from 'enzyme'
|
||||||
import MetaMetricsOptIn from '../index'
|
import MetaMetricsOptIn from '../index'
|
||||||
|
|
||||||
describe('MetaMetrics Opt In', () => {
|
describe('MetaMetrics Opt In', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
@ -13,7 +13,7 @@ describe('MetaMetrics Opt In', () => {
|
|||||||
participateInMetaMetrics: null,
|
participateInMetaMetrics: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = mount(
|
wrapper = mount(
|
||||||
<MetaMetricsOptIn.WrappedComponent {...props} />, {
|
<MetaMetricsOptIn.WrappedComponent {...props} />, {
|
||||||
context: {
|
context: {
|
||||||
@ -23,12 +23,12 @@ describe('MetaMetrics Opt In', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
props.setParticipateInMetaMetrics.resetHistory()
|
props.setParticipateInMetaMetrics.resetHistory()
|
||||||
props.hideModal.resetHistory()
|
props.hideModal.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('passes false to setParticipateInMetaMetrics and hides modal', (done) => {
|
it('passes false to setParticipateInMetaMetrics and hides modal', function (done) {
|
||||||
const noThanks = wrapper.find('.btn-default.page-container__footer-button')
|
const noThanks = wrapper.find('.btn-default.page-container__footer-button')
|
||||||
noThanks.simulate('click')
|
noThanks.simulate('click')
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ describe('MetaMetrics Opt In', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('passes true to setParticipateInMetaMetrics and hides modal', (done) => {
|
it('passes true to setParticipateInMetaMetrics and hides modal', function (done) {
|
||||||
const iAgree = wrapper.find('.btn-primary.page-container__footer-button')
|
const iAgree = wrapper.find('.btn-primary.page-container__footer-button')
|
||||||
iAgree.simulate('click')
|
iAgree.simulate('click')
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import sinon from 'sinon'
|
|||||||
import { mount } from 'enzyme'
|
import { mount } from 'enzyme'
|
||||||
import RejectTransactionsModal from '../index'
|
import RejectTransactionsModal from '../index'
|
||||||
|
|
||||||
describe('Reject Transactions Model', () => {
|
describe('Reject Transactions Model', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
@ -13,7 +13,7 @@ describe('Reject Transactions Model', () => {
|
|||||||
unapprovedTxCount: 2,
|
unapprovedTxCount: 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = mount(
|
wrapper = mount(
|
||||||
<RejectTransactionsModal.WrappedComponent {...props} />, {
|
<RejectTransactionsModal.WrappedComponent {...props} />, {
|
||||||
context: {
|
context: {
|
||||||
@ -23,18 +23,18 @@ describe('Reject Transactions Model', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
props.hideModal.resetHistory()
|
props.hideModal.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('hides modal when cancel button is clicked', () => {
|
it('hides modal when cancel button is clicked', function () {
|
||||||
const cancelButton = wrapper.find('.btn-default.modal-container__footer-button')
|
const cancelButton = wrapper.find('.btn-default.modal-container__footer-button')
|
||||||
cancelButton.simulate('click')
|
cancelButton.simulate('click')
|
||||||
|
|
||||||
assert(props.hideModal.calledOnce)
|
assert(props.hideModal.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('onSubmit is called and hides modal when reject all clicked', (done) => {
|
it('onSubmit is called and hides modal when reject all clicked', function (done) {
|
||||||
const rejectAllButton = wrapper.find('.btn-secondary.modal-container__footer-button')
|
const rejectAllButton = wrapper.find('.btn-secondary.modal-container__footer-button')
|
||||||
rejectAllButton.simulate('click')
|
rejectAllButton.simulate('click')
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import sinon from 'sinon'
|
|||||||
import { shallow } from 'enzyme'
|
import { shallow } from 'enzyme'
|
||||||
import AccountDetailsModal from '../account-details-modal'
|
import AccountDetailsModal from '../account-details-modal'
|
||||||
|
|
||||||
describe('Account Details Modal', () => {
|
describe('Account Details Modal', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
global.platform = { openWindow: sinon.spy() }
|
global.platform = { openWindow: sinon.spy() }
|
||||||
@ -36,7 +36,7 @@ describe('Account Details Modal', () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<AccountDetailsModal.WrappedComponent {...props} />, {
|
<AccountDetailsModal.WrappedComponent {...props} />, {
|
||||||
context: {
|
context: {
|
||||||
@ -46,7 +46,7 @@ describe('Account Details Modal', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets account label when changing default account label', () => {
|
it('sets account label when changing default account label', function () {
|
||||||
const accountLabel = wrapper.find('.account-modal__name').first()
|
const accountLabel = wrapper.find('.account-modal__name').first()
|
||||||
accountLabel.simulate('submit', 'New Label')
|
accountLabel.simulate('submit', 'New Label')
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ describe('Account Details Modal', () => {
|
|||||||
assert.equal(props.setAccountLabel.getCall(0).args[1], 'New Label')
|
assert.equal(props.setAccountLabel.getCall(0).args[1], 'New Label')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens new window when view block explorer is clicked', () => {
|
it('opens new window when view block explorer is clicked', function () {
|
||||||
const modalButton = wrapper.find('.account-modal__button')
|
const modalButton = wrapper.find('.account-modal__button')
|
||||||
const etherscanLink = modalButton.first()
|
const etherscanLink = modalButton.first()
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ describe('Account Details Modal', () => {
|
|||||||
assert(global.platform.openWindow.calledOnce)
|
assert(global.platform.openWindow.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows export private key modal when clicked', () => {
|
it('shows export private key modal when clicked', function () {
|
||||||
const modalButton = wrapper.find('.account-modal__button')
|
const modalButton = wrapper.find('.account-modal__button')
|
||||||
const etherscanLink = modalButton.last()
|
const etherscanLink = modalButton.last()
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ describe('Account Details Modal', () => {
|
|||||||
assert(props.showExportPrivateKeyModal.calledOnce)
|
assert(props.showExportPrivateKeyModal.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets blockexplorerview text when block explorer url in rpcPrefs exists', () => {
|
it('sets blockexplorerview text when block explorer url in rpcPrefs exists', function () {
|
||||||
const blockExplorerUrl = 'https://block.explorer'
|
const blockExplorerUrl = 'https://block.explorer'
|
||||||
wrapper.setProps({ rpcPrefs: { blockExplorerUrl } })
|
wrapper.setProps({ rpcPrefs: { blockExplorerUrl } })
|
||||||
|
|
||||||
|
@ -4,25 +4,19 @@ import sinon from 'sinon'
|
|||||||
import { mount } from 'enzyme'
|
import { mount } from 'enzyme'
|
||||||
import TransactionConfirmed from '../index'
|
import TransactionConfirmed from '../index'
|
||||||
|
|
||||||
describe('Transaction Confirmed', () => {
|
describe('Transaction Confirmed', function () {
|
||||||
let wrapper
|
it('clicks ok to submit and hide modal', function () {
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
onSubmit: sinon.spy(),
|
onSubmit: sinon.spy(),
|
||||||
hideModal: sinon.spy(),
|
hideModal: sinon.spy(),
|
||||||
}
|
}
|
||||||
|
const wrapper = mount(
|
||||||
beforeEach(() => {
|
|
||||||
wrapper = mount(
|
|
||||||
<TransactionConfirmed.WrappedComponent {...props} />, {
|
<TransactionConfirmed.WrappedComponent {...props} />, {
|
||||||
context: {
|
context: {
|
||||||
t: str => str,
|
t: str => str,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
|
||||||
|
|
||||||
it('clicks ok to submit and hide modal', () => {
|
|
||||||
const submit = wrapper.find('.btn-secondary.modal-container__footer-button')
|
const submit = wrapper.find('.btn-secondary.modal-container__footer-button')
|
||||||
submit.simulate('click')
|
submit.simulate('click')
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ import assert from 'assert'
|
|||||||
import { render } from 'enzyme'
|
import { render } from 'enzyme'
|
||||||
import SelectedAccount from '../selected-account.component'
|
import SelectedAccount from '../selected-account.component'
|
||||||
|
|
||||||
describe('SelectedAccount Component', () => {
|
describe('SelectedAccount Component', function () {
|
||||||
it('should render checksummed address', () => {
|
it('should render checksummed address', function () {
|
||||||
const wrapper = render((
|
const wrapper = render((
|
||||||
<SelectedAccount
|
<SelectedAccount
|
||||||
selectedAddress="0x1b82543566f41a7db9a9a75fc933c340ffb55c9d"
|
selectedAddress="0x1b82543566f41a7db9a9a75fc933c340ffb55c9d"
|
||||||
|
@ -15,7 +15,7 @@ const propsMethodSpies = {
|
|||||||
describe('Sidebar Component', function () {
|
describe('Sidebar Component', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = shallow((
|
wrapper = shallow((
|
||||||
<Sidebar
|
<Sidebar
|
||||||
sidebarOpen={false}
|
sidebarOpen={false}
|
||||||
@ -26,43 +26,43 @@ describe('Sidebar Component', function () {
|
|||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
propsMethodSpies.hideSidebar.resetHistory()
|
propsMethodSpies.hideSidebar.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('renderOverlay', () => {
|
describe('renderOverlay', function () {
|
||||||
let renderOverlay
|
let renderOverlay
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
renderOverlay = shallow(wrapper.instance().renderOverlay())
|
renderOverlay = shallow(wrapper.instance().renderOverlay())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a overlay element', () => {
|
it('should render a overlay element', function () {
|
||||||
assert(renderOverlay.hasClass('sidebar-overlay'))
|
assert(renderOverlay.hasClass('sidebar-overlay'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should pass the correct onClick function to the element', () => {
|
it('should pass the correct onClick function to the element', function () {
|
||||||
assert.equal(propsMethodSpies.hideSidebar.callCount, 0)
|
assert.equal(propsMethodSpies.hideSidebar.callCount, 0)
|
||||||
renderOverlay.props().onClick()
|
renderOverlay.props().onClick()
|
||||||
assert.equal(propsMethodSpies.hideSidebar.callCount, 1)
|
assert.equal(propsMethodSpies.hideSidebar.callCount, 1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('renderSidebarContent', () => {
|
describe('renderSidebarContent', function () {
|
||||||
let renderSidebarContent
|
let renderSidebarContent
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper.setProps({ type: 'wallet-view' })
|
wrapper.setProps({ type: 'wallet-view' })
|
||||||
renderSidebarContent = wrapper.instance().renderSidebarContent()
|
renderSidebarContent = wrapper.instance().renderSidebarContent()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render sidebar content with the correct props', () => {
|
it('should render sidebar content with the type wallet-view', function () {
|
||||||
wrapper.setProps({ type: 'wallet-view' })
|
wrapper.setProps({ type: 'wallet-view' })
|
||||||
renderSidebarContent = wrapper.instance().renderSidebarContent()
|
renderSidebarContent = wrapper.instance().renderSidebarContent()
|
||||||
assert.equal(renderSidebarContent.props.responsiveDisplayClassname, 'sidebar-right')
|
assert.equal(renderSidebarContent.props.responsiveDisplayClassname, 'sidebar-right')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render sidebar content with the correct props', () => {
|
it('should render sidebar content with the type customize-gas', function () {
|
||||||
wrapper.setProps({ type: 'customize-gas' })
|
wrapper.setProps({ type: 'customize-gas' })
|
||||||
renderSidebarContent = wrapper.instance().renderSidebarContent()
|
renderSidebarContent = wrapper.instance().renderSidebarContent()
|
||||||
const renderedSidebarContent = shallow(renderSidebarContent)
|
const renderedSidebarContent = shallow(renderSidebarContent)
|
||||||
@ -70,25 +70,25 @@ describe('Sidebar Component', function () {
|
|||||||
assert(renderedSidebarContent.childAt(0).is(CustomizeGas))
|
assert(renderedSidebarContent.childAt(0).is(CustomizeGas))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not render with an unrecognized type', () => {
|
it('should not render with an unrecognized type', function () {
|
||||||
wrapper.setProps({ type: 'foobar' })
|
wrapper.setProps({ type: 'foobar' })
|
||||||
renderSidebarContent = wrapper.instance().renderSidebarContent()
|
renderSidebarContent = wrapper.instance().renderSidebarContent()
|
||||||
assert.equal(renderSidebarContent, undefined)
|
assert.equal(renderSidebarContent, undefined)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('render', () => {
|
describe('render', function () {
|
||||||
it('should render a div with one child', () => {
|
it('should render a div with one child', function () {
|
||||||
assert(wrapper.is('div'))
|
assert(wrapper.is('div'))
|
||||||
assert.equal(wrapper.children().length, 1)
|
assert.equal(wrapper.children().length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render the ReactCSSTransitionGroup without any children', () => {
|
it('should render the ReactCSSTransitionGroup without any children', function () {
|
||||||
assert(wrapper.children().at(0).is(ReactCSSTransitionGroup))
|
assert(wrapper.children().at(0).is(ReactCSSTransitionGroup))
|
||||||
assert.equal(wrapper.children().at(0).children().length, 0)
|
assert.equal(wrapper.children().at(0).children().length, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render sidebar content and the overlay if sidebarOpen is true', () => {
|
it('should render sidebar content and the overlay if sidebarOpen is true', function () {
|
||||||
wrapper.setProps({ sidebarOpen: true })
|
wrapper.setProps({ sidebarOpen: true })
|
||||||
assert.equal(wrapper.children().length, 2)
|
assert.equal(wrapper.children().length, 2)
|
||||||
assert(wrapper.children().at(1).hasClass('sidebar-overlay'))
|
assert(wrapper.children().at(1).hasClass('sidebar-overlay'))
|
||||||
|
@ -5,10 +5,9 @@ import SignatureRequest from '../signature-request.component'
|
|||||||
|
|
||||||
|
|
||||||
describe('Signature Request Component', function () {
|
describe('Signature Request Component', function () {
|
||||||
let wrapper
|
describe('render', function () {
|
||||||
|
it('should render a div with one child', function () {
|
||||||
beforeEach(() => {
|
const wrapper = shallow((
|
||||||
wrapper = shallow((
|
|
||||||
<SignatureRequest
|
<SignatureRequest
|
||||||
clearConfirmTransaction={() => {}}
|
clearConfirmTransaction={() => {}}
|
||||||
cancel={() => {}}
|
cancel={() => {}}
|
||||||
@ -21,10 +20,7 @@ describe('Signature Request Component', function () {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
})
|
|
||||||
|
|
||||||
describe('render', () => {
|
|
||||||
it('should render a div with one child', () => {
|
|
||||||
assert(wrapper.is('div'))
|
assert(wrapper.is('div'))
|
||||||
assert.equal(wrapper.length, 1)
|
assert.equal(wrapper.length, 1)
|
||||||
assert(wrapper.hasClass('signature-request'))
|
assert(wrapper.hasClass('signature-request'))
|
||||||
|
@ -6,7 +6,7 @@ import configureMockStore from 'redux-mock-store'
|
|||||||
import { mountWithRouter } from '../../../../../test/lib/render-helpers'
|
import { mountWithRouter } from '../../../../../test/lib/render-helpers'
|
||||||
import SignatureRequest from '../signature-request'
|
import SignatureRequest from '../signature-request'
|
||||||
|
|
||||||
describe('Signature Request', () => {
|
describe('Signature Request', function () {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const mockStore = {
|
const mockStore = {
|
||||||
@ -40,7 +40,7 @@ describe('Signature Request', () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(function () {
|
||||||
wrapper = mountWithRouter(
|
wrapper = mountWithRouter(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<SignatureRequest.WrappedComponent {...props} />
|
<SignatureRequest.WrappedComponent {...props} />
|
||||||
@ -48,18 +48,18 @@ describe('Signature Request', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(function () {
|
||||||
props.clearConfirmTransaction.resetHistory()
|
props.clearConfirmTransaction.resetHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('cancel', () => {
|
it('cancel', function () {
|
||||||
const cancelButton = wrapper.find('button.btn-default')
|
const cancelButton = wrapper.find('button.btn-default')
|
||||||
cancelButton.simulate('click')
|
cancelButton.simulate('click')
|
||||||
|
|
||||||
assert(props.cancel.calledOnce)
|
assert(props.cancel.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sign', () => {
|
it('sign', function () {
|
||||||
const signButton = wrapper.find('button.btn-primary')
|
const signButton = wrapper.find('button.btn-primary')
|
||||||
signButton.simulate('click')
|
signButton.simulate('click')
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user