aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/transaction-action/tests/transaction-action.component.test.js
blob: 158bc8dc4fe9854c9e9bfbd7a2d6122381cad2f5 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import React from 'react'
import assert from 'assert'
import { shallow } from 'enzyme'
import TransactionAction from '../transaction-action.component'

describe('TransactionAction Component', () => {
  const tOrDefault = key => key

  describe('Outgoing transaction', () => {
    it('should render -- when methodData is still fetching', () => {
      const methodData = { data: {}, done: false, error: null }
      const transaction = {
        id: 1,
        status: 'confirmed',
        submittedTime: 1534045442919,
        time: 1534045440641,
        txParams: {
          from: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
          gas: '0x5208',
          gasPrice: '0x3b9aca00',
          nonce: '0x96',
          to: '0x50a9d56c2b8ba9a5c7f2c08c3d26e0499f23a706',
          value: '0x2386f26fc10000',
        },
      }

      const wrapper = shallow(<TransactionAction
        methodData={methodData}
        transaction={transaction}
        className="transaction-action"
      />, { context: { tOrDefault }})

      assert.equal(wrapper.find('.transaction-action').length, 1)
      assert.equal(wrapper.text(), '--')
    })

    it('should render Sent Ether', () => {
      const methodData = { data: {}, done: true, error: null }
      const transaction = {
        id: 1,
        status: 'confirmed',
        submittedTime: 1534045442919,
        time: 1534045440641,
        txParams: {
          from: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
          gas: '0x5208',
          gasPrice: '0x3b9aca00',
          nonce: '0x96',
          to: '0x50a9d56c2b8ba9a5c7f2c08c3d26e0499f23a706',
          value: '0x2386f26fc10000',
        },
      }

      const wrapper = shallow(<TransactionAction
        methodData={methodData}
        transaction={transaction}
        className="transaction-action"
      />, { context: { tOrDefault }})

      assert.equal(wrapper.find('.transaction-action').length, 1)
      assert.equal(wrapper.text(), 'sentEther')
    })

    it('should render Approved', () => {
      const methodData = {
        data: {
          name: 'Approve',
          params: [
            { type: 'address' },
            { type: 'uint256' },
          ],
        },
        done: true,
        error: null,
      }
      const transaction = {
        id: 1,
        status: 'confirmed',
        submittedTime: 1534045442919,
        time: 1534045440641,
        txParams: {
          from: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
          gas: '0x5208',
          gasPrice: '0x3b9aca00',
          nonce: '0x96',
          to: '0x50a9d56c2b8ba9a5c7f2c08c3d26e0499f23a706',
          value: '0x2386f26fc10000',
          data: '0x095ea7b300000000000000000000000050a9d56c2b8ba9a5c7f2c08c3d26e0499f23a7060000000000000000000000000000000000000000000000000000000000000003',
        },
      }

      const wrapper = shallow(<TransactionAction
        methodData={methodData}
        transaction={transaction}
        className="transaction-action"
      />, { context: { tOrDefault }})

      assert.equal(wrapper.find('.transaction-action').length, 1)
      assert.equal(wrapper.text(), 'approve')
    })
  })
})