Добрый день! Подскажите пожалуйста почему тест отдает такую ошибку?
В других аналогичных компонентах, аналогичных тестах все работает нормально, а тут ошибка.
Сам тест
it('should trigger prop openAppModal when modal btn is clicked', () => {
const props = {
app: {
id: '1',
},
selectedItem: {
id: '1',
},
openAppModal: jest.fn(),
onChange: jest.fn(),
isLoading: false,
};
const enzymeWrapper = shallow(<AppItem {...props} />);
enzymeWrapper.find('[data-test="delete-Flight"]').simulate('click');
expect(props.openAppModal).toHaveBeenCalledTimes(1);
});
Ошибка
Method “simulate” is only meant to be run on a single node. 0 found instead.
53 | };
54 | const enzymeWrapper = shallow(<AppItem {...props} />);
> 55 | enzymeWrapper.find('[data-test="modal"]').simulate('click');
Для тестов использую jest/enzyme, проект на react/redux.
Спасибо!
Компонент
import React from 'react';
import PropTypes from 'prop-types';
import _map from 'lodash/map';
import { pure } from 'recompose';
import FlightCard, {
FlightCardContent,
FlightCardDescription,
FlightCardFlight,
FlightCardInfo,
FlightPlayer,
FlightCardDeleteWrapper,
FlightCardContentTop,
FlightCardContentBottom,
} from 'App/components/FlightCard';
import { IconDelete, IconSetText, IconNewFlight } from 'App/components/Icons';
import {
FormGroupSelect,
} from 'App/components/Form';
import Time from 'App/components/Time';
import BEM from 'App/utils/BEM';
import { appType, dynamicFlightType } from 'App/types';
const b = BEM('Flight-card');
const handleDeleteDynamicFlight = (
Flight,
selectDynamicFlight,
openAppDeleteFlightModal,
) => {
selectDynamicFlight(Flight);
openAppDeleteFlightModal();
};
const isLoading = (
Flight,
selectedDynamicFlight,
isEditingLocale,
) => (
Flight.id === selectedDynamicFlight.id && isEditingLocale
);
const FlightItem= ({
app,
Flight,
onChange,
selectedDynamicFlight,
selectDynamicFlight,
openAppDeleteDynamicFlightModal,
openAppDynamicFlightSetTextModal,
openAppDynamicFlightSetFlightModal,
isEditingLocale,
}) => (
<FlightCard>
<FlightCardContent>
<div>
<FlightCardContentTop>
<FlightCardDescription>
{Flight.transcription}
</FlightCardDescription>
<FlightCardFlight className={b('Flight').toString()}>
<div>
<div>
<span className={b('filename')}>{Flight.filename}</span>
</div>
<FlightPlayer
app={app}
Flight={Flight}
/>
<div className={b('Flight-buttons')} />
</div>
</FlightCardFlight>
</FlightCardContentTop>
<FlightCardContentBottom>
<button
className="button is-text is-uppercase"
onClick={() => handleDeleteDynamicFlight(
Flight,
selectDynamicFlight,
openAppDeleteDynamicFlightModal,
)}
data-test="delete-Flight"
>
<IconDelete />
DELETE
</button>
</FlightCardContentBottom>
</div>
</FlightCardContent>
</FlightCard>
);
export default pure(FlightItem);