mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix tests
This commit is contained in:
parent
d19c42fcae
commit
e16f5ab54d
@ -513,7 +513,7 @@ describe('MetaMask', function () {
|
|||||||
it('displays the contract creation data', async () => {
|
it('displays the contract creation data', async () => {
|
||||||
const dataTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Data')]`))
|
const dataTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Data')]`))
|
||||||
dataTab.click()
|
dataTab.click()
|
||||||
await (regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
await findElement(driver, By.xpath(`//div[contains(text(), '127.0.0.1')]`))
|
await findElement(driver, By.xpath(`//div[contains(text(), '127.0.0.1')]`))
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
||||||
detailsTab.click()
|
detailsTab.click()
|
||||||
await (regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('confirms a deploy contract transaction', async () => {
|
it('confirms a deploy contract transaction', async () => {
|
||||||
@ -548,7 +548,7 @@ describe('MetaMask', function () {
|
|||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
await driver.switchTo().window(extension)
|
await driver.switchTo().window(extension)
|
||||||
await delay(regularDelayMs)
|
await delay(largeDelayMs)
|
||||||
|
|
||||||
await findElements(driver, By.css('.tx-list-pending-item-container'))
|
await findElements(driver, By.css('.tx-list-pending-item-container'))
|
||||||
const [txListValue] = await findElements(driver, By.css('.tx-list-value'))
|
const [txListValue] = await findElements(driver, By.css('.tx-list-value'))
|
||||||
@ -741,7 +741,7 @@ describe('MetaMask', function () {
|
|||||||
it('displays the token transfer data', async () => {
|
it('displays the token transfer data', async () => {
|
||||||
const dataTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Data')]`))
|
const dataTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Data')]`))
|
||||||
dataTab.click()
|
dataTab.click()
|
||||||
await (regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type'))
|
const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type'))
|
||||||
const functionTypeText = await functionType.getText()
|
const functionTypeText = await functionType.getText()
|
||||||
@ -753,7 +753,7 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
||||||
detailsTab.click()
|
detailsTab.click()
|
||||||
await (regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('submits the transaction', async function () {
|
it('submits the transaction', async function () {
|
||||||
@ -901,7 +901,7 @@ describe('MetaMask', function () {
|
|||||||
it('displays the token approval data', async () => {
|
it('displays the token approval data', async () => {
|
||||||
const dataTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Data')]`))
|
const dataTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Data')]`))
|
||||||
dataTab.click()
|
dataTab.click()
|
||||||
await (regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type'))
|
const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type'))
|
||||||
const functionTypeText = await functionType.getText()
|
const functionTypeText = await functionType.getText()
|
||||||
@ -913,12 +913,12 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
||||||
detailsTab.click()
|
detailsTab.click()
|
||||||
await (regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const approvalWarning = await findElement(driver, By.css('.confirm-page-container-warning__warning'))
|
const approvalWarning = await findElement(driver, By.css('.confirm-page-container-warning__warning'))
|
||||||
const approvalWarningText = await approvalWarning.getText()
|
const approvalWarningText = await approvalWarning.getText()
|
||||||
assert(approvalWarningText.match(/By approving this/))
|
assert(approvalWarningText.match(/By approving this/))
|
||||||
await (regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens the gas edit modal', async () => {
|
it('opens the gas edit modal', async () => {
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
const assert = require('assert')
|
|
||||||
const h = require('react-hyperscript')
|
|
||||||
const PendingTx = require('../../../ui/app/components/pending-tx')
|
|
||||||
const ethUtil = require('ethereumjs-util')
|
|
||||||
|
|
||||||
const { createMockStore } = require('redux-test-utils')
|
|
||||||
const { shallowWithStore } = require('../../lib/shallow-with-store')
|
|
||||||
|
|
||||||
const identities = { abc: {}, def: {} }
|
|
||||||
const mockState = {
|
|
||||||
metamask: {
|
|
||||||
accounts: { abc: {} },
|
|
||||||
identities,
|
|
||||||
conversionRate: 10,
|
|
||||||
selectedAddress: 'abc',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('PendingTx', function () {
|
|
||||||
const gasPrice = '0x4A817C800' // 20 Gwei
|
|
||||||
const txData = {
|
|
||||||
'id': 5021615666270214,
|
|
||||||
'time': 1494458763011,
|
|
||||||
'status': 'unapproved',
|
|
||||||
'metamaskNetworkId': '1494442339676',
|
|
||||||
'txParams': {
|
|
||||||
'from': '0xfdea65c8e26263f6d9a1b5de9555d2931a33b826',
|
|
||||||
'to': '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
|
|
||||||
'value': '0xde0b6b3a7640000',
|
|
||||||
gasPrice,
|
|
||||||
'gas': '0x7b0c',
|
|
||||||
},
|
|
||||||
'gasLimitSpecified': false,
|
|
||||||
'estimatedGas': '0x5208',
|
|
||||||
}
|
|
||||||
const newGasPrice = '0x77359400'
|
|
||||||
|
|
||||||
const computedBalances = {}
|
|
||||||
computedBalances[Object.keys(identities)[0]] = {
|
|
||||||
ethBalance: '0x00000000000000056bc75e2d63100000',
|
|
||||||
}
|
|
||||||
const props = {
|
|
||||||
txData,
|
|
||||||
computedBalances,
|
|
||||||
sendTransaction: (txMeta, event) => {
|
|
||||||
// Assert changes:
|
|
||||||
const result = ethUtil.addHexPrefix(txMeta.txParams.gasPrice)
|
|
||||||
assert.notEqual(result, gasPrice, 'gas price should change')
|
|
||||||
assert.equal(result, newGasPrice, 'gas price assigned.')
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
let pendingTxComponent
|
|
||||||
let store
|
|
||||||
let component
|
|
||||||
beforeEach(function () {
|
|
||||||
store = createMockStore(mockState)
|
|
||||||
component = shallowWithStore(h(PendingTx, props), store)
|
|
||||||
pendingTxComponent = component
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should render correctly', function (done) {
|
|
||||||
assert.equal(pendingTxComponent.props().identities, identities)
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
@ -5,14 +5,16 @@ import ConfirmTokenTransactionBase from '../confirm-token-transaction-base'
|
|||||||
export default class ConfirmApprove extends Component {
|
export default class ConfirmApprove extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
tokenAmount: PropTypes.number,
|
tokenAmount: PropTypes.number,
|
||||||
|
tokenSymbol: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { tokenAmount } = this.props
|
const { tokenAmount, tokenSymbol } = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfirmTokenTransactionBase
|
<ConfirmTokenTransactionBase
|
||||||
tokenAmount={tokenAmount}
|
tokenAmount={tokenAmount}
|
||||||
|
warning={`By approving this action, you grant permission for this contract to spend up to ${tokenAmount} of your ${tokenSymbol}.`}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@ import ConfirmApprove from './confirm-approve.component'
|
|||||||
import { approveTokenAmountAndToAddressSelector } from '../../../selectors/confirm-transaction'
|
import { approveTokenAmountAndToAddressSelector } from '../../../selectors/confirm-transaction'
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
|
const { confirmTransaction: { tokenProps: { tokenSymbol } = {} } } = state
|
||||||
const { tokenAmount } = approveTokenAmountAndToAddressSelector(state)
|
const { tokenAmount } = approveTokenAmountAndToAddressSelector(state)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tokenAmount,
|
tokenAmount,
|
||||||
|
tokenSymbol,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user