mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-15 06:06:35 +08:00
c214ba1e34
Summary: This fixes multiple issues, including snippets telling you you ought to look at the HTML as well as cruft like HTML entities and CSS in snippets. Test Plan: unit tests included o.O Reviewers: juan Reviewed By: juan Subscribers: evan Differential Revision: https://phab.nylas.com/D3500
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const FIXTURES_PATH = path.join(__dirname, 'fixtures');
|
|
const ACCOUNT_ID = 'test-account-id';
|
|
|
|
function forEachJSONFixture(relativePath, callback) {
|
|
const fixturesDir = path.join(FIXTURES_PATH, relativePath);
|
|
const filenames = fs.readdirSync(fixturesDir).filter(f => f.endsWith('.json'));
|
|
filenames.forEach((filename) => {
|
|
const json = JSON.parse(fs.readFileSync(path.join(fixturesDir, filename)));
|
|
callback(filename, json);
|
|
});
|
|
}
|
|
|
|
function forEachHTMLAndTXTFixture(relativePath, callback) {
|
|
const fixturesDir = path.join(FIXTURES_PATH, relativePath);
|
|
const filenames = fs.readdirSync(fixturesDir).filter(f => f.endsWith('.html'));
|
|
filenames.forEach((filename) => {
|
|
const html = fs.readFileSync(path.join(fixturesDir, filename)).toString();
|
|
const basename = path.parse(filename).name;
|
|
const txt = fs.readFileSync(path.join(fixturesDir, `${basename}.txt`)).toString().replace(/\n$/, '');
|
|
callback(filename, html, txt);
|
|
});
|
|
}
|
|
|
|
const silentLogger = {
|
|
info: () => {},
|
|
warn: () => {},
|
|
debug: () => {},
|
|
error: () => {},
|
|
}
|
|
|
|
module.exports = {
|
|
FIXTURES_PATH,
|
|
ACCOUNT_ID,
|
|
silentLogger,
|
|
forEachJSONFixture,
|
|
forEachHTMLAndTXTFixture,
|
|
}
|