1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-28 23:06:37 +01:00
metamask-extension/ui/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.component.test.js

33 lines
1.0 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { shallow } from 'enzyme';
import SendRowErrorMessage from './send-row-error-message.component';
2018-05-11 08:37:33 +02:00
describe('SendRowErrorMessage Component', () => {
let wrapper;
2018-05-11 08:37:33 +02:00
describe('render', () => {
beforeEach(() => {
2020-11-03 00:41:28 +01:00
wrapper = shallow(
<SendRowErrorMessage
errors={{ error1: 'abc', error2: 'def' }}
errorType="error3"
2020-11-03 00:41:28 +01:00
/>,
{ context: { t: (str) => `${str}_t` } },
);
});
2018-05-11 08:37:33 +02:00
it('should render null if the passed errors do not contain an error of errorType', () => {
expect(wrapper.find('.send-v2__error')).toHaveLength(0);
expect(wrapper.html()).toBeNull();
});
2018-05-11 08:37:33 +02:00
it('should render an error message if the passed errors contain an error of errorType', () => {
2020-11-03 00:41:28 +01:00
wrapper.setProps({
errors: { error1: 'abc', error2: 'def', error3: 'xyz' },
});
expect(wrapper.find('.send-v2__error')).toHaveLength(1);
expect(wrapper.find('.send-v2__error').text()).toStrictEqual('xyz_t');
});
});
});