@operato/popup 10.29.39 → 10.29.40

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.
@@ -0,0 +1,38 @@
1
+ import { expect, fixture } from '@open-wc/testing'
2
+ import { html, render } from 'lit'
3
+
4
+ import '../src/ox-popup-list.js'
5
+ import type { OxPopupList } from '../src/ox-popup-list.js'
6
+
7
+ /**
8
+ * A value can arrive before the options that hold it - a filter's year choices are read from the server after the
9
+ * address has named the year. The list marked its choice only when its value changed, so options that came later were
10
+ * never marked: the dropdown opened with nothing chosen, and its owner showed the raw value.
11
+ */
12
+ describe('ox-popup-list with options that arrive after its value', () => {
13
+ const chosen = (list: OxPopupList) =>
14
+ Array.from(list.querySelectorAll('[option]'))
15
+ .filter(option => option.hasAttribute('selected'))
16
+ .map(option => option.getAttribute('value'))
17
+
18
+ it('marks the option of its value once that option arrives', async () => {
19
+ const list = await fixture<OxPopupList>(html`<ox-popup-list></ox-popup-list>`)
20
+ list.value = '2026'
21
+ await list.updateComplete
22
+ render(html`<div option value="2027">2027</div><div option value="2026">2026</div>`, list)
23
+ await new Promise(resolve => setTimeout(resolve))
24
+ await list.updateComplete
25
+ expect(chosen(list)).to.deep.equal(['2026'])
26
+ })
27
+
28
+ it('tells its owner the options changed, after marking them', async () => {
29
+ const list = await fixture<OxPopupList>(html`<ox-popup-list></ox-popup-list>`)
30
+ list.value = '10'
31
+ await list.updateComplete
32
+ let labels: unknown
33
+ list.addEventListener('options-change', () => (labels = list.getSelectedLabels()))
34
+ render(html`<div option value="9">9월</div><div option value="10">10월</div>`, list)
35
+ await new Promise(resolve => setTimeout(resolve))
36
+ expect(labels).to.equal('10월')
37
+ })
38
+ })