2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import sinon from 'sinon';
|
2021-03-16 22:00:08 +01:00
|
|
|
import * as i18nHook from '../../../hooks/useI18nContext';
|
|
|
|
import Tooltip from '../../ui/tooltip';
|
|
|
|
import TransactionStatus from './transaction-status.component';
|
2018-11-14 01:51:46 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('TransactionStatus Component', () => {
|
|
|
|
beforeAll(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
sinon.stub(i18nHook, 'useI18nContext').returns((str) => str.toUpperCase());
|
|
|
|
});
|
2020-06-10 22:38:34 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
afterAll(() => {
|
|
|
|
sinon.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render CONFIRMED properly', () => {
|
2018-11-14 01:51:46 +01:00
|
|
|
const wrapper = mount(
|
2020-11-03 00:41:28 +01:00
|
|
|
<TransactionStatus status="confirmed" date="June 1" />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-11-14 01:51:46 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(wrapper.find(TransactionStatus)).toHaveLength(1);
|
|
|
|
expect(wrapper.text()).toStrictEqual('June 1');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-06-10 22:38:34 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render PENDING properly when status is APPROVED', () => {
|
2020-06-10 22:38:34 +02:00
|
|
|
const wrapper = mount(
|
|
|
|
<TransactionStatus
|
|
|
|
status="approved"
|
|
|
|
isEarliestNonce
|
|
|
|
error={{ message: 'test-title' }}
|
2020-07-14 17:20:41 +02:00
|
|
|
/>,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-06-10 22:38:34 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(wrapper.text()).toStrictEqual('PENDING');
|
|
|
|
expect(wrapper.find(Tooltip).props().title).toStrictEqual('test-title');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-11-14 01:51:46 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render PENDING properly', () => {
|
2018-11-14 01:51:46 +01:00
|
|
|
const wrapper = mount(
|
2020-11-03 00:41:28 +01:00
|
|
|
<TransactionStatus date="June 1" status="submitted" isEarliestNonce />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-11-14 01:51:46 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(wrapper.find(TransactionStatus)).toHaveLength(1);
|
|
|
|
expect(wrapper.text()).toStrictEqual('PENDING');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-06-10 22:38:34 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render QUEUED properly', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const wrapper = mount(<TransactionStatus status="queued" />);
|
2020-06-10 22:38:34 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(wrapper.find(TransactionStatus)).toHaveLength(1);
|
|
|
|
expect(wrapper.find('.transaction-status--queued')).toHaveLength(1);
|
|
|
|
expect(wrapper.text()).toStrictEqual('QUEUED');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-06-10 22:38:34 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render UNAPPROVED properly', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const wrapper = mount(<TransactionStatus status="unapproved" />);
|
2020-06-10 22:38:34 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(wrapper.find(TransactionStatus)).toHaveLength(1);
|
|
|
|
expect(wrapper.find('.transaction-status--unapproved')).toHaveLength(1);
|
|
|
|
expect(wrapper.text()).toStrictEqual('UNAPPROVED');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|