|
|
@ -6,14 +6,18 @@ import TransactionAction from '../transaction-action.component' |
|
|
|
|
|
|
|
|
|
|
|
describe('TransactionAction Component', () => { |
|
|
|
describe('TransactionAction Component', () => { |
|
|
|
const t = key => key |
|
|
|
const t = key => key |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('Outgoing transaction', () => { |
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
global.eth = { |
|
|
|
global.eth = { |
|
|
|
getCode: sinon.stub().callsFake(address => { |
|
|
|
getCode: sinon.stub().callsFake(address => { |
|
|
|
const code = address === 'approveAddress' ? 'contract' : '0x' |
|
|
|
const code = address === 'approveAddress' ? 'contract' : '0x' |
|
|
|
return Promise.resolve(code) |
|
|
|
return Promise.resolve(code) |
|
|
|
}), |
|
|
|
}), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
describe('Outgoing transaction', () => { |
|
|
|
|
|
|
|
it('should render -- when methodData is still fetching', () => { |
|
|
|
it('should render -- when methodData is still fetching', () => { |
|
|
|
const methodData = { data: {}, done: false, error: null } |
|
|
|
const methodData = { data: {}, done: false, error: null } |
|
|
|
const transaction = { |
|
|
|
const transaction = { |
|
|
@ -69,7 +73,7 @@ describe('TransactionAction Component', () => { |
|
|
|
assert.equal(wrapper.text(), 'sentEther') |
|
|
|
assert.equal(wrapper.text(), 'sentEther') |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it('should render Approved', () => { |
|
|
|
it('should render Approved', async () => { |
|
|
|
const methodData = { |
|
|
|
const methodData = { |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
name: 'Approve', |
|
|
|
name: 'Approve', |
|
|
@ -97,15 +101,62 @@ describe('TransactionAction Component', () => { |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const wrapper = shallow(<TransactionAction |
|
|
|
const wrapper = shallow( |
|
|
|
|
|
|
|
<TransactionAction |
|
|
|
methodData={methodData} |
|
|
|
methodData={methodData} |
|
|
|
transaction={transaction} |
|
|
|
transaction={transaction} |
|
|
|
className="transaction-action" |
|
|
|
className="test-class" |
|
|
|
/>, { context: { t }}) |
|
|
|
/>, |
|
|
|
|
|
|
|
{ context: { t } } |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
assert.equal(wrapper.find('.transaction-action').length, 1) |
|
|
|
assert.ok(wrapper) |
|
|
|
wrapper.setState({ transactionAction: 'approve' }) |
|
|
|
assert.equal(wrapper.find('.test-class').length, 1) |
|
|
|
assert.equal(wrapper.text(), 'approve') |
|
|
|
await wrapper.instance().getTransactionAction() |
|
|
|
|
|
|
|
assert.equal(wrapper.state('transactionAction'), 'approve') |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should render Accept Fulfillment', async () => { |
|
|
|
|
|
|
|
const methodData = { |
|
|
|
|
|
|
|
data: { |
|
|
|
|
|
|
|
name: 'AcceptFulfillment', |
|
|
|
|
|
|
|
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: 'approveAddress', |
|
|
|
|
|
|
|
value: '0x2386f26fc10000', |
|
|
|
|
|
|
|
data: '0x095ea7b300000000000000000000000050a9d56c2b8ba9a5c7f2c08c3d26e0499f23a7060000000000000000000000000000000000000000000000000000000000000003', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const wrapper = shallow( |
|
|
|
|
|
|
|
<TransactionAction |
|
|
|
|
|
|
|
methodData={methodData} |
|
|
|
|
|
|
|
transaction={transaction} |
|
|
|
|
|
|
|
className="test-class" |
|
|
|
|
|
|
|
/>, |
|
|
|
|
|
|
|
{ context: { t }} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.ok(wrapper) |
|
|
|
|
|
|
|
assert.equal(wrapper.find('.test-class').length, 1) |
|
|
|
|
|
|
|
await wrapper.instance().getTransactionAction() |
|
|
|
|
|
|
|
assert.equal(wrapper.state('transactionAction'), ' Accept Fulfillment') |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|