html-validate
Version:
Offline HTML5 validator and linter
67 lines (60 loc) • 2.34 kB
JavaScript
;
var kleur = require('kleur');
var jestSnapshot = require('jest-snapshot');
var core = require('./core.js');
var matchers = require('./matchers.js');
var matcherUtils = require('./matcher-utils.js');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var kleur__default = /*#__PURE__*/_interopDefault(kleur);
const options$1 = {
showLink: false,
showSummary: false,
showSelector: true
};
function createMatcher$1() {
function toMatchCodeframe(actual, ...rest) {
const filename = this.testPath ?? "inline";
const results = matchers.getResults(filename, actual);
const enabled = kleur__default.default.enabled;
kleur__default.default.enabled = false;
const snapshot = core.codeframe(results, options$1).replace(/\s+$/gm, "");
kleur__default.default.enabled = enabled;
return jestSnapshot.toMatchSnapshot.call(this, snapshot, ...rest);
}
return matcherUtils.diverge(toMatchCodeframe);
}
const options = {
showLink: false,
showSummary: false,
showSelector: true
};
function toMatchInlineCodeframeImpl(context, actual, ...rest) {
const filename = context.testPath ?? "inline";
const results = matchers.getResults(filename, actual);
const enabled = kleur__default.default.enabled;
kleur__default.default.enabled = false;
const snapshot = core.codeframe(results, options).replace(/\s+$/gm, "");
kleur__default.default.enabled = enabled;
return jestSnapshot.toMatchInlineSnapshot.call(context, snapshot, ...rest);
}
function createMatcher() {
function toMatchInlineCodeframe(actual, ...rest) {
const context = {
...this,
/* Capture the original stack frames as they are needed by "jest-snapshot"
* to determine where to write the inline snapshots. When resolving the
* promise the original stack frames are lost and the snapshot will be
* written in this files instaed. */
error: new Error()
};
if (matcherUtils.isThenable(actual)) {
return actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));
} else {
return toMatchInlineCodeframeImpl(context, actual, ...rest);
}
}
return toMatchInlineCodeframe;
}
exports.createMatcher = createMatcher;
exports.createMatcher$1 = createMatcher$1;
//# sourceMappingURL=matchers-jestonly.js.map