@leaflink/dom-testing-utils 4.1.0 → 4.2.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/README.md CHANGED
@@ -22,6 +22,8 @@
22
22
  - [`assertAndDismissNoty`](#assertanddismissnoty)
23
23
  - [`getByDescriptionTerm`](#getbydescriptionterm)
24
24
  - [`getAllByDescriptionTerm`](#getallbydescriptionterm)
25
+ - [`getSelectedOption`](#getselectedoption)
26
+ - [`getSelectedOptions`](#getselectedoptions)
25
27
  - [`createFixtureGenerator`](#createfixturegenerator)
26
28
  - [Mocking API Endpoints](#mocking-api-endpoints)
27
29
 
@@ -150,6 +152,32 @@ Queries and returns an array of HTML elements with the role "definition" (DD) th
150
152
 
151
153
  **Returns**: `HTMLElement[]` - An array of HTML description detail elements that match the given text.
152
154
 
155
+
156
+ ### `getSelectedOption`
157
+
158
+ Finds the first selected HTML element with the role "definition" (LI) "listitem" inside the specified select element.
159
+
160
+ | **Parameters** | **Type** | **Default** | **Summary** |
161
+ | ----------- | ----------- | ----------- |----------- |
162
+ | element | HTMLSelectElement | *Required* | Stash Select element to be checked. |
163
+ | selectedClass | string | 'is-selected' | Selected class added on selected items |
164
+ | options | ByRoleOptions | null | `getAllByRole()` options values using `ByRoleOptions` type |
165
+
166
+ **Returns**: `HTMLElement | undefined` - The first selected HTML listitem element or undefined if no match is found.
167
+
168
+
169
+ ### `getSelectedOptions`
170
+
171
+ Finds all the selected HTML elements with the role "definition" (LI) "listitem" inside the specified select element.
172
+
173
+ | **Parameters** | **Type** | **Default** | **Summary** |
174
+ | ----------- | ----------- | ----------- |----------- |
175
+ | element | HTMLSelectElement | *Required* | Stash Select element to be checked. |
176
+ | selectedClass | string | 'is-selected' | Selected class added on selected items |
177
+ | options | ByRoleOptions | null | `getAllByRole()` options values using `ByRoleOptions` type |
178
+
179
+ **Returns**: `HTMLElement[]` - An array of selected HTML listitem elements.
180
+
153
181
  ### `createFixtureGenerator`
154
182
 
155
183
  Higher order function that takes a method whose responsibility is to create a **single** data fixture object and returns a new generator function that allows you to create 1 or more of those fixtures. Fixture generator function that's returned supports passing optional `num` and `overrides` params.
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@ export { default as cleanupToasts } from './utils/cleanupToasts.js';
6
6
  export { default as createFixtureGenerator } from './utils/createFixtureGenerator.js';
7
7
  export { default as getAllByDescriptionTerm } from './utils/getAllByDescriptionTerm.js';
8
8
  export { default as getByDescriptionTerm } from './utils/getByDescriptionTerm.js';
9
+ export { default as getSelectedOption } from './utils/getSelectedOption.js';
10
+ export { default as getSelectedOptions } from './utils/getSelectedOptions.js';
9
11
  export { default as hasText } from './utils/hasText.js';
10
12
  export { default as isHTMLElement } from './utils/isHTMLElement.js';
11
13
  export { default as createMockApiUtils, RestMethod } from './utils/mockEndpoints.js';
package/dist/index.js CHANGED
@@ -6,6 +6,8 @@ export { default as cleanupToasts } from './utils/cleanupToasts.js';
6
6
  export { default as createFixtureGenerator } from './utils/createFixtureGenerator.js';
7
7
  export { default as getAllByDescriptionTerm } from './utils/getAllByDescriptionTerm.js';
8
8
  export { default as getByDescriptionTerm } from './utils/getByDescriptionTerm.js';
9
+ export { default as getSelectedOption } from './utils/getSelectedOption.js';
10
+ export { default as getSelectedOptions } from './utils/getSelectedOptions.js';
9
11
  export { default as hasText } from './utils/hasText.js';
10
12
  export { default as isHTMLElement } from './utils/isHTMLElement.js';
11
13
  export { default as createMockApiUtils } from './utils/mockEndpoints.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OA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AE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAc,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/setup-env.js CHANGED
@@ -34,7 +34,7 @@ global.window.location = Object.defineProperties({}, {
34
34
  },
35
35
  },
36
36
  });
37
- global.window.open = vi.fn();
37
+ vi.stubGlobal('open', vi.fn());
38
38
  global.window.ResizeObserver =
39
39
  global.window.ResizeObserver ||
40
40
  class ResizeObserver {
@@ -1 +1 @@
1
- {"version":3,"file":"setup-env.js","sourceRoot":"src/","sources":["setup-env.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,SAAS,IAAI,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAC3D,OAAO,aAAa,EAAE,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,aAAa,EAAE,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEjF,sDAAsD;AACtD,6EAA6E;AAC7E,+EAA+E;AAC/E,4BAA4B;AAC5B,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;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};
@@ -0,0 +1,79 @@
1
+ import { render, screen } from '@testing-library/vue';
2
+ import getSelectedOption from '../getSelectedOption';
3
+ // This content was extracted from https://stash.leaflink.com/?path=/story/components-select--single
4
+ const template = `<div class="input ll-select" data-test="ll-select">
5
+ <label class="stash-label tw-block tw-truncate tw-text-ice-900 tw-font-medium tw-text-sm tw-leading-6" for="field-92" id="field-label-91">
6
+ Single<!---->
7
+ </label>
8
+ <select id="field-92" aria-errormessage="field-error-93" aria-invalid="false" class="sr-only">
9
+ <option value="1">First</option>
10
+ <option value="2">Second</option>
11
+ <option value=""></option>
12
+ </select>
13
+ <div role="listbox" aria-hidden="true" aria-controls="listbox-field-92" aria-expanded="false" aria-label="Select option" class="_ll-select_1vqjp_176 is-single">
14
+ <div id="listbox-field-92" class="input-field tw-p-0 _content_1vqjp_190" tabindex="0">
15
+ <ul class="tw-pr-9 _chips_1vqjp_243">
16
+ <!---->
17
+ <li class="tw-pl-1.5 tw-mr-0 _selected_1vqjp_275 text-truncate">
18
+ First
19
+ <button tabindex="-1" class="_remove_1vqjp_278">
20
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--close _small_1x7lf_22" data-test="stash-icon" icon="close">
21
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="close">
22
+ <path fill="currentColor" fill-rule="evenodd" d="m16.95 18.364 1.414-1.414-4.95-4.95 4.95-4.95-1.414-1.414-4.95 4.95-4.95-4.95L5.636 7.05l4.95 4.95-4.95 4.95 1.414 1.414 4.95-4.95 4.95 4.95Z" clip-rule="evenodd"></path>
23
+ </symbol>
24
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#close"></use>
25
+ </svg>
26
+ </button>
27
+ </li>
28
+ </ul>
29
+ <!---->
30
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--caret-down _standard_1x7lf_8 _icon_1vqjp_222" data-test="stash-icon">
31
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="caret-down">
32
+ <path fill="currentColor" d="m6 9 6 6 6-6H6Z"></path>
33
+ </symbol>
34
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#caret-down"></use>
35
+ </svg>
36
+ <div class="border-selector shadow-low w-full _options_1vqjp_302" style="--options-gap: 40px; display: none;">
37
+ <div class="flex align-middle tw-pr-1.5 border-b border-blue">
38
+ <input type="text" autocomplete="off" class="no-border _search_1vqjp_298" data-test="search-select" placeholder="Search" spellcheck="false">
39
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--search _standard_1x7lf_8 text-ice" data-test="stash-icon">
40
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="search">
41
+ <path fill="currentColor" fill-rule="evenodd" d="M15.14 10.14a5 5 0 1 1-10 0 5 5 0 0 1 10 0Zm-.808 5.606a7 7 0 1 1 1.414-1.414l5.101 5.1-1.414 1.415-5.1-5.1Z" clip-rule="evenodd"></path>
42
+ </symbol>
43
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#search"></use>
44
+ </svg>
45
+ </div>
46
+ <ul class="options tw-my-1.5 ll-bg-white w-full">
47
+ <li data-test="1" class="_option_1vqjp_302 is-selected">
48
+ First
49
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--check _standard_1x7lf_8 text-blue ml-auto" data-test="stash-icon">
50
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="check">
51
+ <path fill="currentColor" fill-rule="evenodd" d="M20.707 6.854 9 18.561l-5.707-5.707 1.414-1.414L9 15.733 19.293 5.44l1.414 1.414Z" clip-rule="evenodd"></path>
52
+ </symbol>
53
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#check"></use>
54
+ </svg>
55
+ </li>
56
+ <li data-test="2" class="_option_1vqjp_302">
57
+ Second<!---->
58
+ </li>
59
+ <li class="tw-m-1.5 tw-p-1.5 cursor-default" style="display: none;">
60
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--working _standard_1x7lf_8 text-ice fx-spin" data-test="options-loading">
61
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="working">
62
+ <rect fill="#fff"></rect>
63
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12 6a6 6 0 0 0 0 12 1 1 0 1 1 0 2 8 8 0 0 1 0-16 1 1 0 1 1 0 2Z" fill="currentColor"></path>
64
+ </symbol>
65
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#working"></use>
66
+ </svg>
67
+ </li>
68
+ <li class="tw-m-1.5 tw-p-1.5 cursor-default" data-test="ll-select|no-options" style="display: none;"> No options </li>
69
+ </ul>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ <!---->
74
+ </div>`;
75
+ it('should return only the selected item', () => {
76
+ render({ template });
77
+ expect(getSelectedOption(screen.getByTestId('ll-select'))).toHaveTextContent('First');
78
+ });
79
+ //# sourceMappingURL=getBySelectedOption.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBySelectedOption.spec.js","sourceRoot":"src/","sources":["utils/__tests__/getBySelectedOption.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAErD,oGAAoG;AACpG,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsEV,CAAC;AAER,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;IAC9C,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAErB,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACxF,CAAC,CAAC,CAAC"}
@@ -0,0 +1,104 @@
1
+ import { render, screen } from '@testing-library/vue';
2
+ import getSelectedOptions from '../getSelectedOptions';
3
+ // This content was extracted from https://stash.leaflink.com/?path=/story/components-select--multiple
4
+ const template = `<div class="input ll-select _has-hint_9vzwe_6" data-test="ll-select">
5
+ <label class="stash-label tw-block tw-truncate tw-text-ice-900 tw-font-medium tw-text-sm tw-leading-6" for="field-101" id="field-label-100">
6
+ Multiple<!---->
7
+ </label>
8
+ <select multiple="" id="field-101" aria-errormessage="field-error-102" aria-invalid="false" class="sr-only">
9
+ <option value="1">First</option>
10
+ <option value="2">Second</option>
11
+ <option value="3">Third</option>
12
+ <option value=""></option>
13
+ </select>
14
+ <div role="listbox" aria-hidden="true" aria-controls="listbox-field-101" aria-expanded="false" aria-label="Select option" class="_ll-select_1vqjp_176">
15
+ <div id="listbox-field-101" class="input-field tw-p-0 _content_1vqjp_190" tabindex="0">
16
+ <ul class="tw-pr-9 _chips_1vqjp_243">
17
+ <!---->
18
+ <li class="inline-block">
19
+ <span class="stash-chip tw-inline-flex tw-items-center tw-relative stash-chip--radius-standard _root_jxnu3_2 _size-medium_jxnu3_12 tw-rounded-sm tw-text-white tw-bg-blue _chip_1vqjp_243" data-test="stash-chip">
20
+ <span class="tw-mr-6 tw-truncate">First</span>
21
+ <button tabindex="-1" class="stash-chip-remove-button tw-absolute _remove-button_jxnu3_22">
22
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--close _small_1x7lf_22" data-test="icon|close">
23
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="close">
24
+ <path fill="currentColor" fill-rule="evenodd" d="m16.95 18.364 1.414-1.414-4.95-4.95 4.95-4.95-1.414-1.414-4.95 4.95-4.95-4.95L5.636 7.05l4.95 4.95-4.95 4.95 1.414 1.414 4.95-4.95 4.95 4.95Z" clip-rule="evenodd"></path>
25
+ </symbol>
26
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#close"></use>
27
+ </svg>
28
+ </button>
29
+ </span>
30
+ </li>
31
+ <li class="inline-block">
32
+ <span class="stash-chip tw-inline-flex tw-items-center tw-relative stash-chip--radius-standard _root_jxnu3_2 _size-medium_jxnu3_12 tw-rounded-sm tw-text-white tw-bg-blue _chip_1vqjp_243" data-test="stash-chip">
33
+ <span class="tw-mr-6 tw-truncate">Second</span>
34
+ <button tabindex="-1" class="stash-chip-remove-button tw-absolute _remove-button_jxnu3_22">
35
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--close _small_1x7lf_22" data-test="icon|close">
36
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="close">
37
+ <path fill="currentColor" fill-rule="evenodd" d="m16.95 18.364 1.414-1.414-4.95-4.95 4.95-4.95-1.414-1.414-4.95 4.95-4.95-4.95L5.636 7.05l4.95 4.95-4.95 4.95 1.414 1.414 4.95-4.95 4.95 4.95Z" clip-rule="evenodd"></path>
38
+ </symbol>
39
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#close"></use>
40
+ </svg>
41
+ </button>
42
+ </span>
43
+ </li>
44
+ </ul>
45
+ <!---->
46
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--caret-down _standard_1x7lf_8 _icon_1vqjp_222" data-test="stash-icon">
47
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="caret-down">
48
+ <path fill="currentColor" d="m6 9 6 6 6-6H6Z"></path>
49
+ </symbol>
50
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#caret-down"></use>
51
+ </svg>
52
+ <div class="border-selector shadow-low w-full _options_1vqjp_302" style="--options-gap: 40px; display: none;">
53
+ <div class="flex align-middle tw-pr-1.5 border-b border-blue">
54
+ <input type="text" autocomplete="off" class="no-border _search_1vqjp_298" data-test="search-select" placeholder="Search" spellcheck="false">
55
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--search _standard_1x7lf_8 text-ice" data-test="stash-icon">
56
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="search">
57
+ <path fill="currentColor" fill-rule="evenodd" d="M15.14 10.14a5 5 0 1 1-10 0 5 5 0 0 1 10 0Zm-.808 5.606a7 7 0 1 1 1.414-1.414l5.101 5.1-1.414 1.415-5.1-5.1Z" clip-rule="evenodd"></path>
58
+ </symbol>
59
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#search"></use>
60
+ </svg>
61
+ </div>
62
+ <ul class="options tw-my-1.5 ll-bg-white w-full">
63
+ <li data-test="1" class="_option_1vqjp_302 is-selected">
64
+ First
65
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--check _standard_1x7lf_8 text-blue ml-auto" data-test="stash-icon">
66
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="check">
67
+ <path fill="currentColor" fill-rule="evenodd" d="M20.707 6.854 9 18.561l-5.707-5.707 1.414-1.414L9 15.733 19.293 5.44l1.414 1.414Z" clip-rule="evenodd"></path>
68
+ </symbol>
69
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#check"></use>
70
+ </svg>
71
+ </li>
72
+ <li data-test="2" class="_option_1vqjp_302 is-selected">
73
+ Second
74
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--check _standard_1x7lf_8 text-blue ml-auto" data-test="stash-icon">
75
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="check">
76
+ <path fill="currentColor" fill-rule="evenodd" d="M20.707 6.854 9 18.561l-5.707-5.707 1.414-1.414L9 15.733 19.293 5.44l1.414 1.414Z" clip-rule="evenodd"></path>
77
+ </symbol>
78
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#check"></use>
79
+ </svg>
80
+ </li>
81
+ <li data-test="3" class="_option_1vqjp_302">
82
+ Third<!---->
83
+ </li>
84
+ <li class="tw-m-1.5 tw-p-1.5 cursor-default" style="display: none;">
85
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" id="ll-icon-1" role="presentation" aria-labelledby="ll-icon-1" class="stash-icon _icon_1x7lf_2 icon--working _standard_1x7lf_8 text-ice fx-spin" data-test="options-loading">
86
+ <symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" id="working">
87
+ <rect fill="#fff"></rect>
88
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12 6a6 6 0 0 0 0 12 1 1 0 1 1 0 2 8 8 0 0 1 0-16 1 1 0 1 1 0 2Z" fill="currentColor"></path>
89
+ </symbol>
90
+ <use xmlns="http://www.w3.org/1999/xhtml" href="#working"></use>
91
+ </svg>
92
+ </li>
93
+ <li class="tw-m-1.5 tw-p-1.5 cursor-default" data-test="ll-select|no-options" style="display: none;"> No options </li>
94
+ </ul>
95
+ </div>
96
+ </div>
97
+ </div>
98
+ <span class="block text-small _hint_9vzwe_11" data-test="field-hint">Notice 'overflow' treatment when 5+ are selected</span>
99
+ </div>`;
100
+ it('should return only the selected items', () => {
101
+ render({ template });
102
+ expect(getSelectedOptions(screen.getByTestId('ll-select')).map((el) => el.textContent)).toEqual(['First', 'Second']);
103
+ });
104
+ //# sourceMappingURL=getBySelectedOptions.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBySelectedOptions.spec.js","sourceRoot":"src/","sources":["utils/__tests__/getBySelectedOptions.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAEvD,sGAAsG;AACtG,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+FV,CAAC;AAER,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;IAC/C,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAErB,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AACvH,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createFixtureGenerator.js","sourceRoot":"src/","sources":["utils/createFixtureGenerator.ts"],"names":[],"mappings":"A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,CAAC,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type GetSelectedOptionArgs } from './getSelectedOptions.js';
2
+ /**
3
+ * Queries and returns the selected option inside of `select` HTML element with
4
+ * the role "definition" (LI) "listitem"
5
+ *
6
+ * E.G:
7
+ *```
8
+ * expect(
9
+ * getSelectedOption(screen.getByTestId('ll-select')),
10
+ * ).toHaveTextContent('First');
11
+ *```
12
+ * @param element - The Stash `select` HTML element wrapper to be used for search purposes
13
+ * @param options - `GetSelectedOptionArgs` options
14
+ * @returns A single selected `listitem` HTML element.
15
+ */
16
+ export default function getSelectedOption(element: HTMLSelectElement, { selectedClass, ...options }?: GetSelectedOptionArgs): HTMLElement;
@@ -0,0 +1,26 @@
1
+ import { queryHelpers } from '@testing-library/dom';
2
+ import getSelectedOptions from './getSelectedOptions.js';
3
+ /**
4
+ * Queries and returns the selected option inside of `select` HTML element with
5
+ * the role "definition" (LI) "listitem"
6
+ *
7
+ * E.G:
8
+ *```
9
+ * expect(
10
+ * getSelectedOption(screen.getByTestId('ll-select')),
11
+ * ).toHaveTextContent('First');
12
+ *```
13
+ * @param element - The Stash `select` HTML element wrapper to be used for search purposes
14
+ * @param options - `GetSelectedOptionArgs` options
15
+ * @returns A single selected `listitem` HTML element.
16
+ */
17
+ export default function getSelectedOption(element, { selectedClass = 'is-selected', ...options } = {}) {
18
+ const selectedOption = getSelectedOptions(element, { selectedClass, ...options });
19
+ if (selectedOption.length > 1) {
20
+ throw queryHelpers.getElementError(`Found multiple options with the ".${selectedClass}" className: \n${selectedOption
21
+ .map((option, index) => `- Element with text "${option.textContent}" at index "${index}"`)
22
+ .join(`\n`)}`, element);
23
+ }
24
+ return selectedOption[0];
25
+ }
26
+ //# sourceMappingURL=getSelectedOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSelectedOption.js","sourceRoot":"src/","sources":["utils/getSelectedOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,kBAAkD,MAAM,yBAAyB,CAAC;AACzF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,OAA0B,EAC1B,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,OAAO,KAA4B,EAAE;IAEzE,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAElF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,MAAM,YAAY,CAAC,eAAe,CAChC,qCAAqC,aAAa,kBAAkB,cAAc;aAC/E,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,wBAAwB,MAAM,CAAC,WAAW,eAAe,KAAK,GAAG,CAAC;aACzF,IAAI,CAAC,IAAI,CAAC,EAAE,EACf,OAAO,CACR,CAAC;IACJ,CAAC;IAED,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type ByRoleOptions } from '@testing-library/vue';
2
+ /**
3
+ * `getAllByRole()` options values using `ByRoleOptions` type
4
+ */
5
+ export interface GetSelectedOptionArgs extends ByRoleOptions {
6
+ /**
7
+ * Selected class
8
+ * By default it's using Stash Select class `is-selected`
9
+ */
10
+ selectedClass?: string;
11
+ }
12
+ /**
13
+ * Queries and returns the selected options inside of `select` HTML element with
14
+ * the role "definition" (LI) "listitem"
15
+ *
16
+ * E.G:
17
+ *```
18
+ *
19
+ * expect(
20
+ * getSelectedOptions(screen.getByTestId('ll-select'))
21
+ * ).toEqual(['First', 'Second'])
22
+ *```
23
+ * @param selectElement - The `select` HTML element to be used for search purposes.
24
+ * @param options - `GetSelectedOptionArgs` options
25
+ * @returns A list of selected `listitem` HTML elements.
26
+ */
27
+ export default function getSelectedOptions(element: HTMLSelectElement, { selectedClass, ...opts }?: GetSelectedOptionArgs): HTMLElement[];
@@ -0,0 +1,30 @@
1
+ import { within } from '@testing-library/vue';
2
+ /**
3
+ * Queries and returns the selected options inside of `select` HTML element with
4
+ * the role "definition" (LI) "listitem"
5
+ *
6
+ * E.G:
7
+ *```
8
+ *
9
+ * expect(
10
+ * getSelectedOptions(screen.getByTestId('ll-select'))
11
+ * ).toEqual(['First', 'Second'])
12
+ *```
13
+ * @param selectElement - The `select` HTML element to be used for search purposes.
14
+ * @param options - `GetSelectedOptionArgs` options
15
+ * @returns A list of selected `listitem` HTML elements.
16
+ */
17
+ export default function getSelectedOptions(element, { selectedClass = 'is-selected', ...opts } = {}) {
18
+ return within(element)
19
+ .getAllByRole('listitem', {
20
+ hidden: true,
21
+ ...opts,
22
+ })
23
+ .filter((term) => term.tagName === 'LI' && term.classList.contains(selectedClass))
24
+ .map((element) => {
25
+ // Removing spaces before and after the text content inside the visible option
26
+ element.textContent = (element.textContent || '').trim();
27
+ return element;
28
+ });
29
+ }
30
+ //# sourceMappingURL=getSelectedOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSelectedOptions.js","sourceRoot":"src/","sources":["utils/getSelectedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAalE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,OAA0B,EAC1B,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,IAAI,KAA4B,EAAE;IAEtE,OAAO,MAAM,CAAC,OAAO,CAAC;SACnB,YAAY,CAAC,UAAU,EAAE;QACxB,MAAM,EAAE,IAAI;QACZ,GAAG,IAAI;KACR,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;SACjF,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACf,8EAA8E;QAC9E,OAAO,CAAC,WAAW,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAEzD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"waitForLoading.js","sourceRoot":"src/","sources":["utils/waitForLoading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAgB/B;;GAEG;AACH,KAAK,UAAU,cAAc,CAAC,EAC5B,MAAM,GAAG,0CAA0C,EACnD,OAAO,GAAG,IAAI,EACd,UAAU,GAAG,KAAK,MACI,EAAE;IACxB,MAAM,QAAQ,EAAE,CAAC,CAAC,6CAA6C;IAE/D,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7D,OAAO,yBAAyB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;KAC3F;IAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC;AAED,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"waitForLoading.js","sourceRoot":"src/","sources":["utils/waitForLoading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAgB/B;;GAEG;AACH,KAAK,UAAU,cAAc,CAAC,EAC5B,MAAM,GAAG,0CAA0C,EACnD,OAAO,GAAG,IAAI,EACd,UAAU,GAAG,KAAK,MACI,EAAE;IACxB,MAAM,QAAQ,EAAE,CAAC,CAAC,6CAA6C;IAE/D,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9D,OAAO,yBAAyB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC;AAED,eAAe,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflink/dom-testing-utils",
3
- "version": "4.1.0",
3
+ "version": "4.2.1",
4
4
  "description": "Frontend DOM testing utilities",
5
5
  "engines": {
6
6
  "node": ">=16",