2016-03-15 03:30:54 +08:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
2017-09-27 02:33:08 +08:00
|
|
|
import { autolink } from '../lib/autolinker';
|
2016-03-15 03:30:54 +08:00
|
|
|
|
2016-05-06 06:13:51 +08:00
|
|
|
describe('autolink', function autolinkSpec() {
|
2016-03-15 03:30:54 +08:00
|
|
|
const fixturesDir = path.join(__dirname, 'autolinker-fixtures');
|
2017-09-27 02:33:08 +08:00
|
|
|
fs
|
|
|
|
.readdirSync(fixturesDir)
|
|
|
|
.filter(filename => filename.indexOf('-in.html') !== -1)
|
|
|
|
.forEach(filename => {
|
|
|
|
it(`should properly autolink a variety of email bodies ${filename}`, () => {
|
|
|
|
const div = document.createElement('div');
|
|
|
|
const inputPath = path.join(fixturesDir, filename);
|
|
|
|
const expectedPath = inputPath.replace('-in', '-out');
|
2016-03-15 03:30:54 +08:00
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
const input = fs.readFileSync(inputPath).toString();
|
|
|
|
const expected = fs.readFileSync(expectedPath).toString();
|
2016-03-15 03:30:54 +08:00
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
div.innerHTML = input;
|
|
|
|
autolink({ body: div });
|
2016-03-15 03:30:54 +08:00
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
expect(div.innerHTML).toEqual(expected);
|
|
|
|
});
|
2016-03-15 03:30:54 +08:00
|
|
|
});
|
|
|
|
});
|