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

Commit 2cf203e

Browse files
committed
failing test for updates
1 parent 0a37f25 commit 2cf203e

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#= require task_list
2+
3+
module "Blockquoted TaskList updates",
4+
setup: ->
5+
@blockquote = $ '<blockquote>'
6+
7+
@container = $ '<div>', class: 'js-task-list-container'
8+
9+
@list = $ '<ul>', class: 'task-list'
10+
11+
@completeItem = $ '<li>', class: 'task-list-item'
12+
@completeCheckbox = $ '<input>',
13+
type: 'checkbox'
14+
class: 'task-list-item-checkbox'
15+
disabled: true
16+
checked: true
17+
18+
@incompleteItem = $ '<li>', class: 'task-list-item'
19+
@incompleteCheckbox = $ '<input>',
20+
type: 'checkbox'
21+
class: 'task-list-item-checkbox'
22+
disabled: true
23+
checked: false
24+
25+
@field = $ '<textarea>', class: 'js-task-list-field', text: """
26+
> - [x] complete
27+
> - [ ] incomplete
28+
"""
29+
30+
@changes =
31+
toComplete: """
32+
> - [ ] complete
33+
> - [ ] incomplete
34+
"""
35+
toIncomplete: """
36+
> - [x] complete
37+
> - [x] incomplete
38+
"""
39+
40+
@completeItem.append @completeCheckbox
41+
@list.append @completeItem
42+
@completeItem.expectedIndex = 1
43+
44+
@incompleteItem.append @incompleteCheckbox
45+
@list.append @incompleteItem
46+
@incompleteItem.expectedIndex = 2
47+
48+
@container.append @list
49+
@container.append @field
50+
51+
@blockquote.append @container
52+
53+
$('#qunit-fixture').append(@blockquote)
54+
@container.taskList()
55+
56+
teardown: ->
57+
$(document).off 'tasklist:changed'
58+
59+
asyncTest "updates the source, marking the incomplete item as complete", ->
60+
expect 3
61+
62+
@field.on 'tasklist:changed', (event, index, checked) =>
63+
ok checked
64+
equal index, @incompleteItem.expectedIndex
65+
equal @field.val(), @changes.toIncomplete
66+
67+
setTimeout ->
68+
start()
69+
, 20
70+
71+
@incompleteCheckbox.click()
72+
73+
asyncTest "updates the source, marking the complete item as incomplete", ->
74+
expect 3
75+
76+
@field.on 'tasklist:changed', (event, index, checked) =>
77+
ok !checked
78+
equal index, @completeItem.expectedIndex
79+
equal @field.val(), @changes.toComplete
80+
81+
setTimeout ->
82+
start()
83+
, 20
84+
85+
@completeCheckbox.click()

0 commit comments

Comments
 (0)