Created
September 3, 2022 18:49
-
-
Save trikitrok/d6a9fdeca0d482c86e051544b5f5d501 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {when} from "jest-when"; | |
export function stub(paymentsRepository) { | |
const monthPaymentsBuilder = { | |
inMonth: inMonth | |
}; | |
return knowingThat; | |
function knowingThat() { | |
return monthPaymentsBuilder; | |
} | |
function inMonth(month) { | |
return { | |
userWith: (userId) => { | |
return { | |
hasPaid: (payments) => { | |
when(paymentsRepository.find).calledWith(userId, month) | |
.mockReturnValue(payments); | |
return { | |
andThat: knowingThat | |
}; | |
} | |
}; | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment