I have the following code:
it('Should return error', async () => {
const searchMetadata = {
details: {}
};
sandbox.mock(resultService).expects('doesSearchExists').atLeast(1).resolves(true);
sandbox.mock(resultService).expects('doesSearchExists').atLeast(1).withArgs("limit").resolves(false);
sandbox.mock(analyticsService).expects('getMetadata').throws(UNABLE_TO_CALCULATE_METADATA);
await GET(request, res, (result: any) => {
expect(result).to.be.deep.equal(UNABLE_TO_CALCULATE_METADATA)
});
});
As you can see I am trying to mock the same function doesSearchExists twice differently based on the argument I sent. If limit is sent doesSearchExists should return false and if limit is missing doesSearchExists should return true. But when I try it I get
TypeError: Attempted to wrap doesSearchExists which is already wrapped
any idea how I can achieve the above?