Skip to content
This repository was archived by the owner on Nov 1, 2017. It is now read-only.

Commit ff954fd

Browse files
committed
Add failing test for task list updates on links
1 parent 7c8d7d1 commit ff954fd

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

test/unit/test_updates.coffee

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,69 @@ asyncTest "update ignores items that look like Task List items but lack list pre
440440
, 20
441441

442442
item2Checkbox.click()
443+
444+
asyncTest "update ignores items that look like Task List items but are links", ->
445+
expect 3
446+
447+
$('#qunit-fixture').empty()
448+
449+
container = $ '<div>', class: 'js-task-list-container'
450+
451+
list = $ '<ul>', class: 'task-list'
452+
453+
item1 = $ '<li>', class: 'task-list-item'
454+
item1Checkbox = $ '<input>',
455+
type: 'checkbox'
456+
class: 'task-list-item-checkbox'
457+
disabled: true
458+
checked: false
459+
460+
item2 = $ '<li>', class: 'task-list-item'
461+
item2Checkbox = $ '<input>',
462+
type: 'checkbox'
463+
class: 'task-list-item-checkbox'
464+
disabled: true
465+
checked: false
466+
467+
field = $ '<textarea>', class: 'js-task-list-field', text: """
468+
- [ ] (link)
469+
- [ ] [reference]
470+
- [ ] () collapsed
471+
- [ ] [] collapsed reference
472+
- [ ] \(escaped item)
473+
- [ ] item
474+
"""
475+
476+
changes = """
477+
- [ ] (link)
478+
- [ ] [reference]
479+
- [ ] () collapsed
480+
- [ ] [] collapsed reference
481+
- [ ] \(escaped item)
482+
- [x] item
483+
"""
484+
485+
item1.append item2Checkbox
486+
list.append item1
487+
item1.expectedIndex = 1
488+
489+
item2.append item2Checkbox
490+
list.append item2
491+
item2.expectedIndex = 2
492+
493+
container.append list
494+
container.append field
495+
496+
$('#qunit-fixture').append(container)
497+
container.taskList()
498+
499+
field.on 'tasklist:changed', (event, index, checked) =>
500+
ok checked
501+
equal index, item2.expectedIndex
502+
equal field.val(), changes
503+
504+
setTimeout ->
505+
start()
506+
, 20
507+
508+
item2Checkbox.click()

0 commit comments

Comments
 (0)