mocking with jest-when
There is a handy library for mocking function return values, called jest-when:
when(fn) .calledWith(1) .mockReturnValue("yay!") .calledWith(2) .mockReturnValue("nay!")
Sidenote on mocks: After seeing Simple Made Easy talk by my engineering guru Rich Hickey, I realized that mocks most probably signal complecting of two unrelated components and thus point to accidental complexity. To remove the complexity, one can pass mocked data via function arguments instead.