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.
33 lines
1.0 KiB
33 lines
1.0 KiB
4 years ago
|
import React from 'react';
|
||
|
import { shallow } from 'enzyme';
|
||
4 years ago
|
import SendRowErrorMessage from './send-row-error-message.component';
|
||
7 years ago
|
|
||
4 years ago
|
describe('SendRowErrorMessage Component', () => {
|
||
4 years ago
|
let wrapper;
|
||
7 years ago
|
|
||
4 years ago
|
describe('render', () => {
|
||
|
beforeEach(() => {
|
||
4 years ago
|
wrapper = shallow(
|
||
5 years ago
|
<SendRowErrorMessage
|
||
|
errors={{ error1: 'abc', error2: 'def' }}
|
||
|
errorType="error3"
|
||
4 years ago
|
/>,
|
||
|
{ context: { t: (str) => `${str}_t` } },
|
||
4 years ago
|
);
|
||
|
});
|
||
7 years ago
|
|
||
4 years ago
|
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();
|
||
4 years ago
|
});
|
||
7 years ago
|
|
||
4 years ago
|
it('should render an error message if the passed errors contain an error of errorType', () => {
|
||
4 years ago
|
wrapper.setProps({
|
||
|
errors: { error1: 'abc', error2: 'def', error3: 'xyz' },
|
||
4 years ago
|
});
|
||
4 years ago
|
expect(wrapper.find('.send-v2__error')).toHaveLength(1);
|
||
|
expect(wrapper.find('.send-v2__error').text()).toStrictEqual('xyz_t');
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|