2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
2021-03-16 22:00:08 +01:00
|
|
|
import SendRowErrorMessage from './send-row-error-message.component';
|
2018-05-11 08:37:33 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('SendRowErrorMessage Component', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2018-05-11 08:37:33 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('render', () => {
|
|
|
|
beforeEach(() => {
|
2020-11-03 00:41:28 +01:00
|
|
|
wrapper = shallow(
|
2020-02-11 17:51:13 +01:00
|
|
|
<SendRowErrorMessage
|
|
|
|
errors={{ error1: 'abc', error2: 'def' }}
|
|
|
|
errorType="error3"
|
2020-11-03 00:41:28 +01:00
|
|
|
/>,
|
|
|
|
{ context: { t: (str) => `${str}_t` } },
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2018-05-11 08:37:33 +02:00
|
|
|
|
2021-04-15 20:01:46 +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();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-05-11 08:37:33 +02:00
|
|
|
|
2021-04-15 20:01:46 +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' },
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(wrapper.find('.send-v2__error')).toHaveLength(1);
|
|
|
|
expect(wrapper.find('.send-v2__error').text()).toStrictEqual('xyz_t');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|