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

Prevent errors during the verification trigger tests

no issue

These tests were erroring because they subscribed to events but didn't have the handler injected.
This commit is contained in:
Sam Lord 2023-03-24 12:32:28 +00:00
parent c7928827a0
commit 8856822092

View file

@ -8,6 +8,14 @@ const DomainEvents = require('@tryghost/domain-events');
const {MemberCreatedEvent} = require('@tryghost/member-events');
describe('Import threshold', function () {
beforeEach(function () {
// Stub this method to prevent unnecessary subscriptions to domain events
sinon.stub(DomainEvents, 'subscribe');
});
afterEach(function () {
sinon.restore();
});
it('Creates a threshold based on config', async function () {
const trigger = new VerificationTrigger({
getImportTriggerThreshold: () => 2,
@ -60,6 +68,15 @@ describe('Import threshold', function () {
});
describe('Email verification flow', function () {
let domainEventsStub;
beforeEach(function () {
domainEventsStub = sinon.stub(DomainEvents, 'subscribe');
});
afterEach(function () {
sinon.restore();
});
it('Triggers verification process', async function () {
const emailStub = sinon.stub().resolves(null);
const settingsStub = sinon.stub().resolves(null);
@ -169,6 +186,8 @@ describe('Email verification flow', function () {
});
it('Triggers when a number of API events are dispatched', async function () {
// We need to use the real event repository here to test event handling
domainEventsStub.restore();
const emailStub = sinon.stub().resolves(null);
const settingsStub = sinon.stub().resolves(null);
const eventStub = sinon.stub().callsFake(async (_unused, {source}) => {