2016-03-15 03:30:54 +08:00
|
|
|
import {autolink} from '../lib/autolinker';
|
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
|
2016-05-05 05:03:15 +08:00
|
|
|
describe('autolink', function autolink() {
|
2016-03-15 03:30:54 +08:00
|
|
|
const fixturesDir = path.join(__dirname, 'autolinker-fixtures');
|
|
|
|
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');
|
|
|
|
|
|
|
|
const input = fs.readFileSync(inputPath).toString();
|
|
|
|
const expected = fs.readFileSync(expectedPath).toString();
|
|
|
|
|
|
|
|
div.innerHTML = input;
|
|
|
|
autolink({body: div});
|
|
|
|
|
|
|
|
expect(div.innerHTML).toEqual(expected);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|