presentations/highlight-js/test/utility.js

30 lines
822 B
JavaScript
Raw Permalink Normal View History

2018-12-07 08:48:05 -06:00
'use strict';
let _ = require('lodash');
let bluebird = require('bluebird');
let readFile = bluebird.promisify(require('fs').readFile);
let path = require('path');
// Build a path relative to `test/`
exports.buildPath = function() {
const args = _.slice(arguments, 0),
paths = [__dirname].concat(args);
return path.join.apply(this, paths);
};
exports.numberToString = _.method('toString');
exports.expectedFile = function(filename, encoding, actual) {
return readFile(filename, encoding)
.then(expected => actual.trim().should.equal(expected.trim()));
};
exports.setupFile = function(filename, encoding, that, testHTML) {
return readFile(filename, encoding)
.then(expected => {
that.expected = expected.trim();
that.blocks = _.map(testHTML, 'innerHTML');
});
};