1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 04:46:10 +01:00
metamask-extension/ui/components/app/confirm-page-container/confirm-detail-row/confirm-detail-row.component.test.js

90 lines
2.7 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import ConfirmDetailRow from './confirm-detail-row.component';
2018-07-25 20:57:41 +02:00
const propsMethodSpies = {
onHeaderClick: sinon.spy(),
};
2018-07-25 20:57:41 +02:00
describe('Confirm Detail Row Component', () => {
describe('render', () => {
let wrapper;
2018-07-25 20:57:41 +02:00
beforeEach(() => {
wrapper = shallow(
<ConfirmDetailRow
errorType="mockErrorType"
label="mockLabel"
showError={false}
primaryText="mockFiatText"
secondaryText="mockEthText"
primaryValueTextColor="mockColor"
onHeaderClick={propsMethodSpies.onHeaderClick}
headerText="mockHeaderText"
headerTextClassName="mockHeaderClass"
/>,
);
});
2018-07-25 20:57:41 +02:00
it('should render a div with a confirm-detail-row class', () => {
expect(wrapper.find('div.confirm-detail-row')).toHaveLength(1);
});
2018-07-25 20:57:41 +02:00
it('should render the label as a child of the confirm-detail-row__label', () => {
expect(
2020-11-03 00:41:28 +01:00
wrapper
.find('.confirm-detail-row > .confirm-detail-row__label')
.childAt(0)
.text(),
).toStrictEqual('mockLabel');
});
2018-07-25 20:57:41 +02:00
it('should render the headerText as a child of the confirm-detail-row__header-text', () => {
expect(
2020-11-03 00:41:28 +01:00
wrapper
.find(
'.confirm-detail-row__details > .confirm-detail-row__header-text',
)
.childAt(0)
.text(),
).toStrictEqual('mockHeaderText');
});
2018-07-25 20:57:41 +02:00
it('should render the primaryText as a child of the confirm-detail-row__primary', () => {
expect(
2020-11-03 00:41:28 +01:00
wrapper
.find('.confirm-detail-row__details > .confirm-detail-row__primary')
.childAt(0)
.text(),
).toStrictEqual('mockFiatText');
});
2018-07-25 20:57:41 +02:00
it('should render the ethText as a child of the confirm-detail-row__secondary', () => {
expect(
2020-11-03 00:41:28 +01:00
wrapper
.find('.confirm-detail-row__details > .confirm-detail-row__secondary')
.childAt(0)
.text(),
).toStrictEqual('mockEthText');
});
2018-07-25 20:57:41 +02:00
it('should set the fiatTextColor on confirm-detail-row__primary', () => {
expect(
2020-11-03 00:41:28 +01:00
wrapper.find('.confirm-detail-row__primary').props().style.color,
).toStrictEqual('mockColor');
});
2018-07-25 20:57:41 +02:00
it('should assure the confirm-detail-row__header-text classname is correct', () => {
expect(
2020-11-03 00:41:28 +01:00
wrapper.find('.confirm-detail-row__header-text').props().className,
).toStrictEqual('confirm-detail-row__header-text mockHeaderClass');
});
2018-07-25 20:57:41 +02:00
it('should call onHeaderClick when headerText div gets clicked', () => {
wrapper.find('.confirm-detail-row__header-text').props().onClick();
expect(propsMethodSpies.onHeaderClick.calledOnce).toStrictEqual(true);
});
});
});