Answer the question
In order to leave comments, you need to log in
How to lock function in jest with arguments and return?
I want to lock actionsetTaskItemPin
to make a test
let dispatch = jest.fn();
test('TaskItemContainer actionsetTaskItemPin', () => {
let actionsetTaskItemPin = jest.fn();
instance.setPin();
expect(actionsetTaskItemPin).toHaveBeenCalledWith({ pin: true, keychapter: props.keychapter, keyitem: props.keyitem },dispatch );
});
setPin = (ifo) => {
let pin = true;
let data = { pin: pin, keychapter: this.state.keychapter, keyitem: this.state.keyitem };
actionsetTaskItemPin(data, this.props.dispatch);
}
вот так не сработало тоже
TaskItemContainer › TaskItemContainer actionsetTaskItemPin
expect(jest.fn()).toHaveBeenCalled()
Expected number of calls: >= 1
Received number of calls: 0
test('TaskItemContainer actionsetTaskItemPin, () => {
instance.setPin();
expect(actionsetTaskItemPin).toHaveBeenCalled();
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question