Skip to content

Commit

Permalink
Add test for mixed task list position
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-mig authored and Kristján Oddsson committed Aug 31, 2021
1 parent 3eba7a6 commit b80d309
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ describe('task-lists element', function () {
</ul>
</li>
</ol>
<ul class="contains-task-list">
<li class="task-list-item">
<label>
<input type="checkbox" class="task-list-item-checkbox">
R2-D2
</label>
</li>
<li>bam</li>
<li class="task-list-item">
<label>
<input id="c3po" type="checkbox" class="task-list-item-checkbox">
C-3PO
</label>
</li>
</ul>
</task-lists>`
document.body.append(container)
})
Expand Down Expand Up @@ -100,5 +116,23 @@ describe('task-lists element', function () {

assert(called)
})

it('emits check event with the right position for mixed task list', function () {
let called = false

const list = document.querySelector('task-lists')
list.addEventListener('task-lists-check', function (event) {
called = true
const {position, checked} = event.detail
assert.deepEqual(position, [5, 2])
assert(checked)
})

const checkbox = document.querySelector('#c3po')
checkbox.checked = true
checkbox.dispatchEvent(new CustomEvent('change', {bubbles: true}))

assert(called)
})
})
})

0 comments on commit b80d309

Please sign in to comment.