@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.
- package/CHANGELOG.md +9 -0
- package/coverage/lcov-report/index.html +29 -29
- package/coverage/lcov.info +27778 -26586
- package/dist/src/ox-popup-list.d.ts +7 -0
- package/dist/src/ox-popup-list.js +26 -14
- package/dist/src/ox-popup-list.js.map +1 -1
- package/dist/test/ox-popup-list-late-options.test.d.ts +1 -0
- package/dist/test/ox-popup-list-late-options.test.js +33 -0
- package/dist/test/ox-popup-list-late-options.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/test/ox-popup-list-late-options.test.ts +38 -0
|
@@ -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
|
+
})
|