I’m trying to test a React component by verifying that changeWindow
gets called when I click a button. However, when I run the test, changeWindow.mock.calls
is undefined. I can’t figure out what I’m missing—changeWindow
is defined in the test as a function and changeWindow.mock
is defined as [Object object]. Any ideas?
jest.mock('../../../../../../lib/util/changeWindow');
const changeWindow = require('../../../../../../lib/util/changeWindow').default;
describe('CardPage', () => {
it('calls changeWindowLocation() on clicking button', () => {
const onChangeMock = jest.fn();
const component = enzyme.shallow(<CardPage status={'welcome'} onChange={onChangeMock}/>);
component.find(Button).at(2).simulate('click');
expect(changeWindow.mock.calls[0][0]).toEqual('/items/');
});
});
Aucun commentaire:
Enregistrer un commentaire