1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 21:57:06 +01:00
metamask-extension/test/integration/lib/tx-list-items.js

55 lines
2.2 KiB
JavaScript
Raw Normal View History

const reactTriggerChange = require('../../lib/react-trigger-change')
const {
queryAsync,
findAsync,
} = require('../../lib/util')
QUnit.module('tx list items')
QUnit.test('renders list items successfully', (assert) => {
const done = assert.async()
runTxListItemsTest(assert).then(done).catch((err) => {
assert.notOk(err, `Error was thrown: ${err.stack}`)
done()
})
})
global.ethQuery = global.ethQuery || {}
global.ethQuery.getTransactionCount = (_, cb) => {
cb(null, '0x3')
}
2018-07-03 00:49:33 +02:00
async function runTxListItemsTest (assert, done) {
console.log('*** start runTxListItemsTest')
const selectState = await queryAsync($, 'select')
selectState.val('tx list items')
reactTriggerChange(selectState[0])
2018-05-11 01:51:26 +02:00
const metamaskLogo = await queryAsync($, '.app-header__logo-container')
assert.ok(metamaskLogo[0], 'metamask logo present')
metamaskLogo[0].click()
2018-08-07 07:39:54 +02:00
const txListItems = await queryAsync($, '.transaction-list-item')
2018-12-09 21:48:06 +01:00
assert.equal(txListItems.length, 7, 'all tx list items are rendered')
2018-12-09 21:48:06 +01:00
const approvedTx = txListItems[0]
2018-08-07 07:39:54 +02:00
const approvedTxRenderedStatus = await findAsync($(approvedTx), '.transaction-list-item__status')
assert.equal(approvedTxRenderedStatus[0].textContent, 'pending', 'approvedTx has correct label')
2018-12-09 21:48:06 +01:00
const unapprovedMsg = txListItems[1]
2018-08-07 07:39:54 +02:00
const unapprovedMsgDescription = await findAsync($(unapprovedMsg), '.transaction-list-item__action')
assert.equal(unapprovedMsgDescription[0].textContent, 'Signature Request', 'unapprovedMsg has correct description')
2018-12-09 21:48:06 +01:00
const shapeShiftTx = txListItems[4]
const shapeShiftTxStatus = await findAsync($(shapeShiftTx), '.flex-column div:eq(1)')
assert.equal(shapeShiftTxStatus[0].textContent, 'No deposits received', 'shapeShiftTx has correct status')
2018-12-09 21:48:06 +01:00
const rejectedTx = txListItems[5]
const rejectedTxRenderedStatus = await findAsync($(rejectedTx), '.transaction-list-item__status')
assert.equal(rejectedTxRenderedStatus[0].textContent, 'Rejected', 'rejectedTx has correct label')
const confirmedTokenTx = txListItems[6]
2018-08-07 07:39:54 +02:00
const confirmedTokenTxAddress = await findAsync($(confirmedTokenTx), '.transaction-list-item__status')
2018-08-24 04:19:48 +02:00
assert.equal(confirmedTokenTxAddress[0].textContent, 'Confirmed', 'confirmedTokenTx has correct address')
}