You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.0 KiB
64 lines
2.0 KiB
4 years ago
|
import React from 'react';
|
||
|
import { mount } from 'enzyme';
|
||
|
import sinon from 'sinon';
|
||
4 years ago
|
import * as i18nHook from '../../../hooks/useI18nContext';
|
||
|
import Tooltip from '../../ui/tooltip';
|
||
|
import TransactionStatus from './transaction-status.component';
|
||
6 years ago
|
|
||
4 years ago
|
describe('TransactionStatus Component', () => {
|
||
|
beforeAll(() => {
|
||
4 years ago
|
sinon.stub(i18nHook, 'useI18nContext').returns((str) => str.toUpperCase());
|
||
|
});
|
||
5 years ago
|
|
||
4 years ago
|
afterAll(() => {
|
||
|
sinon.restore();
|
||
|
});
|
||
|
|
||
|
it('should render CONFIRMED properly', () => {
|
||
6 years ago
|
const wrapper = mount(
|
||
4 years ago
|
<TransactionStatus status="confirmed" date="June 1" />,
|
||
4 years ago
|
);
|
||
6 years ago
|
|
||
4 years ago
|
expect(wrapper.find(TransactionStatus)).toHaveLength(1);
|
||
|
expect(wrapper.text()).toStrictEqual('June 1');
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('should render PENDING properly when status is APPROVED', () => {
|
||
5 years ago
|
const wrapper = mount(
|
||
|
<TransactionStatus
|
||
|
status="approved"
|
||
|
isEarliestNonce
|
||
|
error={{ message: 'test-title' }}
|
||
4 years ago
|
/>,
|
||
4 years ago
|
);
|
||
5 years ago
|
|
||
4 years ago
|
expect(wrapper.text()).toStrictEqual('PENDING');
|
||
|
expect(wrapper.find(Tooltip).props().title).toStrictEqual('test-title');
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should render PENDING properly', () => {
|
||
6 years ago
|
const wrapper = mount(
|
||
4 years ago
|
<TransactionStatus date="June 1" status="submitted" isEarliestNonce />,
|
||
4 years ago
|
);
|
||
6 years ago
|
|
||
4 years ago
|
expect(wrapper.find(TransactionStatus)).toHaveLength(1);
|
||
|
expect(wrapper.text()).toStrictEqual('PENDING');
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('should render QUEUED properly', () => {
|
||
4 years ago
|
const wrapper = mount(<TransactionStatus status="queued" />);
|
||
5 years ago
|
|
||
4 years ago
|
expect(wrapper.find(TransactionStatus)).toHaveLength(1);
|
||
|
expect(wrapper.find('.transaction-status--queued')).toHaveLength(1);
|
||
|
expect(wrapper.text()).toStrictEqual('QUEUED');
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('should render UNAPPROVED properly', () => {
|
||
4 years ago
|
const wrapper = mount(<TransactionStatus status="unapproved" />);
|
||
5 years ago
|
|
||
4 years ago
|
expect(wrapper.find(TransactionStatus)).toHaveLength(1);
|
||
|
expect(wrapper.find('.transaction-status--unapproved')).toHaveLength(1);
|
||
|
expect(wrapper.text()).toStrictEqual('UNAPPROVED');
|
||
4 years ago
|
});
|
||
|
});
|