1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +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:
Whymarrh Whitby 2020-02-11 13:21:13 -03:30 committed by GitHub
parent 3bbbe13311
commit 4f3fc95d50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
202 changed files with 2726 additions and 2956 deletions

View File

@ -1,4 +1,5 @@
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
'sourceType': 'module',
@ -20,17 +21,16 @@ module.exports = {
extends: [
'@metamask/eslint-config',
'@metamask/eslint-config/config/nodejs',
'@metamask/eslint-config/config/mocha',
'plugin:react/recommended',
],
env: {
'browser': true,
'mocha': true,
},
plugins: [
'babel',
'mocha',
'chai',
'react',
'json',
@ -90,6 +90,6 @@ module.exports = {
'prop': 'parens-new-line',
}],
'babel/semi': ['error', 'never'],
'mocha/no-exclusive-tests': 'error',
'mocha/no-setup-in-describe': 'off',
},
}

View File

@ -176,7 +176,7 @@
"@babel/preset-env": "^7.5.5",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.5.5",
"@metamask/eslint-config": "^1.0.0",
"@metamask/eslint-config": "^1.1.0",
"@metamask/forwarder": "^1.1.0",
"@metamask/onboarding": "^0.2.0",
"@sentry/cli": "^1.49.0",
@ -208,7 +208,7 @@
"eslint-plugin-chai": "0.0.1",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-json": "^1.2.0",
"eslint-plugin-mocha": "^5.0.0",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-react": "^7.4.0",
"fancy-log": "^1.3.3",
"fetch-mock": "^6.5.2",

5
test/e2e/.eslintrc.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
rules: {
'mocha/no-hooks-for-single-case': 'off',
},
}

View File

@ -52,24 +52,24 @@ describe('MetaMask', function () {
await driver.quit()
})
describe('Going through the first time flow', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('Going through the first time flow', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver.findElement(By.css('.welcome-page__header'))
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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 passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
@ -83,7 +83,7 @@ describe('MetaMask', function () {
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')
await driver.clickElement(byRevealButton)
await driver.delay(regularDelayMs)
@ -102,7 +102,7 @@ describe('MetaMask', function () {
await driver.delay(tinyDelayMs)
}
it('can retype the seed phrase', async () => {
it('can retype the seed phrase', async function () {
const words = seedPhrase.split(' ')
for (const word of words) {
@ -113,15 +113,15 @@ describe('MetaMask', function () {
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.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
await driver.delay(regularDelayMs)
})
})
describe('Import seed phrase', () => {
it('logs out of the vault', async () => {
describe('Import seed phrase', function () {
it('logs out of the vault', async function () {
await driver.clickElement(By.css('.account-menu__icon'))
await driver.delay(regularDelayMs)
@ -131,7 +131,7 @@ describe('MetaMask', function () {
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'))
assert.equal(await restoreSeedLink.getText(), 'Import using account seed phrase')
await restoreSeedLink.click()
@ -150,14 +150,14 @@ describe('MetaMask', function () {
await driver.delay(regularDelayMs)
})
it('balance renders', async () => {
it('balance renders', async function () {
const balance = await driver.findElement(By.css('.balance-display .token-amount'))
await driver.wait(until.elementTextMatches(balance, /25\s*ETH/))
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 () {
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
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 () {
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
await driver.delay(regularDelayMs)

View File

@ -51,24 +51,24 @@ describe('MetaMask', function () {
await driver.quit()
})
describe('Going through the first time flow, but skipping the seed phrase challenge', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('Going through the first time flow, but skipping the seed phrase challenge', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver.findElement(By.css('.welcome-page__header'))
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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 passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
@ -80,7 +80,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -88,7 +88,7 @@ describe('MetaMask', function () {
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'))
publicAddress = await addressInput.getAttribute('value')
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 popup
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.delay(regularDelayMs)
@ -134,13 +134,13 @@ describe('MetaMask', function () {
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'))
await driver.delay(regularDelayMs)
assert.equal(await networkDiv.getText(), '5777')
})
it('changes the network', async () => {
it('changes the network', async function () {
await driver.switchToWindow(extension)
await driver.clickElement(By.css('.network-name'))
@ -150,19 +150,19 @@ describe('MetaMask', function () {
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)
const networkDiv = await driver.findElement(By.css('#network'))
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)
const chainIdDiv = await driver.findElement(By.css('#chainId'))
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)
const accountsDiv = await driver.findElement(By.css('#accounts'))
assert.equal(await accountsDiv.getText(), publicAddress.toLowerCase())

View File

@ -56,24 +56,24 @@ describe('Using MetaMask with an existing account', function () {
await driver.quit()
})
describe('First time flow starting from an existing seed phrase', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('First time flow starting from an existing seed phrase', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver.findElement(By.css('.welcome-page__header'))
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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'))
await seedTextArea.sendKeys(testSeedPhrase)
await driver.delay(regularDelayMs)
@ -89,15 +89,15 @@ describe('Using MetaMask with an existing account', function () {
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.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
await driver.delay(regularDelayMs)
})
})
describe('Show account information', () => {
it('shows the correct account address', async () => {
describe('Show account information', function () {
it('shows the correct account address', async function () {
await driver.clickElement(By.css('.account-details__details-button'))
await driver.findVisibleElement(By.css('.qr-wrapper'))
await driver.delay(regularDelayMs)
@ -109,7 +109,7 @@ describe('Using MetaMask with an existing account', function () {
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.findVisibleElement(By.css('.qr-wrapper'))
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', () => {
it('logs out of the account', async () => {
describe('Lock and unlock', function () {
it('logs out of the account', async function () {
await driver.clickElement(By.css('.account-menu__icon .identicon'))
await driver.delay(regularDelayMs)
@ -132,7 +132,7 @@ describe('Using MetaMask with an existing account', function () {
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'))
await passwordField.sendKeys('correct horse battery staple')
await passwordField.sendKeys(Key.ENTER)
@ -140,8 +140,8 @@ describe('Using MetaMask with an existing account', function () {
})
})
describe('Add an account', () => {
it('switches to localhost', async () => {
describe('Add an account', function () {
it('switches to localhost', async function () {
await driver.clickElement(By.css('.network-name'))
await driver.delay(regularDelayMs)
@ -149,7 +149,7 @@ describe('Using MetaMask with an existing account', function () {
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.delay(regularDelayMs)
@ -157,7 +157,7 @@ describe('Using MetaMask with an existing account', function () {
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'))
await accountName.sendKeys('2nd account')
await driver.delay(regularDelayMs)
@ -166,15 +166,15 @@ describe('Using MetaMask with an existing account', function () {
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'))
assert.equal(await accountName.getText(), '2nd account')
await driver.delay(regularDelayMs)
})
})
describe('Switch back to original account', () => {
it('chooses the original account from the account menu', async () => {
describe('Switch back to original account', function () {
it('chooses the original account from the account menu', async function () {
await driver.clickElement(By.css('.account-menu__icon'))
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 () {
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
await driver.delay(regularDelayMs)
@ -225,8 +225,8 @@ describe('Using MetaMask with an existing account', function () {
})
})
describe('Imports an account with private key', () => {
it('choose Create Account from the account menu', async () => {
describe('Imports an account with private key', function () {
it('choose Create Account from the account menu', async function () {
await driver.clickElement(By.css('.account-menu__icon'))
await driver.delay(regularDelayMs)
@ -234,7 +234,7 @@ describe('Using MetaMask with an existing account', function () {
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'))
await privateKeyInput.sendKeys(testPrivateKey2)
await driver.delay(regularDelayMs)
@ -242,21 +242,21 @@ describe('Using MetaMask with an existing account', function () {
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'))
assert.equal(await accountName.getText(), 'Account 4')
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'))
assert.equal(await importedLabel.getText(), 'IMPORTED')
await driver.delay(regularDelayMs)
})
})
describe('Imports and removes an account', () => {
it('choose Create Account from the account menu', async () => {
describe('Imports and removes an account', function () {
it('choose Create Account from the account menu', async function () {
await driver.clickElement(By.css('.account-menu__icon'))
await driver.delay(regularDelayMs)
@ -264,7 +264,7 @@ describe('Using MetaMask with an existing account', function () {
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'))
await privateKeyInput.sendKeys(testPrivateKey3)
await driver.delay(regularDelayMs)
@ -272,7 +272,7 @@ describe('Using MetaMask with an existing account', function () {
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'))
assert.equal(await accountName.getText(), 'Account 5')
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'))
})
it('should remove the account', async () => {
it('should remove the account', async function () {
await driver.clickElement(By.xpath(`//button[contains(text(), 'Remove')]`))
await driver.delay(regularDelayMs)
@ -303,13 +303,13 @@ describe('Using MetaMask with an existing account', function () {
})
})
describe('Connects to a Hardware wallet', () => {
it('choose Connect Hardware Wallet from the account menu', async () => {
describe('Connects to a Hardware wallet', function () {
it('choose Connect Hardware Wallet from the account menu', async function () {
await driver.clickElement(By.xpath(`//div[contains(text(), 'Connect Hardware Wallet')]`))
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.delay(regularDelayMs)
await driver.clickElement(By.xpath(`//button[contains(text(), 'Connect')]`))

View File

@ -56,24 +56,24 @@ describe('MetaMask', function () {
await driver.quit()
})
describe('Going through the first time flow, but skipping the seed phrase challenge', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('Going through the first time flow, but skipping the seed phrase challenge', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver.findElement(By.css('.welcome-page__header'))
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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 passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
@ -86,7 +86,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -94,7 +94,7 @@ describe('MetaMask', function () {
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'))
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
it('switches to dapp screen', async () => {
it('switches to dapp screen', async function () {
const windowHandles = await driver.getAllWindowHandles()
extension = windowHandles[0]
@ -119,7 +119,7 @@ describe('MetaMask', function () {
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'))
await addressInput.sendKeys(publicAddress)
await driver.delay(regularDelayMs)
@ -130,11 +130,11 @@ describe('MetaMask', function () {
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)
})
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'))
await driver.wait(until.elementTextMatches(balances[0], /1/), 15000)
const balance = await balances[0].getText()
@ -143,20 +143,20 @@ describe('MetaMask', function () {
})
})
describe('backs up the seed phrase', () => {
it('should show a backup reminder', async () => {
describe('backs up the seed phrase', function () {
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')]"))
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.delay(regularDelayMs)
})
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')
await driver.clickElement(byRevealButton)
await driver.delay(regularDelayMs)
@ -175,7 +175,7 @@ describe('MetaMask', function () {
await driver.delay(tinyDelayMs)
}
it('can retype the seed phrase', async () => {
it('can retype the seed phrase', async function () {
const words = seedPhrase.split(' ')
for (const word of words) {
@ -186,12 +186,12 @@ describe('MetaMask', function () {
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.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'))
await driver.wait(until.elementTextMatches(balances[0], /1/), 15000)
const balance = await balances[0].getText()
@ -199,7 +199,7 @@ describe('MetaMask', function () {
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'))
})
})

View File

@ -46,24 +46,24 @@ describe('MetaMask', function () {
await driver.quit()
})
describe('Going through the first time flow', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('Going through the first time flow', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver.findElement(By.css('.welcome-page__header'))
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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 passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
@ -78,7 +78,7 @@ describe('MetaMask', function () {
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')
await driver.clickElement(byRevealButton)
await driver.delay(regularDelayMs)
@ -97,7 +97,7 @@ describe('MetaMask', function () {
await driver.delay(tinyDelayMs)
}
it('can retype the seed phrase', async () => {
it('can retype the seed phrase', async function () {
const words = seedPhrase.split(' ')
for (const word of words) {
@ -108,15 +108,15 @@ describe('MetaMask', function () {
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.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
await driver.delay(regularDelayMs)
})
})
describe('Show account information', () => {
it('show account details dropdown menu', async () => {
describe('Show account information', function () {
it('show account details dropdown menu', async function () {
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'))
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', () => {
it('logs out of the vault', async () => {
describe('Import seed phrase', function () {
it('logs out of the vault', async function () {
await driver.clickElement(By.css('.account-menu__icon'))
await driver.delay(regularDelayMs)
@ -135,7 +135,7 @@ describe('MetaMask', function () {
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'))
assert.equal(await restoreSeedLink.getText(), 'Import using account seed phrase')
await restoreSeedLink.click()
@ -154,7 +154,7 @@ describe('MetaMask', function () {
await driver.delay(regularDelayMs)
})
it('switches to localhost', async () => {
it('switches to localhost', async function () {
await driver.clickElement(By.css('.network-name'))
await driver.delay(regularDelayMs)
@ -162,14 +162,14 @@ describe('MetaMask', function () {
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'))
await driver.wait(until.elementTextMatches(balance, /100\s*ETH/))
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 () {
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
await driver.delay(regularDelayMs)

View File

@ -47,24 +47,24 @@ describe('MetaMask', function () {
await driver.quit()
})
describe('Going through the first time flow', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('Going through the first time flow', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver.findElement(By.css('.welcome-page__header'))
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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 passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
@ -79,7 +79,7 @@ describe('MetaMask', function () {
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')
await driver.findElement(byRevealButton)
await driver.clickElement(byRevealButton)
@ -99,7 +99,7 @@ describe('MetaMask', function () {
await driver.delay(tinyDelayMs)
}
it('can retype the seed phrase', async () => {
it('can retype the seed phrase', async function () {
const words = seedPhrase.split(' ')
for (const word of words) {
@ -110,15 +110,15 @@ describe('MetaMask', function () {
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.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
await driver.delay(regularDelayMs)
})
})
describe('Show account information', () => {
it('shows the QR code for the account', async () => {
describe('Show account information', function () {
it('shows the QR code for the account', async function () {
await driver.clickElement(By.css('.account-details__details-button'))
await driver.findVisibleElement(By.css('.qr-wrapper'))
await driver.delay(regularDelayMs)
@ -131,8 +131,8 @@ describe('MetaMask', function () {
})
})
describe('Lock an unlock', () => {
it('logs out of the account', async () => {
describe('Lock an unlock', function () {
it('logs out of the account', async function () {
await driver.clickElement(By.css('.account-menu__icon'))
await driver.delay(regularDelayMs)
@ -142,7 +142,7 @@ describe('MetaMask', function () {
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'))
await passwordField.sendKeys('correct horse battery staple')
await passwordField.sendKeys(Key.ENTER)
@ -150,8 +150,8 @@ describe('MetaMask', function () {
})
})
describe('Add account', () => {
it('choose Create Account from the account menu', async () => {
describe('Add account', function () {
it('choose Create Account from the account menu', async function () {
await driver.clickElement(By.css('.account-menu__icon'))
await driver.delay(regularDelayMs)
@ -159,7 +159,7 @@ describe('MetaMask', function () {
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'))
await accountName.sendKeys('2nd account')
await driver.delay(regularDelayMs)
@ -168,15 +168,15 @@ describe('MetaMask', function () {
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'))
assert.equal(await accountName.getText(), '2nd account')
await driver.delay(regularDelayMs)
})
})
describe('Import seed phrase', () => {
it('logs out of the vault', async () => {
describe('Import seed phrase', function () {
it('logs out of the vault', async function () {
await driver.clickElement(By.css('.account-menu__icon'))
await driver.delay(regularDelayMs)
@ -186,7 +186,7 @@ describe('MetaMask', function () {
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'))
assert.equal(await restoreSeedLink.getText(), 'Import using account seed phrase')
await restoreSeedLink.click()
@ -205,14 +205,14 @@ describe('MetaMask', function () {
await driver.delay(regularDelayMs)
})
it('balance renders', async () => {
it('balance renders', async function () {
const balance = await driver.findElement(By.css('.balance-display .token-amount'))
await driver.wait(until.elementTextMatches(balance, /100\s*ETH/))
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 () {
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
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 () {
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
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 () {
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
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 extension
let popup
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.delay(regularDelayMs)
@ -394,7 +394,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -422,7 +422,7 @@ describe('MetaMask', function () {
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.delay(2000)
@ -478,8 +478,8 @@ describe('MetaMask', function () {
})
})
describe('Navigate transactions', () => {
it('adds multiple transactions', async () => {
describe('Navigate transactions', function () {
it('adds multiple transactions', async function () {
await driver.delay(regularDelayMs)
await driver.waitUntilXWindowHandles(2)
@ -510,7 +510,7 @@ describe('MetaMask', function () {
await driver.delay(largeDelayMs)
})
it('navigates the transactions', async () => {
it('navigates the transactions', async function () {
await driver.clickElement(By.css('[data-testid="next-page"]'))
let navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
let navigationText = await navigationElement.getText()
@ -547,7 +547,7 @@ describe('MetaMask', function () {
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 navigationText = await navigationElement.getText()
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')
})
it('rejects a transaction', async () => {
it('rejects a transaction', async function () {
await driver.delay(tinyDelayMs)
await driver.clickElement(By.xpath(`//button[contains(text(), 'Reject')]`))
await driver.delay(largeDelayMs * 2)
@ -581,7 +581,7 @@ describe('MetaMask', function () {
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.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
await driver.delay(regularDelayMs)
@ -593,7 +593,7 @@ describe('MetaMask', function () {
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.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 dapp
it('creates a deploy contract transaction', async () => {
it('creates a deploy contract transaction', async function () {
const windowHandles = await driver.getAllWindowHandles()
extension = windowHandles[0]
dapp = windowHandles[1]
@ -627,7 +627,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -641,7 +641,7 @@ describe('MetaMask', function () {
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.delay(largeDelayMs)
@ -655,7 +655,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -721,7 +721,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -749,7 +749,7 @@ describe('MetaMask', function () {
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'))
await driver.delay(regularDelayMs)
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', () => {
it('creates a new token', async () => {
describe('Add a custom token from a dapp', function () {
it('creates a new token', async function () {
let windowHandles = await driver.getAllWindowHandles()
const extension = windowHandles[0]
const dapp = windowHandles[1]
@ -807,12 +807,12 @@ describe('MetaMask', function () {
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.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.delay(regularDelayMs)
@ -827,7 +827,7 @@ describe('MetaMask', function () {
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'))
await driver.wait(until.elementTextMatches(balance, /^10.000\s*TST\s*$/))
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
it('starts to send a transaction', async function () {
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
@ -856,13 +856,13 @@ describe('MetaMask', function () {
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.clickElement(By.xpath(`//button[contains(text(), 'Save')]`))
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))
// Continue to next screen
@ -870,7 +870,7 @@ describe('MetaMask', function () {
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.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
it('sends an already created token', async () => {
it('sends an already created token', async function () {
const windowHandles = await driver.getAllWindowHandles()
const extension = windowHandles[0]
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
@ -945,7 +945,7 @@ describe('MetaMask', function () {
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.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
it('approves an already created token', async () => {
it('approves an already created token', async function () {
const windowHandles = await driver.getAllWindowHandles()
const extension = windowHandles[0]
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
@ -1031,7 +1031,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -1044,14 +1044,14 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
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.delay(regularDelayMs)
@ -1078,7 +1078,7 @@ describe('MetaMask', function () {
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'))
await editButtons[1].click()
await driver.delay(regularDelayMs)
@ -1121,8 +1121,8 @@ describe('MetaMask', function () {
})
})
describe('Tranfers a custom token from dapp when no gas value is specified', () => {
it('transfers an already created token, without specifying gas', async () => {
describe('Tranfers a custom token from dapp when no gas value is specified', function () {
it('transfers an already created token, without specifying gas', async function () {
const windowHandles = await driver.getAllWindowHandles()
const extension = windowHandles[0]
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', () => {
it('approves an already created token', async () => {
describe('Approves a custom token from dapp when no gas value is specified', function () {
it('approves an already created token', async function () {
const windowHandles = await driver.getAllWindowHandles()
const extension = windowHandles[0]
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
@ -1221,8 +1221,8 @@ describe('MetaMask', function () {
})
})
describe('Hide token', () => {
it('hides the token when clicked', async () => {
describe('Hide token', function () {
it('hides the token when clicked', async function () {
await driver.clickElement(By.css('.token-list-item__ellipsis'))
const byTokenMenuDropdownOption = By.css('.menu__item--clickable')
@ -1237,13 +1237,13 @@ describe('MetaMask', function () {
})
})
describe('Add existing token using search', () => {
it('clicks on the Add Token button', async () => {
describe('Add existing token using search', function () {
it('clicks on the Add Token button', async function () {
await driver.clickElement(By.xpath(`//div[contains(text(), 'Add Token')]`))
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'))
await tokenSearch.sendKeys('BAT')
await driver.delay(regularDelayMs)
@ -1258,14 +1258,14 @@ describe('MetaMask', function () {
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'))
await driver.wait(until.elementTextMatches(balance, /0\s*BAT/))
await driver.delay(regularDelayMs)
})
})
describe('Stores custom RPC history', () => {
describe('Stores custom RPC history', function () {
const customRpcUrls = [
'http://127.0.0.1:8545/1',
'http://127.0.0.1:8545/2',
@ -1274,7 +1274,7 @@ describe('MetaMask', function () {
]
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.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.delay(regularDelayMs)
@ -1301,7 +1301,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -1311,7 +1311,7 @@ describe('MetaMask', function () {
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 lastNetworkListItem = networkListItems[networkListItems.length - 1]
await lastNetworkListItem.click()

View File

@ -51,24 +51,24 @@ describe('MetaMask', function () {
await driver.quit()
})
describe('Going through the first time flow, but skipping the seed phrase challenge', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('Going through the first time flow, but skipping the seed phrase challenge', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver.findElement(By.css('.welcome-page__header'))
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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 passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
@ -81,7 +81,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -89,7 +89,7 @@ describe('MetaMask', function () {
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'))
publicAddress = await addressInput.getAttribute('value')
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 popup
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.delay(regularDelayMs)
@ -132,7 +132,7 @@ describe('MetaMask', function () {
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.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')
})
it('can get accounts within the dapp', async () => {
it('can get accounts within the dapp', async function () {
await driver.switchToWindow(dapp)
await driver.delay(regularDelayMs)
@ -159,7 +159,7 @@ describe('MetaMask', function () {
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.clickElement(By.xpath(`//button[contains(text(), 'Disconnect All')]`))
@ -172,7 +172,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)

View File

@ -53,24 +53,24 @@ describe('Using MetaMask with an existing account', function () {
await driver.quit()
})
describe('First time flow starting from an existing seed phrase', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('First time flow starting from an existing seed phrase', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver.findElement(By.css('.welcome-page__header'))
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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'))
await seedTextArea.sendKeys(testSeedPhrase)
await driver.delay(regularDelayMs)
@ -86,14 +86,14 @@ describe('Using MetaMask with an existing account', function () {
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.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
await driver.delay(regularDelayMs)
})
})
describe('Send ETH from inside MetaMask', () => {
describe('Send ETH from inside MetaMask', function () {
it('starts a send transaction', async function () {
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
await driver.delay(regularDelayMs)

View File

@ -51,13 +51,13 @@ describe('MetaMask', function () {
await driver.quit()
})
describe('successfuly signs typed data', () => {
describe('successfuly signs typed data', function () {
let extension
let popup
let dapp
let windowHandles
it('accepts the account password after lock', async () => {
it('accepts the account password after lock', async function () {
await driver.delay(1000)
const passwordField = await driver.findElement(By.id('password'))
await passwordField.sendKeys('correct horse battery staple')
@ -65,7 +65,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -92,7 +92,7 @@ describe('MetaMask', function () {
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.delay(largeDelayMs)
@ -112,7 +112,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)
@ -120,7 +120,7 @@ describe('MetaMask', function () {
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.delay(regularDelayMs)

View File

@ -2,7 +2,7 @@ const { By, Key } = require('selenium-webdriver')
const { withFixtures } = require('../helpers')
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 = {
accounts: [
{

View File

@ -54,26 +54,26 @@ describe('MetaMask', function () {
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', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('First time flow starting from an existing seed phrase', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver.findElement(By.css('.welcome-page__header'))
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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'))
await seedTextArea.sendKeys(testSeedPhrase)
await driver.delay(regularDelayMs)
@ -89,44 +89,44 @@ describe('MetaMask', function () {
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.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
await driver.delay(regularDelayMs)
})
it('balance renders', async () => {
it('balance renders', async function () {
const balance = await driver.findElement(By.css('.balance-display .token-amount'))
await driver.wait(until.elementTextMatches(balance, /25\s*ETH/))
await driver.delay(regularDelayMs)
})
})
describe('turns on threebox syncing', () => {
it('goes to the settings screen', async () => {
describe('turns on threebox syncing', function () {
it('goes to the settings screen', async function () {
await driver.clickElement(By.css('.account-menu__icon'))
await driver.delay(regularDelayMs)
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.css('[data-testid="advanced-setting-3box"] .toggle-button div'))
})
})
describe('updates settings and address book', () => {
it('adds an address to the contact list', async () => {
describe('updates settings and address book', function () {
it('navigates to General settings', async function () {
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'))
})
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.css('.address-book-add-button__button'))
@ -150,7 +150,7 @@ describe('MetaMask', function () {
})
describe('restoration from 3box', () => {
describe('restoration from 3box', function () {
let driver2
before(async function () {
@ -162,24 +162,24 @@ describe('MetaMask', function () {
await driver2.quit()
})
describe('First time flow starting from an existing seed phrase', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('First time flow starting from an existing seed phrase', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver2.findElement(By.css('.welcome-page__header'))
await driver2.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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'))
await seedTextArea.sendKeys(testSeedPhrase)
await driver2.delay(regularDelayMs)
@ -195,40 +195,40 @@ describe('MetaMask', function () {
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.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
await driver2.delay(regularDelayMs)
})
it('balance renders', async () => {
it('balance renders', async function () {
const balance = await driver2.findElement(By.css('.balance-display .token-amount'))
await driver2.wait(until.elementTextMatches(balance, /25\s*ETH/))
await driver2.delay(regularDelayMs)
})
})
describe('restores 3box data', () => {
it('confirms the 3box restore notification', async () => {
describe('restores 3box data', function () {
it('confirms the 3box restore notification', async function () {
await driver2.clickElement(By.css('.home-notification__accept-button'))
})
// 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.delay(regularDelayMs)
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)
const toggleLabel = await driver.findElement(By.css('.toggle-button__status-label'))
const toggleLabelText = await toggleLabel.getText()
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.delay(regularDelayMs)

View File

@ -52,24 +52,24 @@ describe('Using MetaMask with an existing account', function () {
await driver.quit()
})
describe('First time flow starting from an existing seed phrase', () => {
it('clicks the continue button on the welcome screen', async () => {
describe('First time flow starting from an existing seed phrase', function () {
it('clicks the continue button on the welcome screen', async function () {
await driver.findElement(By.css('.welcome-page__header'))
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
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.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.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'))
await seedTextArea.sendKeys(testSeedPhrase)
await driver.delay(regularDelayMs)
@ -85,7 +85,7 @@ describe('Using MetaMask with an existing account', function () {
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.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
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.delay(regularDelayMs)
@ -103,7 +103,7 @@ describe('Using MetaMask with an existing account', function () {
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.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'))
@ -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'))
@ -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'))
@ -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'))
@ -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'))
let parsedData

View File

@ -6,9 +6,9 @@ import '../../app/scripts/lib/freezeGlobals'
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 {
Promise = {}
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 {
global.Promise = {}
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 {
Promise.all = () => {}
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 {
Promise.foo = 'bar'
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 {
delete global.Promise
assert.fail('did not throw error')

View File

@ -25,7 +25,7 @@ describe('tx confirmation screen', function () {
const store = mockStore(initialState)
describe('cancelTx', function () {
before(function (done) {
it('creates COMPLETED_TX with the cancelled transaction ID', async function () {
actions._setBackgroundConnection({
approveTransaction (_, cb) {
cb('An error!')
@ -37,10 +37,7 @@ describe('tx confirmation screen', function () {
cb()
},
})
done()
})
it('creates COMPLETED_TX with the cancelled transaction ID', async function () {
await store.dispatch(actions.cancelTx({ id: txId }))
const storeActions = store.getActions()
const completedTxAction = storeActions.find(({ type }) => type === actions.actionConstants.COMPLETED_TX)

View File

@ -2,20 +2,20 @@ import assert from 'assert'
import ComposableObservableStore from '../../../app/scripts/lib/ComposableObservableStore'
import ObservableStore from 'obs-store'
describe('ComposableObservableStore', () => {
it('should register initial state', () => {
describe('ComposableObservableStore', function () {
it('should register initial state', function () {
const store = new ComposableObservableStore('state')
assert.strictEqual(store.getState(), 'state')
})
it('should register initial structure', () => {
it('should register initial structure', function () {
const testStore = new ObservableStore()
const store = new ComposableObservableStore(null, { TestStore: testStore })
testStore.putState('state')
assert.deepEqual(store.getState(), { TestStore: 'state' })
})
it('should update structure', () => {
it('should update structure', function () {
const testStore = new ObservableStore()
const store = new ComposableObservableStore()
store.updateStructure({ TestStore: testStore })
@ -23,7 +23,7 @@ describe('ComposableObservableStore', () => {
assert.deepEqual(store.getState(), { TestStore: 'state' })
})
it('should return flattened state', () => {
it('should return flattened state', function () {
const fooStore = new ObservableStore({ foo: 'foo' })
const barStore = new ObservableStore({ bar: 'bar' })
const store = new ComposableObservableStore(null, {

View File

@ -12,26 +12,24 @@ describe('Account Import Strategies', function () {
assert.equal(importPrivKey, ethUtil.stripHexPrefix(privkey))
})
it('throws an error for empty string private key', async () => {
return assert.rejects(async function () {
it('throws an error for empty string private key', async function () {
await assert.rejects(async () => {
await accountImporter.importAccount('Private Key', [ '' ])
}, Error, 'no empty strings')
})
it('throws an error for undefined string private key', async () => {
return assert.rejects(async function () {
it('throws an error for undefined string private key', async function () {
await assert.rejects(async () => {
await accountImporter.importAccount('Private Key', [ undefined ])
})
})
it('throws an error for undefined string private key', async () => {
return assert.rejects(async function () {
await assert.rejects(async () => {
await accountImporter.importAccount('Private Key', [])
})
})
it('throws an error for invalid private key', async () => {
return assert.rejects(async function () {
it('throws an error for invalid private key', async function () {
await assert.rejects(async () => {
await accountImporter.importAccount('Private Key', [ 'popcorn' ])
})
})

View File

@ -1,7 +1,7 @@
import assert from 'assert'
import cleanErrorStack from '../../../app/scripts/lib/cleanErrorStack'
describe('Clean Error Stack', () => {
describe('Clean Error Stack', function () {
const testMessage = 'Test Message'
const testError = new Error(testMessage)
@ -9,24 +9,24 @@ describe('Clean Error Stack', () => {
const blankErrorName = new Error(testMessage)
const blankMsgError = new Error()
beforeEach(() => {
beforeEach(function () {
undefinedErrorName.name = undefined
blankErrorName.name = ''
})
it('tests error with message', () => {
it('tests error with message', function () {
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')
})
it('tests error with blank name', () => {
it('tests error with blank name', function () {
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')
})

View File

@ -17,7 +17,7 @@ const accounts = {
},
}
describe('Balance Controller', () => {
describe('Balance Controller', function () {
let balanceController
@ -29,7 +29,7 @@ describe('Balance Controller', () => {
}
})
beforeEach(() => {
beforeEach(function () {
balanceController = new BalanceController({
address: TEST_ADDRESS,
accountTracker: new AccountTracker({

View File

@ -2,9 +2,9 @@ import assert from 'assert'
import sinon from 'sinon'
import CachedBalancesController from '../../../../app/scripts/controllers/cached-balances'
describe('CachedBalancesController', () => {
describe('updateCachedBalances', () => {
it('should update the cached balances', async () => {
describe('CachedBalancesController', function () {
describe('updateCachedBalances', function () {
it('should update the cached balances', async function () {
const controller = new CachedBalancesController({
getNetwork: () => Promise.resolve(17),
accountTracker: {
@ -27,8 +27,8 @@ describe('CachedBalancesController', () => {
})
})
describe('_generateBalancesToCache', () => {
it('should generate updated account balances where the current network was updated', () => {
describe('_generateBalancesToCache', function () {
it('should generate updated account balances where the current network was updated', function () {
const controller = new CachedBalancesController({
accountTracker: {
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({
accountTracker: {
store: {
@ -109,8 +109,8 @@ describe('CachedBalancesController', () => {
})
})
describe('_registerUpdates', () => {
it('should subscribe to the account tracker with the updateCachedBalances method', async () => {
describe('_registerUpdates', function () {
it('should subscribe to the account tracker with the updateCachedBalances method', async function () {
const subscribeSpy = sinon.spy()
const controller = new CachedBalancesController({
getNetwork: () => Promise.resolve(17),

View File

@ -6,7 +6,7 @@ import DetectTokensController from '../../../../app/scripts/controllers/detect-t
import NetworkController from '../../../../app/scripts/controllers/network/network'
import PreferencesController from '../../../../app/scripts/controllers/preferences'
describe('DetectTokensController', () => {
describe('DetectTokensController', function () {
const sandbox = sinon.createSandbox()
let clock, keyringMemStore, network, preferences, controller
@ -16,7 +16,7 @@ describe('DetectTokensController', () => {
getAccounts: noop,
}
beforeEach(async () => {
beforeEach(async function () {
nock('https://api.infura.io')
@ -32,19 +32,19 @@ describe('DetectTokensController', () => {
})
after(() => {
after(function () {
sandbox.restore()
nock.cleanAll()
})
it('should poll on correct interval', async () => {
it('should poll on correct interval', async function () {
const stub = sinon.stub(global, 'setInterval')
new DetectTokensController({ interval: 1337 }) // eslint-disable-line no-new
assert.strictEqual(stub.getCall(0).args[1], 1337)
stub.restore()
})
it('should be called on every polling period', async () => {
it('should be called on every polling period', async function () {
clock = sandbox.useFakeTimers()
const network = new NetworkController()
network.initializeProvider(networkControllerProviderConfig)
@ -66,7 +66,7 @@ describe('DetectTokensController', () => {
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.isUnlocked = true
@ -78,7 +78,7 @@ describe('DetectTokensController', () => {
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 })
controller.isOpen = true
controller.isUnlocked = true
@ -94,7 +94,7 @@ describe('DetectTokensController', () => {
{ 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)
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isOpen = true
@ -111,7 +111,7 @@ describe('DetectTokensController', () => {
{ 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.isUnlocked = true
const stub = sandbox.stub(controller, 'detectNewTokens')
@ -119,7 +119,7 @@ describe('DetectTokensController', () => {
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.selectedAddress = '0x0'
const stub = sandbox.stub(controller, 'detectNewTokens')
@ -127,7 +127,7 @@ describe('DetectTokensController', () => {
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.isUnlocked = false
const stub = sandbox.stub(controller, 'detectTokenBalance')

View File

@ -9,7 +9,7 @@ const ZERO_X_ERROR_ADDRESS = '0x'
describe('EnsController', 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 currentNetworkId = '3'
const networkStore = new ObservableStore(currentNetworkId)
@ -21,7 +21,7 @@ describe('EnsController', function () {
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 = {
subscribe: sinon.spy(),
}
@ -35,7 +35,7 @@ describe('EnsController', 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 networkStore = {
subscribe: sinon.spy(),
@ -52,7 +52,7 @@ describe('EnsController', function () {
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 reverse = sinon.stub().withArgs(address).returns('peaksignal.eth')
const lookup = sinon.stub().withArgs('peaksignal.eth').returns(address)
@ -73,7 +73,7 @@ describe('EnsController', function () {
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 networkStore = {
subscribe: sinon.spy(),
@ -90,7 +90,7 @@ describe('EnsController', function () {
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 networkStore = {
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 networkStore = {
subscribe: sinon.spy(),

View File

@ -8,7 +8,7 @@ const IncomingTransactionsController = proxyquire('../../../../app/scripts/contr
import { ROPSTEN, RINKEBY, KOVAN, GOERLI, MAINNET } from '../../../../app/scripts/controllers/network/enums'
describe('IncomingTransactionsController', () => {
describe('IncomingTransactionsController', function () {
const EMPTY_INIT_STATE = {
incomingTransactions: {},
incomingTxLastFetchedBlocksByNetwork: {
@ -71,8 +71,8 @@ describe('IncomingTransactionsController', () => {
},
}
describe('constructor', () => {
it('should set up correct store, listeners and properties in the constructor', () => {
describe('constructor', function () {
it('should set up correct store, listeners and properties in the constructor', function () {
const incomingTransactionsController = new IncomingTransactionsController({
blockTracker: MOCK_BLOCKTRACKER,
networkController: MOCK_NETWORK_CONTROLLER,
@ -102,7 +102,7 @@ describe('IncomingTransactionsController', () => {
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({
blockTracker: MOCK_BLOCKTRACKER,
networkController: MOCK_NETWORK_CONTROLLER,
@ -114,8 +114,8 @@ describe('IncomingTransactionsController', () => {
})
})
describe('#start', () => {
it('should set up a listener for the latest block', () => {
describe('#start', function () {
it('should set up a listener for the latest block', function () {
const incomingTransactionsController = new IncomingTransactionsController({
blockTracker: MOCK_BLOCKTRACKER,
networkController: MOCK_NETWORK_CONTROLLER,
@ -139,8 +139,8 @@ describe('IncomingTransactionsController', () => {
})
})
describe('_getDataForUpdate', () => {
it('should call fetchAll with the correct params when passed a new block number and the current network has no stored block', async () => {
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 function () {
const incomingTransactionsController = new IncomingTransactionsController({
blockTracker: MOCK_BLOCKTRACKER,
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({
blockTracker: MOCK_BLOCKTRACKER,
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({
blockTracker: MOCK_BLOCKTRACKER,
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 () => {
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 () => {
it('should return the expected data', async function () {
const incomingTransactionsController = new IncomingTransactionsController({
blockTracker: MOCK_BLOCKTRACKER,
networkController: MOCK_NETWORK_CONTROLLER,
@ -252,7 +234,7 @@ describe('IncomingTransactionsController', () => {
})
})
describe('_updateStateWithNewTxData', () => {
describe('_updateStateWithNewTxData', function () {
const MOCK_INPUT_WITHOUT_LASTEST = {
newTxs: [{ id: 555, hash: '0xfff' }],
currentIncomingTxs: {
@ -275,7 +257,7 @@ describe('IncomingTransactionsController', () => {
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({
blockTracker: MOCK_BLOCKTRACKER,
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({
blockTracker: MOCK_BLOCKTRACKER,
networkController: MOCK_NETWORK_CONTROLLER,
@ -326,22 +308,22 @@ describe('IncomingTransactionsController', () => {
})
})
describe('_fetchTxs', () => {
describe('_fetchTxs', function () {
const mockFetch = sinon.stub().returns(Promise.resolve({
json: () => Promise.resolve({ someKey: 'someValue' }),
}))
let tempFetch
beforeEach(() => {
beforeEach(function () {
tempFetch = global.fetch
global.fetch = mockFetch
})
afterEach(() => {
afterEach(function () {
global.fetch = tempFetch
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({
blockTracker: MOCK_BLOCKTRACKER,
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`)
})
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({
blockTracker: MOCK_BLOCKTRACKER,
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`)
})
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({
blockTracker: MOCK_BLOCKTRACKER,
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`)
})
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({
blockTracker: MOCK_BLOCKTRACKER,
networkController: MOCK_NETWORK_CONTROLLER,
@ -397,7 +379,7 @@ describe('IncomingTransactionsController', () => {
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({
blockTracker: MOCK_BLOCKTRACKER,
networkController: MOCK_NETWORK_CONTROLLER,
@ -416,8 +398,8 @@ describe('IncomingTransactionsController', () => {
})
})
describe('_processTxFetchResponse', () => {
it('should return a null block number and empty tx array if status is 0', () => {
describe('_processTxFetchResponse', function () {
it('should return a null block number and empty tx array if status is 0', function () {
const incomingTransactionsController = new IncomingTransactionsController({
blockTracker: MOCK_BLOCKTRACKER,
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({
blockTracker: MOCK_BLOCKTRACKER,
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({
blockTracker: MOCK_BLOCKTRACKER,
networkController: MOCK_NETWORK_CONTROLLER,
@ -575,8 +557,8 @@ describe('IncomingTransactionsController', () => {
})
})
describe('_normalizeTxFromEtherscan', () => {
it('should return the expected data when the tx is in error', () => {
describe('_normalizeTxFromEtherscan', function () {
it('should return the expected data when the tx is in error', function () {
const incomingTransactionsController = new IncomingTransactionsController({
blockTracker: MOCK_BLOCKTRACKER,
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({
blockTracker: MOCK_BLOCKTRACKER,
networkController: MOCK_NETWORK_CONTROLLER,

View File

@ -6,18 +6,17 @@ describe('infura-controller', function () {
let infuraController, sandbox, networkStatus
const response = { 'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down', 'goerli': 'ok' }
before(async function () {
infuraController = new InfuraController()
sandbox = sinon.createSandbox()
sinon.stub(infuraController, 'checkInfuraNetworkStatus').resolves(response)
networkStatus = await infuraController.checkInfuraNetworkStatus()
})
after(function () {
sandbox.restore()
})
describe('Network status queries', function () {
before(async function () {
infuraController = new InfuraController()
sandbox = sinon.createSandbox()
sinon.stub(infuraController, 'checkInfuraNetworkStatus').resolves(response)
networkStatus = await infuraController.checkInfuraNetworkStatus()
})
after(function () {
sandbox.restore()
})
describe('Mainnet', function () {
it('should have Mainnet', function () {

View File

@ -110,14 +110,10 @@ describe('MetaMaskController', function () {
})
describe('#getAccounts', function () {
beforeEach(async function () {
it('returns first address when dapp calls web3.eth.getAccounts', async function () {
const password = 'a-fake-password'
await metamaskController.createNewVaultAndRestore(password, TEST_SEED)
})
it('returns first address when dapp calls web3.eth.getAccounts', function () {
metamaskController.networkController._baseProviderParams.getAccounts((err, res) => {
assert.ifError(err)
assert.equal(res.length, 1)
@ -127,12 +123,10 @@ describe('MetaMaskController', function () {
})
describe('#importAccountWithStrategy', function () {
const importPrivkey = '4cfd3e90fc78b0f86bf7524722150bb8da9c60cd532564d7ff43f5716514f553'
beforeEach(async function () {
const password = 'a-fake-password'
await metamaskController.createNewVaultAndRestore(password, TEST_SEED)
await metamaskController.importAccountWithStrategy('Private Key', [ importPrivkey ])
})
@ -148,7 +142,7 @@ describe('MetaMaskController', function () {
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()
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)
assert(threeBoxSpies.init.calledOnce)
assert(threeBoxSpies.turnThreeBoxSyncingOn.calledOnce)
@ -242,7 +236,7 @@ describe('MetaMaskController', function () {
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')
metamaskController.getBalance.callsFake(() => {
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')
metamaskController.getBalance.withArgs(TEST_ADDRESS).callsFake(() => {
return Promise.resolve('0x14ced5122ce0a000')
@ -284,8 +278,8 @@ describe('MetaMaskController', function () {
})
})
describe('#getBalance', () => {
it('should return the balance known by accountTracker', async () => {
describe('#getBalance', function () {
it('should return the balance known by accountTracker', async function () {
const accounts = {}
const balance = '0x14ced5122ce0a000'
accounts[TEST_ADDRESS] = { balance: balance }
@ -297,7 +291,7 @@ describe('MetaMaskController', function () {
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 balance = '0x14ced5122ce0a000'
const ethQuery = new EthQuery()
@ -314,13 +308,9 @@ describe('MetaMaskController', function () {
})
describe('#getApi', function () {
let getApi, state
beforeEach(function () {
getApi = metamaskController.getApi()
})
it('getState', function (done) {
let state
const getApi = metamaskController.getApi()
getApi.getState((err, res) => {
if (err) {
done(err)
@ -331,7 +321,6 @@ describe('MetaMaskController', function () {
assert.deepEqual(state, metamaskController.getState())
done()
})
})
describe('preferencesController', function () {
@ -549,16 +538,12 @@ describe('MetaMaskController', function () {
})
describe('#addNewAccount', function () {
let addNewAccount
beforeEach(function () {
addNewAccount = metamaskController.addNewAccount()
})
it('errors when an primary keyring is does not exist', async function () {
const addNewAccount = metamaskController.addNewAccount()
try {
await addNewAccount
assert.equal(1 === 0)
assert.fail('should throw')
} catch (e) {
assert.equal(e.message, 'MetamaskController - No HD Key Tree found')
}
@ -586,8 +571,7 @@ describe('MetaMaskController', function () {
})
describe('#resetAccount', function () {
beforeEach(function () {
it('wipes transactions from only the correct network id and with the selected address', async function () {
const selectedAddressStub = sinon.stub(metamaskController.preferencesController, 'getSelectedAddress')
const getNetworkstub = sinon.stub(metamaskController.txController.txStateManager, 'getNetwork')
@ -600,9 +584,7 @@ describe('MetaMaskController', function () {
createTxMeta({ id: 2, status: 'rejected', metamaskNetworkId: 32 }),
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()
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
const address = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
const data = '0x43727970746f6b697474696573'
beforeEach(async () => {
beforeEach(async function () {
sandbox.stub(metamaskController, 'getBalance')
metamaskController.getBalance.callsFake(() => {
return Promise.resolve('0x0')
@ -746,7 +728,7 @@ describe('MetaMaskController', function () {
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 = {
'data': data,
}
@ -788,23 +770,15 @@ describe('MetaMaskController', function () {
})
describe('#setupUntrustedCommunication', function () {
let streamTest
const phishingMessageSender = {
url: 'http://myethereumwalletntw.com',
tab: {},
}
afterEach(function () {
streamTest.end()
})
it('sets up phishing stream for untrusted communication ', async () => {
it('sets up phishing stream for untrusted communication ', async function () {
const phishingMessageSender = {
url: 'http://myethereumwalletntw.com',
tab: {},
}
await metamaskController.phishingController.updatePhishingLists()
const { promise, resolve } = deferredPromise()
streamTest = createThoughStream((chunk, _, cb) => {
const streamTest = createThoughStream((chunk, _, cb) => {
if (chunk.name !== 'phishing') {
return cb()
}
@ -812,31 +786,29 @@ describe('MetaMaskController', function () {
resolve()
cb()
})
metamaskController.setupUntrustedCommunication(streamTest, phishingMessageSender)
metamaskController.setupUntrustedCommunication(streamTest, phishingMessageSender)
await promise
streamTest.end()
})
})
describe('#setupTrustedCommunication', function () {
let streamTest
afterEach(function () {
streamTest.end()
})
it('sets up controller dnode api for trusted communication', function (done) {
it('sets up controller dnode api for trusted communication', async function () {
const messageSender = {
url: 'http://mycrypto.com',
tab: {},
}
streamTest = createThoughStream((chunk, _, cb) => {
const { promise, resolve } = deferredPromise()
const streamTest = createThoughStream((chunk, _, cb) => {
assert.equal(chunk.name, 'controller')
resolve()
cb()
done()
})
metamaskController.setupTrustedCommunication(streamTest, messageSender)
await promise
streamTest.end()
})
})

View File

@ -3,30 +3,28 @@ import nock from 'nock'
import NetworkController from '../../../../../app/scripts/controllers/network'
import { getNetworkDisplayName } from '../../../../../app/scripts/controllers/network/util'
describe('# Network Controller', function () {
let networkController
const noop = () => {}
const networkControllerProviderConfig = {
getAccounts: noop,
}
describe('NetworkController', function () {
describe('controller', function () {
let networkController
const noop = () => {}
const networkControllerProviderConfig = {
getAccounts: noop,
}
beforeEach(function () {
beforeEach(function () {
nock('https://rinkeby.infura.io')
.persist()
.post('/metamask')
.reply(200)
nock('https://rinkeby.infura.io')
.persist()
.post('/metamask')
.reply(200)
networkController = new NetworkController()
networkController.initializeProvider(networkControllerProviderConfig)
})
networkController = new NetworkController()
afterEach(function () {
nock.cleanAll()
})
networkController.initializeProvider(networkControllerProviderConfig)
})
afterEach(function () {
nock.cleanAll()
})
describe('network', function () {
describe('#provider', function () {
it('provider should be updatable without reassignment', function () {
networkController.initializeProvider(networkControllerProviderConfig)
@ -64,38 +62,38 @@ describe('# Network Controller', function () {
})
})
})
})
describe('Network utils', () => {
it('getNetworkDisplayName should return the correct network name', () => {
const tests = [
{
input: 3,
expected: 'Ropsten',
}, {
input: 4,
expected: 'Rinkeby',
}, {
input: 42,
expected: 'Kovan',
}, {
input: 'ropsten',
expected: 'Ropsten',
}, {
input: 'rinkeby',
expected: 'Rinkeby',
}, {
input: 'kovan',
expected: 'Kovan',
}, {
input: 'mainnet',
expected: 'Main Ethereum Network',
}, {
input: 'goerli',
expected: 'Goerli',
},
]
describe('utils', function () {
it('getNetworkDisplayName should return the correct network name', function () {
const tests = [
{
input: 3,
expected: 'Ropsten',
}, {
input: 4,
expected: 'Rinkeby',
}, {
input: 42,
expected: 'Kovan',
}, {
input: 'ropsten',
expected: 'Ropsten',
}, {
input: 'rinkeby',
expected: 'Rinkeby',
}, {
input: 'kovan',
expected: 'Kovan',
}, {
input: 'mainnet',
expected: 'Main Ethereum Network',
}, {
input: 'goerli',
expected: 'Goerli',
},
]
tests.forEach(({ input, expected }) => assert.equal(getNetworkDisplayName(input), expected))
tests.forEach(({ input, expected }) => assert.equal(getNetworkDisplayName(input), expected))
})
})
})

View File

@ -2,85 +2,77 @@ import assert from 'assert'
import { createPendingNonceMiddleware, createPendingTxMiddleware } from '../../../../../app/scripts/controllers/network/middleware/pending'
import { txMetaStub } from './stubs'
describe('#createPendingNonceMiddleware', function () {
const getPendingNonce = async () => '0x2'
const address = '0xF231D46dD78806E1DD93442cf33C7671f8538748'
const pendingNonceMiddleware = createPendingNonceMiddleware({ getPendingNonce })
describe('PendingNonceMiddleware', function () {
describe('#createPendingNonceMiddleware', function () {
const getPendingNonce = async () => '0x2'
const address = '0xF231D46dD78806E1DD93442cf33C7671f8538748'
const pendingNonceMiddleware = createPendingNonceMiddleware({ getPendingNonce })
it('should call next if not a eth_getTransactionCount request', (done) => {
const req = { method: 'eth_getBlockByNumber' }
const res = {}
pendingNonceMiddleware(req, res, () => done())
})
it('should call next if not a "pending" block request', (done) => {
const req = { method: 'eth_getTransactionCount', params: [address] }
const res = {}
pendingNonceMiddleware(req, res, () => done())
})
it('should fill the result with a the "pending" nonce', (done) => {
const req = { method: 'eth_getTransactionCount', params: [address, 'pending'] }
const res = {}
pendingNonceMiddleware(req, res, () => {
done(new Error('should not have called next'))
}, () => {
assert(res.result === '0x2')
done()
it('should call next if not a eth_getTransactionCount request', function (done) {
const req = { method: 'eth_getBlockByNumber' }
const res = {}
pendingNonceMiddleware(req, res, () => done())
})
})
})
describe('#createPendingTxMiddleware', function () {
let returnUndefined = true
const getPendingTransactionByHash = () => (returnUndefined ? undefined : txMetaStub)
const address = '0xF231D46dD78806E1DD93442cf33C7671f8538748'
const pendingTxMiddleware = createPendingTxMiddleware({ getPendingTransactionByHash })
const spec = {
'blockHash': null,
'blockNumber': null,
'from': '0xf231d46dd78806e1dd93442cf33c7671f8538748',
'gas': '0x5208',
'gasPrice': '0x1e8480',
'hash': '0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09',
'input': '0x',
'nonce': '0x4',
'to': '0xf231d46dd78806e1dd93442cf33c7671f8538748',
'transactionIndex': null,
'value': '0x0',
'v': '0x2c',
'r': '0x5f973e540f2d3c2f06d3725a626b75247593cb36477187ae07ecfe0a4db3cf57',
's': '0x0259b52ee8c58baaa385fb05c3f96116e58de89bcc165cb3bfdfc708672fed8a',
}
it('should call next if not a eth_getTransactionByHash request', (done) => {
const req = { method: 'eth_getBlockByNumber' }
const res = {}
pendingTxMiddleware(req, res, () => done())
})
it('should call next if no pending txMeta is in history', (done) => {
const req = { method: 'eth_getTransactionByHash', params: [address] }
const res = {}
pendingTxMiddleware(req, res, () => done())
})
it('should fill the result with a the "pending" tx the result should match the rpc spec', (done) => {
returnUndefined = false
const req = { method: 'eth_getTransactionByHash', params: [address, 'pending'] }
const res = {}
pendingTxMiddleware(req, res, () => {
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]
it('should call next if not a "pending" block request', function (done) {
const req = { method: 'eth_getTransactionCount', params: [address] }
const res = {}
pendingNonceMiddleware(req, res, () => done())
})
it('should fill the result with a the "pending" nonce', function (done) {
const req = { method: 'eth_getTransactionCount', params: [address, 'pending'] }
const res = {}
pendingNonceMiddleware(req, res, () => {
done(new Error('should not have called next'))
}, () => {
assert(res.result === '0x2')
done()
})
console.log(coppy)
*/
assert.deepStrictEqual(res.result, spec, new Error('result does not match the spec object'))
done()
})
})
describe('#createPendingTxMiddleware', function () {
let returnUndefined = true
const getPendingTransactionByHash = () => (returnUndefined ? undefined : txMetaStub)
const address = '0xF231D46dD78806E1DD93442cf33C7671f8538748'
const pendingTxMiddleware = createPendingTxMiddleware({ getPendingTransactionByHash })
const spec = {
'blockHash': null,
'blockNumber': null,
'from': '0xf231d46dd78806e1dd93442cf33c7671f8538748',
'gas': '0x5208',
'gasPrice': '0x1e8480',
'hash': '0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09',
'input': '0x',
'nonce': '0x4',
'to': '0xf231d46dd78806e1dd93442cf33c7671f8538748',
'transactionIndex': null,
'value': '0x0',
'v': '0x2c',
'r': '0x5f973e540f2d3c2f06d3725a626b75247593cb36477187ae07ecfe0a4db3cf57',
's': '0x0259b52ee8c58baaa385fb05c3f96116e58de89bcc165cb3bfdfc708672fed8a',
}
it('should call next if not a eth_getTransactionByHash request', function (done) {
const req = { method: 'eth_getBlockByNumber' }
const res = {}
pendingTxMiddleware(req, res, () => done())
})
it('should call next if no pending txMeta is in history', function (done) {
const req = { method: 'eth_getTransactionByHash', params: [address] }
const res = {}
pendingTxMiddleware(req, res, () => done())
})
it('should fill the result with a the "pending" tx the result should match the rpc spec', function (done) {
returnUndefined = false
const req = { method: 'eth_getTransactionByHash', params: [address, 'pending'] }
const res = {}
pendingTxMiddleware(req, res, () => {
done(new Error('should not have called next'))
}, () => {
assert.deepStrictEqual(res.result, spec, new Error('result does not match the spec object'))
done()
})
})
})
})

View File

@ -8,7 +8,7 @@ describe('preferences controller', function () {
let preferencesController
let network
beforeEach(() => {
beforeEach(function () {
network = { providerStore: new ObservableStore({ type: 'mainnet' }) }
preferencesController = new PreferencesController({ network })
})
@ -346,7 +346,7 @@ describe('preferences controller', function () {
let stubNext, stubEnd, stubHandleWatchAssetERC20, asy, req, res
const sandbox = sinon.createSandbox()
beforeEach(() => {
beforeEach(function () {
req = { params: {} }
res = {}
asy = { next: () => {}, end: () => {} }
@ -354,7 +354,7 @@ describe('preferences controller', function () {
stubEnd = sandbox.stub(asy, 'end').returns(0)
stubHandleWatchAssetERC20 = sandbox.stub(preferencesController, '_handleWatchAssetERC20')
})
after(() => {
after(function () {
sandbox.restore()
})
@ -404,10 +404,10 @@ describe('preferences controller', function () {
let req
const sandbox = sinon.createSandbox()
beforeEach(() => {
beforeEach(function () {
req = { params: { type: 'ERC20' } }
})
after(() => {
after(function () {
sandbox.restore()
})
@ -514,7 +514,7 @@ describe('preferences controller', function () {
})
describe('#updateRpc', function () {
it('should update the rpcDetails properly', () => {
it('should update the rpcDetails properly', function () {
preferencesController.store.updateState({ frequentRpcListDetail: [{}, { rpcUrl: 'test' }, {}] })
preferencesController.updateRpc({ rpcUrl: 'test', chainId: 1 })
preferencesController.updateRpc({ rpcUrl: 'test/1', chainId: 1 })

View File

@ -3,15 +3,15 @@ import sinon from 'sinon'
import TokenRatesController from '../../../../app/scripts/controllers/token-rates'
import ObservableStore from 'obs-store'
describe('TokenRatesController', () => {
it('should listen for preferences store updates', () => {
describe('TokenRatesController', function () {
it('should listen for preferences store updates', function () {
const preferences = new ObservableStore({ tokens: [] })
const controller = new TokenRatesController({ preferences })
preferences.putState({ 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')
new TokenRatesController({ interval: 1337 }) // eslint-disable-line no-new
assert.strictEqual(stub.getCall(0).args[1], 1337)

View File

@ -56,17 +56,7 @@ describe('PendingTransactionTracker', 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 () {
// SETUP
const txGen = new MockTxGen()
txGen.generate({
@ -83,21 +73,19 @@ describe('PendingTransactionTracker', function () {
status: 'submitted',
}, { count: 1, fromNonce: '0x01' })[0]
stub = sinon.stub(pendingTxTracker, 'getCompletedTransactions')
const stub = sinon.stub(pendingTxTracker, 'getCompletedTransactions')
.returns(txGen.txs)
// THE EXPECTATION
const spy = sinon.spy()
pendingTxTracker.on('tx:dropped', (txId) => {
assert.equal(txId, pending.id, 'should fail the pending tx')
spy(txId)
})
// THE METHOD
await pendingTxTracker._checkPendingTx(pending)
// THE ASSERTION
assert.ok(spy.calledWith(pending.id), 'tx dropped should be emitted')
stub.restore()
})
})
@ -161,7 +149,7 @@ describe('PendingTransactionTracker', function () {
})
describe('#_checkPendingTxs', function () {
beforeEach(function () {
it('should warp all txMeta\'s in #updatePendingTxs', function (done) {
const txMeta2 = txMeta3 = txMeta
txMeta2.id = 2
txMeta3.id = 3
@ -171,9 +159,6 @@ describe('PendingTransactionTracker', function () {
})
return tx
})
})
it('should warp all txMeta\'s in #updatePendingTxs', function (done) {
pendingTxTracker.getPendingTransactions = () => txList
pendingTxTracker._checkPendingTx = (tx) => {
tx.resolve(tx)
@ -263,7 +248,7 @@ describe('PendingTransactionTracker', function () {
const mockFirstRetryBlockNumber = '0x1'
let txMetaToTestExponentialBackoff, enoughBalance
beforeEach(() => {
beforeEach(function () {
pendingTxTracker.getBalance = (address) => {
assert.equal(address, txMeta.txParams.from, 'Should pass the address')
return enoughBalance
@ -280,7 +265,7 @@ describe('PendingTransactionTracker', function () {
})
})
afterEach(() => {
afterEach(function () {
pendingTxTracker.publishTransaction.restore()
})
@ -327,7 +312,7 @@ describe('PendingTransactionTracker', function () {
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 = {
id: 40,
}
@ -340,7 +325,7 @@ describe('PendingTransactionTracker', function () {
})
})
describe('#_checkIftxWasDropped', () => {
describe('#_checkIftxWasDropped', function () {
const txMeta = {
id: 1,
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
@ -352,7 +337,7 @@ describe('PendingTransactionTracker', function () {
},
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_getTransactionReceipt'] = {}
pendingTxTracker._checkIftxWasDropped(txMeta, {}).then((dropped) => {

View File

@ -4,22 +4,21 @@ import { ROPSTEN_CODE, RINKEBY_CODE, KOVAN_CODE, GOERLI_CODE } from '../../../..
import KeyringController from 'eth-keyring-controller'
describe('Recipient Blacklist Checker', function () {
let publicAccounts
before(async function () {
const damnedMnemonic = 'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat'
const keyringController = new KeyringController({})
const Keyring = keyringController.getKeyringClassForType('HD Key Tree')
const opts = {
mnemonic: damnedMnemonic,
numberOfAccounts: 10,
}
const keyring = new Keyring(opts)
publicAccounts = await keyring.getAccounts()
})
describe('#checkAccount', function () {
let publicAccounts
before(async function () {
const damnedMnemonic = 'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat'
const keyringController = new KeyringController({})
const Keyring = keyringController.getKeyringClassForType('HD Key Tree')
const opts = {
mnemonic: damnedMnemonic,
numberOfAccounts: 10,
}
const keyring = new Keyring(opts)
publicAccounts = await keyring.getAccounts()
})
it('does not fail on test networks', function () {
let callCount = 0
const networks = [ROPSTEN_CODE, RINKEBY_CODE, KOVAN_CODE, GOERLI_CODE]

View File

@ -87,9 +87,8 @@ describe('Transaction Controller', function () {
})
describe('#getConfirmedTransactions', function () {
let address
beforeEach(function () {
address = '0xc684832530fcbddae4b4230a47e991ddcec2831d'
it('should return the number of confirmed txs', function () {
const address = '0xc684832530fcbddae4b4230a47e991ddcec2831d'
const txParams = {
'from': address,
'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
@ -105,9 +104,6 @@ describe('Transaction Controller', function () {
{ id: 7, status: 'submitted', 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)
})
})
@ -132,11 +128,11 @@ describe('Transaction Controller', function () {
txController.emit('newUnapprovedTx', txMeta)
return Promise.resolve(txController.txStateManager.addTx(txMeta))
})
})
afterEach(function () {
txController.txStateManager._saveTxList([])
stub.restore()
})
afterEach(function () {
txController.txStateManager._saveTxList([])
stub.restore()
})
it('should resolve when finished and status is submitted and resolve with the hash', function (done) {
@ -226,11 +222,11 @@ describe('Transaction Controller', function () {
it('should fail if the from address isn\'t the selected address', function (done) {
txController.addUnapprovedTransaction({ from: '0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2' })
.then(function () {
.then(() => {
assert.fail('transaction should not have been added')
done()
})
.catch(function () {
.catch(() => {
assert.ok('pass')
done()
})
@ -259,7 +255,7 @@ describe('Transaction Controller', 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 = {
txParams: {
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
@ -307,11 +303,9 @@ describe('Transaction Controller', function () {
})
describe('#approveTransaction', function () {
let txMeta, originalValue
beforeEach(function () {
originalValue = '0x01'
txMeta = {
it('does not overwrite set values', function (done) {
const originalValue = '0x01'
const txMeta = {
id: '1',
status: 'unapproved',
metamaskNetworkId: currentNetworkId,
@ -321,10 +315,6 @@ describe('Transaction Controller', function () {
gasPrice: originalValue,
},
}
})
it('does not overwrite set values', function (done) {
this.timeout(15000)
const wrongValue = '0x05'
@ -366,9 +356,8 @@ describe('Transaction Controller', function () {
})
describe('#updateAndApproveTransaction', function () {
let txMeta
beforeEach(() => {
txMeta = {
it('should update and approve transactions', async function () {
const txMeta = {
id: 1,
status: 'unapproved',
txParams: {
@ -380,8 +369,6 @@ describe('Transaction Controller', function () {
},
metamaskNetworkId: currentNetworkId,
}
})
it('should update and approve transactions', async () => {
txController.txStateManager.addTx(txMeta)
const approvalPromise = txController.updateAndApproveTransaction(txMeta)
const tx = txController.txStateManager.getTx(1)
@ -398,7 +385,7 @@ describe('Transaction Controller', function () {
})
describe('#cancelTransaction', function () {
beforeEach(function () {
it('should emit a status change to rejected', function (done) {
txController.txStateManager._saveTxList([
{ id: 0, status: 'unapproved', 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: 6, status: 'failed', txParams: {}, metamaskNetworkId: currentNetworkId, history: [{}] },
])
})
it('should emit a status change to rejected', function (done) {
txController.once('tx:status-update', (txId, status) => {
try {
assert.equal(status, 'rejected', 'status should e rejected')
@ -426,13 +411,13 @@ describe('Transaction Controller', function () {
})
describe('#createSpeedUpTransaction', () => {
describe('#createSpeedUpTransaction', function () {
let addTxSpy
let approveTransactionSpy
let txParams
let expectedTxParams
beforeEach(() => {
beforeEach(function () {
addTxSpy = sinon.spy(txController, 'addTx')
approveTransactionSpy = sinon.spy(txController, 'approveTransaction')
@ -450,12 +435,12 @@ describe('Transaction Controller', function () {
expectedTxParams = Object.assign({}, txParams, { gasPrice: '0xb' })
})
afterEach(() => {
afterEach(function () {
addTxSpy.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)
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)
assert.equal(approveTransactionSpy.callCount, 1)
@ -477,7 +462,7 @@ describe('Transaction Controller', function () {
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)
assert.deepEqual(result.txParams, expectedTxParams)
@ -686,7 +671,7 @@ describe('Transaction Controller', function () {
})
describe('#getPendingTransactions', function () {
beforeEach(function () {
it('should show only submitted and approved transactions as pending transasction', function () {
txController.txStateManager._saveTxList([
{ id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
{ 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: 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)
const states = txController.pendingTxTracker.getPendingTransactions().map(tx => tx.status)
assert(states.includes('approved'), 'includes approved')

View File

@ -30,7 +30,7 @@ describe('TransactionStateManager', function () {
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 noop = function () {
assert(true, 'event listener has been triggered and noop executed')
@ -53,7 +53,7 @@ describe('TransactionStateManager', function () {
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: {} }
txStateManager.addTx(tx)
const noop = () => {
@ -303,7 +303,6 @@ describe('TransactionStateManager', function () {
assert.equal(txStateManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
filterParams = { status: (status) => status !== 'confirmed' }
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(txFromOtherNetworks.length, 2)
})
})
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._removeTx(1)
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._removeTx(1)
assert.equal(txStateManager.getFullTxList()[0].id, 2, 'txList should have a id of 2')

View File

@ -25,8 +25,8 @@ describe('txUtils', function () {
})
})
describe('#normalizeTxParams', () => {
it('should normalize txParams', () => {
describe('#normalizeTxParams', function () {
it('should normalize txParams', function () {
const txParams = {
chainId: '0x1',
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 () {
const zeroRecipientandDataTxParams = {
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 () {
// where from is undefined

View File

@ -3,8 +3,8 @@ import nock from 'nock'
import fetchWithTimeout from '../../../app/scripts/lib/fetch-with-timeout'
describe('fetchWithTimeout', () => {
it('fetches a url', async () => {
describe('fetchWithTimeout', function () {
it('fetches a url', async function () {
nock('https://api.infura.io')
.get('/money')
.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')
.get('/moon')
.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')
.get('/moon')
.delay(2000)

View File

@ -12,7 +12,7 @@ describe('nodeify', function () {
it('should retain original context', function (done) {
const nodified = nodeify(obj.promiseFunc, obj)
nodified('baz', function (err, res) {
nodified('baz', (err, res) => {
if (!err) {
assert.equal(res, 'barbaz')
done()
@ -36,7 +36,7 @@ describe('nodeify', function () {
const nodified = nodeify(async () => {
throw new Error('boom!')
}, obj)
process.prependOnceListener('uncaughtException', function (err) {
process.prependOnceListener('uncaughtException', (err) => {
assert.ok(err, 'got expected error')
assert.ok(err.message.includes('boom!'), 'got expected error message')
done()

View File

@ -45,19 +45,15 @@ describe('PendingBalanceCalculator', function () {
})
describe('if you have no pending txs and one ether', function () {
beforeEach(function () {
balanceCalculator = generateBalanceCalcWith([], etherBn)
})
it('returns the network balance', async function () {
balanceCalculator = generateBalanceCalcWith([], etherBn)
const result = await balanceCalculator.getBalance()
assert.equal(result, ether, `gave ${result} needed ${ether}`)
})
})
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()
pendingTxs = txGen.generate({
status: 'submitted',
@ -69,14 +65,11 @@ describe('PendingBalanceCalculator', function () {
}, { count: 1 })
balanceCalculator = generateBalanceCalcWith(pendingTxs, etherBn)
})
it('returns the subtracted result', async function () {
const result = await balanceCalculator.getBalance()
assert.equal(result, '0x0', `gave ${result} needed '0x0'`)
return true
})
})
})

View File

@ -3,14 +3,14 @@ import sinon from 'sinon'
import NetworkController from '../../../app/scripts/controllers/network/index'
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
const address = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
const networkController = new NetworkController()
sinon.stub(networkController, 'getNetworkState').returns('1')
beforeEach(() => {
beforeEach(function () {
typedMessageManager = new TypedMessageManager({
networkController,
})
@ -72,7 +72,7 @@ describe('Typed Message Manager', () => {
numberMsgId = parseInt(msgId)
})
it('supports version 1 of signedTypedData', () => {
it('supports version 1 of signedTypedData', function () {
typedMessageManager.addUnapprovedMessage(msgParamsV1, null, 'V1')
assert.equal(messages[messages.length - 1].msgParams.data, msgParamsV1.data)
})

View File

@ -8,82 +8,84 @@ import {
ENVIRONMENT_TYPE_BACKGROUND,
} from '../../../app/scripts/lib/enums'
describe('getEnvironmentType', function () {
it('should return popup type', function () {
const environmentType = getEnvironmentType('http://extension-id/popup.html')
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP)
describe('app utils', function () {
describe('getEnvironmentType', function () {
it('should return popup type', function () {
const environmentType = getEnvironmentType('http://extension-id/popup.html')
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP)
})
it('should return notification type', function () {
const environmentType = getEnvironmentType('http://extension-id/notification.html')
assert.equal(environmentType, ENVIRONMENT_TYPE_NOTIFICATION)
})
it('should return fullscreen type for home.html', function () {
const environmentType = getEnvironmentType('http://extension-id/home.html')
assert.equal(environmentType, ENVIRONMENT_TYPE_FULLSCREEN)
})
it('should return fullscreen type for phishing.html', function () {
const environmentType = getEnvironmentType('http://extension-id/phishing.html')
assert.equal(environmentType, ENVIRONMENT_TYPE_FULLSCREEN)
})
it('should return background type', function () {
const environmentType = getEnvironmentType('http://extension-id/_generated_background_page.html')
assert.equal(environmentType, ENVIRONMENT_TYPE_BACKGROUND)
})
it('should return the correct type for a URL with a hash fragment', function () {
const environmentType = getEnvironmentType('http://extension-id/popup.html#hash')
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP)
})
it('should return the correct type for a URL with query parameters', function () {
const environmentType = getEnvironmentType('http://extension-id/popup.html?param=foo')
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP)
})
it('should return the correct type for a URL with query parameters and a hash fragment', function () {
const environmentType = getEnvironmentType('http://extension-id/popup.html?param=foo#hash')
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP)
})
})
it('should return notification type', function () {
const environmentType = getEnvironmentType('http://extension-id/notification.html')
assert.equal(environmentType, ENVIRONMENT_TYPE_NOTIFICATION)
})
describe('SufficientBalance', function () {
it('returns true if max tx cost is equal to balance.', function () {
const tx = {
'value': '0x1',
'gas': '0x2',
'gasPrice': '0x3',
}
const balance = '0x8'
it('should return fullscreen type for home.html', function () {
const environmentType = getEnvironmentType('http://extension-id/home.html')
assert.equal(environmentType, ENVIRONMENT_TYPE_FULLSCREEN)
})
const result = sufficientBalance(tx, balance)
assert.ok(result, 'sufficient balance found.')
})
it('should return fullscreen type for phishing.html', function () {
const environmentType = getEnvironmentType('http://extension-id/phishing.html')
assert.equal(environmentType, ENVIRONMENT_TYPE_FULLSCREEN)
})
it('returns true if max tx cost is less than balance.', function () {
const tx = {
'value': '0x1',
'gas': '0x2',
'gasPrice': '0x3',
}
const balance = '0x9'
it('should return background type', function () {
const environmentType = getEnvironmentType('http://extension-id/_generated_background_page.html')
assert.equal(environmentType, ENVIRONMENT_TYPE_BACKGROUND)
})
const result = sufficientBalance(tx, balance)
assert.ok(result, 'sufficient balance found.')
})
it('should return the correct type for a URL with a hash fragment', function () {
const environmentType = getEnvironmentType('http://extension-id/popup.html#hash')
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP)
})
it('returns false if max tx cost is more than balance.', function () {
const tx = {
'value': '0x1',
'gas': '0x2',
'gasPrice': '0x3',
}
const balance = '0x6'
it('should return the correct type for a URL with query parameters', function () {
const environmentType = getEnvironmentType('http://extension-id/popup.html?param=foo')
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP)
})
it('should return the correct type for a URL with query parameters and a hash fragment', function () {
const environmentType = getEnvironmentType('http://extension-id/popup.html?param=foo#hash')
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP)
})
})
describe('SufficientBalance', function () {
it('returns true if max tx cost is equal to balance.', function () {
const tx = {
'value': '0x1',
'gas': '0x2',
'gasPrice': '0x3',
}
const balance = '0x8'
const result = sufficientBalance(tx, balance)
assert.ok(result, 'sufficient balance found.')
})
it('returns true if max tx cost is less than balance.', function () {
const tx = {
'value': '0x1',
'gas': '0x2',
'gasPrice': '0x3',
}
const balance = '0x9'
const result = sufficientBalance(tx, balance)
assert.ok(result, 'sufficient balance found.')
})
it('returns false if max tx cost is more than balance.', function () {
const tx = {
'value': '0x1',
'gas': '0x2',
'gasPrice': '0x3',
}
const balance = '0x6'
const result = sufficientBalance(tx, balance)
assert.ok(!result, 'insufficient balance found.')
const result = sufficientBalance(tx, balance)
assert.ok(!result, 'insufficient balance found.')
})
})
})

View File

@ -2,8 +2,8 @@ import assert from 'assert'
import wallet2 from '../../lib/migrations/002.json'
import migration21 from '../../../app/scripts/migrations/021'
describe('wallet2 is migrated successfully with out the BlacklistController', () => {
it('should delete BlacklistController key', (done) => {
describe('wallet2 is migrated successfully with out the BlacklistController', function () {
it('should delete BlacklistController key', function (done) {
migration21.migrate(wallet2)
.then((migratedData) => {
assert.equal(migratedData.meta.version, 21)

View File

@ -15,8 +15,8 @@ const storage = {
},
}
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => {
it('should add submittedTime key on the txMeta if appropriate', (done) => {
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', function () {
it('should add submittedTime key on the txMeta if appropriate', function (done) {
migration22.migrate(storage)
.then((migratedData) => {
const [txMeta1, txMeta2, txMeta3] = migratedData.data.TransactionController.transactions

View File

@ -57,8 +57,8 @@ while (transactions20.length < 20) {
storage.data.TransactionController.transactions = transactions
describe('storage is migrated successfully and the proper transactions are remove from state', () => {
it('should remove transactions that are unneeded', (done) => {
describe('storage is migrated successfully and the proper transactions are remove from state', function () {
it('should remove transactions that are unneeded', function (done) {
migration23.migrate(storage)
.then((migratedData) => {
let leftoverNonDeletableTxCount = 0
@ -74,7 +74,7 @@ describe('storage is migrated successfully and the proper transactions are remov
}).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.data.TransactionController.transactions = transactions40
migration23.migrate(storage)
@ -86,7 +86,7 @@ describe('storage is migrated successfully and the proper transactions are remov
}).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.data.TransactionController.transactions = transactions20
migration23.migrate(storage)

View File

@ -27,8 +27,8 @@ while (transactions.length <= 10) {
storage.data.TransactionController.transactions = transactions
describe('storage is migrated successfully and the txParams.from are lowercase', () => {
it('should lowercase the from for unapproved txs', (done) => {
describe('storage is migrated successfully and the txParams.from are lowercase', function () {
it('should lowercase the from for unapproved txs', function (done) {
migration24.migrate(storage)
.then((migratedData) => {
const migratedTransactions = migratedData.data.TransactionController.transactions
@ -43,7 +43,7 @@ describe('storage is migrated successfully and the txParams.from are lowercase',
}).catch(done)
})
it('should migrate first time state', (done) => {
it('should migrate first time state', function (done) {
migration24.migrate(firstTimeState)
.then((migratedData) => {
assert.equal(migratedData.meta.version, 24)

View File

@ -28,8 +28,8 @@ while (transactions.length <= 10) {
storage.data.TransactionController.transactions = transactions
describe('storage is migrated successfully and the txParams.from are lowercase', () => {
it('should lowercase the from for unapproved txs', (done) => {
describe('storage is migrated successfully and the txParams.from are lowercase', function () {
it('should lowercase the from for unapproved txs', function (done) {
migration25.migrate(storage)
.then((migratedData) => {
const migratedTransactions = migratedData.data.TransactionController.transactions
@ -45,7 +45,7 @@ describe('storage is migrated successfully and the txParams.from are lowercase',
}).catch(done)
})
it('should migrate first time state', (done) => {
it('should migrate first time state', function (done) {
migration25.migrate(firstTimeState)
.then((migratedData) => {
assert.equal(migratedData.meta.version, 25)

View File

@ -14,8 +14,8 @@ const oldStorage = {
},
}
describe('migration #26', () => {
it('should move the identities from KeyringController', (done) => {
describe('migration #26', function () {
it('should move the identities from KeyringController', function (done) {
migration26.migrate(oldStorage)
.then((newStorage) => {
const identities = newStorage.data.PreferencesController.identities
@ -29,7 +29,7 @@ describe('migration #26', () => {
.catch(done)
})
it('should successfully migrate first time state', (done) => {
it('should successfully migrate first time state', function (done) {
migration26.migrate({
meta: {},
data: require('../../../app/scripts/first-time-state'),

View File

@ -23,8 +23,8 @@ while (transactions.length < 9) {
oldStorage.data.TransactionController.transactions = transactions
describe('migration #27', () => {
it('should remove rejected transactions', (done) => {
describe('migration #27', function () {
it('should remove rejected transactions', function (done) {
migration27.migrate(oldStorage)
.then((newStorage) => {
const newTransactions = newStorage.data.TransactionController.transactions
@ -39,7 +39,7 @@ describe('migration #27', () => {
.catch(done)
})
it('should successfully migrate first time state', (done) => {
it('should successfully migrate first time state', function (done) {
migration27.migrate({
meta: {},
data: require('../../../app/scripts/first-time-state'),

View File

@ -14,8 +14,8 @@ const oldStorage = {
},
}
describe('migration #28', () => {
it('should add corresponding tokens to accountTokens', (done) => {
describe('migration #28', function () {
it('should add corresponding tokens to accountTokens', function (done) {
migration28.migrate(oldStorage)
.then((newStorage) => {
const newTokens = newStorage.data.PreferencesController.tokens
@ -33,7 +33,7 @@ describe('migration #28', () => {
.catch(done)
})
it('should successfully migrate first time state', (done) => {
it('should successfully migrate first time state', function (done) {
migration28.migrate({
meta: {},
data: require('../../../app/scripts/first-time-state'),

View File

@ -17,8 +17,8 @@ const storage = {
},
}
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => {
it('should auto fail transactions more than 12 hours old', (done) => {
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', function () {
it('should auto fail transactions more than 12 hours old', function (done) {
migration29.migrate(storage)
.then((migratedData) => {
const txs = migratedData.data.TransactionController.transactions

View File

@ -23,8 +23,8 @@ const storage = {
},
}
describe('storage is migrated successfully', () => {
it('should work', (done) => {
describe('storage is migrated successfully', function () {
it('should work', function (done) {
migrationTemplate.migrate(storage)
.then((migratedData) => {
assert.equal(migratedData.meta.version, 30)

View File

@ -1,8 +1,8 @@
import assert from 'assert'
import migration31 from '../../../app/scripts/migrations/031'
describe('migration #31', () => {
it('should set completedOnboarding to true if vault exists', done => {
describe('migration #31', function () {
it('should set completedOnboarding to true if vault exists', function (done) {
const oldStorage = {
'meta': {},
'data': {
@ -31,7 +31,7 @@ describe('migration #31', () => {
.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 = {
'meta': {},
'data': {

View File

@ -1,7 +1,7 @@
import assert from 'assert'
import migration33 from '../../../app/scripts/migrations/033'
describe('Migration to delete notice controller', () => {
describe('Migration to delete notice controller', function () {
const oldStorage = {
'meta': {},
'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)
.then(newStorage => {
assert.equal(newStorage.data.NoticeController, undefined)

View File

@ -1,8 +1,8 @@
import assert from 'assert'
import migration34 from '../../../app/scripts/migrations/034'
describe('migration #34', () => {
it('should update the version metadata', (done) => {
describe('migration #34', function () {
it('should update the version metadata', function (done) {
const oldStorage = {
'meta': {
'version': 33,
@ -20,7 +20,7 @@ describe('migration #34', () => {
.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 = {
'meta': {},
'data': {
@ -45,7 +45,7 @@ describe('migration #34', () => {
.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 = {
'meta': {},
'data': {
@ -66,7 +66,7 @@ describe('migration #34', () => {
.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 = {
'meta': {},
'data': {
@ -87,7 +87,7 @@ describe('migration #34', () => {
.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 = {
'meta': {},
'data': {},
@ -101,7 +101,7 @@ describe('migration #34', () => {
.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 = {
'meta': {},
'data': {

View File

@ -1,8 +1,8 @@
import assert from 'assert'
import migration35 from '../../../app/scripts/migrations/035'
describe('migration #35', () => {
it('should update the version metadata', (done) => {
describe('migration #35', function () {
it('should update the version metadata', function (done) {
const oldStorage = {
meta: {
version: 34,
@ -20,7 +20,7 @@ describe('migration #35', () => {
.catch(done)
})
it('should delete seedWords', (done) => {
it('should delete seedWords', function (done) {
const oldStorage = {
meta: {},
data: {
@ -38,7 +38,7 @@ describe('migration #35', () => {
.catch(done)
})
it('should delete falsy seedWords', (done) => {
it('should delete falsy seedWords', function (done) {
const oldStorage = {
meta: {},
data: {
@ -56,7 +56,7 @@ describe('migration #35', () => {
.catch(done)
})
it('should leave state without seedWords unchanged', (done) => {
it('should leave state without seedWords unchanged', function (done) {
const oldStorage = {
meta: {},
data: {

View File

@ -1,8 +1,8 @@
import assert from 'assert'
import migration36 from '../../../app/scripts/migrations/036'
describe('migration #36', () => {
it('should update the version metadata', (done) => {
describe('migration #36', function () {
it('should update the version metadata', function (done) {
const oldStorage = {
'meta': {
'version': 35,
@ -20,7 +20,7 @@ describe('migration #36', () => {
.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 = {
'meta': {},
'data': {
@ -43,7 +43,7 @@ describe('migration #36', () => {
.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 = {
'meta': {},
'data': {
@ -66,7 +66,7 @@ describe('migration #36', () => {
.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 = {
'meta': {},
'data': {
@ -86,7 +86,7 @@ describe('migration #36', () => {
.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 = {
'meta': {},
'data': {},
@ -100,7 +100,7 @@ describe('migration #36', () => {
.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 = {
'meta': {},
'data': {

View File

@ -1,8 +1,8 @@
import assert from 'assert'
import migration37 from '../../../app/scripts/migrations/037'
describe('migration #37', () => {
it('should update the version metadata', (done) => {
describe('migration #37', function () {
it('should update the version metadata', function (done) {
const oldStorage = {
'meta': {
'version': 36,
@ -20,7 +20,7 @@ describe('migration #37', () => {
.catch(done)
})
it('should transform old state to new format', (done) => {
it('should transform old state to new format', function (done) {
const oldStorage = {
'meta': {},
'data': {
@ -84,7 +84,7 @@ describe('migration #37', () => {
.catch(done)
})
it('ens validation test', (done) => {
it('ens validation test', function (done) {
const oldStorage = {
'meta': {},
'data': {

View File

@ -1,8 +1,8 @@
import assert from 'assert'
import migration38 from '../../../app/scripts/migrations/038'
describe('migration #38', () => {
it('should update the version metadata', (done) => {
describe('migration #38', function () {
it('should update the version metadata', function (done) {
const oldStorage = {
'meta': {
'version': 37,
@ -20,7 +20,7 @@ describe('migration #38', () => {
.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 = {
'meta': {},
'data': {},
@ -34,7 +34,7 @@ describe('migration #38', () => {
.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 = {
'meta': {},
'data': {

View File

@ -1,8 +1,8 @@
import assert from 'assert'
import migration39 from '../../../app/scripts/migrations/039'
describe('migration #39', () => {
it('should update the version metadata', (done) => {
describe('migration #39', function () {
it('should update the version metadata', function (done) {
const oldStorage = {
'meta': {
'version': 38,
@ -20,7 +20,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -64,7 +64,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -152,7 +152,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -170,7 +170,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -206,7 +206,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -258,7 +258,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -284,7 +284,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -310,7 +310,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -333,7 +333,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -351,7 +351,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -369,7 +369,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -386,7 +386,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {
@ -403,7 +403,7 @@ describe('migration #39', () => {
.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 = {
'meta': {},
'data': {},

View File

@ -19,8 +19,8 @@ let vault5, vault6, vault7, vault8, vault9 // vault10, vault11
const oldTestRpc = 'https://rawtestrpc.metamask.io/'
const newTestRpc = 'https://testrpc.metamask.io/'
describe('wallet1 is migrated successfully', () => {
it('should convert providers', () => {
describe('wallet1 is migrated successfully', function () {
it('should convert providers', function () {
wallet1.data.config.provider = { type: 'etherscan', rpcTarget: null }
return migration2.migrate(wallet1)

View File

@ -40,47 +40,50 @@ const firstTimeState = {
meta: { version: 0 },
data,
}
describe('liveMigrations require list', () => {
it('should include all the migrations', async () => {
const fileNames = await pify(cb => fs.readdir('./app/scripts/migrations/', cb))()
const migrationNumbers = fileNames.reduce((agg, filename) => {
const name = filename.split('.')[0]
if (/^\d+$/.test(name)) {
agg.push(name)
}
return agg
}, []).map((num) => parseInt(num))
migrationNumbers.forEach((num) => {
const migration = liveMigrations.find((m) => m.version === num)
assert(migration, `migration should be include in the index missing migration ${num}`)
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 migrationNumbers = fileNames.reduce((agg, filename) => {
const name = filename.split('.')[0]
if (/^\d+$/.test(name)) {
agg.push(name)
}
return agg
}, []).map((num) => parseInt(num))
migrationNumbers.forEach((num) => {
const migration = liveMigrations.find((m) => m.version === num)
assert(migration, `migration should be include in the index missing migration ${num}`)
})
})
})
describe('Migrator', function () {
const migrator = new Migrator({ migrations: stubMigrations })
it('migratedData version should be version 3', async function () {
const migratedData = await migrator.migrateData(versionedData)
assert.equal(migratedData.meta.version, stubMigrations[2].version)
})
it('should match the last version in live migrations', async function () {
const migrator = new Migrator({ migrations: liveMigrations })
const migratedData = await migrator.migrateData(firstTimeState)
const last = liveMigrations.length - 1
assert.equal(migratedData.meta.version, liveMigrations[last].version)
})
it('should emit an error', async function () {
const migrator = new Migrator({
migrations: [{
version: 1,
async migrate () {
throw new Error('test')
},
}],
})
await assert.rejects(migrator.migrateData({ meta: { version: 0 } }))
})
})
})
describe('Migrator', () => {
const migrator = new Migrator({ migrations: stubMigrations })
it('migratedData version should be version 3', async () => {
const migratedData = await migrator.migrateData(versionedData)
assert.equal(migratedData.meta.version, stubMigrations[2].version)
})
it('should match the last version in live migrations', async () => {
const migrator = new Migrator({ migrations: liveMigrations })
const migratedData = await migrator.migrateData(firstTimeState)
const last = liveMigrations.length - 1
assert.equal(migratedData.meta.version, liveMigrations[last].version)
})
it('should emit an error', async () => {
const migrator = new Migrator({
migrations: [{
version: 1,
async migrate () {
throw new Error('test')
},
}],
})
await assert.rejects(migrator.migrateData({ meta: { version: 0 } }))
})
})

View File

@ -6,8 +6,8 @@ const storage = {
data: {},
}
describe('storage is migrated successfully', () => {
it('should work', (done) => {
describe('storage is migrated successfully', function () {
it('should work', function (done) {
migrationTemplate.migrate(storage)
.then((migratedData) => {
assert.equal(migratedData.meta.version, 0)

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ import { mount } from 'enzyme'
import TokenCell from '../../../../../ui/app/components/app/token-cell'
import Identicon from '../../../../../ui/app/components/ui/identicon'
describe('Token Cell', () => {
describe('Token Cell', function () {
let wrapper
const state = {
@ -33,7 +33,7 @@ describe('Token Cell', () => {
const mockStore = configureMockStore(middlewares)
const store = mockStore(state)
beforeEach(() => {
beforeEach(function () {
wrapper = mount(
<Provider store={store}>
<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('network'), 'test')
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')
})
it('renders token symbol', () => {
it('renders token symbol', function () {
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')
})

View File

@ -4,7 +4,7 @@ import { actionConstants } from '../../../../../ui/app/store/actions'
const actions = actionConstants
describe('App State', () => {
describe('App State', function () {
const metamaskState = {
selectedAddress: '0xAddress',
@ -16,13 +16,13 @@ describe('App State', () => {
},
}
it('App init state', () => {
it('App init state', function () {
const initState = reduceApp(metamaskState, {})
assert(initState)
})
it('sets networkDropdownOpen dropdown to true', () => {
it('sets networkDropdownOpen dropdown to true', function () {
const state = reduceApp(metamaskState, {
type: actions.NETWORK_DROPDOWN_OPEN,
})
@ -30,7 +30,7 @@ describe('App State', () => {
assert.equal(state.networkDropdownOpen, true)
})
it('sets networkDropdownOpen dropdown to false', () => {
it('sets networkDropdownOpen dropdown to false', function () {
const dropdown = { networkDropdowopen: true }
const state = { ...metamaskState, ...dropdown }
const newState = reduceApp(state, {
@ -40,7 +40,7 @@ describe('App State', () => {
assert.equal(newState.networkDropdownOpen, false)
})
it('opens sidebar', () => {
it('opens sidebar', function () {
const value = {
'transitionName': 'sidebar-right',
'type': 'wallet-view',
@ -54,7 +54,7 @@ describe('App State', () => {
assert.deepEqual(state.sidebar, value)
})
it('closes sidebar', () => {
it('closes sidebar', function () {
const openSidebar = { sidebar: { isOpen: true } }
const state = { ...metamaskState, ...openSidebar }
@ -65,7 +65,7 @@ describe('App State', () => {
assert.equal(newState.sidebar.isOpen, false)
})
it('opens alert', () => {
it('opens alert', function () {
const state = reduceApp(metamaskState, {
type: actions.ALERT_OPEN,
value: 'test message',
@ -75,7 +75,7 @@ describe('App State', () => {
assert.equal(state.alertMessage, 'test message')
})
it('closes alert', () => {
it('closes alert', function () {
const alert = { alertOpen: true, alertMessage: 'test message' }
const state = { ...metamaskState, ...alert }
const newState = reduceApp(state, {
@ -86,7 +86,7 @@ describe('App State', () => {
assert.equal(newState.alertMessage, null)
})
it('detects qr code data', () => {
it('detects qr code data', function () {
const state = reduceApp(metamaskState, {
type: actions.QR_CODE_DETECTED,
value: 'qr data',
@ -95,7 +95,7 @@ describe('App State', () => {
assert.equal(state.qrCodeData, 'qr data')
})
it('opens modal', () => {
it('opens modal', function () {
const state = reduceApp(metamaskState, {
type: actions.MODAL_OPEN,
payload: {
@ -107,7 +107,7 @@ describe('App State', () => {
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 = {
modal: {
open: true,
@ -127,7 +127,7 @@ describe('App State', () => {
assert.equal(newState.modal.modalState.name, null)
})
it('transitions forwards', () => {
it('transitions forwards', function () {
const state = reduceApp(metamaskState, {
type: actions.TRANSITION_FORWARD,
})
@ -135,7 +135,7 @@ describe('App State', () => {
assert.equal(state.transForward, true)
})
it('shows send token page', () => {
it('shows send token page', function () {
const state = reduceApp(metamaskState, {
type: actions.SHOW_SEND_TOKEN_PAGE,
})
@ -144,7 +144,7 @@ describe('App State', () => {
assert.equal(state.warning, null)
})
it('unlocks Metamask', () => {
it('unlocks Metamask', function () {
const state = reduceApp(metamaskState, {
type: actions.UNLOCK_METAMASK,
})
@ -155,7 +155,7 @@ describe('App State', () => {
assert.equal(state.warning, null)
})
it('locks Metamask', () => {
it('locks Metamask', function () {
const state = reduceApp(metamaskState, {
type: actions.LOCK_METAMASK,
})
@ -164,7 +164,7 @@ describe('App State', () => {
assert.equal(state.warning, null)
})
it('goes home', () => {
it('goes home', function () {
const state = reduceApp(metamaskState, {
type: actions.GO_HOME,
})
@ -177,7 +177,7 @@ describe('App State', () => {
})
it('shows account detail', () => {
it('shows account detail', function () {
const state = reduceApp(metamaskState, {
type: actions.SHOW_ACCOUNT_DETAIL,
value: 'context address',
@ -190,7 +190,7 @@ describe('App State', () => {
})
it('shoes account page', () => {
it('shoes account page', function () {
const state = reduceApp(metamaskState, {
type: actions.SHOW_ACCOUNTS_PAGE,
})
@ -202,7 +202,7 @@ describe('App State', () => {
assert.equal(state.forgottenPassword, false)
})
it('shows confirm tx page', () => {
it('shows confirm tx page', function () {
const txs = {
unapprovedTxs: {
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 = {
unapprovedTxs: {
1: {
@ -253,7 +253,7 @@ describe('App State', () => {
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, {
type: actions.COMPLETED_TX,
value: {
@ -264,10 +264,9 @@ describe('App State', () => {
assert.equal(state.transForward, false)
assert.equal(state.warning, null)
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, {
type: actions.UNLOCK_FAILED,
})
@ -275,7 +274,7 @@ describe('App State', () => {
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, {
type: actions.UNLOCK_FAILED,
value: 'errors',
@ -284,7 +283,7 @@ describe('App State', () => {
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 oldState = { ...metamaskState, ...errorState }
const state = reduceApp(oldState, {
@ -294,7 +293,7 @@ describe('App State', () => {
assert.equal(state.warning, '')
})
it('sets hardware wallet default hd path', () => {
it('sets hardware wallet default hd path', function () {
const hdPaths = {
trezor: "m/44'/60'/0'/0",
ledger: "m/44'/60'/0'",
@ -310,7 +309,7 @@ describe('App State', () => {
assert.deepEqual(state.defaultHdPaths, hdPaths)
})
it('shows loading message', () => {
it('shows loading message', function () {
const state = reduceApp(metamaskState, {
type: actions.SHOW_LOADING,
value: 'loading',
@ -320,7 +319,7 @@ describe('App State', () => {
assert.equal(state.loadingMessage, 'loading')
})
it('hides loading message', () => {
it('hides loading message', function () {
const loadingState = { isLoading: true }
const oldState = { ...metamaskState, ...loadingState }
@ -331,7 +330,7 @@ describe('App State', () => {
assert.equal(state.isLoading, false)
})
it('shows sub loading indicator', () => {
it('shows sub loading indicator', function () {
const state = reduceApp(metamaskState, {
type: actions.SHOW_SUB_LOADING_INDICATION,
})
@ -339,7 +338,7 @@ describe('App State', () => {
assert.equal(state.isSubLoading, true)
})
it('hides sub loading indicator', () => {
it('hides sub loading indicator', function () {
const oldState = { ...metamaskState, isSubLoading: true }
const state = reduceApp(oldState, {
type: actions.HIDE_SUB_LOADING_INDICATION,
@ -348,7 +347,7 @@ describe('App State', () => {
assert.equal(state.isSubLoading, false)
})
it('displays warning', () => {
it('displays warning', function () {
const state = reduceApp(metamaskState, {
type: actions.DISPLAY_WARNING,
value: 'warning',
@ -358,7 +357,7 @@ describe('App State', () => {
assert.equal(state.warning, 'warning')
})
it('hides warning', () => {
it('hides warning', function () {
const displayWarningState = { warning: 'warning' }
const oldState = { ...metamaskState, ...displayWarningState }
const state = reduceApp(oldState, {
@ -368,7 +367,7 @@ describe('App State', () => {
assert.equal(state.warning, undefined)
})
it('shows private key', () => {
it('shows private key', function () {
const state = reduceApp(metamaskState, {
type: actions.SHOW_PRIVATE_KEY,
value: 'private key',
@ -379,7 +378,7 @@ describe('App State', () => {
assert.equal(state.accountDetail.privateKey, 'private key')
})
it('updates pair', () => {
it('updates pair', function () {
const coinOptions = {
BTC: {
symbol: 'BTC',
@ -427,7 +426,7 @@ describe('App State', () => {
assert.equal(state.buyView.amount, '12.00')
})
it('shows QR', () => {
it('shows QR', function () {
const state = reduceApp(metamaskState, {
type: actions.SHOW_QR,
value: {
@ -442,7 +441,7 @@ describe('App State', () => {
assert.equal(state.Qr.data, 'data')
})
it('shows qr view', () => {
it('shows qr view', function () {
const appState = {
currentView: {
context: 'accounts',
@ -463,7 +462,7 @@ describe('App State', () => {
assert.equal(state.Qr.data, 'data')
})
it('set mouse user state', () => {
it('set mouse user state', function () {
const state = reduceApp(metamaskState, {
type: actions.SET_MOUSE_USER_STATE,
value: true,
@ -472,7 +471,7 @@ describe('App State', () => {
assert.equal(state.isMouseUser, true)
})
it('sets gas loading', () => {
it('sets gas loading', function () {
const state = reduceApp(metamaskState, {
type: actions.GAS_LOADING_STARTED,
})
@ -480,7 +479,7 @@ describe('App State', () => {
assert.equal(state.gasIsLoading, true)
})
it('unsets gas loading', () => {
it('unsets gas loading', function () {
const gasLoadingState = { gasIsLoading: true }
const oldState = { ...metamaskState, ...gasLoadingState }
const state = reduceApp(oldState, {
@ -490,7 +489,7 @@ describe('App State', () => {
assert.equal(state.gasIsLoading, false)
})
it('sets network nonce', () => {
it('sets network nonce', function () {
const state = reduceApp(metamaskState, {
type: actions.SET_NETWORK_NONCE,
value: '33',

View File

@ -2,14 +2,14 @@ import assert from 'assert'
import reduceMetamask from '../../../../../ui/app/ducks/metamask/metamask'
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, {})
assert(initState)
})
it('unlocks MetaMask', () => {
it('unlocks MetaMask', function () {
const state = reduceMetamask({}, {
type: actions.UNLOCK_METAMASK,
value: 'test address',
@ -20,7 +20,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.selectedAddress, 'test address')
})
it('locks MetaMask', () => {
it('locks MetaMask', function () {
const unlockMetaMaskState = {
isUnlocked: true,
isInitialzed: false,
@ -33,7 +33,7 @@ describe('MetaMask Reducers', () => {
assert.equal(lockMetaMask.isUnlocked, false)
})
it('sets rpc target', () => {
it('sets rpc target', function () {
const state = reduceMetamask({}, {
type: actions.SET_RPC_TARGET,
value: 'https://custom.rpc',
@ -42,7 +42,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.provider.rpcTarget, 'https://custom.rpc')
})
it('sets provider type', () => {
it('sets provider type', function () {
const state = reduceMetamask({}, {
type: actions.SET_PROVIDER_TYPE,
value: 'provider type',
@ -51,7 +51,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.provider.type, 'provider type')
})
it('shows account detail', () => {
it('shows account detail', function () {
const state = reduceMetamask({}, {
type: actions.SHOW_ACCOUNT_DETAIL,
@ -63,7 +63,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.selectedAddress, 'test address')
})
it('sets select ', () => {
it('sets select ', function () {
const state = reduceMetamask({}, {
type: actions.SET_SELECTED_TOKEN,
value: 'test token',
@ -72,7 +72,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.selectedTokenAddress, 'test token')
})
it('sets account label', () => {
it('sets account label', function () {
const state = reduceMetamask({}, {
type: actions.SET_ACCOUNT_LABEL,
value: {
@ -84,7 +84,7 @@ describe('MetaMask Reducers', () => {
assert.deepEqual(state.identities, { 'test account': { name: 'test label' } })
})
it('sets current fiat', () => {
it('sets current fiat', function () {
const value = {
currentCurrency: 'yen',
conversionRate: 3.14,
@ -101,7 +101,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.conversionDate, value.conversionDate)
})
it('updates tokens', () => {
it('updates tokens', function () {
const newTokens = {
'address': '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
'decimals': 18,
@ -116,7 +116,7 @@ describe('MetaMask Reducers', () => {
assert.deepEqual(state.tokens, newTokens)
})
it('updates send gas limit', () => {
it('updates send gas limit', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_GAS_LIMIT,
@ -126,7 +126,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.send.gasLimit, '0xGasLimit')
})
it('updates send gas price', () => {
it('updates send gas price', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_GAS_PRICE,
value: '0xGasPrice',
@ -135,7 +135,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.send.gasPrice, '0xGasPrice')
})
it('toggles account menu ', () => {
it('toggles account menu ', function () {
const state = reduceMetamask({}, {
type: actions.TOGGLE_ACCOUNT_MENU,
})
@ -143,7 +143,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.isAccountMenuOpen, true)
})
it('updates gas total', () => {
it('updates gas total', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_GAS_TOTAL,
value: '0xGasTotal',
@ -152,7 +152,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.send.gasTotal, '0xGasTotal')
})
it('updates send token balance', () => {
it('updates send token balance', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_SEND_TOKEN_BALANCE,
value: '0xTokenBalance',
@ -161,7 +161,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.send.tokenBalance, '0xTokenBalance')
})
it('updates data', () => {
it('updates data', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_SEND_HEX_DATA,
value: '0xData',
@ -170,7 +170,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.send.data, '0xData')
})
it('updates send to', () => {
it('updates send to', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_SEND_TO,
value: {
@ -183,7 +183,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.send.toNickname, 'nickname')
})
it('update send amount', () => {
it('update send amount', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_SEND_AMOUNT,
value: '0xAmount',
@ -192,7 +192,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.send.amount, '0xAmount')
})
it('updates max mode', () => {
it('updates max mode', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_MAX_MODE,
value: true,
@ -201,7 +201,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.send.maxModeOn, true)
})
it('update send', () => {
it('update send', function () {
const value = {
gasLimit: '0xGasLimit',
gasPrice: '0xGasPrice',
@ -228,7 +228,7 @@ describe('MetaMask Reducers', () => {
assert.deepEqual(sendState.send, value)
})
it('clears send', () => {
it('clears send', function () {
const initStateSend = {
send:
{ gasLimit: null,
@ -272,7 +272,7 @@ describe('MetaMask Reducers', () => {
assert.deepEqual(state.send, initStateSend.send)
})
it('updates value of tx by id', () => {
it('updates value of tx by id', function () {
const oldState = {
selectedAddressTxList: [
{
@ -291,7 +291,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.selectedAddressTxList[0].txParams, 'bar')
})
it('updates pair for shapeshift', () => {
it('updates pair for shapeshift', function () {
const state = reduceMetamask({}, {
type: actions.PAIR_UPDATE,
value: {
@ -304,7 +304,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.tokenExchangeRates['test pair'].pair, 'test pair')
})
it('sets blockies', () => {
it('sets blockies', function () {
const state = reduceMetamask({}, {
type: actions.SET_USE_BLOCKIE,
value: true,
@ -313,7 +313,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.useBlockie, true)
})
it('updates an arbitrary feature flag', () => {
it('updates an arbitrary feature flag', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_FEATURE_FLAGS,
value: {
@ -324,7 +324,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.featureFlags.foo, true)
})
it('close welcome screen', () => {
it('close welcome screen', function () {
const state = reduceMetamask({}, {
type: actions.CLOSE_WELCOME_SCREEN,
})
@ -332,7 +332,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.welcomeScreenSeen, true)
})
it('sets current locale', () => {
it('sets current locale', function () {
const state = reduceMetamask({}, {
type: actions.SET_CURRENT_LOCALE,
value: { locale: 'ge' },
@ -341,7 +341,7 @@ describe('MetaMask Reducers', () => {
assert.equal(state.currentLocale, 'ge')
})
it('sets pending tokens ', () => {
it('sets pending tokens ', function () {
const payload = {
'address': '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
'decimals': 18,
@ -356,7 +356,7 @@ describe('MetaMask Reducers', () => {
assert.deepEqual(pendingTokensState.pendingTokens, payload)
})
it('clears pending tokens', () => {
it('clears pending tokens', function () {
const payload = {
'address': '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4',
'decimals': 18,
@ -374,7 +374,7 @@ describe('MetaMask Reducers', () => {
assert.deepEqual(state.pendingTokens, {})
})
it('update ensResolution', () => {
it('update ensResolution', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_SEND_ENS_RESOLUTION,
payload: '0x1337',
@ -384,7 +384,7 @@ describe('MetaMask Reducers', () => {
assert.deepEqual(state.send.ensResolutionError, '')
})
it('update ensResolutionError', () => {
it('update ensResolutionError', function () {
const state = reduceMetamask({}, {
type: actions.UPDATE_SEND_ENS_RESOLUTION_ERROR,
payload: 'ens name not found',

View File

@ -109,50 +109,50 @@ describe('Selectors', function () {
assert.equal(currentAccountwithSendEther.name, 'Test Account')
})
it('#getGasIsLoading', () => {
it('#getGasIsLoading', function () {
const gasIsLoading = selectors.getGasIsLoading(mockState)
assert.equal(gasIsLoading, false)
})
describe('Send From', () => {
it('#getSendFrom', () => {
describe('Send From', function () {
it('#getSendFrom', function () {
const sendFrom = selectors.getSendFrom(mockState)
assert.equal(sendFrom, '0xc42edfcc21ed14dda456aa0756c153f7985d8813')
})
it('#getForceGasMin', () => {
it('#getForceGasMin', function () {
const forceGasMin = selectors.getForceGasMin(mockState)
assert.equal(forceGasMin, null)
})
it('#getSendAmount', () => {
it('#getSendAmount', function () {
const sendAmount = selectors.getSendAmount(mockState)
assert.equal(sendAmount, '1bc16d674ec80000')
})
it('#getSendMaxModeState', () => {
it('#getSendMaxModeState', function () {
const sendMaxModeState = selectors.getSendMaxModeState(mockState)
assert.equal(sendMaxModeState, false)
})
})
it('#getCurrentCurrency', () => {
it('#getCurrentCurrency', function () {
const currentCurrency = selectors.getCurrentCurrency(mockState)
assert.equal(currentCurrency, 'usd')
})
it('#getSelectedTokenToFiatRate', () => {
it('#getSelectedTokenToFiatRate', function () {
const selectedTokenToFiatRate = selectors.getSelectedTokenToFiatRate(mockState)
assert.equal(selectedTokenToFiatRate, '0.21880988420033492152')
})
it('#getSelectedTokenContract', () => {
it('#getSelectedTokenContract', function () {
global.eth = new Eth(provider)
const selectedTokenContract = selectors.getSelectedTokenContract(mockState)
assert(selectedTokenContract.abi)
})
it('#getTotalUnapprovedCount', () => {
it('#getTotalUnapprovedCount', function () {
const totalUnapprovedCount = selectors.getTotalUnapprovedCount(mockState)
assert.equal(totalUnapprovedCount, 1)
})

View File

@ -1,29 +1,29 @@
import assert from 'assert'
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(), '')
})
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), '')
})
it('returns ropsten as prefix for networkId of 3', () => {
it('returns ropsten as prefix for networkId of 3', function () {
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.')
})
it('returs kovan as prefix for networkId of 42', () => {
it('returs kovan as prefix for networkId of 42', function () {
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.')
})

View File

@ -12,12 +12,12 @@ web3.currentProvider.enable().then(() => {
Object.keys(methodGroup).forEach(methodKey => {
const methodButton = document.getElementById(methodKey)
methodButton.addEventListener('click', function () {
methodButton.addEventListener('click', () => {
window.ethereum.sendAsync({
method: methodKey,
params: methodGroup[methodKey][1],
}, function (err, result) {
}, (err, result) => {
if (err) {
console.log(err)
console.log(methodKey)

View File

@ -6,7 +6,7 @@ import { mountWithRouter } from '../../../../../../test/lib/render-helpers'
import AccountMenu from '../index'
import { Provider } from 'react-redux'
describe('Account Menu', async () => {
describe('Account Menu', function () {
let wrapper
@ -63,7 +63,7 @@ describe('Account Menu', async () => {
}
before(() => {
before(function () {
wrapper = mountWithRouter(
<Provider store={store}>
<AccountMenu.WrappedComponent {...props} />
@ -71,23 +71,23 @@ describe('Account Menu', async () => {
)
})
afterEach(() => {
afterEach(function () {
props.toggleAccountMenu.resetHistory()
props.history.push.resetHistory()
})
describe('Render Content', () => {
it('returns account name from identities', () => {
describe('Render Content', function () {
it('returns account name from identities', function () {
const accountName = wrapper.find('.account-menu__name')
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')
assert.equal(accountBalance.length, 2)
})
it('simulate click', () => {
it('simulate click', function () {
const click = wrapper.find('.account-menu__account.menu__item--clickable')
click.first().simulate('click')
@ -95,12 +95,12 @@ describe('Account Menu', async () => {
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')
assert.equal(importedAccount.text(), 'imported')
})
it('remove account', () => {
it('remove account', function () {
const removeAccount = wrapper.find('.remove-account-icon')
removeAccount.simulate('click', {
preventDefault: () => {},
@ -114,93 +114,93 @@ describe('Account Menu', async () => {
})
})
describe('Log Out', () => {
describe('Log Out', function () {
let logout
it('logout', () => {
it('logout', function () {
logout = wrapper.find('.account-menu__lock-button')
assert.equal(logout.length, 1)
})
it('simulate click', () => {
it('simulate click', function () {
logout.simulate('click')
assert(props.lockMetamask.calledOnce)
assert.equal(props.history.push.getCall(0).args[0], '/')
})
})
describe('Create Account', () => {
describe('Create Account', function () {
let createAccount
it('renders create account item', () => {
it('renders create account item', function () {
createAccount = wrapper.find({ text: 'createAccount' })
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')
assert(props.toggleAccountMenu.calledOnce)
assert.equal(props.history.push.getCall(0).args[0], '/new-account')
})
})
describe('Import Account', () => {
describe('Import Account', function () {
let importAccount
it('renders import account item', () => {
it('renders import account item', function () {
importAccount = wrapper.find({ text: 'importAccount' })
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')
assert(props.toggleAccountMenu.calledOnce)
assert(props.history.push.getCall(0).args[0], '/new-account/import')
})
})
describe('Connect Hardware Wallet', () => {
describe('Connect Hardware Wallet', function () {
let connectHardwareWallet
it('renders import account item', () => {
it('renders import account item', function () {
connectHardwareWallet = wrapper.find({ text: 'connectHardwareWallet' })
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')
assert(props.toggleAccountMenu.calledOnce)
assert.equal(props.history.push.getCall(0).args[0], '/new-account/connect')
})
})
describe('Info & Help', () => {
describe('Info & Help', function () {
let infoHelp
it('renders import account item', () => {
it('renders import account item', function () {
infoHelp = wrapper.find({ text: 'infoHelp' })
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')
assert(props.toggleAccountMenu.calledOnce)
assert.equal(props.history.push.getCall(0).args[0], '/settings/about-us')
})
})
describe('Settings', () => {
describe('Settings', function () {
let settings
it('renders import account item', () => {
it('renders import account item', function () {
settings = wrapper.find({ text: 'settings' })
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')
assert(props.toggleAccountMenu.calledOnce)
assert.equal(props.history.push.getCall(0).args[0], '/settings')

View File

@ -5,7 +5,7 @@ import { shallow } from 'enzyme'
import MetaFoxLogo from '../../../ui/metafox-logo'
import AppHeader from '../index'
describe('App Header', () => {
describe('App Header', function () {
let wrapper
const props = {
@ -25,7 +25,7 @@ describe('App Header', () => {
isUnlocked: true,
}
beforeEach(() => {
beforeEach(function () {
wrapper = shallow(
<AppHeader.WrappedComponent {...props} />, {
context: {
@ -36,12 +36,12 @@ describe('App Header', () => {
)
})
afterEach(() => {
afterEach(function () {
props.toggleAccountMenu.resetHistory()
})
describe('App Header Logo', () => {
it('routes to default route when logo is clicked', () => {
describe('App Header Logo', function () {
it('routes to default route when logo is clicked', function () {
const appLogo = wrapper.find(MetaFoxLogo)
appLogo.simulate('click')
assert(props.history.push.calledOnce)
@ -49,8 +49,8 @@ describe('App Header', () => {
})
})
describe('Network', () => {
it('shows network dropdown when networkDropdownOpen is false', () => {
describe('Network', function () {
it('shows network dropdown when networkDropdownOpen is false', function () {
const network = wrapper.find({ network: 'test' })
network.simulate('click', {
@ -61,7 +61,7 @@ describe('App Header', () => {
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 })
const network = wrapper.find({ network: 'test' })
@ -73,22 +73,22 @@ describe('App Header', () => {
assert(props.hideNetworkDropdown.calledOnce)
})
it('hides network indicator', () => {
it('hides network indicator', function () {
wrapper.setProps({ hideNetworkIndicator: true })
const network = wrapper.find({ network: 'test' })
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')
accountMenu.simulate('click')
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 })
const accountMenu = wrapper.find('.account-menu__icon')
accountMenu.simulate('click')

View File

@ -9,56 +9,56 @@ const propsMethodSpies = {
}
describe('Confirm Detail Row Component', function () {
let wrapper
describe('render', function () {
let wrapper
beforeEach(() => {
wrapper = shallow(
<ConfirmDetailRow
errorType="mockErrorType"
label="mockLabel"
showError={false}
primaryText="mockFiatText"
secondaryText="mockEthText"
primaryValueTextColor="mockColor"
onHeaderClick={propsMethodSpies.onHeaderClick}
headerText="mockHeaderText"
headerTextClassName="mockHeaderClass"
/>
)
})
beforeEach(function () {
wrapper = shallow(
<ConfirmDetailRow
errorType="mockErrorType"
label="mockLabel"
showError={false}
primaryText="mockFiatText"
secondaryText="mockEthText"
primaryValueTextColor="mockColor"
onHeaderClick={propsMethodSpies.onHeaderClick}
headerText="mockHeaderText"
headerTextClassName="mockHeaderClass"
/>
)
})
describe('render', () => {
it('should render a div with a confirm-detail-row class', () => {
it('should render a div with a confirm-detail-row class', function () {
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')
})
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')
})
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')
})
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')
})
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')
})
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')
})
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()
assert.equal(assert.equal(propsMethodSpies.onHeaderClick.callCount, 1))
assert.ok(propsMethodSpies.onHeaderClick.calledOnce)
})
})
})

View File

@ -4,12 +4,12 @@ import sinon from 'sinon'
import { shallow } from 'enzyme'
import { DropdownMenuItem } from '../components/dropdown.js'
describe('Dropdown', () => {
describe('Dropdown', function () {
let wrapper
const onClickSpy = sinon.spy()
const closeMenuSpy = sinon.spy()
beforeEach(() => {
beforeEach(function () {
wrapper = shallow(
<DropdownMenuItem
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)
})
it('adds style based on props passed', () => {
it('adds style based on props passed', function () {
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')()
assert.equal(onClickSpy.callCount, 1)
assert.equal(closeMenuSpy.callCount, 1)

View File

@ -4,29 +4,21 @@ import sinon from 'sinon'
import { shallow } from 'enzyme'
import { Menu, Item, Divider, CloseArea } from '../components/menu'
describe('Dropdown Menu Components', () => {
describe('Menu', () => {
let wrapper
beforeEach(() => {
wrapper = shallow(
describe('Dropdown Menu Components', function () {
describe('Menu', function () {
it('adds prop className to menu', function () {
const wrapper = shallow(
<Menu className="Test Class" isShowing />
)
})
it('adds prop className to menu', () => {
assert.equal(wrapper.find('.menu').prop('className'), 'menu Test Class')
})
})
describe('Item', () => {
describe('Item', function () {
let wrapper
const onClickSpy = sinon.spy()
beforeEach(() => {
beforeEach(function () {
wrapper = shallow(
<Item
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')
})
it('simulates onClick called', () => {
it('simulates onClick called', function () {
wrapper.find('.menu__item').prop('onClick')()
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')
})
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')
})
})
describe('Divider', () => {
let wrapper
before(() => {
wrapper = shallow(<Divider />)
})
it('renders menu divider', () => {
describe('Divider', function () {
it('renders menu divider', function () {
const wrapper = shallow(<Divider />)
assert.equal(wrapper.find('.menu__divider').length, 1)
})
})
describe('CloseArea', () => {
let wrapper
const onClickSpy = sinon.spy()
beforeEach(() => {
wrapper = shallow((
describe('CloseArea', function () {
it('simulates click', function () {
const onClickSpy = sinon.spy()
const wrapper = shallow((
<CloseArea
onClick={onClickSpy}
/>
))
})
it('simulates click', () => {
wrapper.prop('onClick')()
assert.equal(onClickSpy.callCount, 1)
assert.ok(onClickSpy.calledOnce)
})
})
})

View File

@ -3,11 +3,9 @@ import assert from 'assert'
import { shallow } from 'enzyme'
import NetworkDropdownIcon from '../components/network-dropdown-icon'
describe('Network Dropdown Icon', () => {
let wrapper
beforeEach(() => {
wrapper = shallow((
describe('Network Dropdown Icon', function () {
it('adds style props based on props', function () {
const wrapper = shallow((
<NetworkDropdownIcon
backgroundColor="red"
isSelected={false}
@ -15,9 +13,6 @@ describe('Network Dropdown Icon', () => {
diameter="12"
/>
))
})
it('adds style props based on props', () => {
const styleProp = wrapper.find('.menu-icon-circle').children().prop('style')
assert.equal(styleProp.background, 'red')
assert.equal(styleProp.border, 'none')

View File

@ -6,10 +6,10 @@ import NetworkDropdown from '../network-dropdown'
import { DropdownMenuItem } from '../components/dropdown'
import NetworkDropdownIcon from '../components/network-dropdown-icon'
describe('Network Dropdown', () => {
describe('Network Dropdown', function () {
let wrapper
describe('NetworkDropdown in appState in false', () => {
describe('NetworkDropdown in appState in false', function () {
const mockState = {
metamask: {
network: '1',
@ -24,23 +24,23 @@ describe('Network Dropdown', () => {
const store = createMockStore(mockState)
beforeEach(() => {
beforeEach(function () {
wrapper = mountWithRouter(
<NetworkDropdown store={store} />
)
})
it('checks for network droppo class', () => {
it('checks for network droppo class', function () {
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)
})
})
describe('NetworkDropdown in appState is true', () => {
describe('NetworkDropdown in appState is true', function () {
const mockState = {
metamask: {
network: '1',
@ -57,45 +57,45 @@ describe('Network Dropdown', () => {
}
const store = createMockStore(mockState)
beforeEach(() => {
beforeEach(function () {
wrapper = mountWithRouter(
<NetworkDropdown store={store} />,
)
})
it('renders 7 DropDownMenuItems ', () => {
it('renders 7 DropDownMenuItems ', function () {
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
})
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
})
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
})
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
})
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
})
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')
})
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')
})
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')
})

View File

@ -4,7 +4,7 @@ import sinon from 'sinon'
import { mount } from 'enzyme'
import AdvancedTabContent from '../index'
describe('Advanced Gas Inputs', () => {
describe('Advanced Gas Inputs', function () {
let wrapper, clock
const props = {
@ -19,7 +19,7 @@ describe('Advanced Gas Inputs', () => {
isSpeedUp: false,
}
beforeEach(() => {
beforeEach(function () {
clock = sinon.useFakeTimers()
wrapper = mount(
@ -32,11 +32,11 @@ describe('Advanced Gas Inputs', () => {
})
})
afterEach(() => {
afterEach(function () {
clock.restore()
})
it('wont update gasPrice in props before debounce', () => {
it('wont update gasPrice in props before debounce', function () {
const event = { target: { value: 1 } }
wrapper.find('input').at(0).simulate('change', event)
@ -45,7 +45,7 @@ describe('Advanced Gas Inputs', () => {
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 } }
wrapper.find('input').at(0).simulate('change', event)
@ -55,7 +55,7 @@ describe('Advanced Gas Inputs', () => {
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 } }
wrapper.find('input').at(1).simulate('change', event)
@ -64,7 +64,7 @@ describe('Advanced Gas Inputs', () => {
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 } }
wrapper.find('input').at(1).simulate('change', event)
@ -74,7 +74,7 @@ describe('Advanced Gas Inputs', () => {
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 })
const renderError = wrapper.find('.advanced-gas-inputs__gas-edit-row__error-text')
assert.equal(renderError.length, 2)
@ -83,7 +83,7 @@ describe('Advanced Gas Inputs', () => {
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 })
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')
})
it('warns when custom gas price is too low', () => {
it('warns when custom gas price is too low', function () {
wrapper.setProps({ customPriceIsSafe: false })
const renderWarning = wrapper.find('.advanced-gas-inputs__gas-edit-row__warning-text')

View File

@ -17,7 +17,7 @@ sinon.spy(AdvancedTabContent.prototype, 'renderDataSummary')
describe('AdvancedTabContent Component', function () {
let wrapper
beforeEach(() => {
beforeEach(function () {
wrapper = shallow((
<AdvancedTabContent
updateCustomGasPrice={propsMethodSpies.updateCustomGasPrice}
@ -34,18 +34,18 @@ describe('AdvancedTabContent Component', function () {
))
})
afterEach(() => {
afterEach(function () {
propsMethodSpies.updateCustomGasPrice.resetHistory()
propsMethodSpies.updateCustomGasLimit.resetHistory()
AdvancedTabContent.prototype.renderDataSummary.resetHistory()
})
describe('render()', () => {
it('should render the advanced-tab root node', () => {
describe('render()', function () {
it('should render the advanced-tab root node', function () {
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()
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'))
})
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 })
const advancedTabChildren = wrapper.children()
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'))
})
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
assert.deepEqual(renderDataSummaryArgs, ['$0.25', 21500])
})
})
describe('renderDataSummary()', () => {
describe('renderDataSummary()', function () {
let dataSummary
beforeEach(() => {
beforeEach(function () {
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'))
})
it('should render titles of the data', () => {
it('should render titles of the data', function () {
const titlesNode = dataSummary.children().at(0)
assert(titlesNode.hasClass('advanced-tab__transaction-data-summary__titles'))
assert.equal(titlesNode.children().at(0).text(), 'newTransactionFee')
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)
assert(dataNode.hasClass('advanced-tab__transaction-data-summary__container'))
assert.equal(dataNode.children().at(0).text(), 'mockTotalFee')

View File

@ -2,7 +2,6 @@ import React from 'react'
import assert from 'assert'
import shallow from '../../../../../../../lib/shallow-with-context'
import BasicTabContent from '../basic-tab-content.component'
import GasPriceButtonGroup from '../../../gas-price-button-group'
import Loading from '../../../../../ui/loading-screen'
import { GAS_ESTIMATE_TYPES } from '../../../../../../helpers/constants/common'
@ -39,26 +38,26 @@ const mockGasPriceButtonGroupProps = {
}
describe('BasicTabContent Component', function () {
let wrapper
describe('render', function () {
let wrapper
beforeEach(() => {
wrapper = shallow((
<BasicTabContent
gasPriceButtonGroupProps={mockGasPriceButtonGroupProps}
/>
))
})
beforeEach(function () {
wrapper = shallow((
<BasicTabContent
gasPriceButtonGroupProps={mockGasPriceButtonGroupProps}
/>
))
})
describe('render', () => {
it('should have a title', () => {
it('should have a title', function () {
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)
})
it('should pass correct props to GasPriceButtonGroup', () => {
it('should pass correct props to GasPriceButtonGroup', function () {
const {
buttonDataLoading,
className,
@ -76,7 +75,7 @@ describe('BasicTabContent Component', function () {
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({
gasPriceButtonGroupProps: { ...mockGasPriceButtonGroupProps, loading: true },
})

View File

@ -62,7 +62,7 @@ const GP = GasModalPageContainer.prototype
describe('GasModalPageContainer Component', function () {
let wrapper
beforeEach(() => {
beforeEach(function () {
wrapper = shallow((
<GasModalPageContainer
cancelAndClose={propsMethodSpies.cancelAndClose}
@ -84,19 +84,19 @@ describe('GasModalPageContainer Component', function () {
))
})
afterEach(() => {
afterEach(function () {
propsMethodSpies.cancelAndClose.resetHistory()
})
describe('componentDidMount', () => {
it('should call props.fetchBasicGasAndTimeEstimates', () => {
describe('componentDidMount', function () {
it('should call props.fetchBasicGasAndTimeEstimates', function () {
propsMethodSpies.fetchBasicGasAndTimeEstimates.resetHistory()
assert.equal(propsMethodSpies.fetchBasicGasAndTimeEstimates.callCount, 0)
wrapper.instance().componentDidMount()
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()
assert.equal(propsMethodSpies.fetchGasEstimates.callCount, 0)
wrapper.instance().componentDidMount()
@ -106,12 +106,12 @@ describe('GasModalPageContainer Component', function () {
})
})
describe('render', () => {
it('should render a PageContainer compenent', () => {
describe('render', function () {
it('should render a PageContainer compenent', function () {
assert.equal(wrapper.find(PageContainer).length, 1)
})
it('should pass correct props to PageContainer', () => {
it('should pass correct props to PageContainer', function () {
const {
title,
subtitle,
@ -122,7 +122,7 @@ describe('GasModalPageContainer Component', function () {
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 {
onCancel,
onClose,
@ -134,7 +134,7 @@ describe('GasModalPageContainer Component', function () {
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')
const renderTabsWrapperTester = shallow((
<GasModalPageContainer
@ -148,20 +148,20 @@ describe('GasModalPageContainer Component', function () {
})
})
describe('renderTabs', () => {
beforeEach(() => {
describe('renderTabs', function () {
beforeEach(function () {
sinon.spy(GP, 'renderBasicTabContent')
sinon.spy(GP, 'renderAdvancedTabContent')
sinon.spy(GP, 'renderInfoRows')
})
afterEach(() => {
afterEach(function () {
GP.renderBasicTabContent.restore()
GP.renderAdvancedTabContent.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 renderedTabs = shallow(renderTabsResult)
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')
})
it('should call renderInfoRows with the expected props', () => {
it('should call renderInfoRows with the expected props', function () {
assert.equal(GP.renderInfoRows.callCount, 0)
wrapper.instance().renderTabs()
@ -187,7 +187,7 @@ describe('GasModalPageContainer Component', function () {
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((
<GasModalPageContainer
cancelAndClose={propsMethodSpies.cancelAndClose}
@ -217,8 +217,8 @@ describe('GasModalPageContainer Component', function () {
})
})
describe('renderBasicTabContent', () => {
it('should render', () => {
describe('renderBasicTabContent', function () {
it('should render', function () {
const renderBasicTabContentResult = wrapper.instance().renderBasicTabContent(mockGasPriceButtonGroupProps)
assert.deepEqual(
@ -228,8 +228,8 @@ describe('GasModalPageContainer Component', function () {
})
})
describe('renderInfoRows', () => {
it('should render the info rows with the passed data', () => {
describe('renderInfoRows', function () {
it('should render the info rows with the passed data', function () {
const baseClassName = 'gas-modal-content__info-row'
const renderedInfoRowsContainer = shallow(wrapper.instance().renderInfoRows(
'mockNewTotalFiat',

View File

@ -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()', () => {
it('should map the correct properties to props', () => {
describe('mapStateToProps()', function () {
it('should map the correct properties to props', function () {
const baseMockState = {
appState: {
modal: {
@ -257,31 +257,31 @@ describe('gas-modal-page-container container', () => {
})
describe('mapDispatchToProps()', () => {
describe('mapDispatchToProps()', function () {
let dispatchSpy
let mapDispatchToPropsObject
beforeEach(() => {
beforeEach(function () {
dispatchSpy = sinon.spy()
mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy)
})
afterEach(() => {
afterEach(function () {
actionSpies.hideModal.resetHistory()
gasActionSpies.setCustomGasPrice.resetHistory()
gasActionSpies.setCustomGasLimit.resetHistory()
})
describe('hideGasButtonGroup()', () => {
it('should dispatch a hideGasButtonGroup action', () => {
describe('hideGasButtonGroup()', function () {
it('should dispatch a hideGasButtonGroup action', function () {
mapDispatchToPropsObject.hideGasButtonGroup()
assert(dispatchSpy.calledOnce)
assert(sendActionSpies.hideGasButtonGroup.calledOnce)
})
})
describe('cancelAndClose()', () => {
it('should dispatch a hideModal action', () => {
describe('cancelAndClose()', function () {
it('should dispatch a hideModal action', function () {
mapDispatchToPropsObject.cancelAndClose()
assert(dispatchSpy.calledTwice)
assert(actionSpies.hideModal.calledOnce)
@ -289,17 +289,15 @@ describe('gas-modal-page-container container', () => {
})
})
describe('updateCustomGasPrice()', () => {
it('should dispatch a setCustomGasPrice action with the arg passed to updateCustomGasPrice hex prefixed', () => {
describe('updateCustomGasPrice()', function () {
it('should dispatch a setCustomGasPrice action with the arg passed to updateCustomGasPrice hex prefixed', function () {
mapDispatchToPropsObject.updateCustomGasPrice('ffff')
assert(dispatchSpy.calledOnce)
assert(gasActionSpies.setCustomGasPrice.calledOnce)
assert.equal(gasActionSpies.setCustomGasPrice.getCall(0).args[0], '0xffff')
})
})
describe('updateCustomGasPrice()', () => {
it('should dispatch a setCustomGasPrice action', () => {
it('should dispatch a setCustomGasPrice action', function () {
mapDispatchToPropsObject.updateCustomGasPrice('0xffff')
assert(dispatchSpy.calledOnce)
assert(gasActionSpies.setCustomGasPrice.calledOnce)
@ -307,9 +305,8 @@ describe('gas-modal-page-container container', () => {
})
})
describe('updateCustomGasLimit()', () => {
it('should dispatch a setCustomGasLimit action', () => {
describe('updateCustomGasLimit()', function () {
it('should dispatch a setCustomGasLimit action', function () {
mapDispatchToPropsObject.updateCustomGasLimit('0x10')
assert(dispatchSpy.calledOnce)
assert(gasActionSpies.setCustomGasLimit.calledOnce)
@ -317,8 +314,8 @@ describe('gas-modal-page-container container', () => {
})
})
describe('setGasData()', () => {
it('should dispatch a setGasPrice and setGasLimit action with the correct props', () => {
describe('setGasData()', function () {
it('should dispatch a setGasPrice and setGasLimit action with the correct props', function () {
mapDispatchToPropsObject.setGasData('ffff', 'aaaa')
assert(dispatchSpy.calledTwice)
assert(actionSpies.setGasPrice.calledOnce)
@ -328,8 +325,8 @@ describe('gas-modal-page-container container', () => {
})
})
describe('updateConfirmTxGasAndCalculate()', () => {
it('should dispatch a updateGasAndCalculate action with the correct props', () => {
describe('updateConfirmTxGasAndCalculate()', function () {
it('should dispatch a updateGasAndCalculate action with the correct props', function () {
mapDispatchToPropsObject.updateConfirmTxGasAndCalculate('ffff', 'aaaa')
assert.equal(dispatchSpy.callCount, 3)
assert(actionSpies.setGasPrice.calledOnce)
@ -341,12 +338,12 @@ describe('gas-modal-page-container container', () => {
})
describe('mergeProps', () => {
describe('mergeProps', function () {
let stateProps
let dispatchProps
let ownProps
beforeEach(() => {
beforeEach(function () {
stateProps = {
gasPriceButtonGroupProps: {
someGasPriceButtonGroupProp: 'foo',
@ -370,7 +367,7 @@ describe('gas-modal-page-container container', () => {
ownProps = { someOwnProp: 123 }
})
afterEach(() => {
afterEach(function () {
dispatchProps.updateCustomGasPrice.resetHistory()
dispatchProps.hideGasButtonGroup.resetHistory()
dispatchProps.setGasData.resetHistory()
@ -380,7 +377,7 @@ describe('gas-modal-page-container container', () => {
dispatchProps.hideSidebar.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)
assert.equal(result.isConfirm, true)
@ -410,7 +407,7 @@ describe('gas-modal-page-container container', () => {
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)
assert.equal(result.isConfirm, false)
@ -441,7 +438,7 @@ describe('gas-modal-page-container container', () => {
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)
result.onSubmit()

View File

@ -47,7 +47,7 @@ sinon.spy(GasPriceButtonGroup.prototype, 'renderButtonContent')
describe('GasPriceButtonGroup Component', function () {
let wrapper
beforeEach(() => {
beforeEach(function () {
wrapper = shallow((
<GasPriceButtonGroup
{...mockGasPriceButtonGroupProps}
@ -55,18 +55,18 @@ describe('GasPriceButtonGroup Component', function () {
))
})
afterEach(() => {
afterEach(function () {
GasPriceButtonGroup.prototype.renderButton.resetHistory()
GasPriceButtonGroup.prototype.renderButtonContent.resetHistory()
mockGasPriceButtonGroupProps.handleGasPriceSelection.resetHistory()
})
describe('render', () => {
it('should render a ButtonGroup', () => {
describe('render', function () {
it('should render a ButtonGroup', function () {
assert(wrapper.is(ButtonGroup))
})
it('should render the correct props on the ButtonGroup', () => {
it('should render the correct props on the ButtonGroup', function () {
const {
className,
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)
renderButtonArgsTest(0, mockButtonPropsAndFlags)
renderButtonArgsTest(1, mockButtonPropsAndFlags)
renderButtonArgsTest(2, mockButtonPropsAndFlags)
})
it('should show loading if buttonDataLoading', () => {
it('should show loading if buttonDataLoading', function () {
wrapper.setProps({ buttonDataLoading: true })
assert(wrapper.is('div'))
assert(wrapper.hasClass('gas-price-button-group__loading-container'))
@ -103,10 +103,10 @@ describe('GasPriceButtonGroup Component', function () {
})
})
describe('renderButton', () => {
describe('renderButton', function () {
let wrappedRenderButtonResult
beforeEach(() => {
beforeEach(function () {
GasPriceButtonGroup.prototype.renderButtonContent.resetHistory()
const renderButtonResult = GasPriceButtonGroup.prototype.renderButton(
Object.assign({}, mockGasPriceButtonGroupProps.gasButtonInfo[0]),
@ -115,11 +115,11 @@ describe('GasPriceButtonGroup Component', function () {
wrappedRenderButtonResult = shallow(renderButtonResult)
})
it('should render a button', () => {
it('should render a button', function () {
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)
wrappedRenderButtonResult.props().onClick()
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)
const {
feeInPrimaryCurrency,
@ -157,8 +157,8 @@ describe('GasPriceButtonGroup Component', function () {
})
})
describe('renderButtonContent', () => {
it('should render a label if passed a gasEstimateType', () => {
describe('renderButtonContent', function () {
it('should render a label if passed a gasEstimateType', function () {
const renderButtonContentResult = wrapper.instance().renderButtonContent({
gasEstimateType: 'SLOW',
}, {
@ -169,7 +169,7 @@ describe('GasPriceButtonGroup Component', function () {
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({
feeInPrimaryCurrency: 'mockFeeInPrimaryCurrency',
}, {
@ -180,7 +180,7 @@ describe('GasPriceButtonGroup Component', function () {
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({
feeInSecondaryCurrency: 'mockFeeInSecondaryCurrency',
}, {
@ -191,7 +191,7 @@ describe('GasPriceButtonGroup Component', function () {
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({
timeEstimate: 'mockTimeEstimate',
}, {
@ -202,7 +202,7 @@ describe('GasPriceButtonGroup Component', function () {
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({}, {
className: 'someClass',
showCheck: true,
@ -211,7 +211,7 @@ describe('GasPriceButtonGroup Component', function () {
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({
gasEstimateType: 'SLOW',
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 wrappedRenderButtonContentResult = shallow(renderButtonContentResult)
assert.equal(wrappedRenderButtonContentResult.children().length, 0)

View File

@ -77,37 +77,37 @@ sinon.spy(GasPriceChart.prototype, 'renderChart')
describe('GasPriceChart Component', function () {
let wrapper
beforeEach(() => {
beforeEach(function () {
wrapper = shallow(<GasPriceChart {...testProps} />)
})
describe('render()', () => {
it('should render', () => {
describe('render()', function () {
it('should render', function () {
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.equal(wrapper.childAt(0).props().id, 'chart')
})
})
describe('componentDidMount', () => {
it('should call this.renderChart', () => {
describe('componentDidMount', function () {
it('should call this.renderChart', function () {
assert(GasPriceChart.prototype.renderChart.callCount, 1)
wrapper.instance().componentDidMount()
assert(GasPriceChart.prototype.renderChart.callCount, 2)
})
})
describe('componentDidUpdate', () => {
it('should call handleChartUpdate if props.currentPrice has changed', () => {
describe('componentDidUpdate', function () {
it('should call handleChartUpdate if props.currentPrice has changed', function () {
gasPriceChartUtilsSpies.handleChartUpdate.resetHistory()
wrapper.instance().componentDidUpdate({ currentPrice: 7 })
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()
wrapper.instance().componentDidUpdate({ currentPrice: 7 })
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()
wrapper.instance().componentDidUpdate({ currentPrice: 6 })
assert.equal(gasPriceChartUtilsSpies.handleChartUpdate.callCount, 0)
})
})
describe('renderChart', () => {
it('should call setTickPosition 4 times, with the expected props', async () => {
describe('renderChart', function () {
it('should call setTickPosition 4 times, with the expected props', async function () {
await timeout(0)
gasPriceChartUtilsSpies.setTickPosition.resetHistory()
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])
})
it('should call handleChartUpdate with the correct props', async () => {
it('should call handleChartUpdate with the correct props', async function () {
await timeout(0)
gasPriceChartUtilsSpies.handleChartUpdate.resetHistory()
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)
selectReturnSpies.on.resetHistory()
assert.equal(selectReturnSpies.on.callCount, 0)
@ -168,7 +168,7 @@ describe('GasPriceChart Component', function () {
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)
selectReturnSpies.on.resetHistory()
wrapper.instance().renderChart(testProps)
@ -181,7 +181,7 @@ describe('GasPriceChart Component', function () {
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)
selectReturnSpies.on.resetHistory()
wrapper.instance().renderChart(testProps)
@ -194,7 +194,7 @@ describe('GasPriceChart Component', function () {
assert.equal(propsMethodSpies.updateCustomGasPrice.getCall(0).args[0], 'mockX')
})
it('should handle mousemove', async () => {
it('should handle mousemove', async function () {
await timeout(0)
selectReturnSpies.on.resetHistory()
wrapper.instance().renderChart(testProps)

View File

@ -5,7 +5,7 @@ import { shallow } from 'enzyme'
import InfoBox from '../index'
describe('InfoBox', () => {
describe('InfoBox', function () {
let wrapper
@ -15,21 +15,21 @@ describe('InfoBox', () => {
onClose: sinon.spy(),
}
beforeEach(() => {
beforeEach(function () {
wrapper = shallow(<InfoBox {...props} />)
})
it('renders title from props', () => {
it('renders title from props', function () {
const title = wrapper.find('.info-box__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')
assert.equal(description.text(), props.description)
})
it('closes info box', () => {
it('closes info box', function () {
const close = wrapper.find('.info-box__close')
close.simulate('click')
assert(props.onClose.calledOnce)

View File

@ -6,7 +6,7 @@ import { mountWithRouter } from '../../../../../../test/lib/render-helpers'
import MenuBar from '../index'
import { Provider } from 'react-redux'
describe('MenuBar', () => {
describe('MenuBar', function () {
let wrapper
const mockStore = {
@ -38,11 +38,11 @@ describe('MenuBar', () => {
const store = configureStore()(mockStore)
afterEach(() => {
afterEach(function () {
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 = {
showSidebar: sinon.spy(),
}
@ -58,7 +58,7 @@ describe('MenuBar', () => {
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 = {
showSidebar: sinon.spy(),
hideSidebar: sinon.spy(),
@ -76,13 +76,13 @@ describe('MenuBar', () => {
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')
accountOptions.simulate('click')
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.update()

View File

@ -3,8 +3,8 @@ import assert from 'assert'
import { shallow } from 'enzyme'
import ModalContent from '../modal-content.component'
describe('ModalContent Component', () => {
it('should render a title', () => {
describe('ModalContent Component', function () {
it('should render a title', function () {
const wrapper = shallow(
<ModalContent
title="Modal Title"
@ -16,7 +16,7 @@ describe('ModalContent Component', () => {
assert.equal(wrapper.find('.modal-content__description').length, 0)
})
it('should render a description', () => {
it('should render a description', function () {
const wrapper = shallow(
<ModalContent
description="Modal Description"
@ -28,7 +28,7 @@ describe('ModalContent Component', () => {
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(
<ModalContent
title="Modal Title"

View File

@ -5,8 +5,8 @@ import sinon from 'sinon'
import Modal from '../modal.component'
import Button from '../../../ui/button'
describe('Modal Component', () => {
it('should render a modal with a submit button', () => {
describe('Modal Component', function () {
it('should render a modal with a submit button', function () {
const wrapper = shallow(<Modal />)
assert.equal(wrapper.find('.modal-container').length, 1)
@ -15,7 +15,7 @@ describe('Modal Component', () => {
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 handleSubmit = sinon.spy()
const wrapper = shallow(
@ -45,7 +45,7 @@ describe('Modal Component', () => {
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(
<Modal
onCancel={() => {}}
@ -63,7 +63,7 @@ describe('Modal Component', () => {
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(
<Modal
onCancel={() => {}}
@ -78,7 +78,7 @@ describe('Modal Component', () => {
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 handleSubmit = sinon.spy()
const wrapper = shallow(
@ -101,7 +101,7 @@ describe('Modal Component', () => {
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 handleSubmit = sinon.spy()
const wrapper = mount(

View File

@ -4,8 +4,8 @@ import { shallow } from 'enzyme'
import CancelTransactionGasFee from '../cancel-transaction-gas-fee.component'
import UserPreferencedCurrencyDisplay from '../../../../user-preferenced-currency-display'
describe('CancelTransactionGasFee Component', () => {
it('should render', () => {
describe('CancelTransactionGasFee Component', function () {
it('should render', function () {
const wrapper = shallow(
<CancelTransactionGasFee
value="0x3b9aca00"

View File

@ -6,10 +6,10 @@ import CancelTransaction from '../cancel-transaction.component'
import CancelTransactionGasFee from '../cancel-transaction-gas-fee'
import Modal from '../../../modal'
describe('CancelTransaction Component', () => {
describe('CancelTransaction Component', function () {
const t = key => key
it('should render a CancelTransaction modal', () => {
it('should render a CancelTransaction modal', function () {
const wrapper = shallow(
<CancelTransaction
newGasFee="0x1319718a5000"
@ -25,7 +25,7 @@ describe('CancelTransaction Component', () => {
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 hideModalSpy = sinon.spy()

View File

@ -4,7 +4,7 @@ import sinon from 'sinon'
import { mount } from 'enzyme'
import ConfirmDeleteNetwork from '../index'
describe('Confirm Delete Network', () => {
describe('Confirm Delete Network', function () {
let wrapper
const props = {
@ -14,7 +14,7 @@ describe('Confirm Delete Network', () => {
target: '',
}
beforeEach(() => {
beforeEach(function () {
wrapper = mount(
<ConfirmDeleteNetwork.WrappedComponent {...props} />, {
context: {
@ -24,18 +24,18 @@ describe('Confirm Delete Network', () => {
)
})
afterEach(() => {
afterEach(function () {
props.hideModal.resetHistory()
props.delRpcTarget.resetHistory()
props.onConfirm.resetHistory()
})
it('renders delete network modal title', () => {
it('renders delete network modal title', function () {
const modalTitle = wrapper.find('.modal-content__title')
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')
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')
deleteButton.simulate('click')

View File

@ -7,7 +7,7 @@ import configureStore from 'redux-mock-store'
import { mount } from 'enzyme'
import ConfirmRemoveAccount from '../index'
describe('Confirm Remove Account', () => {
describe('Confirm Remove Account', function () {
let wrapper
const state = {
@ -30,7 +30,7 @@ describe('Confirm Remove Account', () => {
const mockStore = configureStore()
const store = mockStore(state)
beforeEach(() => {
beforeEach(function () {
wrapper = mount(
<Provider store={store} >
@ -48,18 +48,18 @@ describe('Confirm Remove Account', () => {
)
})
afterEach(() => {
afterEach(function () {
props.hideModal.resetHistory()
})
it('nevermind', () => {
it('nevermind', function () {
const nevermind = wrapper.find({ type: 'default' })
nevermind.simulate('click')
assert(props.hideModal.calledOnce)
})
it('remove', (done) => {
it('remove', function (done) {
const remove = wrapper.find({ type: 'secondary' })
remove.simulate('click')
@ -73,7 +73,7 @@ describe('Confirm Remove Account', () => {
})
it('closes', () => {
it('closes', function () {
const close = wrapper.find('.modal-container__header-close')
close.simulate('click')

View File

@ -4,7 +4,7 @@ import sinon from 'sinon'
import { mount } from 'enzyme'
import ConfirmResetAccount from '../index'
describe('Confirm Reset Account', () => {
describe('Confirm Reset Account', function () {
let wrapper
const props = {
@ -12,7 +12,7 @@ describe('Confirm Reset Account', () => {
resetAccount: sinon.stub().resolves(),
}
beforeEach(() => {
beforeEach(function () {
wrapper = mount(
<ConfirmResetAccount.WrappedComponent {...props} />, {
context: {
@ -22,18 +22,18 @@ describe('Confirm Reset Account', () => {
)
})
afterEach(() => {
afterEach(function () {
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')
nevermind.simulate('click')
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')
reset.simulate('click')

View File

@ -4,7 +4,7 @@ import sinon from 'sinon'
import { mount } from 'enzyme'
import MetaMetricsOptIn from '../index'
describe('MetaMetrics Opt In', () => {
describe('MetaMetrics Opt In', function () {
let wrapper
const props = {
@ -13,7 +13,7 @@ describe('MetaMetrics Opt In', () => {
participateInMetaMetrics: null,
}
beforeEach(() => {
beforeEach(function () {
wrapper = mount(
<MetaMetricsOptIn.WrappedComponent {...props} />, {
context: {
@ -23,12 +23,12 @@ describe('MetaMetrics Opt In', () => {
)
})
afterEach(() => {
afterEach(function () {
props.setParticipateInMetaMetrics.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')
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')
iAgree.simulate('click')

View File

@ -4,7 +4,7 @@ import sinon from 'sinon'
import { mount } from 'enzyme'
import RejectTransactionsModal from '../index'
describe('Reject Transactions Model', () => {
describe('Reject Transactions Model', function () {
let wrapper
const props = {
@ -13,7 +13,7 @@ describe('Reject Transactions Model', () => {
unapprovedTxCount: 2,
}
beforeEach(() => {
beforeEach(function () {
wrapper = mount(
<RejectTransactionsModal.WrappedComponent {...props} />, {
context: {
@ -23,18 +23,18 @@ describe('Reject Transactions Model', () => {
)
})
afterEach(() => {
afterEach(function () {
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')
cancelButton.simulate('click')
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')
rejectAllButton.simulate('click')

View File

@ -4,7 +4,7 @@ import sinon from 'sinon'
import { shallow } from 'enzyme'
import AccountDetailsModal from '../account-details-modal'
describe('Account Details Modal', () => {
describe('Account Details Modal', function () {
let wrapper
global.platform = { openWindow: sinon.spy() }
@ -36,7 +36,7 @@ describe('Account Details Modal', () => {
},
}
beforeEach(() => {
beforeEach(function () {
wrapper = shallow(
<AccountDetailsModal.WrappedComponent {...props} />, {
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()
accountLabel.simulate('submit', 'New Label')
@ -54,7 +54,7 @@ describe('Account Details Modal', () => {
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 etherscanLink = modalButton.first()
@ -62,7 +62,7 @@ describe('Account Details Modal', () => {
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 etherscanLink = modalButton.last()
@ -70,7 +70,7 @@ describe('Account Details Modal', () => {
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'
wrapper.setProps({ rpcPrefs: { blockExplorerUrl } })

View File

@ -4,25 +4,19 @@ import sinon from 'sinon'
import { mount } from 'enzyme'
import TransactionConfirmed from '../index'
describe('Transaction Confirmed', () => {
let wrapper
const props = {
onSubmit: sinon.spy(),
hideModal: sinon.spy(),
}
beforeEach(() => {
wrapper = mount(
describe('Transaction Confirmed', function () {
it('clicks ok to submit and hide modal', function () {
const props = {
onSubmit: sinon.spy(),
hideModal: sinon.spy(),
}
const wrapper = mount(
<TransactionConfirmed.WrappedComponent {...props} />, {
context: {
t: str => str,
},
}
)
})
it('clicks ok to submit and hide modal', () => {
const submit = wrapper.find('.btn-secondary.modal-container__footer-button')
submit.simulate('click')

View File

@ -3,8 +3,8 @@ import assert from 'assert'
import { render } from 'enzyme'
import SelectedAccount from '../selected-account.component'
describe('SelectedAccount Component', () => {
it('should render checksummed address', () => {
describe('SelectedAccount Component', function () {
it('should render checksummed address', function () {
const wrapper = render((
<SelectedAccount
selectedAddress="0x1b82543566f41a7db9a9a75fc933c340ffb55c9d"

View File

@ -15,7 +15,7 @@ const propsMethodSpies = {
describe('Sidebar Component', function () {
let wrapper
beforeEach(() => {
beforeEach(function () {
wrapper = shallow((
<Sidebar
sidebarOpen={false}
@ -26,43 +26,43 @@ describe('Sidebar Component', function () {
))
})
afterEach(() => {
afterEach(function () {
propsMethodSpies.hideSidebar.resetHistory()
})
describe('renderOverlay', () => {
describe('renderOverlay', function () {
let renderOverlay
beforeEach(() => {
beforeEach(function () {
renderOverlay = shallow(wrapper.instance().renderOverlay())
})
it('should render a overlay element', () => {
it('should render a overlay element', function () {
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)
renderOverlay.props().onClick()
assert.equal(propsMethodSpies.hideSidebar.callCount, 1)
})
})
describe('renderSidebarContent', () => {
describe('renderSidebarContent', function () {
let renderSidebarContent
beforeEach(() => {
beforeEach(function () {
wrapper.setProps({ type: 'wallet-view' })
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' })
renderSidebarContent = wrapper.instance().renderSidebarContent()
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' })
renderSidebarContent = wrapper.instance().renderSidebarContent()
const renderedSidebarContent = shallow(renderSidebarContent)
@ -70,25 +70,25 @@ describe('Sidebar Component', function () {
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' })
renderSidebarContent = wrapper.instance().renderSidebarContent()
assert.equal(renderSidebarContent, undefined)
})
})
describe('render', () => {
it('should render a div with one child', () => {
describe('render', function () {
it('should render a div with one child', function () {
assert(wrapper.is('div'))
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.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 })
assert.equal(wrapper.children().length, 2)
assert(wrapper.children().at(1).hasClass('sidebar-overlay'))

View File

@ -5,26 +5,22 @@ import SignatureRequest from '../signature-request.component'
describe('Signature Request Component', function () {
let wrapper
describe('render', function () {
it('should render a div with one child', function () {
const wrapper = shallow((
<SignatureRequest
clearConfirmTransaction={() => {}}
cancel={() => {}}
sign={() => {}}
txData={{
msgParams: {
data: '{"message": {"from": {"name": "hello"}}}',
from: '0x123456789abcdef',
},
}}
/>
))
beforeEach(() => {
wrapper = shallow((
<SignatureRequest
clearConfirmTransaction={() => {}}
cancel={() => {}}
sign={() => {}}
txData={{
msgParams: {
data: '{"message": {"from": {"name": "hello"}}}',
from: '0x123456789abcdef',
},
}}
/>
))
})
describe('render', () => {
it('should render a div with one child', () => {
assert(wrapper.is('div'))
assert.equal(wrapper.length, 1)
assert(wrapper.hasClass('signature-request'))

View File

@ -6,7 +6,7 @@ import configureMockStore from 'redux-mock-store'
import { mountWithRouter } from '../../../../../test/lib/render-helpers'
import SignatureRequest from '../signature-request'
describe('Signature Request', () => {
describe('Signature Request', function () {
let wrapper
const mockStore = {
@ -40,7 +40,7 @@ describe('Signature Request', () => {
},
}
beforeEach(() => {
beforeEach(function () {
wrapper = mountWithRouter(
<Provider store={store}>
<SignatureRequest.WrappedComponent {...props} />
@ -48,18 +48,18 @@ describe('Signature Request', () => {
)
})
afterEach(() => {
afterEach(function () {
props.clearConfirmTransaction.resetHistory()
})
it('cancel', () => {
it('cancel', function () {
const cancelButton = wrapper.find('button.btn-default')
cancelButton.simulate('click')
assert(props.cancel.calledOnce)
})
it('sign', () => {
it('sign', function () {
const signButton = wrapper.find('button.btn-primary')
signButton.simulate('click')

Some files were not shown because too many files have changed in this diff Show More