Added additional tests for email analytics (#20805)
ref 4267ff9
- unit tests didn't cover what events were passed along to be fetched,
important now that it's split out
This commit is contained in:
parent
3c9b8d682d
commit
54b0b87633
@ -99,7 +99,7 @@ module.exports = class EmailAnalyticsService {
|
||||
};
|
||||
}
|
||||
|
||||
return await this.#fetchEvents(this.#fetchLatestOpenedData, {begin, end, maxEvents, events: ['opened']});
|
||||
return await this.#fetchEvents(this.#fetchLatestOpenedData, {begin, end, maxEvents, eventTypes: ['opened']});
|
||||
}
|
||||
|
||||
async fetchLatestNonOpenedEvents({maxEvents = Infinity} = {}) {
|
||||
@ -120,7 +120,7 @@ module.exports = class EmailAnalyticsService {
|
||||
};
|
||||
}
|
||||
|
||||
return await this.#fetchEvents(this.#fetchLatestNonOpenedData, {begin, end, maxEvents, events: ['delivered', 'failed', 'unsubscribed', 'complained']});
|
||||
return await this.#fetchEvents(this.#fetchLatestNonOpenedData, {begin, end, maxEvents, eventTypes: ['delivered', 'failed', 'unsubscribed', 'complained']});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,6 +75,44 @@ describe('EmailAnalyticsService', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Fetching events', function () {
|
||||
afterEach(function () {
|
||||
sinon.restore();
|
||||
});
|
||||
describe('fetchLatestOpenedEvents', function () {
|
||||
it('fetches only opened events', async function () {
|
||||
const fetchLatestSpy = sinon.spy();
|
||||
const service = new EmailAnalyticsService({
|
||||
queries: {
|
||||
getLastEventTimestamp: sinon.stub().resolves()
|
||||
},
|
||||
providers: [{
|
||||
fetchLatest: fetchLatestSpy
|
||||
}]
|
||||
});
|
||||
await service.fetchLatestOpenedEvents();
|
||||
fetchLatestSpy.calledOnce.should.be.true();
|
||||
fetchLatestSpy.getCall(0).args[1].should.have.property('events', ['opened']);
|
||||
});
|
||||
});
|
||||
describe('fetchLatestNonOpenedEvents', function () {
|
||||
it('fetches only non-opened events', async function () {
|
||||
const fetchLatestSpy = sinon.spy();
|
||||
const service = new EmailAnalyticsService({
|
||||
queries: {
|
||||
getLastEventTimestamp: sinon.stub().resolves()
|
||||
},
|
||||
providers: [{
|
||||
fetchLatest: fetchLatestSpy
|
||||
}]
|
||||
});
|
||||
await service.fetchLatestNonOpenedEvents();
|
||||
fetchLatestSpy.calledOnce.should.be.true();
|
||||
fetchLatestSpy.getCall(0).args[1].should.have.property('events', ['delivered', 'failed', 'unsubscribed', 'complained']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('processEventBatch', function () {
|
||||
let eventProcessor;
|
||||
beforeEach(function () {
|
||||
|
Loading…
Reference in New Issue
Block a user