@aquera/nile-elements 0.1.12 → 0.1.14
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 +7 -0
- package/dist/nile-code-editor/extensionSetup.cjs.js +5 -5
- package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -1
- package/dist/nile-code-editor/extensionSetup.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +3 -3
- package/dist/nile-code-editor/theme.cjs.js +1 -1
- package/dist/nile-code-editor/theme.cjs.js.map +1 -1
- package/dist/nile-code-editor/theme.esm.js +1 -1
- package/dist/nile-form-help-text/index.cjs.js +1 -1
- package/dist/nile-form-help-text/index.esm.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.cjs.js.map +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.css.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.css.cjs.js.map +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.css.esm.js +22 -6
- package/dist/nile-form-help-text/nile-form-help-text.esm.js +20 -16
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js.map +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
- package/dist/src/nile-code-editor/extensionSetup.js +1 -3
- package/dist/src/nile-code-editor/extensionSetup.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +5 -0
- package/dist/src/nile-code-editor/nile-code-editor.js +32 -2
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-code-editor/theme.d.ts +24 -0
- package/dist/src/nile-code-editor/theme.js +24 -0
- package/dist/src/nile-code-editor/theme.js.map +1 -1
- package/dist/src/nile-form-help-text/nile-form-help-text.css.js +22 -6
- package/dist/src/nile-form-help-text/nile-form-help-text.css.js.map +1 -1
- package/dist/src/nile-form-help-text/nile-form-help-text.d.ts +13 -10
- package/dist/src/nile-form-help-text/nile-form-help-text.js +61 -82
- package/dist/src/nile-form-help-text/nile-form-help-text.js.map +1 -1
- package/dist/src/nile-form-help-text/nile-form-help-text.test.js +73 -52
- package/dist/src/nile-form-help-text/nile-form-help-text.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-code-editor/extensionSetup.ts +0 -6
- package/src/nile-code-editor/nile-code-editor.ts +34 -2
- package/src/nile-code-editor/theme.ts +28 -0
- package/src/nile-form-help-text/nile-form-help-text.css.ts +22 -6
- package/src/nile-form-help-text/nile-form-help-text.test.ts +83 -59
- package/src/nile-form-help-text/nile-form-help-text.ts +64 -82
- package/vscode-html-custom-data.json +2 -14
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-form-help-text.js","sourceRoot":"","sources":["../../../src/nile-form-help-text/nile-form-help-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,UAAU,EAAE,IAAI,
|
1
|
+
{"version":3,"file":"nile-form-help-text.js","sourceRoot":"","sources":["../../../src/nile-form-help-text/nile-form-help-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,UAAU,EAAE,IAAI,EAAkC,OAAO,EAAiB,MAAM,KAAK,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAC,MAAM,EAAC,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD;;;;;GAKG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QASwC,eAAU,GAAY,KAAK,CA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IAED;;;OAGG;IACH,kBAAkB,CAAC,OAAmB;QAEpC,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;YAClD,KAAK,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC;gBACzC,IAAI,QAAQ;oBAAE,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAChD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEhC,OAAO,cAAc,CAAC,CAAC,mDAAmD;IAC5E,CAAC;CACF,CAAA;AAlF8C;IAA5C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAG,CAAC;oDAA6B;AAEhE;IAAR,KAAK,EAAE;oDAA6B;AAET;IAA3B,KAAK,CAAC,mBAAmB,CAAC;uDAA+B;AAb/C,gBAAgB;IAD5B,aAAa,CAAC,qBAAqB,CAAC;GACxB,gBAAgB,CA2F5B;;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {LitElement, html, CSSResultArray, TemplateResult, nothing, PropertyValues} from 'lit';\nimport { customElement, query, property, state } from 'lit/decorators.js';\nimport {styles} from './nile-form-help-text.css';\nimport { classMap } from 'lit/directives/class-map.js';\n\n/**\n * Nile icon component.\n *\n * @tag nile-form-help-text\n *\n */\n@customElement('nile-form-help-text')\nexport class NileFormHelpText extends LitElement {\n /**\n * The styles for FormHelpText\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean, reflect: true }) isExpanded: boolean = false;\n\n @state() showButton: boolean = false;\n\n @query('.help__text__full') textContainer:HTMLSpanElement;\n\n private resizeObserver:ResizeObserver;\n\n /* #endregion */\n\n /* #region Methods */\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n this.resizeObserver=this.observeWidthChange(this.textContainer);\n }\n\n disconnectedCallback(): void {\n this.resizeObserver.disconnect();\n }\n\n /**\n * Render method\n * @slot This is a slot test\n */\n public render(): TemplateResult {\n const iconName = this.isExpanded ? 'arrowup' : 'arrowdown';\n\n return html`\n <div \n class=\"${classMap({\n 'nile-form-help-text':true,\n \"nile-form-help-text--expanded\":this.isExpanded\n })}\" \n part=\"container\"\n >\n <span\n class=\"${classMap({\n \"help__text__full\":true,\n \"help__text__full--expanded\":this.isExpanded\n })}\"\n >\n <slot @slotchange=\"${this.decideToToggleShowButton}\"></slot>\n </span>\n ${this.showButton?html`\n <span\n class=\"nile-form-help-text__more-button\"\n part=\"toggle-button\"\n @click=${this.toggleExpanded}\n >${this.isExpanded ? 'View Less' : 'View More'}\n <nile-icon color=\"#005EA6\" part=\"icon\" size=\"14\" name=\"${iconName}\"></nile-icon>\n </span>\n `:nothing}\n </div>\n `;\n }\n\n toggleExpanded() {\n this.isExpanded = !this.isExpanded;\n }\n \n decideToToggleShowButton(){\n if(!this.textContainer) return;\n this.showButton=this.textContainer.clientWidth<this.textContainer.scrollWidth\n }\n\n /**\n * Logs whenever the width of an element changes.\n * @param {HTMLElement} element - The element to observe for width changes.\n */\n observeWidthChange(element:HTMLElement) {\n\n const resizeObserver = new ResizeObserver(entries => {\n for (let entry of entries) {\n const newWidth = entry.contentRect.width;\n if (newWidth) this.decideToToggleShowButton();\n }\n });\n\n resizeObserver.observe(element);\n\n return resizeObserver; // Return observer to allow disconnection if needed\n }\n}\n\nexport default NileFormHelpText;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-form-help-text': NileFormHelpText;\n }\n}"]}
|
@@ -1,67 +1,88 @@
|
|
1
|
-
import { fixture, expect, html } from '@open-wc/testing';
|
1
|
+
import { fixture, expect, html, elementUpdated } from '@open-wc/testing';
|
2
2
|
import './nile-form-help-text';
|
3
|
+
import { NileFormHelpText } from './nile-form-help-text';
|
3
4
|
const wait = (ms = 50000) => new Promise(resolve => setTimeout(resolve, ms));
|
4
5
|
describe('NileFormHelpText', () => {
|
5
6
|
it('should render with default properties', async () => {
|
6
|
-
const el = await fixture(html `<nile-form-help-text>This is a
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
const el = await fixture(html `<nile-form-help-text>This is a short text</nile-form-help-text>`);
|
8
|
+
expect(el).to.be.instanceOf(NileFormHelpText);
|
9
|
+
expect(el.isExpanded).to.be.false;
|
10
|
+
// Check if text content matches
|
11
|
+
const textContent = el?.textContent?.trim();
|
12
|
+
expect(textContent).to.equal('This is a short text');
|
10
13
|
});
|
11
|
-
it('should
|
12
|
-
const
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
expect(
|
17
|
-
|
18
|
-
|
14
|
+
it('should not show "View More" button if the text fits within the container', async () => {
|
15
|
+
const el = await fixture(html `<nile-form-help-text>This is a short text</nile-form-help-text>`);
|
16
|
+
await elementUpdated(el);
|
17
|
+
const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');
|
18
|
+
expect(moreButton).to.be.null;
|
19
|
+
expect(el.showButton).to.be.false;
|
20
|
+
});
|
21
|
+
it('should show "View More" button if the text overflows the container', async () => {
|
22
|
+
const longText = 'This is a very long help text that exceeds the container width and should show a "View More" button.';
|
23
|
+
const el = await fixture(html `<nile-form-help-text>${longText}</nile-form-help-text>`);
|
24
|
+
// Simulate overflow
|
25
|
+
const textContainer = el.shadowRoot?.querySelector('.help__text__full');
|
26
|
+
Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });
|
27
|
+
Object.defineProperty(textContainer, 'clientWidth', { value: 200 });
|
28
|
+
el.decideToToggleShowButton();
|
29
|
+
await elementUpdated(el);
|
30
|
+
const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');
|
19
31
|
expect(moreButton).to.exist;
|
20
|
-
expect(
|
32
|
+
expect(el.showButton).to.be.true;
|
21
33
|
});
|
22
34
|
it('should expand to show full text when "View More" is clicked', async () => {
|
23
|
-
const longText =
|
24
|
-
const el = await fixture(html `<nile-form-help-text
|
25
|
-
// Simulate
|
26
|
-
const
|
35
|
+
const longText = 'This is a very long help text that exceeds the container width and should show a "View More" button.';
|
36
|
+
const el = await fixture(html `<nile-form-help-text>${longText}</nile-form-help-text>`);
|
37
|
+
// Simulate overflow
|
38
|
+
const textContainer = el.shadowRoot?.querySelector('.help__text__full');
|
39
|
+
Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });
|
40
|
+
Object.defineProperty(textContainer, 'clientWidth', { value: 200 });
|
41
|
+
el.decideToToggleShowButton();
|
42
|
+
await elementUpdated(el);
|
43
|
+
// Click "View More"
|
44
|
+
const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');
|
27
45
|
moreButton?.click();
|
28
|
-
await el
|
29
|
-
|
30
|
-
|
31
|
-
expect(textContent).to.
|
32
|
-
// Check if the "View Less" button is now visible
|
33
|
-
const lessButton = el.shadowRoot.querySelector('.nile-form-help-text__more-button');
|
34
|
-
expect(lessButton).to.exist;
|
35
|
-
expect(lessButton?.textContent).to.include('View Less');
|
46
|
+
await elementUpdated(el);
|
47
|
+
expect(el.isExpanded).to.be.true;
|
48
|
+
expect(textContainer).to.have.class('help__text__full--expanded');
|
49
|
+
expect(moreButton?.textContent).to.include('View Less');
|
36
50
|
});
|
37
51
|
it('should collapse back to truncated text when "View Less" is clicked', async () => {
|
38
|
-
const longText =
|
39
|
-
const el = await fixture(html `<nile-form-help-text
|
40
|
-
//
|
41
|
-
const
|
52
|
+
const longText = 'This is a very long help text that exceeds the container width and should show a "View More" button.';
|
53
|
+
const el = await fixture(html `<nile-form-help-text>${longText}</nile-form-help-text>`);
|
54
|
+
// Simulate overflow
|
55
|
+
const textContainer = el.shadowRoot?.querySelector('.help__text__full');
|
56
|
+
Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });
|
57
|
+
Object.defineProperty(textContainer, 'clientWidth', { value: 200 });
|
58
|
+
el.decideToToggleShowButton();
|
59
|
+
await elementUpdated(el);
|
60
|
+
// Expand and then collapse
|
61
|
+
const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');
|
42
62
|
moreButton?.click();
|
43
|
-
await el
|
44
|
-
// Collapse
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
const textContent = el.shadowRoot.querySelector('div>span:first-child')?.textContent?.trim();
|
50
|
-
expect(textContent?.endsWith('...')).to.be.true;
|
51
|
-
// Check if the "View More" button is visible again
|
52
|
-
const viewMoreButton = el.shadowRoot.querySelector('.nile-form-help-text__more-button');
|
53
|
-
expect(viewMoreButton).to.exist;
|
54
|
-
expect(viewMoreButton?.textContent).to.include('View More');
|
55
|
-
});
|
56
|
-
it('should not show "View More" button when text is within limit', async () => {
|
57
|
-
const shortText = "Short help text.";
|
58
|
-
const el = await fixture(html `<nile-form-help-text><span>${shortText}</span></nile-form-help-text>`);
|
59
|
-
// Check if the displayed text is not truncated
|
60
|
-
const textContent = el.shadowRoot.querySelector('div>span:first-child')?.textContent?.trim();
|
61
|
-
expect(textContent).to.equal(shortText);
|
62
|
-
// Verify that "View More" button is not rendered
|
63
|
-
const moreButton = el.shadowRoot.querySelector('.nile-form-help-text__more-button');
|
64
|
-
expect(moreButton).to.be.null;
|
63
|
+
await elementUpdated(el);
|
64
|
+
moreButton?.click(); // Collapse
|
65
|
+
await elementUpdated(el);
|
66
|
+
expect(el.isExpanded).to.be.false;
|
67
|
+
expect(textContainer).not.to.have.class('help__text__full--expanded');
|
68
|
+
expect(moreButton?.textContent).to.include('View More');
|
65
69
|
});
|
70
|
+
// it('should dynamically adjust "View More" visibility on text change', async () => {
|
71
|
+
// const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>Initial text</nile-form-help-text>`);
|
72
|
+
// await elementUpdated(el);
|
73
|
+
// const textContainer = el.shadowRoot?.querySelector('.help__text__full') as HTMLSpanElement;
|
74
|
+
// Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });
|
75
|
+
// Object.defineProperty(textContainer, 'clientWidth', { value: 200 });
|
76
|
+
// el.decideToToggleShowButton();
|
77
|
+
// await elementUpdated(el);
|
78
|
+
// expect(el.showButton).to.be.true;
|
79
|
+
// // Change slot content to short text
|
80
|
+
// textContainer.textContent = 'Short text';
|
81
|
+
// Object.defineProperty(textContainer, 'scrollWidth', { value: 100 });
|
82
|
+
// Object.defineProperty(textContainer, 'clientWidth', { value: 200 });
|
83
|
+
// el.decideToToggleShowButton();
|
84
|
+
// await elementUpdated(el);
|
85
|
+
// expect(el.showButton).to.be.false;
|
86
|
+
// });
|
66
87
|
});
|
67
88
|
//# sourceMappingURL=nile-form-help-text.test.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-form-help-text.test.js","sourceRoot":"","sources":["../../../src/nile-form-help-text/nile-form-help-text.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"nile-form-help-text.test.js","sourceRoot":"","sources":["../../../src/nile-form-help-text/nile-form-help-text.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,IAAI,GAAG,CAAC,KAAa,KAAK,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAGpF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAmB,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AAE,WAAW,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,sFAAsF;IACtF,+GAA+G;IAC/G,8BAA8B;IAE9B,gGAAgG;IAChG,yEAAyE;IACzE,yEAAyE;IACzE,mCAAmC;IACnC,8BAA8B;IAE9B,sCAAsC;IAEtC,yCAAyC;IACzC,8CAA8C;IAC9C,yEAAyE;IACzE,yEAAyE;IACzE,mCAAmC;IACnC,8BAA8B;IAE9B,uCAAuC;IACvC,MAAM;AACR,CAAC,CAAC,CAAC","sourcesContent":["import { fixture, expect, html, elementUpdated } from '@open-wc/testing';\nimport './nile-form-help-text';\nimport { NileFormHelpText } from './nile-form-help-text';\n\nconst wait = (ms: number = 50000) => new Promise(resolve => setTimeout(resolve, ms))\n\n\ndescribe('NileFormHelpText', () => {\n it('should render with default properties', async () => {\n const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>This is a short text</nile-form-help-text>`);\n expect(el).to.be.instanceOf(NileFormHelpText);\n expect(el.isExpanded).to.be.false;\n\n // Check if text content matches\n const textContent = el?.textContent?.trim();\n expect(textContent).to.equal('This is a short text');\n });\n\n it('should not show \"View More\" button if the text fits within the container', async () => {\n const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>This is a short text</nile-form-help-text>`);\n await elementUpdated(el);\n\n const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');\n expect(moreButton).to.be.null;\n expect(el.showButton).to.be.false;\n });\n\n it('should show \"View More\" button if the text overflows the container', async () => {\n const longText = 'This is a very long help text that exceeds the container width and should show a \"View More\" button.';\n const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>${longText}</nile-form-help-text>`);\n \n // Simulate overflow\n const textContainer = el.shadowRoot?.querySelector('.help__text__full') as HTMLSpanElement;\n Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });\n Object.defineProperty(textContainer, 'clientWidth', { value: 200 });\n el.decideToToggleShowButton();\n await elementUpdated(el);\n\n const moreButton = el.shadowRoot?.querySelector('.nile-form-help-text__more-button');\n expect(moreButton).to.exist;\n expect(el.showButton).to.be.true;\n });\n\n it('should expand to show full text when \"View More\" is clicked', async () => {\n const longText = 'This is a very long help text that exceeds the container width and should show a \"View More\" button.';\n const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>${longText}</nile-form-help-text>`);\n\n // Simulate overflow\n const textContainer = el.shadowRoot?.querySelector('.help__text__full') as HTMLSpanElement;\n Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });\n Object.defineProperty(textContainer, 'clientWidth', { value: 200 });\n el.decideToToggleShowButton();\n await elementUpdated(el);\n\n // Click \"View More\"\n const moreButton = el.shadowRoot?.querySelector<HTMLElement>('.nile-form-help-text__more-button');\n moreButton?.click();\n await elementUpdated(el);\n\n expect(el.isExpanded).to.be.true;\n expect(textContainer).to.have.class('help__text__full--expanded');\n expect(moreButton?.textContent).to.include('View Less');\n });\n\n it('should collapse back to truncated text when \"View Less\" is clicked', async () => {\n const longText = 'This is a very long help text that exceeds the container width and should show a \"View More\" button.';\n const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>${longText}</nile-form-help-text>`);\n\n // Simulate overflow\n const textContainer = el.shadowRoot?.querySelector('.help__text__full') as HTMLSpanElement;\n Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });\n Object.defineProperty(textContainer, 'clientWidth', { value: 200 });\n el.decideToToggleShowButton();\n await elementUpdated(el);\n\n // Expand and then collapse\n const moreButton = el.shadowRoot?.querySelector<HTMLElement>('.nile-form-help-text__more-button');\n moreButton?.click();\n await elementUpdated(el);\n\n moreButton?.click(); // Collapse\n await elementUpdated(el);\n\n expect(el.isExpanded).to.be.false;\n expect(textContainer).not.to.have.class('help__text__full--expanded');\n expect(moreButton?.textContent).to.include('View More');\n });\n\n // it('should dynamically adjust \"View More\" visibility on text change', async () => {\n // const el = await fixture<NileFormHelpText>(html`<nile-form-help-text>Initial text</nile-form-help-text>`);\n // await elementUpdated(el);\n\n // const textContainer = el.shadowRoot?.querySelector('.help__text__full') as HTMLSpanElement;\n // Object.defineProperty(textContainer, 'scrollWidth', { value: 300 });\n // Object.defineProperty(textContainer, 'clientWidth', { value: 200 });\n // el.decideToToggleShowButton();\n // await elementUpdated(el);\n\n // expect(el.showButton).to.be.true;\n\n // // Change slot content to short text\n // textContainer.textContent = 'Short text';\n // Object.defineProperty(textContainer, 'scrollWidth', { value: 100 });\n // Object.defineProperty(textContainer, 'clientWidth', { value: 200 });\n // el.decideToToggleShowButton();\n // await elementUpdated(el);\n\n // expect(el.showButton).to.be.false;\n // });\n});\n"]}
|