@operato/utils 10.7.0 → 10.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +328 -0
- package/dist/src/has-overflow.js +23 -1
- package/dist/src/has-overflow.js.map +1 -1
- package/dist/src/reactive-controllers/tooltip-reactive-controller.js +16 -3
- package/dist/src/reactive-controllers/tooltip-reactive-controller.js.map +1 -1
- package/dist/test/has-overflow.test.d.ts +1 -0
- package/dist/test/has-overflow.test.js +49 -0
- package/dist/test/has-overflow.test.js.map +1 -0
- package/dist/test/tooltip-reactive-controller.test.d.ts +1 -0
- package/dist/test/tooltip-reactive-controller.test.js +78 -0
- package/dist/test/tooltip-reactive-controller.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/test/has-overflow.test.ts +61 -0
- package/test/tooltip-reactive-controller.test.ts +88 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { expect, fixture, html, waitUntil } from '@open-wc/testing'
|
|
2
|
+
import { LitElement, html as litHtml } from 'lit'
|
|
3
|
+
import { customElement } from 'lit/decorators.js'
|
|
4
|
+
|
|
5
|
+
import { TooltipReactiveController } from '../src/reactive-controllers/tooltip-reactive-controller.js'
|
|
6
|
+
|
|
7
|
+
const LONG = 'CAM-LEAK-VISUAL-INSPECTION-STATION-284-AND-THEN-SOME'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A row of the shape hosts actually draw: a marker, a prefix and the title, each in its own
|
|
11
|
+
* span. The pointer lands on one of those children, never on the row itself - on the plant
|
|
12
|
+
* calendar the title span alone covers 104 of the row's 114px.
|
|
13
|
+
*/
|
|
14
|
+
@customElement('tooltip-host-fixture')
|
|
15
|
+
class TooltipHostFixture extends LitElement {
|
|
16
|
+
/*
|
|
17
|
+
* The content function the plant calendar passes: the host writes the sentence it wants read
|
|
18
|
+
* into the attribute, which is more than the row's own cut text.
|
|
19
|
+
*/
|
|
20
|
+
tooltip = new TooltipReactiveController(this, {
|
|
21
|
+
enterDelay: 0,
|
|
22
|
+
content: element => element.getAttribute('data-reactive-tooltip') || element.textContent?.trim() || ''
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
render() {
|
|
26
|
+
return litHtml`
|
|
27
|
+
<div
|
|
28
|
+
data-reactive-tooltip="the whole sentence"
|
|
29
|
+
style="display:flex; gap:4px; width:60px; overflow:hidden; white-space:nowrap"
|
|
30
|
+
>
|
|
31
|
+
<span mark style="flex:none; width:6px; height:6px"></span>
|
|
32
|
+
<span title-part style="overflow:hidden; text-overflow:ellipsis">${LONG}</span>
|
|
33
|
+
</div>
|
|
34
|
+
`
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function box(): HTMLElement {
|
|
39
|
+
return document.querySelector('.ox-tooltip-container') as HTMLElement
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function hover(el: Element) {
|
|
43
|
+
el.dispatchEvent(new MouseEvent('mouseover', { bubbles: true, composed: true }))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('TooltipReactiveController', () => {
|
|
47
|
+
let host: TooltipHostFixture
|
|
48
|
+
|
|
49
|
+
beforeEach(async () => {
|
|
50
|
+
host = (await fixture(html`<tooltip-host-fixture></tooltip-host-fixture>`)) as TooltipHostFixture
|
|
51
|
+
box().style.display = 'none'
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('shows when the pointer is over a child of the marked row', async () => {
|
|
55
|
+
/*
|
|
56
|
+
* The regression this file exists for. The controller read the attribute off e.target, and
|
|
57
|
+
* the pointer is over a child for all but a few pixels of the row - so the tooltip never
|
|
58
|
+
* appeared on the plant calendar, on any row.
|
|
59
|
+
*/
|
|
60
|
+
hover(host.shadowRoot!.querySelector('[title-part]')!)
|
|
61
|
+
|
|
62
|
+
await waitUntil(() => box().style.display === 'block')
|
|
63
|
+
expect(box().textContent).to.equal('the whole sentence')
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('shows when the pointer is over the marked row itself', async () => {
|
|
67
|
+
hover(host.shadowRoot!.querySelector('[data-reactive-tooltip]')!)
|
|
68
|
+
|
|
69
|
+
await waitUntil(() => box().style.display === 'block')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('reads the attribute of the marked ancestor, not the child under the pointer', async () => {
|
|
73
|
+
hover(host.shadowRoot!.querySelector('[mark]')!)
|
|
74
|
+
|
|
75
|
+
await waitUntil(() => box().style.display === 'block')
|
|
76
|
+
expect(box().textContent, 'the marker span holds no text of its own').to.equal('the whole sentence')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('stays hidden when nothing in the ancestry is marked', async () => {
|
|
80
|
+
const plain = (await fixture(html`<span>${LONG}</span>`)) as HTMLElement
|
|
81
|
+
host.shadowRoot!.appendChild(plain)
|
|
82
|
+
|
|
83
|
+
hover(plain)
|
|
84
|
+
|
|
85
|
+
await new Promise(resolve => setTimeout(resolve, 50))
|
|
86
|
+
expect(box().style.display).to.equal('none')
|
|
87
|
+
})
|
|
88
|
+
})
|