Я тестирую компонент, используя Jest, вот компонент, который я хочу протестировать:
<div className={'b-popover b-hover b-bottom'}>
<div className={'b-content b-pull-left'}>
<div className={'b-body bui-text-small'}>
<FormattedMessage id={getStringByKey(GROUP_ASSIGNMENT_STRINGS, 'exceeding-fifty-groups-warning-tooltip-id')} defaultMessage={getStringByKey(GROUP_ASSIGNMENT_STRINGS, 'exceeding-fifty-groups-warning-tooltip')}/>
</div>
</div>
</div>
А вот мой тестовый код:
describe('When <GroupRow />', () => {
it('it should structure the component correctly when input is disabled', () => {
const props = {inputSectionType: ROW_INPUT_TYPE_DISABLED};
const content = render(<GroupRow inputSectionType={props.inputSectionType}/>);
expect(content).toMatchSnapshot();
});
});
Внутри FormattedMessage
здесь есть функция getStringByKey()
, и она импортируется из ../../../constants
.Функциональность getStringByKey()
в настоящее время не важна.Но когда я запускаю набор тестов, я получаю сообщение об ошибке:
TypeError: (0 , _constants.getStringByKey) is not a function
Итак, как я могу издеваться над этой функцией?Спасибо.