@leaflink/dom-testing-utils 0.0.0-PR-215--9237e01 → 0.0.0-PR-215--a64f64f
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/setup-env.spec.d.ts +0 -0
- package/dist/setup-env.spec.js +22 -0
- package/dist/setup-env.spec.js.map +1 -0
- package/dist/utils/__tests__/createFixtureGenerator.spec.d.ts +1 -0
- package/dist/utils/__tests__/createFixtureGenerator.spec.js +55 -0
- package/dist/utils/__tests__/createFixtureGenerator.spec.js.map +1 -0
- package/dist/utils/__tests__/getAllByDescriptionTerm.spec.d.ts +1 -0
- package/dist/utils/__tests__/getAllByDescriptionTerm.spec.js +17 -0
- package/dist/utils/__tests__/getAllByDescriptionTerm.spec.js.map +1 -0
- package/dist/utils/__tests__/getByDescriptionTerm.spec.d.ts +1 -0
- package/dist/utils/__tests__/getByDescriptionTerm.spec.js +12 -0
- package/dist/utils/__tests__/getByDescriptionTerm.spec.js.map +1 -0
- package/dist/utils/__tests__/getBySelectedOption.spec.d.ts +1 -0
- package/dist/utils/__tests__/getBySelectedOption.spec.js +79 -0
- package/dist/utils/__tests__/getBySelectedOption.spec.js.map +1 -0
- package/dist/utils/__tests__/getBySelectedOptions.spec.d.ts +1 -0
- package/dist/utils/__tests__/getBySelectedOptions.spec.js +104 -0
- package/dist/utils/__tests__/getBySelectedOptions.spec.js.map +1 -0
- package/dist/utils/__tests__/isHTMLElement.spec.d.ts +1 -0
- package/dist/utils/__tests__/isHTMLElement.spec.js +14 -0
- package/dist/utils/__tests__/isHTMLElement.spec.js.map +1 -0
- package/package.json +2 -2
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
it('should stub window open method', () => {
|
|
3
|
+
const url = 'my-url';
|
|
4
|
+
const openSpy = vi.spyOn(window, 'open');
|
|
5
|
+
expect(openSpy).not.toHaveBeenCalled();
|
|
6
|
+
window.open(url);
|
|
7
|
+
expect(openSpy).toHaveBeenCalledWith(url);
|
|
8
|
+
});
|
|
9
|
+
it('should stub fetch method', async () => {
|
|
10
|
+
const url = 'my-url';
|
|
11
|
+
const fetchSpy = vi.spyOn(globalThis, 'fetch');
|
|
12
|
+
expect(fetchSpy).not.toHaveBeenCalled();
|
|
13
|
+
await fetch(url);
|
|
14
|
+
expect(fetchSpy).toHaveBeenCalledWith(url);
|
|
15
|
+
});
|
|
16
|
+
it.each(['disconnect', 'observe', 'takeRecords', 'unobserve'])('should stub intersection observer %s method', (method) => {
|
|
17
|
+
const observer = new globalThis.IntersectionObserver(() => ({}), {});
|
|
18
|
+
const methodSpy = vi.spyOn(observer, method);
|
|
19
|
+
observer[method](document.createElement('div'));
|
|
20
|
+
expect(methodSpy).toHaveBeenCalled();
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=setup-env.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-env.spec.js","sourceRoot":"src/","sources":["setup-env.spec.ts"],"names":[],"mappings":";AAAA,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC;IAErB,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEzC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAEvC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEjB,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC;IAErB,MAAM,QAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAE/C,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAExC,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjB,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,IAAI,CAAyD,CAAC,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CACpH,6CAA6C,EAC7C,CAAC,MAA8D,EAAE,EAAE;IACjE,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAErE,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE7C,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAEhD,MAAM,CAAC,SAAS,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACvC,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import createFixtureGenerator from '../createFixtureGenerator';
|
|
2
|
+
it('returns a function that can generate an array of data objects', () => {
|
|
3
|
+
const generator = (overrides) => ({
|
|
4
|
+
foo: 'bar',
|
|
5
|
+
bar: 'baz',
|
|
6
|
+
...overrides,
|
|
7
|
+
});
|
|
8
|
+
expect(createFixtureGenerator(generator)(5)).toEqual([
|
|
9
|
+
{ foo: 'bar', bar: 'baz' },
|
|
10
|
+
{ foo: 'bar', bar: 'baz' },
|
|
11
|
+
{ foo: 'bar', bar: 'baz' },
|
|
12
|
+
{ foo: 'bar', bar: 'baz' },
|
|
13
|
+
{ foo: 'bar', bar: 'baz' },
|
|
14
|
+
]);
|
|
15
|
+
expect(createFixtureGenerator(generator)(3, { bar: 'yak' })).toEqual([
|
|
16
|
+
{ foo: 'bar', bar: 'yak' },
|
|
17
|
+
{ foo: 'bar', bar: 'yak' },
|
|
18
|
+
{ foo: 'bar', bar: 'yak' },
|
|
19
|
+
]);
|
|
20
|
+
});
|
|
21
|
+
it('returns a function that can generate a single data object', () => {
|
|
22
|
+
const generator = (overrides) => ({
|
|
23
|
+
foo: 'bar',
|
|
24
|
+
bar: 'baz',
|
|
25
|
+
...overrides,
|
|
26
|
+
});
|
|
27
|
+
expect(createFixtureGenerator(generator)()).toEqual({
|
|
28
|
+
foo: 'bar',
|
|
29
|
+
bar: 'baz',
|
|
30
|
+
});
|
|
31
|
+
expect(createFixtureGenerator(generator)({ bar: 'yak' })).toEqual({
|
|
32
|
+
foo: 'bar',
|
|
33
|
+
bar: 'yak',
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
it('returns a function that can generate an array of data objects with index of each item', () => {
|
|
37
|
+
const generator = (overrides, index) => ({
|
|
38
|
+
foo: `bar-${index}`,
|
|
39
|
+
bar: `baz-${index}`,
|
|
40
|
+
...overrides,
|
|
41
|
+
});
|
|
42
|
+
expect(createFixtureGenerator(generator)(5)).toEqual([
|
|
43
|
+
{ foo: 'bar-0', bar: 'baz-0' },
|
|
44
|
+
{ foo: 'bar-1', bar: 'baz-1' },
|
|
45
|
+
{ foo: 'bar-2', bar: 'baz-2' },
|
|
46
|
+
{ foo: 'bar-3', bar: 'baz-3' },
|
|
47
|
+
{ foo: 'bar-4', bar: 'baz-4' },
|
|
48
|
+
]);
|
|
49
|
+
expect(createFixtureGenerator(generator)(3, { bar: 'yak' })).toEqual([
|
|
50
|
+
{ foo: 'bar-0', bar: 'yak' },
|
|
51
|
+
{ foo: 'bar-1', bar: 'yak' },
|
|
52
|
+
{ foo: 'bar-2', bar: 'yak' },
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=createFixtureGenerator.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFixtureGenerator.spec.js","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AAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE;KAC7B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { render } from '@testing-library/vue';
|
|
2
|
+
import getAllByDescriptionTerm from '../getAllByDescriptionTerm';
|
|
3
|
+
it.each `
|
|
4
|
+
term | type
|
|
5
|
+
${'foo'} | ${'string'}
|
|
6
|
+
${/foo/i} | ${'regex'}
|
|
7
|
+
${new RegExp('foo', 'i')} | ${'RegExp'}
|
|
8
|
+
`('should return the description details for a given $type term', ({ term }) => {
|
|
9
|
+
render({
|
|
10
|
+
template: `<dl><dt>foo</dt><dd>bar1</dd></dl><dl><dt>foo</dt><dd>bar2</dd></dl>`,
|
|
11
|
+
});
|
|
12
|
+
const details = getAllByDescriptionTerm(term);
|
|
13
|
+
expect(details).toHaveLength(2);
|
|
14
|
+
expect(details[0]).toHaveTextContent('bar1');
|
|
15
|
+
expect(details[1]).toHaveTextContent('bar2');
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=getAllByDescriptionTerm.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAllByDescriptionTerm.spec.js","sourceRoot":"src/","sources":["utils/__tests__/getAllByDescriptionTerm.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,uBAAuB,MAAM,4BAA4B,CAAC;AAEjE,EAAE,CAAC,IAAI,CAAA;;IAEH,KAAK,uBAAuB,QAAQ;IACpC,MAAM,sBAAsB,OAAO;IACnC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,QAAQ;CACvC,CAAC,8DAA8D,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC7E,MAAM,CAAC;QACL,QAAQ,EAAE,sEAAsE;KACjF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { render } from '@testing-library/vue';
|
|
2
|
+
import getByDescriptionTerm from '../getByDescriptionTerm';
|
|
3
|
+
it.each `
|
|
4
|
+
term | type
|
|
5
|
+
${'foo'} | ${'string'}
|
|
6
|
+
${/foo/i} | ${'regex'}
|
|
7
|
+
${new RegExp('foo', 'i')} | ${'RegExp'}
|
|
8
|
+
`('should return the description detail for a given $type term', ({ term }) => {
|
|
9
|
+
render({ template: `<dl><dt>foo</dt><dd>bar</dd></dl>` });
|
|
10
|
+
expect(getByDescriptionTerm(term)).toHaveTextContent('bar');
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=getByDescriptionTerm.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getByDescriptionTerm.spec.js","sourceRoot":"src/","sources":["utils/__tests__/getByDescriptionTerm.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,EAAE,CAAC,IAAI,CAAA;;IAEH,KAAK,uBAAuB,QAAQ;IACpC,MAAM,sBAAsB,OAAO;IACnC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,QAAQ;CACvC,CAAC,6DAA6D,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC5E,MAAM,CAAC,EAAE,QAAQ,EAAE,mCAAmC,EAAE,CAAC,CAAC;IAE1D,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import isHTMLElement from '../isHTMLElement';
|
|
2
|
+
it('should return `true` if element received is a HTML', () => {
|
|
3
|
+
expect(isHTMLElement(document.createElement('div'))).toBe(true);
|
|
4
|
+
});
|
|
5
|
+
it('should return `true` if element received is NOT a HTML', () => {
|
|
6
|
+
expect(isHTMLElement({})).toBe(false);
|
|
7
|
+
expect(isHTMLElement([])).toBe(false);
|
|
8
|
+
expect(isHTMLElement(null)).toBe(false);
|
|
9
|
+
expect(isHTMLElement(false)).toBe(false);
|
|
10
|
+
expect(isHTMLElement(true)).toBe(false);
|
|
11
|
+
expect(isHTMLElement(10)).toBe(false);
|
|
12
|
+
expect(isHTMLElement('<p>This is a string</p>')).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=isHTMLElement.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isHTMLElement.spec.js","sourceRoot":"src/","sources":["utils/__tests__/isHTMLElement.spec.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;IAC5D,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;IAChE,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leaflink/dom-testing-utils",
|
|
3
|
-
"version": "0.0.0-PR-215--
|
|
3
|
+
"version": "0.0.0-PR-215--a64f64f",
|
|
4
4
|
"description": "Frontend DOM testing utilities",
|
|
5
5
|
"packageManager": "pnpm@11.0.9",
|
|
6
6
|
"engines": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"scripts": {
|
|
36
|
-
"build": "tsc
|
|
36
|
+
"build": "tsc",
|
|
37
37
|
"fix": "pnpm lint --fix",
|
|
38
38
|
"lint": "eslint .",
|
|
39
39
|
"lint:commits": "commitlint",
|