Skip to content

Commit b80d309

Browse files
mr-migKristján Oddsson
authored and
Kristján Oddsson
committed
Add test for mixed task list position
1 parent 3eba7a6 commit b80d309

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Diff for: test/test.js

+34
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ describe('task-lists element', function () {
5757
</ul>
5858
</li>
5959
</ol>
60+
61+
<ul class="contains-task-list">
62+
<li class="task-list-item">
63+
<label>
64+
<input type="checkbox" class="task-list-item-checkbox">
65+
R2-D2
66+
</label>
67+
</li>
68+
<li>bam</li>
69+
<li class="task-list-item">
70+
<label>
71+
<input id="c3po" type="checkbox" class="task-list-item-checkbox">
72+
C-3PO
73+
</label>
74+
</li>
75+
</ul>
6076
</task-lists>`
6177
document.body.append(container)
6278
})
@@ -100,5 +116,23 @@ describe('task-lists element', function () {
100116

101117
assert(called)
102118
})
119+
120+
it('emits check event with the right position for mixed task list', function () {
121+
let called = false
122+
123+
const list = document.querySelector('task-lists')
124+
list.addEventListener('task-lists-check', function (event) {
125+
called = true
126+
const {position, checked} = event.detail
127+
assert.deepEqual(position, [5, 2])
128+
assert(checked)
129+
})
130+
131+
const checkbox = document.querySelector('#c3po')
132+
checkbox.checked = true
133+
checkbox.dispatchEvent(new CustomEvent('change', {bubbles: true}))
134+
135+
assert(called)
136+
})
103137
})
104138
})

0 commit comments

Comments
 (0)