html-validate 8.7.3 → 8.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/cjs/browser.js +7 -21
  2. package/dist/cjs/browser.js.map +1 -1
  3. package/dist/cjs/cli.js +468 -451
  4. package/dist/cjs/cli.js.map +1 -1
  5. package/dist/cjs/core-browser.js +9 -20
  6. package/dist/cjs/core-browser.js.map +1 -1
  7. package/dist/cjs/core-nodejs.js +203 -297
  8. package/dist/cjs/core-nodejs.js.map +1 -1
  9. package/dist/cjs/core.js +9511 -10450
  10. package/dist/cjs/core.js.map +1 -1
  11. package/dist/cjs/elements.js +2293 -2296
  12. package/dist/cjs/elements.js.map +1 -1
  13. package/dist/cjs/html-validate.js +148 -169
  14. package/dist/cjs/html-validate.js.map +1 -1
  15. package/dist/cjs/html5.js.map +1 -1
  16. package/dist/cjs/index.js +8 -21
  17. package/dist/cjs/index.js.map +1 -1
  18. package/dist/cjs/jest-diff.js +26 -36
  19. package/dist/cjs/jest-diff.js.map +1 -1
  20. package/dist/cjs/jest.js +8 -8
  21. package/dist/cjs/jest.js.map +1 -1
  22. package/dist/cjs/matcher-utils.js +12 -28
  23. package/dist/cjs/matcher-utils.js.map +1 -1
  24. package/dist/cjs/matchers-jestonly.js +38 -47
  25. package/dist/cjs/matchers-jestonly.js.map +1 -1
  26. package/dist/cjs/matchers.js +196 -196
  27. package/dist/cjs/matchers.js.map +1 -1
  28. package/dist/cjs/meta-helper.js +40 -60
  29. package/dist/cjs/meta-helper.js.map +1 -1
  30. package/dist/cjs/test-utils.js +26 -47
  31. package/dist/cjs/test-utils.js.map +1 -1
  32. package/dist/cjs/tsdoc-metadata.json +1 -1
  33. package/dist/cjs/utils/natural-join.js +10 -23
  34. package/dist/cjs/utils/natural-join.js.map +1 -1
  35. package/dist/cjs/vitest.js +6 -6
  36. package/dist/cjs/vitest.js.map +1 -1
  37. package/dist/es/browser.js +2 -2
  38. package/dist/es/cli.js +467 -454
  39. package/dist/es/cli.js.map +1 -1
  40. package/dist/es/core-browser.js +10 -21
  41. package/dist/es/core-browser.js.map +1 -1
  42. package/dist/es/core-nodejs.js +204 -299
  43. package/dist/es/core-nodejs.js.map +1 -1
  44. package/dist/es/core.js +9506 -10451
  45. package/dist/es/core.js.map +1 -1
  46. package/dist/es/elements.js +2293 -2296
  47. package/dist/es/elements.js.map +1 -1
  48. package/dist/es/html-validate.js +150 -171
  49. package/dist/es/html-validate.js.map +1 -1
  50. package/dist/es/html5.js.map +1 -1
  51. package/dist/es/index.js +3 -3
  52. package/dist/es/jest-diff.js +11 -21
  53. package/dist/es/jest-diff.js.map +1 -1
  54. package/dist/es/jest.js +8 -8
  55. package/dist/es/jest.js.map +1 -1
  56. package/dist/es/matcher-utils.js +12 -28
  57. package/dist/es/matcher-utils.js.map +1 -1
  58. package/dist/es/matchers-jestonly.js +39 -48
  59. package/dist/es/matchers-jestonly.js.map +1 -1
  60. package/dist/es/matchers.js +196 -196
  61. package/dist/es/matchers.js.map +1 -1
  62. package/dist/es/meta-helper.js +40 -60
  63. package/dist/es/meta-helper.js.map +1 -1
  64. package/dist/es/test-utils.js +26 -47
  65. package/dist/es/test-utils.js.map +1 -1
  66. package/dist/es/utils/natural-join.js +10 -23
  67. package/dist/es/utils/natural-join.js.map +1 -1
  68. package/dist/es/vitest.js +6 -6
  69. package/dist/es/vitest.js.map +1 -1
  70. package/dist/tsdoc-metadata.json +1 -1
  71. package/dist/types/browser.d.ts +62 -30
  72. package/dist/types/index.d.ts +89 -32
  73. package/package.json +22 -18
@@ -1,40 +1,24 @@
1
1
  'use strict';
2
2
 
3
- function isThenable(src) {
4
- return src && typeof src === "object" && typeof src.then === "function";
3
+ function isThenable(value) {
4
+ return value && typeof value === "object" && "then" in value && typeof value.then === "function";
5
5
  }
6
6
 
7
- /**
8
- * Creates a wrapped function based on the passed function.
9
- *
10
- * The returned function takes either a `T` or `Promise<T>`. If `T` the result
11
- * will be synchronous or if `Promise<T>` the result will be asynchronous.
12
- *
13
- * In practice this means that if you pass a synchronous object into it you will
14
- * maintain synchronous code but if you pass an asynchronous object you must
15
- * await the result.
16
- *
17
- * @internal
18
- */
19
7
  function diverge(fn) {
20
- function diverged(actual, ...args) {
21
- if (isThenable(actual)) {
22
- return actual.then((resolved) => fn.call(this, resolved, ...args));
23
- }
24
- else {
25
- return fn.call(this, actual, ...args);
26
- }
8
+ function diverged(actual, ...args) {
9
+ if (isThenable(actual)) {
10
+ return actual.then((resolved) => fn.call(this, resolved, ...args));
11
+ } else {
12
+ return fn.call(this, actual, ...args);
27
13
  }
28
- return diverged;
14
+ }
15
+ return diverged;
29
16
  }
30
17
 
31
- /**
32
- * Takes all messages from all files and flattens to a single array.
33
- */
34
18
  function flattenMessages(report) {
35
- return report.results.reduce((aggregated, result) => {
36
- return aggregated.concat(result.messages);
37
- }, []);
19
+ return report.results.reduce((aggregated, result) => {
20
+ return aggregated.concat(result.messages);
21
+ }, []);
38
22
  }
39
23
 
40
24
  exports.diverge = diverge;
@@ -1 +1 @@
1
- {"version":3,"file":"matcher-utils.js","sources":["../../../src/jest/utils/is-thenable.ts","../../../src/jest/utils/diverge.ts","../../../src/jest/utils/flatten-messages.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;AAAM,SAAU,UAAU,CAAI,GAAmB,EAAA;AAChD,IAAA,OAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAQ,GAAW,CAAC,IAAI,KAAK,UAAU,CAAC;AAClF;;ACgBA;;;;;;;;;;;AAWG;AACG,SAAU,OAAO,CACtB,EAA0B,EAAA;AAQ1B,IAAA,SAAS,QAAQ,CAEhB,MAAsB,EACtB,GAAG,IAAW,EAAA;AAEd,QAAA,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE;YACvB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;SACnE;aAAM;YACN,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;SACtC;KACD;AACD,IAAA,OAAO,QAAQ,CAAC;AACjB;;ACjDA;;AAEG;AACG,SAAU,eAAe,CAAC,MAAc,EAAA;IAC7C,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,UAAqB,EAAE,MAAc,KAAI;QACtE,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;KAC1C,EAAE,EAAE,CAAC,CAAC;AACR;;;;;;"}
1
+ {"version":3,"file":"matcher-utils.js","sources":["../../src/jest/utils/is-thenable.ts","../../src/jest/utils/diverge.ts","../../src/jest/utils/flatten-messages.ts"],"sourcesContent":["/**\n * @internal\n */\nexport function isThenable<T>(value: T | Promise<T>): value is Promise<T> {\n\treturn value && typeof value === \"object\" && \"then\" in value && typeof value.then === \"function\";\n}\n","import { isThenable } from \"./is-thenable\";\nimport { type MatcherContext } from \"./matcher-context\";\nimport { type MatcherResult } from \"./matcher-result\";\n\ntype SyncCallback<T, TArgs extends any[]> = (\n\tthis: MatcherContext,\n\tactual: T,\n\t...args: TArgs\n) => MatcherResult;\n\n/**\n * @internal\n */\nexport interface MaybeAsyncCallback<TActual, TArgs extends any[]> {\n\t(this: MatcherContext, actual: TActual, ...args: TArgs): MatcherResult;\n\t(this: MatcherContext, actual: Promise<TActual>, ...args: TArgs): Promise<MatcherResult>;\n}\n\n/**\n * Creates a wrapped function based on the passed function.\n *\n * The returned function takes either a `T` or `Promise<T>`. If `T` the result\n * will be synchronous or if `Promise<T>` the result will be asynchronous.\n *\n * In practice this means that if you pass a synchronous object into it you will\n * maintain synchronous code but if you pass an asynchronous object you must\n * await the result.\n *\n * @internal\n */\nexport function diverge<T, TArgs extends any[]>(\n\tfn: SyncCallback<T, TArgs>,\n): MaybeAsyncCallback<T, TArgs> {\n\tfunction diverged(this: MatcherContext, actual: T, ...args: TArgs): MatcherResult;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: Promise<T>,\n\t\t...args: TArgs\n\t): Promise<MatcherResult>;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: T | Promise<T>,\n\t\t...args: TArgs\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => fn.call(this, resolved, ...args));\n\t\t} else {\n\t\t\treturn fn.call(this, actual, ...args);\n\t\t}\n\t}\n\treturn diverged;\n}\n","import { type Message, type Report, type Result } from \"../../reporter\";\n\n/**\n * Takes all messages from all files and flattens to a single array.\n */\nexport function flattenMessages(report: Report): Message[] {\n\treturn report.results.reduce((aggregated: Message[], result: Result) => {\n\t\treturn aggregated.concat(result.messages);\n\t}, []);\n}\n"],"names":[],"mappings":";;AAGO,SAAS,WAAc,KAA4C,EAAA;AACzE,EAAO,OAAA,KAAA,IAAS,OAAO,KAAU,KAAA,QAAA,IAAY,UAAU,KAAS,IAAA,OAAO,MAAM,IAAS,KAAA,UAAA,CAAA;AACvF;;ACyBO,SAAS,QACf,EAC+B,EAAA;AAO/B,EAAS,SAAA,QAAA,CAER,WACG,IACsC,EAAA;AACzC,IAAI,IAAA,UAAA,CAAW,MAAM,CAAG,EAAA;AACvB,MAAO,OAAA,MAAA,CAAO,IAAK,CAAA,CAAC,QAAa,KAAA,EAAA,CAAG,KAAK,IAAM,EAAA,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA,CAAA;AAAA,KAC3D,MAAA;AACN,MAAA,OAAO,EAAG,CAAA,IAAA,CAAK,IAAM,EAAA,MAAA,EAAQ,GAAG,IAAI,CAAA,CAAA;AAAA,KACrC;AAAA,GACD;AACA,EAAO,OAAA,QAAA,CAAA;AACR;;AC9CO,SAAS,gBAAgB,MAA2B,EAAA;AAC1D,EAAA,OAAO,MAAO,CAAA,OAAA,CAAQ,MAAO,CAAA,CAAC,YAAuB,MAAmB,KAAA;AACvE,IAAO,OAAA,UAAA,CAAW,MAAO,CAAA,MAAA,CAAO,QAAQ,CAAA,CAAA;AAAA,GACzC,EAAG,EAAE,CAAA,CAAA;AACN;;;;;;"}
@@ -11,63 +11,54 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
  var kleur__default = /*#__PURE__*/_interopDefault(kleur);
12
12
 
13
13
  const options$1 = {
14
- showLink: false,
15
- showSummary: false,
16
- showSelector: true,
14
+ showLink: false,
15
+ showSummary: false,
16
+ showSelector: true
17
17
  };
18
18
  function createMatcher$1() {
19
- function toMatchCodeframe(actual, ...rest) {
20
- var _a;
21
- /* istanbul ignore next: cant figure out when this would be unset */
22
- const filename = (_a = this.testPath) !== null && _a !== void 0 ? _a : "inline";
23
- const results = matchers.getResults(filename, actual);
24
- const enabled = kleur__default.default.enabled;
25
- kleur__default.default.enabled = false;
26
- const snapshot = core.codeframe(results, options$1).replace(/\s+$/gm, "");
27
- kleur__default.default.enabled = enabled;
28
- /* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --
29
- * the implementation works but the declarations doesn't allow it */
30
- return jestSnapshot.toMatchSnapshot.call(this, snapshot, ...rest);
31
- }
32
- return matcherUtils.diverge(toMatchCodeframe);
19
+ function toMatchCodeframe(actual, ...rest) {
20
+ const filename = this.testPath ?? "inline";
21
+ const results = matchers.getResults(filename, actual);
22
+ const enabled = kleur__default.default.enabled;
23
+ kleur__default.default.enabled = false;
24
+ const snapshot = core.codeframe(results, options$1).replace(/\s+$/gm, "");
25
+ kleur__default.default.enabled = enabled;
26
+ return jestSnapshot.toMatchSnapshot.call(this, snapshot, ...rest);
27
+ }
28
+ return matcherUtils.diverge(toMatchCodeframe);
33
29
  }
34
30
 
35
31
  const options = {
36
- showLink: false,
37
- showSummary: false,
38
- showSelector: true,
32
+ showLink: false,
33
+ showSummary: false,
34
+ showSelector: true
39
35
  };
40
36
  function toMatchInlineCodeframeImpl(context, actual, ...rest) {
41
- var _a;
42
- /* istanbul ignore next: cant figure out when this would be unset */
43
- const filename = (_a = context.testPath) !== null && _a !== void 0 ? _a : "inline";
44
- const results = matchers.getResults(filename, actual);
45
- const enabled = kleur__default.default.enabled;
46
- kleur__default.default.enabled = false;
47
- const snapshot = core.codeframe(results, options).replace(/\s+$/gm, "");
48
- kleur__default.default.enabled = enabled;
49
- /* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --
50
- * the implementation works but the declarations doesn't allow it */
51
- return jestSnapshot.toMatchInlineSnapshot.call(context, snapshot, ...rest);
37
+ const filename = context.testPath ?? "inline";
38
+ const results = matchers.getResults(filename, actual);
39
+ const enabled = kleur__default.default.enabled;
40
+ kleur__default.default.enabled = false;
41
+ const snapshot = core.codeframe(results, options).replace(/\s+$/gm, "");
42
+ kleur__default.default.enabled = enabled;
43
+ return jestSnapshot.toMatchInlineSnapshot.call(context, snapshot, ...rest);
52
44
  }
53
45
  function createMatcher() {
54
- function toMatchInlineCodeframe(actual, ...rest) {
55
- const context = {
56
- ...this,
57
- /* Capture the original stack frames as they are needed by "jest-snapshot"
58
- * to determine where to write the inline snapshots. When resolving the
59
- * promise the original stack frames are lost and the snapshot will be
60
- * written in this files instaed. */
61
- error: new Error(),
62
- };
63
- if (matcherUtils.isThenable(actual)) {
64
- return actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));
65
- }
66
- else {
67
- return toMatchInlineCodeframeImpl(context, actual, ...rest);
68
- }
46
+ function toMatchInlineCodeframe(actual, ...rest) {
47
+ const context = {
48
+ ...this,
49
+ /* Capture the original stack frames as they are needed by "jest-snapshot"
50
+ * to determine where to write the inline snapshots. When resolving the
51
+ * promise the original stack frames are lost and the snapshot will be
52
+ * written in this files instaed. */
53
+ error: new Error()
54
+ };
55
+ if (matcherUtils.isThenable(actual)) {
56
+ return actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));
57
+ } else {
58
+ return toMatchInlineCodeframeImpl(context, actual, ...rest);
69
59
  }
70
- return toMatchInlineCodeframe;
60
+ }
61
+ return toMatchInlineCodeframe;
71
62
  }
72
63
 
73
64
  exports.createMatcher = createMatcher$1;
@@ -1 +1 @@
1
- {"version":3,"file":"matchers-jestonly.js","sources":["../../../src/jest/matchers/to-match-codeframe.ts","../../../src/jest/matchers/to-match-inline-codeframe.ts"],"sourcesContent":[null,null],"names":["options","createMatcher","getResults","kleur","codeframe","toMatchSnapshot","diverge","toMatchInlineSnapshot","isThenable"],"mappings":";;;;;;;;;;;;AAYA,MAAMA,SAAO,GAAqB;AACjC,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,YAAY,EAAE,IAAI;CAClB,CAAC;AAEF,SAASC,eAAa,GAAA;AACrB,IAAA,SAAS,gBAAgB,CAExB,MAAuB,EACvB,GAAG,IAA4B,EAAA;;;QAG/B,MAAM,QAAQ,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,QAAQ,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,QAAQ,CAAC;QAC3C,MAAM,OAAO,GAAGC,mBAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7C,QAAA,MAAM,OAAO,GAAGC,sBAAK,CAAC,OAAO,CAAC;AAC9B,QAAAA,sBAAK,CAAC,OAAO,GAAG,KAAK,CAAC;AACtB,QAAA,MAAM,QAAQ,GAAGC,cAAS,CAAC,OAAO,EAAEJ,SAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACnE,QAAAG,sBAAK,CAAC,OAAO,GAAG,OAAO,CAAC;AAExB;AACoE;QACpE,OAAQE,4BAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;KAC9D;AACD,IAAA,OAAOC,oBAAO,CAAC,gBAAgB,CAAC,CAAC;AAClC;;AC9BA,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AE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;SAC5D;KACD;AAED,IAAA,OAAO,sBAAsB,CAAC;AAC/B;;;;;"}
1
+ {"version":3,"file":"matchers-jestonly.js","sources":["../../src/jest/matchers/to-match-codeframe.ts","../../src/jest/matchers/to-match-inline-codeframe.ts"],"sourcesContent":["import kleur from \"kleur\";\nimport { toMatchSnapshot } from \"jest-snapshot\";\nimport { codeframe, type CodeframeOptions } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype MatcherContext,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction createMatcher(): MaybeAsyncCallback<Report | string, [Array<string | object>]> {\n\tfunction toMatchCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | string,\n\t\t...rest: Array<string | object>\n\t): MatcherResult {\n\t\t/* istanbul ignore next: cant figure out when this would be unset */\n\t\tconst filename = this.testPath ?? \"inline\";\n\t\tconst results = getResults(filename, actual);\n\t\tconst enabled = kleur.enabled;\n\t\tkleur.enabled = false;\n\t\tconst snapshot = codeframe(results, options).replace(/\\s+$/gm, \"\");\n\t\tkleur.enabled = enabled;\n\n\t\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --\n\t\t * the implementation works but the declarations doesn't allow it */\n\t\treturn (toMatchSnapshot as any).call(this, snapshot, ...rest);\n\t}\n\treturn diverge(toMatchCodeframe);\n}\n\nexport { createMatcher as toMatchCodeframe };\n","import kleur from \"kleur\";\nimport { toMatchInlineSnapshot } from \"jest-snapshot\";\nimport { codeframe, type CodeframeOptions } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport { type MatcherContext, type MatcherResult, isThenable } from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction toMatchInlineCodeframeImpl(\n\tcontext: MatcherContext,\n\tactual: Report | string,\n\t...rest: Array<string | object>\n): MatcherResult {\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst filename = context.testPath ?? \"inline\";\n\tconst results = getResults(filename, actual);\n\tconst enabled = kleur.enabled;\n\tkleur.enabled = false;\n\tconst snapshot = codeframe(results, options).replace(/\\s+$/gm, \"\");\n\tkleur.enabled = enabled;\n\n\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --\n\t * the implementation works but the declarations doesn't allow it */\n\treturn (toMatchInlineSnapshot as any).call(context, snapshot, ...rest);\n}\n\ntype ToMatchInlineCodeframeMatcher = (\n\tthis: MatcherContext,\n\tactual: Report | Promise<Report> | string,\n\t...rest: Array<string | object>\n) => MatcherResult | Promise<MatcherResult>;\n\nfunction createMatcher(): ToMatchInlineCodeframeMatcher {\n\tfunction toMatchInlineCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | Promise<Report> | string,\n\t\t...rest: Array<string | object>\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tconst context = {\n\t\t\t...this,\n\n\t\t\t/* Capture the original stack frames as they are needed by \"jest-snapshot\"\n\t\t\t * to determine where to write the inline snapshots. When resolving the\n\t\t\t * promise the original stack frames are lost and the snapshot will be\n\t\t\t * written in this files instaed. */\n\t\t\terror: new Error(),\n\t\t};\n\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));\n\t\t} else {\n\t\t\treturn toMatchInlineCodeframeImpl(context, actual, ...rest);\n\t\t}\n\t}\n\n\treturn toMatchInlineCodeframe;\n}\n\nexport { createMatcher as toMatchInlineCodeframe };\n"],"names":["options","createMatcher","getResults","kleur","codeframe","toMatchSnapshot","diverge","toMatchInlineSnapshot","isThenable"],"mappings":";;;;;;;;;;;;AA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A,EAAS,OAAO,CAAE,CAAA,OAAA,CAAQ,UAAU,EAAE,CAAA,CAAA;AACjE,EAAAD,sBAAA,CAAM,OAAU,GAAA,OAAA,CAAA;AAIhB,EAAA,OAAQI,kCAA8B,CAAA,IAAA,CAAK,OAAS,EAAA,QAAA,EAAU,GAAG,IAAI,CAAA,CAAA;AACtE,CAAA;AAQA,SAAS,aAA+C,GAAA;AACvD,EAAS,SAAA,sBAAA,CAER,WACG,IACsC,EAAA;AACzC,IAAA,MAAM,OAAU,GAAA;AAAA,MACf,GAAG,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMH,KAAA,EAAO,IAAI,KAAM,EAAA;AAAA,KAClB,CAAA;AAEA,IAAI,IAAAC,uBAAA,CAAW,MAAM,CAAG,EAAA;AACvB,MAAO,OAAA,MAAA,CAAO,KAAK,CAAC,QAAA,KAAa,2BAA2B,OAAS,EAAA,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA,CAAA;AAAA,KACjF,MAAA;AACN,MAAA,OAAO,0BAA2B,CAAA,OAAA,EAAS,MAAQ,EAAA,GAAG,IAAI,CAAA,CAAA;AAAA,KAC3D;AAAA,GACD;AAEA,EAAO,OAAA,sBAAA,CAAA;AACR;;;;;"}
@@ -5,234 +5,234 @@ var core = require('./core.js');
5
5
  var coreNodejs = require('./core-nodejs.js');
6
6
 
7
7
  function createMatcher$4() {
8
- function toBeValid(report) {
9
- if (report.valid) {
10
- return {
11
- pass: true,
12
- message: /* istanbul ignore next */ () => "Result should not contain error",
13
- };
14
- }
15
- else {
16
- const firstError = report.results[0].messages[0];
17
- return {
18
- pass: false,
19
- message: () => `Result should be valid but had error "${firstError.message}"`,
20
- };
21
- }
8
+ function toBeValid(report) {
9
+ if (report.valid) {
10
+ return {
11
+ pass: true,
12
+ message: (
13
+ /* istanbul ignore next */
14
+ () => "Result should not contain error"
15
+ )
16
+ };
17
+ } else {
18
+ const firstError = report.results[0].messages[0];
19
+ return {
20
+ pass: false,
21
+ message: () => `Result should be valid but had error "${firstError.message}"`
22
+ };
22
23
  }
23
- return matcherUtils.diverge(toBeValid);
24
+ }
25
+ return matcherUtils.diverge(toBeValid);
24
26
  }
25
27
 
26
28
  function createMatcher$3() {
27
- function toBeInvalid(report) {
28
- if (report.valid) {
29
- return {
30
- pass: false,
31
- message: () => "Result should be invalid but had no errors",
32
- };
33
- }
34
- else {
35
- return {
36
- pass: true,
37
- message: /* istanbul ignore next */ () => "Result should not contain error",
38
- };
39
- }
29
+ function toBeInvalid(report) {
30
+ if (report.valid) {
31
+ return {
32
+ pass: false,
33
+ message: () => "Result should be invalid but had no errors"
34
+ };
35
+ } else {
36
+ return {
37
+ pass: true,
38
+ message: (
39
+ /* istanbul ignore next */
40
+ () => "Result should not contain error"
41
+ )
42
+ };
40
43
  }
41
- return matcherUtils.diverge(toBeInvalid);
44
+ }
45
+ return matcherUtils.diverge(toBeInvalid);
42
46
  }
43
47
 
44
48
  function isMessage(arg) {
45
- if (!arg) {
46
- return false;
47
- }
48
- return Boolean(arg.ruleId ||
49
- arg.severity ||
50
- arg.message ||
51
- arg.offset ||
52
- arg.line ||
53
- arg.column ||
54
- arg.size ||
55
- arg.selector ||
56
- arg.context);
49
+ if (!arg) {
50
+ return false;
51
+ }
52
+ return Boolean(
53
+ arg.ruleId || arg.severity || arg.message || arg.offset || arg.line || arg.column || arg.size || arg.selector || arg.context
54
+ );
57
55
  }
58
56
  function isConfig(arg) {
59
- if (!arg) {
60
- return false;
61
- }
62
- return Boolean(arg.root || arg.extends || arg.elements || arg.plugin || arg.transform || arg.rules);
57
+ if (!arg) {
58
+ return false;
59
+ }
60
+ return Boolean(
61
+ arg.root || arg.extends || arg.elements || arg.plugin || arg.transform || arg.rules
62
+ );
63
63
  }
64
64
  function isString(arg) {
65
- return typeof arg === "string";
65
+ return typeof arg === "string";
66
66
  }
67
67
  function getMarkup(src) {
68
- if (typeof HTMLElement !== "undefined" && src instanceof HTMLElement) {
69
- return src.outerHTML;
70
- }
71
- /* istanbul ignore else: prototype only allows string or HTMLElement */
72
- if (typeof src === "string") {
73
- return src;
74
- }
75
- else {
76
- throw new Error(`Failed to get markup from "${typeof src}" argument`);
77
- }
68
+ if (typeof HTMLElement !== "undefined" && src instanceof HTMLElement) {
69
+ return src.outerHTML;
70
+ }
71
+ if (typeof src === "string") {
72
+ return src;
73
+ } else {
74
+ throw new Error(`Failed to get markup from "${typeof src}" argument`);
75
+ }
78
76
  }
79
77
  function createMatcher$2(expect, diff) {
80
- function toHTMLValidate(actual, arg0, arg1, arg2) {
81
- const markup = getMarkup(actual);
82
- const message = isMessage(arg0) ? arg0 : undefined;
83
- const config = isConfig(arg0) ? arg0 : isConfig(arg1) ? arg1 : undefined;
84
- const filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2;
85
- return toHTMLValidateImpl.call(this, expect, diff, markup, message, config, filename);
86
- }
87
- return matcherUtils.diverge(toHTMLValidate);
78
+ function toHTMLValidate(actual, arg0, arg1, arg2) {
79
+ const markup = getMarkup(actual);
80
+ const message = isMessage(arg0) ? arg0 : void 0;
81
+ const config = isConfig(arg0) ? arg0 : isConfig(arg1) ? arg1 : void 0;
82
+ const filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2;
83
+ return toHTMLValidateImpl.call(this, expect, diff, markup, message, config, filename);
84
+ }
85
+ return matcherUtils.diverge(toHTMLValidate);
88
86
  }
89
87
  function toHTMLValidateImpl(expect, diff, actual, expectedError, userConfig, filename) {
90
- var _a;
91
- const defaultConfig = {
92
- rules: {
93
- /* jsdom normalizes style so disabling rule when using this matcher or it
94
- * gets quite noisy when configured with self-closing */
95
- "void-style": "off",
96
- },
97
- };
98
- const config = core.deepmerge(defaultConfig, userConfig !== null && userConfig !== void 0 ? userConfig : {});
99
- /* istanbul ignore next: cant figure out when this would be unset */
100
- const actualFilename = (_a = filename !== null && filename !== void 0 ? filename : this.testPath) !== null && _a !== void 0 ? _a : "inline";
101
- const loader = new coreNodejs.FileSystemConfigLoader({
102
- extends: ["html-validate:recommended"],
103
- });
104
- const htmlvalidate = new core.HtmlValidate(loader);
105
- const report = htmlvalidate.validateStringSync(actual, actualFilename, config);
106
- const pass = report.valid;
107
- const result = report.results[0];
108
- if (pass) {
109
- return { pass, message: () => "HTML is valid when an error was expected" };
88
+ const defaultConfig = {
89
+ rules: {
90
+ /* jsdom normalizes style so disabling rule when using this matcher or it
91
+ * gets quite noisy when configured with self-closing */
92
+ "void-style": "off"
110
93
  }
111
- else {
112
- if (expectedError) {
113
- const actual = result.messages;
114
- const expected = expect.arrayContaining([expect.objectContaining(expectedError)]);
115
- const errorPass = this.equals(actual, expected);
116
- const diffString = diff
117
- ? diff(expected, actual, {
118
- expand: this.expand,
119
- aAnnotation: "Expected error",
120
- bAnnotation: "Actual error",
121
- })
122
- : /* istanbul ignore next */ undefined;
123
- const hint = this.utils.matcherHint(".not.toHTMLValidate", undefined, undefined, {
124
- comment: "expected error",
125
- });
126
- const expectedErrorMessage = () => [
127
- hint,
128
- "",
129
- "Expected error to be present:",
130
- this.utils.printExpected(expectedError),
131
- /* istanbul ignore next */ diffString ? `\n${diffString}` : "",
132
- ].join("\n");
133
- return { pass: !errorPass, message: expectedErrorMessage, actual, expected };
134
- }
135
- const errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);
136
- return {
137
- pass,
138
- message: () => ["Expected HTML to be valid but had the following errors:", ""].concat(errors).join("\n"),
139
- };
94
+ };
95
+ const config = core.deepmerge(defaultConfig, userConfig ?? {});
96
+ const actualFilename = filename ?? this.testPath ?? "inline";
97
+ const loader = new coreNodejs.FileSystemConfigLoader({
98
+ extends: ["html-validate:recommended"]
99
+ });
100
+ const htmlvalidate = new core.HtmlValidate(loader);
101
+ const report = htmlvalidate.validateStringSync(actual, actualFilename, config);
102
+ const pass = report.valid;
103
+ const result = report.results[0];
104
+ if (pass) {
105
+ return { pass, message: () => "HTML is valid when an error was expected" };
106
+ } else {
107
+ if (expectedError) {
108
+ const actual2 = result.messages;
109
+ const expected = expect.arrayContaining([expect.objectContaining(expectedError)]);
110
+ const errorPass = this.equals(actual2, expected);
111
+ const diffString = diff ? diff(expected, actual2, {
112
+ expand: this.expand,
113
+ aAnnotation: "Expected error",
114
+ bAnnotation: "Actual error"
115
+ }) : (
116
+ /* istanbul ignore next */
117
+ void 0
118
+ );
119
+ const hint = this.utils.matcherHint(".not.toHTMLValidate", void 0, void 0, {
120
+ comment: "expected error"
121
+ });
122
+ const expectedErrorMessage = () => [
123
+ hint,
124
+ "",
125
+ "Expected error to be present:",
126
+ this.utils.printExpected(expectedError),
127
+ /* istanbul ignore next */
128
+ diffString ? `
129
+ ${diffString}` : ""
130
+ ].join("\n");
131
+ return { pass: !errorPass, message: expectedErrorMessage, actual: actual2, expected };
140
132
  }
133
+ const errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);
134
+ return {
135
+ pass,
136
+ message: () => ["Expected HTML to be valid but had the following errors:", ""].concat(errors).join("\n")
137
+ };
138
+ }
141
139
  }
142
140
 
143
141
  function toHaveErrorImpl(context, expect, diff, actual, expected) {
144
- const flattened = matcherUtils.flattenMessages(actual);
145
- const matcher = [expect.objectContaining(expected)];
146
- const pass = context.equals(flattened, matcher);
147
- const diffString = diff
148
- ? diff(matcher, flattened, { expand: context.expand })
149
- : /* istanbul ignore next */ undefined;
150
- const hint = context.utils.matcherHint(".toHaveError");
151
- const prettyExpected = context.utils.printExpected(matcher);
152
- const prettyReceived = context.utils.printReceived(flattened);
153
- const resultMessage = () => {
154
- return [
155
- hint,
156
- "",
157
- "Expected error to equal:",
158
- ` ${prettyExpected}`,
159
- "Received:",
160
- ` ${prettyReceived}`,
161
- /* istanbul ignore next */ diffString ? `\nDifference:\n\n${diffString}` : "",
162
- ].join("\n");
163
- };
164
- return { pass, message: resultMessage, actual: flattened, expected: matcher };
142
+ const flattened = matcherUtils.flattenMessages(actual);
143
+ const matcher = [expect.objectContaining(expected)];
144
+ const pass = context.equals(flattened, matcher);
145
+ const diffString = diff ? diff(matcher, flattened, { expand: context.expand }) : (
146
+ /* istanbul ignore next */
147
+ void 0
148
+ );
149
+ const hint = context.utils.matcherHint(".toHaveError");
150
+ const prettyExpected = context.utils.printExpected(matcher);
151
+ const prettyReceived = context.utils.printReceived(flattened);
152
+ const resultMessage = () => {
153
+ return [
154
+ hint,
155
+ "",
156
+ "Expected error to equal:",
157
+ ` ${prettyExpected}`,
158
+ "Received:",
159
+ ` ${prettyReceived}`,
160
+ /* istanbul ignore next */
161
+ diffString ? `
162
+ Difference:
163
+
164
+ ${diffString}` : ""
165
+ ].join("\n");
166
+ };
167
+ return { pass, message: resultMessage, actual: flattened, expected: matcher };
165
168
  }
166
169
  function createMatcher$1(expect, diff) {
167
- function toHaveError(actual, arg1, arg2, arg3) {
168
- if (typeof arg1 === "string") {
169
- const expected = {
170
- ruleId: arg1,
171
- message: arg2,
172
- };
173
- if (arg3) {
174
- /* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- this is supposed to accept anything */
175
- expected.context = arg3;
176
- }
177
- return toHaveErrorImpl(this, expect, diff, actual, expected);
178
- }
179
- else {
180
- return toHaveErrorImpl(this, expect, diff, actual, arg1);
181
- }
170
+ function toHaveError(actual, arg1, arg2, arg3) {
171
+ if (typeof arg1 === "string") {
172
+ const expected = {
173
+ ruleId: arg1,
174
+ message: arg2
175
+ };
176
+ if (arg3) {
177
+ expected.context = arg3;
178
+ }
179
+ return toHaveErrorImpl(this, expect, diff, actual, expected);
180
+ } else {
181
+ return toHaveErrorImpl(this, expect, diff, actual, arg1);
182
182
  }
183
- return matcherUtils.diverge(toHaveError);
183
+ }
184
+ return matcherUtils.diverge(toHaveError);
184
185
  }
185
186
 
186
- /* eslint-disable prefer-template -- technical debt, should be refactored */
187
187
  function createMatcher(expect, diff) {
188
- function toHaveErrors(report, errors) {
189
- const flattened = matcherUtils.flattenMessages(report);
190
- const matcher = errors.map((entry) => {
191
- if (Array.isArray(entry)) {
192
- const [ruleId, message] = entry;
193
- return expect.objectContaining({ ruleId, message });
194
- }
195
- else {
196
- return expect.objectContaining(entry);
197
- }
198
- });
199
- const pass = this.equals(flattened, matcher);
200
- const diffString = diff
201
- ? diff(matcher, flattened, { expand: this.expand })
202
- : /* istanbul ignore next */ undefined;
203
- const resultMessage = () => this.utils.matcherHint(".toHaveErrors") +
204
- "\n\n" +
205
- "Expected error to equal:\n" +
206
- ` ${this.utils.printExpected(matcher)}\n` +
207
- "Received:\n" +
208
- ` ${this.utils.printReceived(flattened)}` +
209
- /* istanbul ignore next */ (diffString ? `\n\nDifference:\n\n${diffString}` : "");
210
- return { pass, message: resultMessage };
211
- }
212
- return matcherUtils.diverge(toHaveErrors);
188
+ function toHaveErrors(report, errors) {
189
+ const flattened = matcherUtils.flattenMessages(report);
190
+ const matcher = errors.map((entry) => {
191
+ if (Array.isArray(entry)) {
192
+ const [ruleId, message] = entry;
193
+ return expect.objectContaining({ ruleId, message });
194
+ } else {
195
+ return expect.objectContaining(entry);
196
+ }
197
+ });
198
+ const pass = this.equals(flattened, matcher);
199
+ const diffString = diff ? diff(matcher, flattened, { expand: this.expand }) : (
200
+ /* istanbul ignore next */
201
+ void 0
202
+ );
203
+ const resultMessage = () => this.utils.matcherHint(".toHaveErrors") + `
204
+
205
+ Expected error to equal:
206
+ ${this.utils.printExpected(matcher)}
207
+ Received:
208
+ ${this.utils.printReceived(flattened)}` + /* istanbul ignore next */
209
+ (diffString ? `
210
+
211
+ Difference:
212
+
213
+ ${diffString}` : "");
214
+ return { pass, message: resultMessage };
215
+ }
216
+ return matcherUtils.diverge(toHaveErrors);
213
217
  }
214
218
 
215
- /**
216
- * @internal
217
- */
218
219
  function getResults(filename, value) {
219
- if (typeof value === "string") {
220
- const loader = new coreNodejs.FileSystemConfigLoader({
221
- extends: ["html-validate:recommended"],
222
- });
223
- const htmlvalidate = new core.HtmlValidate(loader);
224
- const report = htmlvalidate.validateStringSync(value, filename, {
225
- rules: {
226
- "void-style": "off",
227
- },
228
- });
229
- return report.results.map((it) => {
230
- return { ...it, filePath: "inline" };
231
- });
232
- }
233
- else {
234
- return value.results;
235
- }
220
+ if (typeof value === "string") {
221
+ const loader = new coreNodejs.FileSystemConfigLoader({
222
+ extends: ["html-validate:recommended"]
223
+ });
224
+ const htmlvalidate = new core.HtmlValidate(loader);
225
+ const report = htmlvalidate.validateStringSync(value, filename, {
226
+ rules: {
227
+ "void-style": "off"
228
+ }
229
+ });
230
+ return report.results.map((it) => {
231
+ return { ...it, filePath: "inline" };
232
+ });
233
+ } else {
234
+ return value.results;
235
+ }
236
236
  }
237
237
 
238
238
  exports.createMatcher = createMatcher$4;