@fkui/test-utils 5.36.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.
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2021 Försäkringskassan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # fkui/test-utils
2
+
3
+ Biblioteket innehåller en samling med funktioner och komponenter till Jest och Cypress för att underlätta utveckling av automatiska testfall.
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/jest.ts
21
+ var jest_exports = {};
22
+ __export(jest_exports, {
23
+ createPlaceholderInDocument: () => createPlaceholderInDocument,
24
+ generateSelector: () => generateSelector
25
+ });
26
+ module.exports = __toCommonJS(jest_exports);
27
+
28
+ // src/utils/generate-selector.ts
29
+ function canUseID(element) {
30
+ if (!element.isConnected) {
31
+ return false;
32
+ }
33
+ if (!element.id) {
34
+ return false;
35
+ }
36
+ const hits = document.querySelectorAll(`#${element.id}`);
37
+ return hits.length === 1;
38
+ }
39
+ function stringifyNode(element) {
40
+ if (canUseID(element)) {
41
+ return [`#${element.id}`, true];
42
+ }
43
+ const tagName = element.tagName.toLowerCase();
44
+ const classes = Array.from(element.classList.values()).map((it) => `.${it}`).join("");
45
+ return [`${tagName}${classes}`, false];
46
+ }
47
+ function generateSelector(element) {
48
+ if (!element) {
49
+ return "<null>";
50
+ }
51
+ const [text, final] = stringifyNode(element);
52
+ if (final) {
53
+ return text;
54
+ }
55
+ const ancestry = [text];
56
+ let cur = element;
57
+ while (cur.parentElement) {
58
+ const parent = cur.parentElement;
59
+ const [text2, final2] = stringifyNode(parent);
60
+ ancestry.push(text2);
61
+ if (final2) {
62
+ break;
63
+ }
64
+ cur = parent;
65
+ }
66
+ return ancestry.reverse().join(" > ");
67
+ }
68
+
69
+ // src/utils/create-placeholder-in-document.ts
70
+ function createPlaceholderInDocument() {
71
+ const elem = document.createElement("div");
72
+ if (document.body) {
73
+ document.body.appendChild(elem);
74
+ }
75
+ return elem;
76
+ }
77
+
78
+ // src/matchers/to-have-focus.ts
79
+ function toHaveFocus(element) {
80
+ if (!(element instanceof Element)) {
81
+ throw new TypeError(
82
+ `Expected value must be Element instance but got "${typeof element}" instead`
83
+ );
84
+ }
85
+ const { matcherHint, printExpected, printReceived } = this.utils;
86
+ const currentFocus = document.activeElement;
87
+ const isFocused = element.isSameNode(currentFocus);
88
+ if (isFocused) {
89
+ return {
90
+ pass: true,
91
+ message: () => "Expected element not to have focus"
92
+ };
93
+ } else {
94
+ return {
95
+ pass: false,
96
+ message() {
97
+ const expected = generateSelector(element);
98
+ const actual = generateSelector(currentFocus);
99
+ const another = currentFocus ? "another" : "no";
100
+ return [
101
+ matcherHint(".toHaveFocus"),
102
+ "",
103
+ `Expected element to have focus but ${another} element was focused`,
104
+ "",
105
+ "Expected:",
106
+ ` ${printExpected(expected)}`,
107
+ "Received:",
108
+ ` ${printReceived(actual)}`
109
+ ].join("\n");
110
+ }
111
+ };
112
+ }
113
+ }
114
+
115
+ // src/matchers/index.ts
116
+ expect.extend({
117
+ toHaveFocus
118
+ });
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ createPlaceholderInDocument,
122
+ generateSelector
123
+ });
124
+ //# sourceMappingURL=jest.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/jest.ts", "../../src/utils/generate-selector.ts", "../../src/utils/create-placeholder-in-document.ts", "../../src/matchers/to-have-focus.ts", "../../src/matchers/index.ts"],
4
+ "sourcesContent": ["/* imported for side-effects only */\nimport \"./matchers\";\n\nexport * from \"./lib\";\n", "function canUseID(element: Element): boolean {\n if (!element.isConnected) {\n return false;\n }\n if (!element.id) {\n return false;\n }\n const hits = document.querySelectorAll(`#${element.id}`);\n return hits.length === 1;\n}\n\nfunction stringifyNode(element: Element): [text: string, final: boolean] {\n if (canUseID(element)) {\n return [`#${element.id}`, true];\n }\n\n const tagName = element.tagName.toLowerCase();\n const classes = Array.from(element.classList.values())\n .map((it) => `.${it}`)\n .join(\"\");\n return [`${tagName}${classes}`, false];\n}\n\n/**\n * Generate a selector for given element.\n *\n * @public\n * @param element - Element to generate selector for.\n * @returns DOM selector\n */\nexport function generateSelector(element: Element | null): string {\n if (!element) {\n return \"<null>\";\n }\n\n const [text, final] = stringifyNode(element);\n\n /* if the element itself is the final node needed for the selector just\n * return it right away */\n if (final) {\n return text;\n }\n\n const ancestry: string[] = [text];\n let cur = element;\n while (cur.parentElement) {\n const parent = cur.parentElement;\n const [text, final] = stringifyNode(parent);\n ancestry.push(text);\n if (final) {\n break;\n }\n cur = parent;\n }\n\n return ancestry.reverse().join(\" > \");\n}\n", "/**\n * Creates a placeholder element as a child under `<body>`.\n * The element should be cleaned by the caller.\n *\n * @example\n *\n * In Vue.js tests this can be used with `attachTo` when the component must be\n * present in the document (e.g. dealing with focus).\n *\n * ```ts\n * shallowMount(MyComponent, {\n * attachTo: createPlaceholderInDocument(),\n * });\n * ```\n *\n * @public\n */\nexport function createPlaceholderInDocument(): HTMLElement {\n const elem = document.createElement(\"div\");\n if (document.body) {\n document.body.appendChild(elem);\n }\n return elem;\n}\n", "import { generateSelector } from \"../utils\";\n\nexport function toHaveFocus(\n this: jest.MatcherUtils,\n element: Element,\n): jest.CustomMatcherResult {\n if (!(element instanceof Element)) {\n throw new TypeError(\n `Expected value must be Element instance but got \"${typeof element}\" instead`,\n );\n }\n\n const { matcherHint, printExpected, printReceived } = this.utils;\n const currentFocus = document.activeElement;\n const isFocused = element.isSameNode(currentFocus);\n if (isFocused) {\n return {\n pass: true,\n message: () => \"Expected element not to have focus\",\n };\n } else {\n return {\n pass: false,\n message(): string {\n const expected = generateSelector(element);\n const actual = generateSelector(currentFocus);\n const another = currentFocus ? \"another\" : \"no\";\n return [\n matcherHint(\".toHaveFocus\"),\n \"\",\n `Expected element to have focus but ${another} element was focused`,\n \"\",\n \"Expected:\",\n ` ${printExpected(expected)}`,\n \"Received:\",\n ` ${printReceived(actual)}`,\n ].join(\"\\n\");\n },\n };\n }\n}\n", "import { toHaveFocus } from \"./to-have-focus\";\n\nexpect.extend({\n toHaveFocus,\n});\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,SAAS,SAAS,SAA2B;AACzC,MAAI,CAAC,QAAQ,aAAa;AACtB,WAAO;AAAA,EACX;AACA,MAAI,CAAC,QAAQ,IAAI;AACb,WAAO;AAAA,EACX;AACA,QAAM,OAAO,SAAS,iBAAiB,IAAI,QAAQ,EAAE,EAAE;AACvD,SAAO,KAAK,WAAW;AAC3B;AAEA,SAAS,cAAc,SAAkD;AACrE,MAAI,SAAS,OAAO,GAAG;AACnB,WAAO,CAAC,IAAI,QAAQ,EAAE,IAAI,IAAI;AAAA,EAClC;AAEA,QAAM,UAAU,QAAQ,QAAQ,YAAY;AAC5C,QAAM,UAAU,MAAM,KAAK,QAAQ,UAAU,OAAO,CAAC,EAChD,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,EACpB,KAAK,EAAE;AACZ,SAAO,CAAC,GAAG,OAAO,GAAG,OAAO,IAAI,KAAK;AACzC;AASO,SAAS,iBAAiB,SAAiC;AAC9D,MAAI,CAAC,SAAS;AACV,WAAO;AAAA,EACX;AAEA,QAAM,CAAC,MAAM,KAAK,IAAI,cAAc,OAAO;AAI3C,MAAI,OAAO;AACP,WAAO;AAAA,EACX;AAEA,QAAM,WAAqB,CAAC,IAAI;AAChC,MAAI,MAAM;AACV,SAAO,IAAI,eAAe;AACtB,UAAM,SAAS,IAAI;AACnB,UAAM,CAACA,OAAMC,MAAK,IAAI,cAAc,MAAM;AAC1C,aAAS,KAAKD,KAAI;AAClB,QAAIC,QAAO;AACP;AAAA,IACJ;AACA,UAAM;AAAA,EACV;AAEA,SAAO,SAAS,QAAQ,EAAE,KAAK,KAAK;AACxC;;;ACvCO,SAAS,8BAA2C;AACvD,QAAM,OAAO,SAAS,cAAc,KAAK;AACzC,MAAI,SAAS,MAAM;AACf,aAAS,KAAK,YAAY,IAAI;AAAA,EAClC;AACA,SAAO;AACX;;;ACrBO,SAAS,YAEZ,SACwB;AACxB,MAAI,EAAE,mBAAmB,UAAU;AAC/B,UAAM,IAAI;AAAA,MACN,oDAAoD,OAAO,OAAO;AAAA,IACtE;AAAA,EACJ;AAEA,QAAM,EAAE,aAAa,eAAe,cAAc,IAAI,KAAK;AAC3D,QAAM,eAAe,SAAS;AAC9B,QAAM,YAAY,QAAQ,WAAW,YAAY;AACjD,MAAI,WAAW;AACX,WAAO;AAAA,MACH,MAAM;AAAA,MACN,SAAS,MAAM;AAAA,IACnB;AAAA,EACJ,OAAO;AACH,WAAO;AAAA,MACH,MAAM;AAAA,MACN,UAAkB;AACd,cAAM,WAAW,iBAAiB,OAAO;AACzC,cAAM,SAAS,iBAAiB,YAAY;AAC5C,cAAM,UAAU,eAAe,YAAY;AAC3C,eAAO;AAAA,UACH,YAAY,cAAc;AAAA,UAC1B;AAAA,UACA,sCAAsC,OAAO;AAAA,UAC7C;AAAA,UACA;AAAA,UACA,KAAK,cAAc,QAAQ,CAAC;AAAA,UAC5B;AAAA,UACA,KAAK,cAAc,MAAM,CAAC;AAAA,QAC9B,EAAE,KAAK,IAAI;AAAA,MACf;AAAA,IACJ;AAAA,EACJ;AACJ;;;ACtCA,OAAO,OAAO;AAAA,EACV;AACJ,CAAC;",
6
+ "names": ["text", "final"]
7
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib.ts
21
+ var lib_exports = {};
22
+ __export(lib_exports, {
23
+ createPlaceholderInDocument: () => createPlaceholderInDocument,
24
+ generateSelector: () => generateSelector
25
+ });
26
+ module.exports = __toCommonJS(lib_exports);
27
+
28
+ // src/utils/generate-selector.ts
29
+ function canUseID(element) {
30
+ if (!element.isConnected) {
31
+ return false;
32
+ }
33
+ if (!element.id) {
34
+ return false;
35
+ }
36
+ const hits = document.querySelectorAll(`#${element.id}`);
37
+ return hits.length === 1;
38
+ }
39
+ function stringifyNode(element) {
40
+ if (canUseID(element)) {
41
+ return [`#${element.id}`, true];
42
+ }
43
+ const tagName = element.tagName.toLowerCase();
44
+ const classes = Array.from(element.classList.values()).map((it) => `.${it}`).join("");
45
+ return [`${tagName}${classes}`, false];
46
+ }
47
+ function generateSelector(element) {
48
+ if (!element) {
49
+ return "<null>";
50
+ }
51
+ const [text, final] = stringifyNode(element);
52
+ if (final) {
53
+ return text;
54
+ }
55
+ const ancestry = [text];
56
+ let cur = element;
57
+ while (cur.parentElement) {
58
+ const parent = cur.parentElement;
59
+ const [text2, final2] = stringifyNode(parent);
60
+ ancestry.push(text2);
61
+ if (final2) {
62
+ break;
63
+ }
64
+ cur = parent;
65
+ }
66
+ return ancestry.reverse().join(" > ");
67
+ }
68
+
69
+ // src/utils/create-placeholder-in-document.ts
70
+ function createPlaceholderInDocument() {
71
+ const elem = document.createElement("div");
72
+ if (document.body) {
73
+ document.body.appendChild(elem);
74
+ }
75
+ return elem;
76
+ }
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ createPlaceholderInDocument,
80
+ generateSelector
81
+ });
82
+ //# sourceMappingURL=lib.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib.ts", "../../src/utils/generate-selector.ts", "../../src/utils/create-placeholder-in-document.ts"],
4
+ "sourcesContent": ["export * from \"./utils\";\n", "function canUseID(element: Element): boolean {\n if (!element.isConnected) {\n return false;\n }\n if (!element.id) {\n return false;\n }\n const hits = document.querySelectorAll(`#${element.id}`);\n return hits.length === 1;\n}\n\nfunction stringifyNode(element: Element): [text: string, final: boolean] {\n if (canUseID(element)) {\n return [`#${element.id}`, true];\n }\n\n const tagName = element.tagName.toLowerCase();\n const classes = Array.from(element.classList.values())\n .map((it) => `.${it}`)\n .join(\"\");\n return [`${tagName}${classes}`, false];\n}\n\n/**\n * Generate a selector for given element.\n *\n * @public\n * @param element - Element to generate selector for.\n * @returns DOM selector\n */\nexport function generateSelector(element: Element | null): string {\n if (!element) {\n return \"<null>\";\n }\n\n const [text, final] = stringifyNode(element);\n\n /* if the element itself is the final node needed for the selector just\n * return it right away */\n if (final) {\n return text;\n }\n\n const ancestry: string[] = [text];\n let cur = element;\n while (cur.parentElement) {\n const parent = cur.parentElement;\n const [text, final] = stringifyNode(parent);\n ancestry.push(text);\n if (final) {\n break;\n }\n cur = parent;\n }\n\n return ancestry.reverse().join(\" > \");\n}\n", "/**\n * Creates a placeholder element as a child under `<body>`.\n * The element should be cleaned by the caller.\n *\n * @example\n *\n * In Vue.js tests this can be used with `attachTo` when the component must be\n * present in the document (e.g. dealing with focus).\n *\n * ```ts\n * shallowMount(MyComponent, {\n * attachTo: createPlaceholderInDocument(),\n * });\n * ```\n *\n * @public\n */\nexport function createPlaceholderInDocument(): HTMLElement {\n const elem = document.createElement(\"div\");\n if (document.body) {\n document.body.appendChild(elem);\n }\n return elem;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,SAAS,SAAS,SAA2B;AACzC,MAAI,CAAC,QAAQ,aAAa;AACtB,WAAO;AAAA,EACX;AACA,MAAI,CAAC,QAAQ,IAAI;AACb,WAAO;AAAA,EACX;AACA,QAAM,OAAO,SAAS,iBAAiB,IAAI,QAAQ,EAAE,EAAE;AACvD,SAAO,KAAK,WAAW;AAC3B;AAEA,SAAS,cAAc,SAAkD;AACrE,MAAI,SAAS,OAAO,GAAG;AACnB,WAAO,CAAC,IAAI,QAAQ,EAAE,IAAI,IAAI;AAAA,EAClC;AAEA,QAAM,UAAU,QAAQ,QAAQ,YAAY;AAC5C,QAAM,UAAU,MAAM,KAAK,QAAQ,UAAU,OAAO,CAAC,EAChD,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,EACpB,KAAK,EAAE;AACZ,SAAO,CAAC,GAAG,OAAO,GAAG,OAAO,IAAI,KAAK;AACzC;AASO,SAAS,iBAAiB,SAAiC;AAC9D,MAAI,CAAC,SAAS;AACV,WAAO;AAAA,EACX;AAEA,QAAM,CAAC,MAAM,KAAK,IAAI,cAAc,OAAO;AAI3C,MAAI,OAAO;AACP,WAAO;AAAA,EACX;AAEA,QAAM,WAAqB,CAAC,IAAI;AAChC,MAAI,MAAM;AACV,SAAO,IAAI,eAAe;AACtB,UAAM,SAAS,IAAI;AACnB,UAAM,CAACA,OAAMC,MAAK,IAAI,cAAc,MAAM;AAC1C,aAAS,KAAKD,KAAI;AAClB,QAAIC,QAAO;AACP;AAAA,IACJ;AACA,UAAM;AAAA,EACV;AAEA,SAAO,SAAS,QAAQ,EAAE,KAAK,KAAK;AACxC;;;ACvCO,SAAS,8BAA2C;AACvD,QAAM,OAAO,SAAS,cAAc,KAAK;AACzC,MAAI,SAAS,MAAM;AACf,aAAS,KAAK,YAAY,IAAI;AAAA,EAClC;AACA,SAAO;AACX;",
6
+ "names": ["text", "final"]
7
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/vue/index.ts
21
+ var vue_exports = {};
22
+ __export(vue_exports, {
23
+ DensityWrapper: () => DensityWrapper,
24
+ SizeWrapper: () => SizeWrapper,
25
+ createPlaceholderInDocument: () => createPlaceholderInDocument,
26
+ densityWrapperHeight: () => densityWrapperHeight,
27
+ densityWrapperWidth: () => densityWrapperWidth,
28
+ generateSelector: () => generateSelector,
29
+ sizeWrapperHeight: () => sizeWrapperHeight,
30
+ sizeWrapperWidth: () => sizeWrapperWidth
31
+ });
32
+ module.exports = __toCommonJS(vue_exports);
33
+
34
+ // src/utils/generate-selector.ts
35
+ function canUseID(element) {
36
+ if (!element.isConnected) {
37
+ return false;
38
+ }
39
+ if (!element.id) {
40
+ return false;
41
+ }
42
+ const hits = document.querySelectorAll(`#${element.id}`);
43
+ return hits.length === 1;
44
+ }
45
+ function stringifyNode(element) {
46
+ if (canUseID(element)) {
47
+ return [`#${element.id}`, true];
48
+ }
49
+ const tagName = element.tagName.toLowerCase();
50
+ const classes = Array.from(element.classList.values()).map((it) => `.${it}`).join("");
51
+ return [`${tagName}${classes}`, false];
52
+ }
53
+ function generateSelector(element) {
54
+ if (!element) {
55
+ return "<null>";
56
+ }
57
+ const [text, final] = stringifyNode(element);
58
+ if (final) {
59
+ return text;
60
+ }
61
+ const ancestry = [text];
62
+ let cur = element;
63
+ while (cur.parentElement) {
64
+ const parent = cur.parentElement;
65
+ const [text2, final2] = stringifyNode(parent);
66
+ ancestry.push(text2);
67
+ if (final2) {
68
+ break;
69
+ }
70
+ cur = parent;
71
+ }
72
+ return ancestry.reverse().join(" > ");
73
+ }
74
+
75
+ // src/utils/create-placeholder-in-document.ts
76
+ function createPlaceholderInDocument() {
77
+ const elem = document.createElement("div");
78
+ if (document.body) {
79
+ document.body.appendChild(elem);
80
+ }
81
+ return elem;
82
+ }
83
+
84
+ // src/vue/size-wrapper.ts
85
+ var import_vue = require("vue");
86
+ var aspectRatio = 16 / 9;
87
+ var cypressPadding = 8;
88
+ var variants = [
89
+ { name: "min", size: "320px" },
90
+ { name: "mobile", size: "639px" },
91
+ { name: "desktop-low", size: "640px" },
92
+ { name: "desktop-normal", size: "1024px" }
93
+ ];
94
+ var sizeWrapperWidth = 1024 + cypressPadding;
95
+ var sizeWrapperHeight = sizeWrapperWidth / aspectRatio;
96
+ var SizeWrapper = (0, import_vue.defineComponent)({
97
+ name: "SizeWrapper",
98
+ render() {
99
+ const children = variants.map((it) => {
100
+ const data = {
101
+ style: {
102
+ border: "1px dashed hotpink",
103
+ width: it.size
104
+ },
105
+ "data-variant": it.name
106
+ };
107
+ const slot = this.$slots.default ?? (() => "");
108
+ const content = slot({
109
+ variant: it.name
110
+ });
111
+ return (0, import_vue.h)("div", data, [(0, import_vue.h)("span", it.size), content]);
112
+ });
113
+ return (0, import_vue.h)("div", children);
114
+ }
115
+ });
116
+
117
+ // src/vue/density-wrapper.ts
118
+ var import_vue2 = require("vue");
119
+ var aspectRatio2 = 16 / 9;
120
+ var cypressPadding2 = 8;
121
+ var densities = [
122
+ {
123
+ name: "Default",
124
+ class: "density-default"
125
+ },
126
+ {
127
+ name: "Dense",
128
+ class: "density-dense"
129
+ },
130
+ {
131
+ name: "Densest",
132
+ class: "density-densest"
133
+ }
134
+ ];
135
+ var densityWrapperWidth = 640 + cypressPadding2;
136
+ var densityWrapperHeight = 640 / aspectRatio2;
137
+ var DensityWrapper = (0, import_vue2.defineComponent)({
138
+ name: "DensityWrapper",
139
+ render() {
140
+ const children = densities.map((it) => {
141
+ const data = {
142
+ class: it.class,
143
+ style: {
144
+ border: "1px dashed hotpink",
145
+ width: "640px"
146
+ }
147
+ };
148
+ const slot = this.$slots.default ?? (() => "");
149
+ const content = slot({
150
+ density: it.name
151
+ });
152
+ return (0, import_vue2.h)("div", data, [content]);
153
+ });
154
+ return (0, import_vue2.h)("div", children);
155
+ }
156
+ });
157
+ // Annotate the CommonJS export names for ESM import in node:
158
+ 0 && (module.exports = {
159
+ DensityWrapper,
160
+ SizeWrapper,
161
+ createPlaceholderInDocument,
162
+ densityWrapperHeight,
163
+ densityWrapperWidth,
164
+ generateSelector,
165
+ sizeWrapperHeight,
166
+ sizeWrapperWidth
167
+ });
168
+ //# sourceMappingURL=vue.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/vue/index.ts", "../../src/utils/generate-selector.ts", "../../src/utils/create-placeholder-in-document.ts", "../../src/vue/size-wrapper.ts", "../../src/vue/density-wrapper.ts"],
4
+ "sourcesContent": ["export * from \"../lib\";\nexport {\n SizeWrapper,\n sizeWrapperWidth,\n sizeWrapperHeight,\n} from \"./size-wrapper\";\nexport {\n DensityWrapper,\n densityWrapperWidth,\n densityWrapperHeight,\n} from \"./density-wrapper\";\n", "function canUseID(element: Element): boolean {\n if (!element.isConnected) {\n return false;\n }\n if (!element.id) {\n return false;\n }\n const hits = document.querySelectorAll(`#${element.id}`);\n return hits.length === 1;\n}\n\nfunction stringifyNode(element: Element): [text: string, final: boolean] {\n if (canUseID(element)) {\n return [`#${element.id}`, true];\n }\n\n const tagName = element.tagName.toLowerCase();\n const classes = Array.from(element.classList.values())\n .map((it) => `.${it}`)\n .join(\"\");\n return [`${tagName}${classes}`, false];\n}\n\n/**\n * Generate a selector for given element.\n *\n * @public\n * @param element - Element to generate selector for.\n * @returns DOM selector\n */\nexport function generateSelector(element: Element | null): string {\n if (!element) {\n return \"<null>\";\n }\n\n const [text, final] = stringifyNode(element);\n\n /* if the element itself is the final node needed for the selector just\n * return it right away */\n if (final) {\n return text;\n }\n\n const ancestry: string[] = [text];\n let cur = element;\n while (cur.parentElement) {\n const parent = cur.parentElement;\n const [text, final] = stringifyNode(parent);\n ancestry.push(text);\n if (final) {\n break;\n }\n cur = parent;\n }\n\n return ancestry.reverse().join(\" > \");\n}\n", "/**\n * Creates a placeholder element as a child under `<body>`.\n * The element should be cleaned by the caller.\n *\n * @example\n *\n * In Vue.js tests this can be used with `attachTo` when the component must be\n * present in the document (e.g. dealing with focus).\n *\n * ```ts\n * shallowMount(MyComponent, {\n * attachTo: createPlaceholderInDocument(),\n * });\n * ```\n *\n * @public\n */\nexport function createPlaceholderInDocument(): HTMLElement {\n const elem = document.createElement(\"div\");\n if (document.body) {\n document.body.appendChild(elem);\n }\n return elem;\n}\n", "import { defineComponent, h } from \"vue\";\n\nconst aspectRatio = 16 / 9;\nconst cypressPadding = 8;\n\nconst variants = [\n { name: \"min\", size: \"320px\" },\n { name: \"mobile\", size: \"639px\" },\n { name: \"desktop-low\", size: \"640px\" },\n { name: \"desktop-normal\", size: \"1024px\" },\n];\n\n/**\n * Width of SizeWrapper component including padding added by cypress during tests.\n *\n * @public\n */\nexport const sizeWrapperWidth = 1024 + cypressPadding;\n\n/**\n * Height for SizeWrapper component with an aspect ratio of 16:9 based on its width.\n *\n * @public\n */\nexport const sizeWrapperHeight = sizeWrapperWidth / aspectRatio;\n\n/**\n * @public\n */\nexport const SizeWrapper = defineComponent({\n name: \"SizeWrapper\",\n render() {\n const children = variants.map((it) => {\n const data = {\n style: {\n border: \"1px dashed hotpink\",\n width: it.size,\n },\n \"data-variant\": it.name,\n };\n const slot = this.$slots.default ?? (() => \"\");\n const content = slot({\n variant: it.name,\n });\n return h(\"div\", data, [h(\"span\", it.size), content]);\n });\n return h(\"div\", children);\n },\n});\n", "import { defineComponent, h } from \"vue\";\n\nconst aspectRatio = 16 / 9;\nconst cypressPadding = 8;\n\nconst densities = [\n {\n name: \"Default\",\n class: \"density-default\",\n },\n {\n name: \"Dense\",\n class: \"density-dense\",\n },\n {\n name: \"Densest\",\n class: \"density-densest\",\n },\n];\n\n/**\n * Width of DensityWrapper component including padding added by cypress during tests.\n *\n * @public\n */\nexport const densityWrapperWidth = 640 + cypressPadding;\n\n/**\n * Height for DensityWrapper component with an aspect ratio of 16:9 based on its width.\n *\n * @public\n */\nexport const densityWrapperHeight = 640 / aspectRatio;\n\n/**\n * @public\n */\nexport const DensityWrapper = defineComponent({\n name: \"DensityWrapper\",\n render() {\n const children = densities.map((it) => {\n const data = {\n class: it.class,\n style: {\n border: \"1px dashed hotpink\",\n width: \"640px\",\n },\n };\n const slot = this.$slots.default ?? (() => \"\");\n const content = slot({\n density: it.name,\n });\n return h(\"div\", data, [content]);\n });\n return h(\"div\", children);\n },\n});\n"],
5
+ "mappings": "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",
6
+ "names": ["text", "final", "import_vue", "aspectRatio", "cypressPadding"]
7
+ }
@@ -0,0 +1,96 @@
1
+ // src/utils/generate-selector.ts
2
+ function canUseID(element) {
3
+ if (!element.isConnected) {
4
+ return false;
5
+ }
6
+ if (!element.id) {
7
+ return false;
8
+ }
9
+ const hits = document.querySelectorAll(`#${element.id}`);
10
+ return hits.length === 1;
11
+ }
12
+ function stringifyNode(element) {
13
+ if (canUseID(element)) {
14
+ return [`#${element.id}`, true];
15
+ }
16
+ const tagName = element.tagName.toLowerCase();
17
+ const classes = Array.from(element.classList.values()).map((it) => `.${it}`).join("");
18
+ return [`${tagName}${classes}`, false];
19
+ }
20
+ function generateSelector(element) {
21
+ if (!element) {
22
+ return "<null>";
23
+ }
24
+ const [text, final] = stringifyNode(element);
25
+ if (final) {
26
+ return text;
27
+ }
28
+ const ancestry = [text];
29
+ let cur = element;
30
+ while (cur.parentElement) {
31
+ const parent = cur.parentElement;
32
+ const [text2, final2] = stringifyNode(parent);
33
+ ancestry.push(text2);
34
+ if (final2) {
35
+ break;
36
+ }
37
+ cur = parent;
38
+ }
39
+ return ancestry.reverse().join(" > ");
40
+ }
41
+
42
+ // src/utils/create-placeholder-in-document.ts
43
+ function createPlaceholderInDocument() {
44
+ const elem = document.createElement("div");
45
+ if (document.body) {
46
+ document.body.appendChild(elem);
47
+ }
48
+ return elem;
49
+ }
50
+
51
+ // src/matchers/to-have-focus.ts
52
+ function toHaveFocus(element) {
53
+ if (!(element instanceof Element)) {
54
+ throw new TypeError(
55
+ `Expected value must be Element instance but got "${typeof element}" instead`
56
+ );
57
+ }
58
+ const { matcherHint, printExpected, printReceived } = this.utils;
59
+ const currentFocus = document.activeElement;
60
+ const isFocused = element.isSameNode(currentFocus);
61
+ if (isFocused) {
62
+ return {
63
+ pass: true,
64
+ message: () => "Expected element not to have focus"
65
+ };
66
+ } else {
67
+ return {
68
+ pass: false,
69
+ message() {
70
+ const expected = generateSelector(element);
71
+ const actual = generateSelector(currentFocus);
72
+ const another = currentFocus ? "another" : "no";
73
+ return [
74
+ matcherHint(".toHaveFocus"),
75
+ "",
76
+ `Expected element to have focus but ${another} element was focused`,
77
+ "",
78
+ "Expected:",
79
+ ` ${printExpected(expected)}`,
80
+ "Received:",
81
+ ` ${printReceived(actual)}`
82
+ ].join("\n");
83
+ }
84
+ };
85
+ }
86
+ }
87
+
88
+ // src/matchers/index.ts
89
+ expect.extend({
90
+ toHaveFocus
91
+ });
92
+ export {
93
+ createPlaceholderInDocument,
94
+ generateSelector
95
+ };
96
+ //# sourceMappingURL=jest.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/generate-selector.ts", "../../src/utils/create-placeholder-in-document.ts", "../../src/matchers/to-have-focus.ts", "../../src/matchers/index.ts"],
4
+ "sourcesContent": ["function canUseID(element: Element): boolean {\n if (!element.isConnected) {\n return false;\n }\n if (!element.id) {\n return false;\n }\n const hits = document.querySelectorAll(`#${element.id}`);\n return hits.length === 1;\n}\n\nfunction stringifyNode(element: Element): [text: string, final: boolean] {\n if (canUseID(element)) {\n return [`#${element.id}`, true];\n }\n\n const tagName = element.tagName.toLowerCase();\n const classes = Array.from(element.classList.values())\n .map((it) => `.${it}`)\n .join(\"\");\n return [`${tagName}${classes}`, false];\n}\n\n/**\n * Generate a selector for given element.\n *\n * @public\n * @param element - Element to generate selector for.\n * @returns DOM selector\n */\nexport function generateSelector(element: Element | null): string {\n if (!element) {\n return \"<null>\";\n }\n\n const [text, final] = stringifyNode(element);\n\n /* if the element itself is the final node needed for the selector just\n * return it right away */\n if (final) {\n return text;\n }\n\n const ancestry: string[] = [text];\n let cur = element;\n while (cur.parentElement) {\n const parent = cur.parentElement;\n const [text, final] = stringifyNode(parent);\n ancestry.push(text);\n if (final) {\n break;\n }\n cur = parent;\n }\n\n return ancestry.reverse().join(\" > \");\n}\n", "/**\n * Creates a placeholder element as a child under `<body>`.\n * The element should be cleaned by the caller.\n *\n * @example\n *\n * In Vue.js tests this can be used with `attachTo` when the component must be\n * present in the document (e.g. dealing with focus).\n *\n * ```ts\n * shallowMount(MyComponent, {\n * attachTo: createPlaceholderInDocument(),\n * });\n * ```\n *\n * @public\n */\nexport function createPlaceholderInDocument(): HTMLElement {\n const elem = document.createElement(\"div\");\n if (document.body) {\n document.body.appendChild(elem);\n }\n return elem;\n}\n", "import { generateSelector } from \"../utils\";\n\nexport function toHaveFocus(\n this: jest.MatcherUtils,\n element: Element,\n): jest.CustomMatcherResult {\n if (!(element instanceof Element)) {\n throw new TypeError(\n `Expected value must be Element instance but got \"${typeof element}\" instead`,\n );\n }\n\n const { matcherHint, printExpected, printReceived } = this.utils;\n const currentFocus = document.activeElement;\n const isFocused = element.isSameNode(currentFocus);\n if (isFocused) {\n return {\n pass: true,\n message: () => \"Expected element not to have focus\",\n };\n } else {\n return {\n pass: false,\n message(): string {\n const expected = generateSelector(element);\n const actual = generateSelector(currentFocus);\n const another = currentFocus ? \"another\" : \"no\";\n return [\n matcherHint(\".toHaveFocus\"),\n \"\",\n `Expected element to have focus but ${another} element was focused`,\n \"\",\n \"Expected:\",\n ` ${printExpected(expected)}`,\n \"Received:\",\n ` ${printReceived(actual)}`,\n ].join(\"\\n\");\n },\n };\n }\n}\n", "import { toHaveFocus } from \"./to-have-focus\";\n\nexpect.extend({\n toHaveFocus,\n});\n"],
5
+ "mappings": ";AAAA,SAAS,SAAS,SAA2B;AACzC,MAAI,CAAC,QAAQ,aAAa;AACtB,WAAO;AAAA,EACX;AACA,MAAI,CAAC,QAAQ,IAAI;AACb,WAAO;AAAA,EACX;AACA,QAAM,OAAO,SAAS,iBAAiB,IAAI,QAAQ,EAAE,EAAE;AACvD,SAAO,KAAK,WAAW;AAC3B;AAEA,SAAS,cAAc,SAAkD;AACrE,MAAI,SAAS,OAAO,GAAG;AACnB,WAAO,CAAC,IAAI,QAAQ,EAAE,IAAI,IAAI;AAAA,EAClC;AAEA,QAAM,UAAU,QAAQ,QAAQ,YAAY;AAC5C,QAAM,UAAU,MAAM,KAAK,QAAQ,UAAU,OAAO,CAAC,EAChD,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,EACpB,KAAK,EAAE;AACZ,SAAO,CAAC,GAAG,OAAO,GAAG,OAAO,IAAI,KAAK;AACzC;AASO,SAAS,iBAAiB,SAAiC;AAC9D,MAAI,CAAC,SAAS;AACV,WAAO;AAAA,EACX;AAEA,QAAM,CAAC,MAAM,KAAK,IAAI,cAAc,OAAO;AAI3C,MAAI,OAAO;AACP,WAAO;AAAA,EACX;AAEA,QAAM,WAAqB,CAAC,IAAI;AAChC,MAAI,MAAM;AACV,SAAO,IAAI,eAAe;AACtB,UAAM,SAAS,IAAI;AACnB,UAAM,CAACA,OAAMC,MAAK,IAAI,cAAc,MAAM;AAC1C,aAAS,KAAKD,KAAI;AAClB,QAAIC,QAAO;AACP;AAAA,IACJ;AACA,UAAM;AAAA,EACV;AAEA,SAAO,SAAS,QAAQ,EAAE,KAAK,KAAK;AACxC;;;ACvCO,SAAS,8BAA2C;AACvD,QAAM,OAAO,SAAS,cAAc,KAAK;AACzC,MAAI,SAAS,MAAM;AACf,aAAS,KAAK,YAAY,IAAI;AAAA,EAClC;AACA,SAAO;AACX;;;ACrBO,SAAS,YAEZ,SACwB;AACxB,MAAI,EAAE,mBAAmB,UAAU;AAC/B,UAAM,IAAI;AAAA,MACN,oDAAoD,OAAO,OAAO;AAAA,IACtE;AAAA,EACJ;AAEA,QAAM,EAAE,aAAa,eAAe,cAAc,IAAI,KAAK;AAC3D,QAAM,eAAe,SAAS;AAC9B,QAAM,YAAY,QAAQ,WAAW,YAAY;AACjD,MAAI,WAAW;AACX,WAAO;AAAA,MACH,MAAM;AAAA,MACN,SAAS,MAAM;AAAA,IACnB;AAAA,EACJ,OAAO;AACH,WAAO;AAAA,MACH,MAAM;AAAA,MACN,UAAkB;AACd,cAAM,WAAW,iBAAiB,OAAO;AACzC,cAAM,SAAS,iBAAiB,YAAY;AAC5C,cAAM,UAAU,eAAe,YAAY;AAC3C,eAAO;AAAA,UACH,YAAY,cAAc;AAAA,UAC1B;AAAA,UACA,sCAAsC,OAAO;AAAA,UAC7C;AAAA,UACA;AAAA,UACA,KAAK,cAAc,QAAQ,CAAC;AAAA,UAC5B;AAAA,UACA,KAAK,cAAc,MAAM,CAAC;AAAA,QAC9B,EAAE,KAAK,IAAI;AAAA,MACf;AAAA,IACJ;AAAA,EACJ;AACJ;;;ACtCA,OAAO,OAAO;AAAA,EACV;AACJ,CAAC;",
6
+ "names": ["text", "final"]
7
+ }
@@ -0,0 +1,54 @@
1
+ // src/utils/generate-selector.ts
2
+ function canUseID(element) {
3
+ if (!element.isConnected) {
4
+ return false;
5
+ }
6
+ if (!element.id) {
7
+ return false;
8
+ }
9
+ const hits = document.querySelectorAll(`#${element.id}`);
10
+ return hits.length === 1;
11
+ }
12
+ function stringifyNode(element) {
13
+ if (canUseID(element)) {
14
+ return [`#${element.id}`, true];
15
+ }
16
+ const tagName = element.tagName.toLowerCase();
17
+ const classes = Array.from(element.classList.values()).map((it) => `.${it}`).join("");
18
+ return [`${tagName}${classes}`, false];
19
+ }
20
+ function generateSelector(element) {
21
+ if (!element) {
22
+ return "<null>";
23
+ }
24
+ const [text, final] = stringifyNode(element);
25
+ if (final) {
26
+ return text;
27
+ }
28
+ const ancestry = [text];
29
+ let cur = element;
30
+ while (cur.parentElement) {
31
+ const parent = cur.parentElement;
32
+ const [text2, final2] = stringifyNode(parent);
33
+ ancestry.push(text2);
34
+ if (final2) {
35
+ break;
36
+ }
37
+ cur = parent;
38
+ }
39
+ return ancestry.reverse().join(" > ");
40
+ }
41
+
42
+ // src/utils/create-placeholder-in-document.ts
43
+ function createPlaceholderInDocument() {
44
+ const elem = document.createElement("div");
45
+ if (document.body) {
46
+ document.body.appendChild(elem);
47
+ }
48
+ return elem;
49
+ }
50
+ export {
51
+ createPlaceholderInDocument,
52
+ generateSelector
53
+ };
54
+ //# sourceMappingURL=lib.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/generate-selector.ts", "../../src/utils/create-placeholder-in-document.ts"],
4
+ "sourcesContent": ["function canUseID(element: Element): boolean {\n if (!element.isConnected) {\n return false;\n }\n if (!element.id) {\n return false;\n }\n const hits = document.querySelectorAll(`#${element.id}`);\n return hits.length === 1;\n}\n\nfunction stringifyNode(element: Element): [text: string, final: boolean] {\n if (canUseID(element)) {\n return [`#${element.id}`, true];\n }\n\n const tagName = element.tagName.toLowerCase();\n const classes = Array.from(element.classList.values())\n .map((it) => `.${it}`)\n .join(\"\");\n return [`${tagName}${classes}`, false];\n}\n\n/**\n * Generate a selector for given element.\n *\n * @public\n * @param element - Element to generate selector for.\n * @returns DOM selector\n */\nexport function generateSelector(element: Element | null): string {\n if (!element) {\n return \"<null>\";\n }\n\n const [text, final] = stringifyNode(element);\n\n /* if the element itself is the final node needed for the selector just\n * return it right away */\n if (final) {\n return text;\n }\n\n const ancestry: string[] = [text];\n let cur = element;\n while (cur.parentElement) {\n const parent = cur.parentElement;\n const [text, final] = stringifyNode(parent);\n ancestry.push(text);\n if (final) {\n break;\n }\n cur = parent;\n }\n\n return ancestry.reverse().join(\" > \");\n}\n", "/**\n * Creates a placeholder element as a child under `<body>`.\n * The element should be cleaned by the caller.\n *\n * @example\n *\n * In Vue.js tests this can be used with `attachTo` when the component must be\n * present in the document (e.g. dealing with focus).\n *\n * ```ts\n * shallowMount(MyComponent, {\n * attachTo: createPlaceholderInDocument(),\n * });\n * ```\n *\n * @public\n */\nexport function createPlaceholderInDocument(): HTMLElement {\n const elem = document.createElement(\"div\");\n if (document.body) {\n document.body.appendChild(elem);\n }\n return elem;\n}\n"],
5
+ "mappings": ";AAAA,SAAS,SAAS,SAA2B;AACzC,MAAI,CAAC,QAAQ,aAAa;AACtB,WAAO;AAAA,EACX;AACA,MAAI,CAAC,QAAQ,IAAI;AACb,WAAO;AAAA,EACX;AACA,QAAM,OAAO,SAAS,iBAAiB,IAAI,QAAQ,EAAE,EAAE;AACvD,SAAO,KAAK,WAAW;AAC3B;AAEA,SAAS,cAAc,SAAkD;AACrE,MAAI,SAAS,OAAO,GAAG;AACnB,WAAO,CAAC,IAAI,QAAQ,EAAE,IAAI,IAAI;AAAA,EAClC;AAEA,QAAM,UAAU,QAAQ,QAAQ,YAAY;AAC5C,QAAM,UAAU,MAAM,KAAK,QAAQ,UAAU,OAAO,CAAC,EAChD,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,EACpB,KAAK,EAAE;AACZ,SAAO,CAAC,GAAG,OAAO,GAAG,OAAO,IAAI,KAAK;AACzC;AASO,SAAS,iBAAiB,SAAiC;AAC9D,MAAI,CAAC,SAAS;AACV,WAAO;AAAA,EACX;AAEA,QAAM,CAAC,MAAM,KAAK,IAAI,cAAc,OAAO;AAI3C,MAAI,OAAO;AACP,WAAO;AAAA,EACX;AAEA,QAAM,WAAqB,CAAC,IAAI;AAChC,MAAI,MAAM;AACV,SAAO,IAAI,eAAe;AACtB,UAAM,SAAS,IAAI;AACnB,UAAM,CAACA,OAAMC,MAAK,IAAI,cAAc,MAAM;AAC1C,aAAS,KAAKD,KAAI;AAClB,QAAIC,QAAO;AACP;AAAA,IACJ;AACA,UAAM;AAAA,EACV;AAEA,SAAO,SAAS,QAAQ,EAAE,KAAK,KAAK;AACxC;;;ACvCO,SAAS,8BAA2C;AACvD,QAAM,OAAO,SAAS,cAAc,KAAK;AACzC,MAAI,SAAS,MAAM;AACf,aAAS,KAAK,YAAY,IAAI;AAAA,EAClC;AACA,SAAO;AACX;",
6
+ "names": ["text", "final"]
7
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,134 @@
1
+ // src/utils/generate-selector.ts
2
+ function canUseID(element) {
3
+ if (!element.isConnected) {
4
+ return false;
5
+ }
6
+ if (!element.id) {
7
+ return false;
8
+ }
9
+ const hits = document.querySelectorAll(`#${element.id}`);
10
+ return hits.length === 1;
11
+ }
12
+ function stringifyNode(element) {
13
+ if (canUseID(element)) {
14
+ return [`#${element.id}`, true];
15
+ }
16
+ const tagName = element.tagName.toLowerCase();
17
+ const classes = Array.from(element.classList.values()).map((it) => `.${it}`).join("");
18
+ return [`${tagName}${classes}`, false];
19
+ }
20
+ function generateSelector(element) {
21
+ if (!element) {
22
+ return "<null>";
23
+ }
24
+ const [text, final] = stringifyNode(element);
25
+ if (final) {
26
+ return text;
27
+ }
28
+ const ancestry = [text];
29
+ let cur = element;
30
+ while (cur.parentElement) {
31
+ const parent = cur.parentElement;
32
+ const [text2, final2] = stringifyNode(parent);
33
+ ancestry.push(text2);
34
+ if (final2) {
35
+ break;
36
+ }
37
+ cur = parent;
38
+ }
39
+ return ancestry.reverse().join(" > ");
40
+ }
41
+
42
+ // src/utils/create-placeholder-in-document.ts
43
+ function createPlaceholderInDocument() {
44
+ const elem = document.createElement("div");
45
+ if (document.body) {
46
+ document.body.appendChild(elem);
47
+ }
48
+ return elem;
49
+ }
50
+
51
+ // src/vue/size-wrapper.ts
52
+ import { defineComponent, h } from "vue";
53
+ var aspectRatio = 16 / 9;
54
+ var cypressPadding = 8;
55
+ var variants = [
56
+ { name: "min", size: "320px" },
57
+ { name: "mobile", size: "639px" },
58
+ { name: "desktop-low", size: "640px" },
59
+ { name: "desktop-normal", size: "1024px" }
60
+ ];
61
+ var sizeWrapperWidth = 1024 + cypressPadding;
62
+ var sizeWrapperHeight = sizeWrapperWidth / aspectRatio;
63
+ var SizeWrapper = defineComponent({
64
+ name: "SizeWrapper",
65
+ render() {
66
+ const children = variants.map((it) => {
67
+ const data = {
68
+ style: {
69
+ border: "1px dashed hotpink",
70
+ width: it.size
71
+ },
72
+ "data-variant": it.name
73
+ };
74
+ const slot = this.$slots.default ?? (() => "");
75
+ const content = slot({
76
+ variant: it.name
77
+ });
78
+ return h("div", data, [h("span", it.size), content]);
79
+ });
80
+ return h("div", children);
81
+ }
82
+ });
83
+
84
+ // src/vue/density-wrapper.ts
85
+ import { defineComponent as defineComponent2, h as h2 } from "vue";
86
+ var aspectRatio2 = 16 / 9;
87
+ var cypressPadding2 = 8;
88
+ var densities = [
89
+ {
90
+ name: "Default",
91
+ class: "density-default"
92
+ },
93
+ {
94
+ name: "Dense",
95
+ class: "density-dense"
96
+ },
97
+ {
98
+ name: "Densest",
99
+ class: "density-densest"
100
+ }
101
+ ];
102
+ var densityWrapperWidth = 640 + cypressPadding2;
103
+ var densityWrapperHeight = 640 / aspectRatio2;
104
+ var DensityWrapper = defineComponent2({
105
+ name: "DensityWrapper",
106
+ render() {
107
+ const children = densities.map((it) => {
108
+ const data = {
109
+ class: it.class,
110
+ style: {
111
+ border: "1px dashed hotpink",
112
+ width: "640px"
113
+ }
114
+ };
115
+ const slot = this.$slots.default ?? (() => "");
116
+ const content = slot({
117
+ density: it.name
118
+ });
119
+ return h2("div", data, [content]);
120
+ });
121
+ return h2("div", children);
122
+ }
123
+ });
124
+ export {
125
+ DensityWrapper,
126
+ SizeWrapper,
127
+ createPlaceholderInDocument,
128
+ densityWrapperHeight,
129
+ densityWrapperWidth,
130
+ generateSelector,
131
+ sizeWrapperHeight,
132
+ sizeWrapperWidth
133
+ };
134
+ //# sourceMappingURL=vue.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/generate-selector.ts", "../../src/utils/create-placeholder-in-document.ts", "../../src/vue/size-wrapper.ts", "../../src/vue/density-wrapper.ts"],
4
+ "sourcesContent": ["function canUseID(element: Element): boolean {\n if (!element.isConnected) {\n return false;\n }\n if (!element.id) {\n return false;\n }\n const hits = document.querySelectorAll(`#${element.id}`);\n return hits.length === 1;\n}\n\nfunction stringifyNode(element: Element): [text: string, final: boolean] {\n if (canUseID(element)) {\n return [`#${element.id}`, true];\n }\n\n const tagName = element.tagName.toLowerCase();\n const classes = Array.from(element.classList.values())\n .map((it) => `.${it}`)\n .join(\"\");\n return [`${tagName}${classes}`, false];\n}\n\n/**\n * Generate a selector for given element.\n *\n * @public\n * @param element - Element to generate selector for.\n * @returns DOM selector\n */\nexport function generateSelector(element: Element | null): string {\n if (!element) {\n return \"<null>\";\n }\n\n const [text, final] = stringifyNode(element);\n\n /* if the element itself is the final node needed for the selector just\n * return it right away */\n if (final) {\n return text;\n }\n\n const ancestry: string[] = [text];\n let cur = element;\n while (cur.parentElement) {\n const parent = cur.parentElement;\n const [text, final] = stringifyNode(parent);\n ancestry.push(text);\n if (final) {\n break;\n }\n cur = parent;\n }\n\n return ancestry.reverse().join(\" > \");\n}\n", "/**\n * Creates a placeholder element as a child under `<body>`.\n * The element should be cleaned by the caller.\n *\n * @example\n *\n * In Vue.js tests this can be used with `attachTo` when the component must be\n * present in the document (e.g. dealing with focus).\n *\n * ```ts\n * shallowMount(MyComponent, {\n * attachTo: createPlaceholderInDocument(),\n * });\n * ```\n *\n * @public\n */\nexport function createPlaceholderInDocument(): HTMLElement {\n const elem = document.createElement(\"div\");\n if (document.body) {\n document.body.appendChild(elem);\n }\n return elem;\n}\n", "import { defineComponent, h } from \"vue\";\n\nconst aspectRatio = 16 / 9;\nconst cypressPadding = 8;\n\nconst variants = [\n { name: \"min\", size: \"320px\" },\n { name: \"mobile\", size: \"639px\" },\n { name: \"desktop-low\", size: \"640px\" },\n { name: \"desktop-normal\", size: \"1024px\" },\n];\n\n/**\n * Width of SizeWrapper component including padding added by cypress during tests.\n *\n * @public\n */\nexport const sizeWrapperWidth = 1024 + cypressPadding;\n\n/**\n * Height for SizeWrapper component with an aspect ratio of 16:9 based on its width.\n *\n * @public\n */\nexport const sizeWrapperHeight = sizeWrapperWidth / aspectRatio;\n\n/**\n * @public\n */\nexport const SizeWrapper = defineComponent({\n name: \"SizeWrapper\",\n render() {\n const children = variants.map((it) => {\n const data = {\n style: {\n border: \"1px dashed hotpink\",\n width: it.size,\n },\n \"data-variant\": it.name,\n };\n const slot = this.$slots.default ?? (() => \"\");\n const content = slot({\n variant: it.name,\n });\n return h(\"div\", data, [h(\"span\", it.size), content]);\n });\n return h(\"div\", children);\n },\n});\n", "import { defineComponent, h } from \"vue\";\n\nconst aspectRatio = 16 / 9;\nconst cypressPadding = 8;\n\nconst densities = [\n {\n name: \"Default\",\n class: \"density-default\",\n },\n {\n name: \"Dense\",\n class: \"density-dense\",\n },\n {\n name: \"Densest\",\n class: \"density-densest\",\n },\n];\n\n/**\n * Width of DensityWrapper component including padding added by cypress during tests.\n *\n * @public\n */\nexport const densityWrapperWidth = 640 + cypressPadding;\n\n/**\n * Height for DensityWrapper component with an aspect ratio of 16:9 based on its width.\n *\n * @public\n */\nexport const densityWrapperHeight = 640 / aspectRatio;\n\n/**\n * @public\n */\nexport const DensityWrapper = defineComponent({\n name: \"DensityWrapper\",\n render() {\n const children = densities.map((it) => {\n const data = {\n class: it.class,\n style: {\n border: \"1px dashed hotpink\",\n width: \"640px\",\n },\n };\n const slot = this.$slots.default ?? (() => \"\");\n const content = slot({\n density: it.name,\n });\n return h(\"div\", data, [content]);\n });\n return h(\"div\", children);\n },\n});\n"],
5
+ "mappings": "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",
6
+ "names": ["text", "final", "defineComponent", "h", "aspectRatio", "cypressPadding"]
7
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Creates a placeholder element as a child under `<body>`.
3
+ * The element should be cleaned by the caller.
4
+ *
5
+ * @example
6
+ *
7
+ * In Vue.js tests this can be used with `attachTo` when the component must be
8
+ * present in the document (e.g. dealing with focus).
9
+ *
10
+ * ```ts
11
+ * shallowMount(MyComponent, {
12
+ * attachTo: createPlaceholderInDocument(),
13
+ * });
14
+ * ```
15
+ *
16
+ * @public
17
+ */
18
+ export declare function createPlaceholderInDocument(): HTMLElement;
19
+
20
+ /**
21
+ * Generate a selector for given element.
22
+ *
23
+ * @public
24
+ * @param element - Element to generate selector for.
25
+ * @returns DOM selector
26
+ */
27
+ export declare function generateSelector(element: Element | null): string;
28
+
29
+ export { }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Creates a placeholder element as a child under `<body>`.
3
+ * The element should be cleaned by the caller.
4
+ *
5
+ * @example
6
+ *
7
+ * In Vue.js tests this can be used with `attachTo` when the component must be
8
+ * present in the document (e.g. dealing with focus).
9
+ *
10
+ * ```ts
11
+ * shallowMount(MyComponent, {
12
+ * attachTo: createPlaceholderInDocument(),
13
+ * });
14
+ * ```
15
+ *
16
+ * @public
17
+ */
18
+ export declare function createPlaceholderInDocument(): HTMLElement;
19
+
20
+ /**
21
+ * Generate a selector for given element.
22
+ *
23
+ * @public
24
+ * @param element - Element to generate selector for.
25
+ * @returns DOM selector
26
+ */
27
+ export declare function generateSelector(element: Element | null): string;
28
+
29
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.47.7"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,72 @@
1
+ import { ComponentOptionsMixin } from 'vue';
2
+ import { DefineComponent } from 'vue';
3
+ import { ExtractPropTypes } from 'vue';
4
+ import { PublicProps } from 'vue';
5
+
6
+ /**
7
+ * Creates a placeholder element as a child under `<body>`.
8
+ * The element should be cleaned by the caller.
9
+ *
10
+ * @example
11
+ *
12
+ * In Vue.js tests this can be used with `attachTo` when the component must be
13
+ * present in the document (e.g. dealing with focus).
14
+ *
15
+ * ```ts
16
+ * shallowMount(MyComponent, {
17
+ * attachTo: createPlaceholderInDocument(),
18
+ * });
19
+ * ```
20
+ *
21
+ * @public
22
+ */
23
+ export declare function createPlaceholderInDocument(): HTMLElement;
24
+
25
+ /**
26
+ * @public
27
+ */
28
+ export declare const DensityWrapper: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {}>>, {}, {}>;
29
+
30
+ /**
31
+ * Height for DensityWrapper component with an aspect ratio of 16:9 based on its width.
32
+ *
33
+ * @public
34
+ */
35
+ export declare const densityWrapperHeight: number;
36
+
37
+ /**
38
+ * Width of DensityWrapper component including padding added by cypress during tests.
39
+ *
40
+ * @public
41
+ */
42
+ export declare const densityWrapperWidth: number;
43
+
44
+ /**
45
+ * Generate a selector for given element.
46
+ *
47
+ * @public
48
+ * @param element - Element to generate selector for.
49
+ * @returns DOM selector
50
+ */
51
+ export declare function generateSelector(element: Element | null): string;
52
+
53
+ /**
54
+ * @public
55
+ */
56
+ export declare const SizeWrapper: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {}>>, {}, {}>;
57
+
58
+ /**
59
+ * Height for SizeWrapper component with an aspect ratio of 16:9 based on its width.
60
+ *
61
+ * @public
62
+ */
63
+ export declare const sizeWrapperHeight: number;
64
+
65
+ /**
66
+ * Width of SizeWrapper component including padding added by cypress during tests.
67
+ *
68
+ * @public
69
+ */
70
+ export declare const sizeWrapperWidth: number;
71
+
72
+ export { }
package/jest.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export * from "./dist/types/jest";
2
+
3
+ declare global {
4
+ namespace jest {
5
+ interface Matchers<R> {
6
+ /**
7
+ * Expects element to have focus.
8
+ */
9
+ toHaveFocus(): R;
10
+ }
11
+ }
12
+ }
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@fkui/test-utils",
3
+ "version": "5.36.0",
4
+ "description": "FKUI test utils for Jest",
5
+ "keywords": [
6
+ "fkui",
7
+ "designsystem",
8
+ "test",
9
+ "jest",
10
+ "vue",
11
+ "cypress"
12
+ ],
13
+ "homepage": "https://forsakringskassan.github.io/designsystem/",
14
+ "bugs": "https://github.com/Forsakringskassan/designsystem/issues",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/Forsakringskassan/designsystem.git",
18
+ "directory": "packages/test-utils"
19
+ },
20
+ "license": "MIT",
21
+ "author": "Försäkringskassan",
22
+ "sideEffects": [
23
+ "./dist/cjs/jest.js",
24
+ "./dist/esm/jest.js",
25
+ "./src/matchers/index.ts"
26
+ ],
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/types/lib.d.ts",
30
+ "import": "./dist/esm/lib.js",
31
+ "require": "./dist/cjs/lib.js"
32
+ },
33
+ "./jest": {
34
+ "types": "./dist/types/jest.d.ts",
35
+ "import": "./dist/esm/jest.js",
36
+ "require": "./dist/cjs/jest.js"
37
+ },
38
+ "./vue": {
39
+ "types": "./dist/types/vue.d.ts",
40
+ "import": "./dist/esm/vue.js",
41
+ "require": "./dist/cjs/vue.js"
42
+ }
43
+ },
44
+ "main": "dist/cjs/lib.js",
45
+ "types": "dist/types/lib.d.ts",
46
+ "files": [
47
+ "dist",
48
+ "jest.d.ts",
49
+ "vue.d.ts"
50
+ ],
51
+ "scripts": {
52
+ "prebuild": "rimraf dist temp && tsc",
53
+ "build": "node build.js",
54
+ "postbuild": "fk-api-extractor api-extractor.json api-extractor-*.json",
55
+ "clean": "rimraf .jest-cache dist temp test-results",
56
+ "prepack": "release-prepack --bundle --retain-scripts",
57
+ "postpack": "release-postpack",
58
+ "prepublishOnly": "release-prepublish --bundle --retain-scripts",
59
+ "test": "jest"
60
+ },
61
+ "peerDependencies": {
62
+ "jest": "^26 || ^27 || ^28 || ^29",
63
+ "vue": "^3"
64
+ },
65
+ "peerDependenciesMeta": {
66
+ "vue": {
67
+ "optional": true
68
+ }
69
+ },
70
+ "engines": {
71
+ "node": ">= 20",
72
+ "npm": ">= 7"
73
+ },
74
+ "gitHead": "098282a45f574bb15aba4c5db57d13e25bb07129"
75
+ }
package/vue.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./dist/types/vue";