Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,17 @@ describe('Batch sending tests', function () {
const calls = stubbedSend.getCalls();
const deadline = new Date(t0.getTime() + targetDeliveryWindow);

// Check that the emails were sent with the deliverytime
for (const call of calls) {
const options = call.args[1];
const deliveryTimeString = options['o:deliverytime'];
const deliveryTimeDate = new Date(Date.parse(deliveryTimeString));
assert.equal(typeof deliveryTimeString, 'string');
assert.ok(deliveryTimeDate.getTime() <= deadline.getTime());
// The first/immediate batch's delivery time is "now" at calculation time,
// which the sender drops once the clock ticks past it (it never schedules a
// delivery in the past), so that batch legitimately sends with no
// deliverytime. Workers also run concurrently, so the batch order isn't
// guaranteed. Assert the windowed batches each carry a valid deliverytime
// within the deadline, rather than requiring one on every batch.
const deliveryTimes = calls.map(call => call.args[1]['o:deliverytime']);
const scheduled = deliveryTimes.filter(time => typeof time === 'string');
assert.ok(scheduled.length >= 3, `expected at least 3 scheduled delivery times, got ${scheduled.length}`);
for (const deliveryTimeString of scheduled) {
assert.ok(Date.parse(deliveryTimeString) <= deadline.getTime());
}
configUtils.restore();
});
Expand Down
Loading