2016-04-29 08:08:30 +08:00
|
|
|
/* eslint no-irregular-whitespace: 0 */
|
2016-05-05 04:44:31 +08:00
|
|
|
import fs from 'fs';
|
2017-09-27 02:33:08 +08:00
|
|
|
import { removeTrackingPixels } from '../lib/main';
|
2016-04-29 08:08:30 +08:00
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
const readFixture = name => {
|
|
|
|
return fs
|
|
|
|
.readFileSync(`${__dirname}/fixtures/${name}`)
|
|
|
|
.toString()
|
|
|
|
.trim();
|
|
|
|
};
|
2016-04-29 08:08:30 +08:00
|
|
|
|
2017-09-27 02:33:08 +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,
|
2017-09-27 02:33:08 +08:00
|
|
|
};
|
2016-05-05 04:44:31 +08:00
|
|
|
removeTrackingPixels(message);
|
|
|
|
expect(message.body).toEqual(expected);
|
|
|
|
});
|
2016-04-29 08:08:30 +08:00
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
it('should always splice Nylas read receipts for the current account id ', () => {
|
2016-05-05 04:44:31 +08:00
|
|
|
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,
|
2017-09-27 02:33:08 +08:00
|
|
|
};
|
2016-05-05 04:44:31 +08:00
|
|
|
removeTrackingPixels(message);
|
|
|
|
expect(message.body).toEqual(expected);
|
2016-04-29 08:08:30 +08:00
|
|
|
});
|
|
|
|
});
|