aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/transaction-list-item-details/tests/transaction-list-item-details.component.test.js
blob: f2bbe8789268f635d7440d9be3f8f5af3c992d7a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React from 'react'
import assert from 'assert'
import { shallow } from 'enzyme'
import TransactionListItemDetails from '../transaction-list-item-details.component'
import Button from '../../button'
import SenderToRecipient from '../../sender-to-recipient'
import TransactionBreakdown from '../../transaction-breakdown'
import TransactionActivityLog from '../../transaction-activity-log'

describe('TransactionListItemDetails Component', () => {
  it('should render properly', () => {
    const transaction = {
      history: [],
      id: 1,
      status: 'confirmed',
      txParams: {
        from: '0x1',
        gas: '0x5208',
        gasPrice: '0x3b9aca00',
        nonce: '0xa4',
        to: '0x2',
        value: '0x2386f26fc10000',
      },
    }

    const wrapper = shallow(
      <TransactionListItemDetails
        transaction={transaction}
      />,
      { context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } }
    )

    assert.ok(wrapper.hasClass('transaction-list-item-details'))
    assert.equal(wrapper.find(Button).length, 1)
    assert.equal(wrapper.find(SenderToRecipient).length, 1)
    assert.equal(wrapper.find(TransactionBreakdown).length, 1)
    assert.equal(wrapper.find(TransactionActivityLog).length, 1)
  })

  it('should render a retry button', () => {
    const transaction = {
      history: [],
      id: 1,
      status: 'confirmed',
      txParams: {
        from: '0x1',
        gas: '0x5208',
        gasPrice: '0x3b9aca00',
        nonce: '0xa4',
        to: '0x2',
        value: '0x2386f26fc10000',
      },
    }

    const wrapper = shallow(
      <TransactionListItemDetails
        transaction={transaction}
        showRetry={true}
      />,
      { context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } }
    )

    assert.ok(wrapper.hasClass('transaction-list-item-details'))
    assert.equal(wrapper.find(Button).length, 2)
  })
})