html-validate
Version:
Offline HTML5 validator and linter
60 lines (56 loc) • 2.03 kB
JavaScript
import kleur from 'kleur';
import { toMatchSnapshot, toMatchInlineSnapshot } from 'jest-snapshot';
import { a1 as codeframe } from './core.js';
import { g as getResults } from './matchers.js';
import { d as diverge, i as isThenable } from './matcher-utils.js';
const options$1 = {
showLink: false,
showSummary: false,
showSelector: true
};
function createMatcher$1() {
function toMatchCodeframe(actual, ...rest) {
const filename = this.testPath ?? "inline";
const results = getResults(filename, actual);
const enabled = kleur.enabled;
kleur.enabled = false;
const snapshot = codeframe(results, options$1).replace(/\s+$/gm, "");
kleur.enabled = enabled;
return toMatchSnapshot.call(this, snapshot, ...rest);
}
return diverge(toMatchCodeframe);
}
const options = {
showLink: false,
showSummary: false,
showSelector: true
};
function toMatchInlineCodeframeImpl(context, actual, ...rest) {
const filename = context.testPath ?? "inline";
const results = getResults(filename, actual);
const enabled = kleur.enabled;
kleur.enabled = false;
const snapshot = codeframe(results, options).replace(/\s+$/gm, "");
kleur.enabled = enabled;
return 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 (isThenable(actual)) {
return actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));
} else {
return toMatchInlineCodeframeImpl(context, actual, ...rest);
}
}
return toMatchInlineCodeframe;
}
export { createMatcher$1 as a, createMatcher as c };
//# sourceMappingURL=matchers-jestonly.js.map