2016-04-29 08:08:30 +08:00
|
|
|
/* eslint no-irregular-whitespace: 0 */
|
2016-05-05 04:44:31 +08:00
|
|
|
import {removeTrackingPixels} from '../lib/main';
|
|
|
|
import fs from 'fs';
|
2016-04-29 08:08:30 +08:00
|
|
|
|
2016-05-05 04:44:31 +08:00
|
|
|
const readFixture = (name) => {
|
|
|
|
return fs.readFileSync(`${__dirname}/fixtures/${name}`).toString().trim()
|
|
|
|
}
|
2016-04-29 08:08:30 +08:00
|
|
|
|
2016-05-05 05:03:15 +08:00
|
|
|
describe("TrackingPixelsExtension", function trackingPixelsExtension() {
|
2016-05-05 04:44:31 +08:00
|
|
|
it("should splice all tracking pixels from emails I've sent", () => {
|
|
|
|
const before = readFixture('a-before.txt');
|
|
|
|
const expected = readFixture('a-after.txt');
|
|
|
|
|
|
|
|
const message = {
|
|
|
|
body: before,
|
|
|
|
accountId: '1234',
|
|
|
|
isFromMe: () => true,
|
|
|
|
}
|
|
|
|
removeTrackingPixels(message);
|
|
|
|
expect(message.body).toEqual(expected);
|
|
|
|
});
|
2016-04-29 08:08:30 +08:00
|
|
|
|
2016-05-05 04:44:31 +08:00
|
|
|
it("should always splice Nylas read receipts for the current account id ", () => {
|
|
|
|
const before = readFixture('b-before.txt');
|
|
|
|
const expected = readFixture('b-after.txt');
|
2016-04-29 08:08:30 +08:00
|
|
|
|
2016-05-05 04:44:31 +08:00
|
|
|
const message = {
|
|
|
|
body: before,
|
|
|
|
accountId: '1234',
|
|
|
|
isFromMe: () => false,
|
|
|
|
}
|
|
|
|
removeTrackingPixels(message);
|
|
|
|
expect(message.body).toEqual(expected);
|
2016-04-29 08:08:30 +08:00
|
|
|
});
|
|
|
|
});
|