0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added disableStripe method to mock manager

Some tests need to run without Stripe connected/enabled, which is the
default at the moment. This method will disconnect stripe for the
lifecycle of the API agent.
This commit is contained in:
Fabien "egg" O'Carroll 2022-03-10 10:55:22 +00:00 committed by Fabien 'egg' O'Carroll
parent 763a0f11cd
commit f655ed3970

View file

@ -13,6 +13,14 @@ let emailCount = 0;
const mailService = require('../../core/server/services/mail/index');
const labs = require('../../core/shared/labs');
const disableStripe = async () => {
// This must be required _after_ startGhost has been called, because the models will
// not have been loaded otherwise. Consider moving the dependency injection of models
// into the init method of the Stripe service.
const stripeService = require('../../core/server/services/stripe');
await stripeService.disconnect();
};
const mockMail = () => {
mocks.mail = sinon
.stub(mailService.GhostMailer.prototype, 'send')
@ -95,6 +103,7 @@ const restore = () => {
module.exports = {
mockMail,
disableStripe,
mockStripe,
mockLabsEnabled,
mockLabsDisabled,