Skip to content

Commit 4fa8d9a

Browse files
committed
Add test for nested task-list-item
1 parent 3f9dd49 commit 4fa8d9a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ describe('task-lists element', function() {
3434
<input id="wall-e" type="checkbox" class="task-list-item-checkbox"> WALL-E
3535
</li>
3636
</ul>
37+
<ul>
38+
<li>
39+
<ul class="contains-task-list">
40+
<li class="task-list-item">
41+
<input id="baymax" type="checkbox" class="task-list-item-checkbox"> Baymax
42+
</li>
43+
</ul>
44+
</li>
45+
</ul>
3746
</task-lists>`
3847
document.body.append(container)
3948
})
@@ -59,5 +68,23 @@ describe('task-lists element', function() {
5968

6069
assert(called)
6170
})
71+
72+
it('emits check event with the right position for nested task list item', function() {
73+
let called = false
74+
75+
const list = document.querySelector('task-lists')
76+
list.addEventListener('task-lists:check', function(event) {
77+
called = true
78+
const {position, checked} = event.detail
79+
assert.deepEqual(position, [3, 0])
80+
assert(checked)
81+
})
82+
83+
const checkbox = document.querySelector('#baymax')
84+
checkbox.checked = true
85+
checkbox.dispatchEvent(new CustomEvent('change', {bubbles: true}))
86+
87+
assert(called)
88+
})
6289
})
6390
})

0 commit comments

Comments
 (0)