@fkui/test-utils 6.2.0 → 6.3.1
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/dist/cjs/jest.js.map +2 -2
- package/dist/esm/jest.js.map +2 -2
- package/dist/types/jest.d.ts +12 -0
- package/dist/types/tsdoc-metadata.json +1 -1
- package/jest.d.ts +0 -11
- package/package.json +5 -4
package/dist/cjs/jest.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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,IAA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d,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;;;
|
|
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 \"./augmentations\";\nimport { 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,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;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;;;ACrCA,OAAO,OAAO;AAAA,EACV;AACJ,CAAC;",
|
|
6
6
|
"names": ["text", "final"]
|
|
7
7
|
}
|
package/dist/esm/jest.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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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C,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;;;
|
|
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 \"./augmentations\";\nimport { 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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C5B;AAAA,UACA,KAAK,cAAc,MAAM,CAAC;AAAA,QAC9B,EAAE,KAAK,IAAI;AAAA,MACf;AAAA,IACJ;AAAA,EACJ;AACJ;;;ACrCA,OAAO,OAAO;AAAA,EACV;AACJ,CAAC;",
|
|
6
6
|
"names": ["text", "final"]
|
|
7
7
|
}
|
package/dist/types/jest.d.ts
CHANGED
|
@@ -27,3 +27,15 @@ export declare function createPlaceholderInDocument(): HTMLElement;
|
|
|
27
27
|
export declare function generateSelector(element: Element | null): string;
|
|
28
28
|
|
|
29
29
|
export { }
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
declare global {
|
|
33
|
+
namespace jest {
|
|
34
|
+
interface Matchers<R> {
|
|
35
|
+
/**
|
|
36
|
+
* Expects element to have focus.
|
|
37
|
+
*/
|
|
38
|
+
toHaveFocus(): R;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
package/jest.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fkui/test-utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"description": "FKUI test utils for Jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fkui",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"vue",
|
|
11
11
|
"cypress"
|
|
12
12
|
],
|
|
13
|
-
"homepage": "https://forsakringskassan.
|
|
13
|
+
"homepage": "https://designsystem.forsakringskassan.se/",
|
|
14
14
|
"bugs": "https://github.com/Forsakringskassan/designsystem/issues",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"sideEffects": [
|
|
23
23
|
"./dist/cjs/jest.js",
|
|
24
24
|
"./dist/esm/jest.js",
|
|
25
|
+
"./src/matchers/augmentations.ts",
|
|
25
26
|
"./src/matchers/index.ts"
|
|
26
27
|
],
|
|
27
28
|
"exports": {
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"scripts": {
|
|
52
53
|
"prebuild": "rimraf dist temp && tsc",
|
|
53
54
|
"build": "node build.js",
|
|
54
|
-
"postbuild": "fk-api-extractor api-extractor.json api-extractor-*.json",
|
|
55
|
+
"postbuild": "fk-api-extractor --patch-augmentations api-extractor.json api-extractor-*.json",
|
|
55
56
|
"clean": "rimraf .jest-cache dist temp test-results",
|
|
56
57
|
"prepack": "release-prepack --bundle --retain-scripts",
|
|
57
58
|
"postpack": "release-postpack",
|
|
@@ -71,5 +72,5 @@
|
|
|
71
72
|
"node": ">= 20",
|
|
72
73
|
"npm": ">= 7"
|
|
73
74
|
},
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "bc7431b02d30435cc2a179f6e5e1ab205ca2f7f4"
|
|
75
76
|
}
|