I have a function getBookingStateObject
that calls another function getBookingStateButtons
. In turn getBookingStateButtons
calls two other functions linkButtons
and sendEventButtons
.
I'm trying to write tests for the above scenario. I have the following in my test file.
import {
getBookingStateButtons,
getBookingStateObject,
linkButtons,
sendEventButtons,
} from './bookingStates'
jest.mock('getBookingStateButtons', () => jest.fn())
jest.mock('linkButtons', () => jest.fn())
jest.mock('sendEventButtons', () => jest.fn())
it('calls getBookingStateButtons, linkButtons, sendEventButtons', () => {
getBookingStateObject({ aasm_state: 'created' }, '123')
expect(getBookingStateButtons).toHaveBeenCalledWith({
bookingId: '123',
events: [{ event: 'mark_requested', type: 'secondary' }],
links: [{ to: 'edit' }],
})
expect(linkButtons).toHaveBeenCalledWith({
to: 'edit',
type: 'secondary',
})
expect(sendEventButtons).toHaveBeenCalledWith({
event: 'mark_requested',
type: 'secondary',
})
})
When I run the tests I get the following error:
Cannot find module 'getBookingStateButtons' from 'bookingStates.spec.tsx'
I'm new to jest, What am I doing wrong?