Added test to ensure events are only fetched if configured

refs https://github.com/TryGhost/Toolbox/issues/363

- this adds coverage for a branch in the code, and ensures we don't
  fetch any events if mailgun is not configured
This commit is contained in:
Daniel Lockyer 2022-08-11 08:17:06 +02:00
parent 843bbfa55d
commit 3e6416431e
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD

View File

@ -88,6 +88,15 @@ describe('MailgunClient', function () {
});
describe('fetchEvents()', function () {
it('does not fetch if not configured', async function () {
const batchHandler = sinon.spy();
const mailgunClient = new MailgunClient({config, settings});
const events = await mailgunClient.fetchEvents(MAILGUN_OPTIONS, batchHandler);
assert.equal(events.length, 0);
assert.equal(batchHandler.callCount, 0);
});
it('fetches from now and works backwards', async function () {
const configStub = sinon.stub(config, 'get');
configStub.withArgs('bulkEmail').returns({