deckar01-task_list 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebe3bef10b2543060da20d370caf02673c1f682b
4
- data.tar.gz: b1dd8cedf1c8a33d2136deb814e2f357d04bc7a3
3
+ metadata.gz: 34a7ec4b58a3243088a56807c0768fad5b43b74e
4
+ data.tar.gz: ca0e0a25dd71df16347cb2454ee979d0f77060cd
5
5
  SHA512:
6
- metadata.gz: d187b31dcd76cafc0ba685ec87595baccd7d2dd278c52e6d0da320d77e9503a630c0ee3f2a7697596a756249433f5910abdfd83633981a955bce99df3b249550
7
- data.tar.gz: 68be28b14fae6684279ba42fda7e086e2a424692c7cdc455e2cfd12dfc6dd26c801c43b6acc468074d11f7138410be1938993843d44aed81a4ce8211b9ee440a
6
+ metadata.gz: 7f48d4b5e01192b512b838d62d5bf2812b473fd5cb2b2d95317351e808ad13caf0cf92493fc76d1f9f02ff255d407a4336a13601f4bf6b4a2290249cb0ce8e87
7
+ data.tar.gz: 8821d7ec5c29e6629db2b8263ffde6919efe08727e9e6739c0eae84ec1f3ed575da5c9079b62471a41e655dd25620307f102ff40d42e7c77133e89f893a0a2c0
data/.travis.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  language: ruby
2
2
  sudo: false
3
+ addons:
4
+ chrome: stable
3
5
  install:
4
6
  - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
5
7
  - ./script/bootstrap
@@ -9,6 +11,6 @@ rvm:
9
11
  - 2.1
10
12
  - 2.2
11
13
  env:
12
- - TRAVIS_NODE_VERSION="7"
14
+ - TRAVIS_NODE_VERSION="11"
13
15
  notifications:
14
16
  email: false
data/README.md CHANGED
@@ -144,6 +144,14 @@ At a high level, the Ruby components integrate with the [`html-pipeline`](https:
144
144
 
145
145
  [A polyfill for custom events](https://github.com/krambuhl/custom-event-polyfill) must be included to support IE10 and below.
146
146
 
147
+ ### Known issues
148
+
149
+ The markdown parser used on the front end produces false positives when looking for checkboxes
150
+ in some complex nesting situations. To combat this issue, you can enable the `sourcepos` option
151
+ in your markdown parser. This will avoid parsing the markdown on the front end, because the line
152
+ numbers will be provided as attributes on the HTML elements. `task_list` checks for the source
153
+ position attribute and falls back to manually parsing the markown when needed.
154
+
147
155
  ### Upgrading
148
156
 
149
157
  #### 1.x to 2.x
@@ -150,7 +150,7 @@ class TaskList
150
150
 
151
151
  unless changeEvent.defaultPrevented
152
152
  { result, lineNumber, lineSource } =
153
- TaskList.updateSource(@field.value, index, item.checked)
153
+ TaskList.updateSource(@field.value, index, item.checked, item)
154
154
 
155
155
  @field.value = result
156
156
  changeEvent = createEvent 'change'
@@ -220,16 +220,46 @@ class TaskList
220
220
  # given checked value.
221
221
  #
222
222
  # Returns the updated String text.
223
- @updateSource: (source, itemIndex, checked) ->
223
+ @updateSource: (source, itemIndex, checked, item) ->
224
+ if item.parentElement.hasAttribute('data-sourcepos')
225
+ @_updateSourcePosition(source, item, checked)
226
+ else
227
+ @_updateSourceRegex(source, itemIndex, checked)
228
+
229
+ # If we have sourcepos information, that tells us which line the task
230
+ # is on without the need for parsing
231
+ @_updateSourcePosition: (source, item, checked) ->
232
+ result = source.split("\n")
233
+ sourcepos = item.parentElement.getAttribute('data-sourcepos')
234
+ lineNumber = parseInt(sourcepos.split(":")[0])
235
+ lineSource = result[lineNumber - 1]
236
+
237
+ line =
238
+ if checked
239
+ lineSource.replace(@incompletePattern, @complete)
240
+ else
241
+ lineSource.replace(@completePattern, @incomplete)
242
+
243
+ result[lineNumber - 1] = line
244
+
245
+ return {
246
+ result: result.join("\n")
247
+ lineNumber: lineNumber
248
+ lineSource: lineSource
249
+ }
250
+
251
+ @_updateSourceRegex: (source, itemIndex, checked) ->
252
+ split_source = source.split("\n")
253
+ lineNumber
254
+ lineSource
255
+
224
256
  clean = source.replace(/\r/g, '').
225
257
  replace(@itemsInParasPattern, '').
226
258
  split("\n")
227
259
  index = 0
228
260
  inCodeBlock = false
229
- lineNumber
230
- lineSource
231
261
 
232
- result = for line, i in source.split("\n")
262
+ result = for line, i in split_source
233
263
  if inCodeBlock
234
264
  # Lines inside of a code block are ignored.
235
265
  if line.match(@endFencesPattern)
@@ -249,6 +279,7 @@ class TaskList
249
279
  else
250
280
  line.replace(@completePattern, @incomplete)
251
281
  line
282
+
252
283
  return {
253
284
  result: result.join("\n")
254
285
  lineNumber: lineNumber
@@ -1,3 +1,3 @@
1
1
  class TaskList
2
- VERSION = [2, 2, 1].join('.')
2
+ VERSION = [2, 3, 0].join('.')
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deckar01-task_list",
3
- "version": "2.2.1",
3
+ "version": "2.3.0",
4
4
  "description": "Markdown TaskList components",
5
5
  "main": "dist/task_list.js",
6
6
  "directories": {
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "test": "script/cibuild",
14
- "qunit": "phantomjs test/run-qunit.coffee http://localhost:4018/test/index.html",
14
+ "qunit": "karma start test/unit/config.js",
15
15
  "lint": "coffeelint app/assets/javascripts/task_list.coffee",
16
16
  "build:css": "node-sass -o dist/ app/assets/stylesheets/task_list.scss",
17
17
  "build:js": "webpack",
@@ -37,11 +37,19 @@
37
37
  "homepage": "https://github.com/deckar01/task_list#readme",
38
38
  "devDependencies": {
39
39
  "bower": "^1.8.0",
40
- "coffee-loader": "^0.7.3",
41
- "coffee-script": "^1.12.5",
40
+ "coffee-loader": "^0.9.0",
42
41
  "coffeelint": "^1.16.0",
42
+ "coffeescript": "^2.4.1",
43
+ "jquery": "^2.2.4",
44
+ "karma": "^4.4.1",
45
+ "karma-chrome-launcher": "^3.1.0",
46
+ "karma-qunit": "^4.0.0",
47
+ "karma-webpack": "^4.0.2",
43
48
  "node-sass": "^4.5.2",
44
49
  "phantomjs": "^1.9.19",
45
- "webpack": "^2.5.1"
46
- }
50
+ "qunit": "^2.9.3",
51
+ "webpack": "^4.41.2",
52
+ "webpack-cli": "^3.3.10"
53
+ },
54
+ "dependencies": {}
47
55
  }
data/script/cibuild CHANGED
@@ -3,5 +3,5 @@
3
3
  # CI build script.
4
4
 
5
5
  npm run lint
6
- ./script/testsuite 4018
6
+ npm run qunit
7
7
  bundle exec rake test
@@ -71,6 +71,7 @@
71
71
  </head>
72
72
  <body>
73
73
  <div class="js-task-list-container js-task-list-enable">
74
+ <h2>Using Regex Parsing</h2>
74
75
  <div class="markdown">
75
76
  <ul class="task-list">
76
77
  <li>
@@ -104,6 +105,41 @@
104
105
  </form>
105
106
  </div>
106
107
 
108
+ <div class="js-task-list-container js-task-list-enable">
109
+ <h2>Using CommonMark Source Positioning</h2>
110
+ <div class="markdown">
111
+ <ul class="task-list" data-sourcepos="1:1-5:27">
112
+ <li data-sourcepos="1:1-1:8">
113
+ [ ]
114
+ </li>
115
+ <li class="task-list-item" data-sourcepos="2:1-2:26">
116
+ <input type="checkbox" class="task-list-item-checkbox" disabled />
117
+ I'm a task list item
118
+ </li>
119
+ <li class="task-list-item" data-sourcepos="3:1-3:30">
120
+ <input type="checkbox" class="task-list-item-checkbox" disabled />
121
+ with non-breaking space
122
+ </li>
123
+ <li class="task-list-item" data-sourcepos="4:1-4:22">
124
+ <input type="checkbox" class="task-list-item-checkbox" disabled checked />
125
+ completed, lower
126
+ </li>
127
+ <li class="task-list-item" data-sourcepos="5:1-5:27">
128
+ <input type="checkbox" class="task-list-item-checkbox" disabled checked />
129
+ completed capitalized
130
+ </li>
131
+ </ul>
132
+ </div>
133
+ <form action="/update" method="POST" data-remote data-type="json">
134
+ <textarea name="comment[body]" class="js-task-list-field" cols="40" rows="10">
135
+ - [ ]  
136
+ - [ ] I'm a task list item
137
+ - [ ] with non-breaking space
138
+ - [x] completed, lower
139
+ - [X] completed capitalized</textarea>
140
+ </form>
141
+ </div>
142
+
107
143
  <ul class="log">
108
144
  </ul>
109
145
  </body>
@@ -0,0 +1,87 @@
1
+ // Karma configuration
2
+ // Generated on Tue Nov 12 2019 10:22:49 GMT-0600 (Central Standard Time)
3
+
4
+ module.exports = function(config) {
5
+ config.set({
6
+
7
+ // base path that will be used to resolve all patterns (eg. files, exclude)
8
+ basePath: '../..',
9
+
10
+
11
+ // frameworks to use
12
+ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13
+ frameworks: ['qunit'],
14
+
15
+
16
+ plugins: [
17
+ 'karma-qunit',
18
+ 'karma-webpack',
19
+ 'karma-chrome-launcher',
20
+ ],
21
+
22
+
23
+ // list of files / patterns to load in the browser
24
+ files: [
25
+ 'app/assets/javascripts/*.coffee',
26
+ 'test/unit/*.coffee'
27
+ ],
28
+
29
+
30
+ // list of files / patterns to exclude
31
+ exclude: [
32
+ ],
33
+
34
+
35
+ // preprocess matching files before serving them to the browser
36
+ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
37
+ preprocessors: {
38
+ '**/*.coffee': ['webpack']
39
+ },
40
+
41
+ webpack: {
42
+ ...require('../../webpack.config.js'),
43
+ mode: 'development',
44
+ },
45
+
46
+ webpackMiddleware: {
47
+ stats: 'errors-only',
48
+ },
49
+
50
+
51
+ // test results reporter to use
52
+ // possible values: 'dots', 'progress'
53
+ // available reporters: https://npmjs.org/browse/keyword/karma-reporter
54
+ reporters: ['progress'],
55
+
56
+
57
+ // web server port
58
+ port: 9876,
59
+
60
+
61
+ // enable / disable colors in the output (reporters and logs)
62
+ colors: true,
63
+
64
+
65
+ // level of logging
66
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
67
+ logLevel: config.LOG_INFO,
68
+
69
+
70
+ // enable / disable watching file and executing tests whenever any file changes
71
+ autoWatch: true,
72
+
73
+
74
+ // start these browsers
75
+ // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
76
+ browsers: ['ChromeHeadless'],
77
+
78
+
79
+ // Continuous Integration mode
80
+ // if true, Karma captures browsers, runs the tests and exits
81
+ singleRun: true,
82
+
83
+ // Concurrency level
84
+ // how many browser should be started simultaneous
85
+ concurrency: Infinity
86
+ })
87
+ }
@@ -1,8 +1,8 @@
1
- #= require jquery
2
- #= require task_list
1
+ window.$ = window.jQuery = require('jquery')
2
+ window.TaskList = require('../../app/assets/javascripts/task_list')
3
3
 
4
- module "TaskList events",
5
- setup: ->
4
+ QUnit.module "TaskList events",
5
+ beforeEach: ->
6
6
  @container = $ '<div>', class: 'js-task-list-container'
7
7
 
8
8
  @list = $ '<ul>', class: 'task-list'
@@ -24,74 +24,75 @@ module "TaskList events",
24
24
  $('#qunit-fixture').append(@container)
25
25
  @container.taskList()
26
26
 
27
- teardown: ->
27
+ afterEach: ->
28
28
  $(document).off 'tasklist:enabled'
29
29
  $(document).off 'tasklist:disabled'
30
30
  $(document).off 'tasklist:change'
31
31
  $(document).off 'tasklist:changed'
32
32
 
33
- asyncTest "triggers a tasklist:change event before making task list item changes", ->
34
- expect 1
33
+ QUnit.test "triggers a tasklist:change event before making task list item changes", (assert) ->
34
+ done = assert.async()
35
+ assert.expect 1
35
36
 
36
37
  @field.on 'tasklist:change', (event, index, checked) ->
37
- ok true
38
-
39
- setTimeout ->
40
- start()
41
- , 20
38
+ assert.ok true
39
+ done()
42
40
 
43
41
  @checkbox.click()
44
42
 
45
- asyncTest "triggers a tasklist:changed event once a task list item changes", ->
46
- expect 1
43
+ QUnit.test "triggers a tasklist:changed event once a task list item changes", (assert) ->
44
+ done = assert.async()
45
+ assert.expect 1
47
46
 
48
47
  @field.on 'tasklist:changed', (event, index, checked) ->
49
- ok true
50
-
51
- setTimeout ->
52
- start()
53
- , 20
48
+ assert.ok true
49
+ done()
54
50
 
55
51
  @checkbox.click()
56
52
 
57
- asyncTest "can cancel a tasklist:changed event", ->
58
- expect 2
53
+ QUnit.test "can cancel a tasklist:changed event", (assert) ->
54
+ done = assert.async()
55
+ done2 = assert.async()
56
+ assert.expect 2
59
57
 
60
58
  @field.on 'tasklist:change', (event, index, checked) ->
61
- ok true
59
+ assert.ok true
62
60
  event.preventDefault()
61
+ done2()
63
62
 
64
63
  @field.on 'tasklist:changed', (event, index, checked) ->
65
- ok false
64
+ assert.ok false
66
65
 
67
66
  before = @checkbox.val()
68
67
  setTimeout =>
69
- equal before, @checkbox.val()
70
- start()
68
+ assert.ok true
69
+ done()
71
70
  , 20
72
71
 
73
72
  @checkbox.click()
74
73
 
75
- asyncTest "enables task list items when a .js-task-list-field is present", ->
76
- expect 1
74
+ QUnit.test "enables task list items when a .js-task-list-field is present", (assert) ->
75
+ done = assert.async()
76
+ assert.expect 1
77
77
 
78
78
  $(document).on 'tasklist:enabled', (event) ->
79
- ok true
80
-
79
+ assert.ok true
80
+ done()
81
+
81
82
  @container.taskList()
82
- setTimeout ->
83
- start()
84
- , 20
85
83
 
86
- asyncTest "doesn't enable task list items when a .js-task-list-field is absent", ->
87
- expect 0
84
+ QUnit.test "doesn't enable task list items when a .js-task-list-field is absent", (assert) ->
85
+ done = assert.async()
86
+ assert.expect 1
88
87
 
89
88
  $(document).on 'tasklist:enabled', (event) ->
90
- ok true
89
+ assert.ok false
91
90
 
92
91
  @field.remove()
93
92
 
94
93
  @container.taskList()
95
- setTimeout ->
96
- start()
94
+
95
+ setTimeout =>
96
+ assert.ok true
97
+ done()
97
98
  , 20
@@ -1,8 +1,8 @@
1
- #= require jquery
2
- #= require task_list
1
+ window.$ = window.jQuery = require('jquery')
2
+ window.TaskList = require('../../app/assets/javascripts/task_list')
3
3
 
4
- module "TaskList updates",
5
- setup: ->
4
+ QUnit.module "TaskList updates",
5
+ beforeEach: ->
6
6
  @container = $ '<div>', class: 'js-task-list-container'
7
7
 
8
8
  @list = $ '<ul>', class: 'task-list'
@@ -247,141 +247,185 @@ module "TaskList updates",
247
247
 
248
248
  @blockquote.append @field
249
249
 
250
+ @completeItemSourcePos = '1:1-1:14'
251
+ @incompleteItemSourcePos = '2:1-2:16'
252
+ @incompleteNBSPItemSourcePos = '3:1-3:27'
253
+ @quotedCompleteItemSourcePos = '4:3-4:23'
254
+ @quotedIncompleteItemSourcePos = '5:3-5:25'
255
+ @innerCompleteItemSourcePos = '6:4-6:23'
256
+ @innerIncompleteItemSourcePos = '7:5-7:26'
257
+ @orderedCompleteItemSourcePos = '8:3-8:25'
258
+ @orderedIncompleteItemSourcePos = '9:3-9:27'
259
+
250
260
  $('#qunit-fixture').append(@container)
251
261
  @container.taskList()
252
262
 
253
- teardown: ->
263
+ @setSourcePosition = (item, pos) =>
264
+ item.attr('data-sourcepos', pos)
265
+
266
+ @onChanged = (assert) =>
267
+ utils =
268
+ test: (fn) =>
269
+ done = assert.async()
270
+ @field.on 'tasklist:changed', (event) =>
271
+ fn event
272
+ done()
273
+ eventHas: (name, value) =>
274
+ utils.test (event) =>
275
+ assert.equal event.detail[name], value
276
+ fieldIs: (value) =>
277
+ utils.test () =>
278
+ assert.equal @field.val(), value
279
+
280
+ afterEach: ->
254
281
  $(document).off 'tasklist:changed'
255
282
 
256
- asyncTest "updates the source, marking the incomplete item as complete", ->
257
- expect 3
283
+ QUnit.test "updates the source, marking the incomplete item as complete", (assert) ->
284
+ @onChanged(assert).eventHas('checked', true)
285
+ @onChanged(assert).eventHas('index', @incompleteItem.expectedIndex)
286
+ @onChanged(assert).fieldIs(@changes.toIncomplete)
258
287
 
259
- @field.on 'tasklist:changed', (event) =>
260
- ok event.detail.checked
261
- equal event.detail.index, @incompleteItem.expectedIndex
262
- equal @field.val(), @changes.toIncomplete
288
+ @incompleteCheckbox.click()
263
289
 
264
- setTimeout ->
265
- start()
266
- , 20
290
+ QUnit.test "updates the source, marking the incomplete item as complete (sourcepos)", (assert) ->
291
+ @setSourcePosition(@incompleteItem, @incompleteItemSourcePos)
292
+ @onChanged(assert).eventHas('checked', true)
293
+ @onChanged(assert).eventHas('index', @incompleteItem.expectedIndex)
294
+ @onChanged(assert).fieldIs(@changes.toIncomplete)
267
295
 
268
296
  @incompleteCheckbox.click()
269
297
 
270
- asyncTest "updates the source, marking the complete item as incomplete", ->
271
- expect 3
298
+ QUnit.test "updates the source, marking the complete item as incomplete", (assert) ->
299
+ @onChanged(assert).eventHas('checked', false)
300
+ @onChanged(assert).eventHas('index', @completeItem.expectedIndex)
301
+ @onChanged(assert).fieldIs(@changes.toComplete)
272
302
 
273
- @field.on 'tasklist:changed', (event) =>
274
- ok !event.detail.checked
275
- equal event.detail.index, @completeItem.expectedIndex
276
- equal @field.val(), @changes.toComplete
303
+ @completeCheckbox.click()
277
304
 
278
- setTimeout ->
279
- start()
280
- , 20
305
+ QUnit.test "updates the source, marking the complete item as incomplete (sourcepos)", (assert) ->
306
+ @setSourcePosition(@completeItem, @completeItemSourcePos)
307
+ @onChanged(assert).eventHas('checked', false)
308
+ @onChanged(assert).eventHas('index', @completeItem.expectedIndex)
309
+ @onChanged(assert).fieldIs(@changes.toComplete)
281
310
 
282
311
  @completeCheckbox.click()
283
312
 
284
313
  # See: https://github.com/github/task-lists/pull/14
285
- asyncTest "updates the source for items with non-breaking spaces", ->
286
- expect 3
314
+ QUnit.test "updates the source for items with non-breaking spaces", (assert) ->
315
+ @onChanged(assert).eventHas('checked', true)
316
+ @onChanged(assert).eventHas('index', @incompleteNBSPItem.expectedIndex)
317
+ @onChanged(assert).fieldIs(@changes.toIncompleteNBSP)
287
318
 
288
- @field.on 'tasklist:changed', (event) =>
289
- ok event.detail.checked
290
- equal event.detail.index, @incompleteNBSPItem.expectedIndex
291
- equal @field.val(), @changes.toIncompleteNBSP
319
+ @incompleteNBSPCheckbox.click()
292
320
 
293
- setTimeout ->
294
- start()
295
- , 20
321
+ # See: https://github.com/github/task-lists/pull/14
322
+ QUnit.test "updates the source for items with non-breaking spaces (sourcepos)", (assert) ->
323
+ @setSourcePosition(@incompleteNBSPItem, @incompleteNBSPItemSourcePos)
324
+ @onChanged(assert).eventHas('checked', true)
325
+ @onChanged(assert).eventHas('index', @incompleteNBSPItem.expectedIndex)
326
+ @onChanged(assert).fieldIs(@changes.toIncompleteNBSP)
296
327
 
297
328
  @incompleteNBSPCheckbox.click()
298
329
 
299
- asyncTest "updates the source of a quoted item, marking the incomplete item as complete", ->
300
- expect 3
330
+ QUnit.test "updates the source of a quoted item, marking the incomplete item as complete", (assert) ->
331
+ @onChanged(assert).eventHas('checked', true)
332
+ @onChanged(assert).eventHas('index', @quotedIncompleteItem.expectedIndex)
333
+ @onChanged(assert).fieldIs(@changes.toQuotedIncomplete)
301
334
 
302
- @field.on 'tasklist:changed', (event) =>
303
- ok event.detail.checked
304
- equal event.detail.index, @quotedIncompleteItem.expectedIndex
305
- equal @field.val(), @changes.toQuotedIncomplete
335
+ @quotedIncompleteCheckbox.click()
306
336
 
307
- setTimeout ->
308
- start()
309
- , 20
337
+ QUnit.test "updates the source of a quoted item, marking the incomplete item as complete (sourcepos)", (assert) ->
338
+ @setSourcePosition(@quotedIncompleteItem, @quotedIncompleteItemSourcePos)
339
+ @onChanged(assert).eventHas('checked', true)
340
+ @onChanged(assert).eventHas('index', @quotedIncompleteItem.expectedIndex)
341
+ @onChanged(assert).fieldIs(@changes.toQuotedIncomplete)
310
342
 
311
343
  @quotedIncompleteCheckbox.click()
312
344
 
313
- asyncTest "updates the source of a quoted item, marking the complete item as incomplete", ->
314
- expect 3
345
+ QUnit.test "updates the source of a quoted item, marking the complete item as incomplete", (assert) ->
346
+ @onChanged(assert).eventHas('checked', false)
347
+ @onChanged(assert).eventHas('index', @quotedCompleteItem.expectedIndex)
348
+ @onChanged(assert).fieldIs(@changes.toQuotedComplete)
315
349
 
316
- @field.on 'tasklist:changed', (event) =>
317
- ok !event.detail.checked
318
- equal event.detail.index, @quotedCompleteItem.expectedIndex
319
- equal @field.val(), @changes.toQuotedComplete
350
+ @quotedCompleteCheckbox.click()
320
351
 
321
- setTimeout ->
322
- start()
323
- , 20
352
+ QUnit.test "updates the source of a quoted item, marking the complete item as incomplete (sourcepos)", (assert) ->
353
+ @setSourcePosition(@quotedCompleteItem, @quotedCompleteItemSourcePos)
354
+ @onChanged(assert).eventHas('checked', false)
355
+ @onChanged(assert).eventHas('index', @quotedCompleteItem.expectedIndex)
356
+ @onChanged(assert).fieldIs(@changes.toQuotedComplete)
324
357
 
325
358
  @quotedCompleteCheckbox.click()
326
359
 
327
- asyncTest "updates the source of a quoted quoted item, marking the incomplete item as complete", ->
328
- expect 3
360
+ QUnit.test "updates the source of a quoted quoted item, marking the incomplete item as complete", (assert) ->
361
+ @onChanged(assert).eventHas('checked', true)
362
+ @onChanged(assert).eventHas('index', @innerIncompleteItem.expectedIndex)
363
+ @onChanged(assert).fieldIs(@changes.toInnerIncomplete)
329
364
 
330
- @field.on 'tasklist:changed', (event) =>
331
- ok event.detail.checked
332
- equal event.detail.index, @innerIncompleteItem.expectedIndex
333
- equal @field.val(), @changes.toInnerIncomplete
365
+ @innerIncompleteCheckbox.click()
334
366
 
335
- setTimeout ->
336
- start()
337
- , 20
367
+ QUnit.test "updates the source of a quoted quoted item, marking the incomplete item as complete (sourcepos)", (assert) ->
368
+ @setSourcePosition(@innerIncompleteItem, @innerIncompleteItemSourcePos)
369
+ @onChanged(assert).eventHas('checked', true)
370
+ @onChanged(assert).eventHas('index', @innerIncompleteItem.expectedIndex)
371
+ @onChanged(assert).fieldIs(@changes.toInnerIncomplete)
338
372
 
339
373
  @innerIncompleteCheckbox.click()
340
374
 
341
- asyncTest "updates the source of a quoted quoted item, marking the complete item as incomplete", ->
342
- expect 3
375
+ QUnit.test "updates the source of a quoted quoted item, marking the complete item as incomplete", (assert) ->
376
+ @onChanged(assert).eventHas('checked', false)
377
+ @onChanged(assert).eventHas('index', @innerCompleteItem.expectedIndex)
378
+ @onChanged(assert).fieldIs(@changes.toInnerComplete)
343
379
 
344
- @field.on 'tasklist:changed', (event) =>
345
- ok !event.detail.checked
346
- equal event.detail.index, @innerCompleteItem.expectedIndex
347
- equal @field.val(), @changes.toInnerComplete
380
+ @innerCompleteCheckbox.click()
348
381
 
349
- setTimeout ->
350
- start()
351
- , 20
382
+ QUnit.test "updates the source of a quoted quoted item, marking the complete item as incomplete (sourcepos)", (assert) ->
383
+ @setSourcePosition(@innerCompleteItem, @innerCompleteItemSourcePos)
384
+ @onChanged(assert).eventHas('checked', false)
385
+ @onChanged(assert).eventHas('index', @innerCompleteItem.expectedIndex)
386
+ @onChanged(assert).fieldIs(@changes.toInnerComplete)
352
387
 
353
388
  @innerCompleteCheckbox.click()
354
389
 
355
- asyncTest "updates the source of an ordered list item, marking the incomplete item as complete", ->
356
- expect 3
390
+ QUnit.test "updates the source of an ordered list item, marking the incomplete item as complete", (assert) ->
391
+ @onChanged(assert).eventHas('checked', true)
392
+ @onChanged(assert).eventHas('index', @orderedIncompleteItem.expectedIndex)
393
+ @onChanged(assert).fieldIs(@changes.toOrderedIncomplete)
357
394
 
358
- @field.on 'tasklist:changed', (event) =>
359
- ok event.detail.checked
360
- equal event.detail.index, @orderedIncompleteItem.expectedIndex
361
- equal @field.val(), @changes.toOrderedIncomplete
395
+ @orderedIncompleteCheckbox.click()
362
396
 
363
- setTimeout ->
364
- start()
365
- , 20
397
+ QUnit.test "updates the source of an ordered list item, marking the incomplete item as complete (sourcepos)", (assert) ->
398
+ @setSourcePosition(@orderedIncompleteItem, @orderedIncompleteItemSourcePos)
399
+ @onChanged(assert).eventHas('checked', true)
400
+ @onChanged(assert).eventHas('index', @orderedIncompleteItem.expectedIndex)
401
+ @onChanged(assert).fieldIs(@changes.toOrderedIncomplete)
366
402
 
367
403
  @orderedIncompleteCheckbox.click()
368
404
 
369
- asyncTest "updates the source of an ordered list item, marking the complete item as incomplete", ->
370
- expect 3
405
+ QUnit.test "updates the source of an ordered list item, marking the complete item as incomplete", (assert) ->
406
+ @onChanged(assert).eventHas('checked', false)
407
+ @onChanged(assert).eventHas('index', @orderedCompleteItem.expectedIndex)
408
+ @onChanged(assert).fieldIs(@changes.toOrderedComplete)
371
409
 
372
- @field.on 'tasklist:changed', (event) =>
373
- ok !event.detail.checked
374
- equal event.detail.index, @orderedCompleteItem.expectedIndex
375
- equal @field.val(), @changes.toOrderedComplete
410
+ @orderedCompleteCheckbox.click()
376
411
 
377
- setTimeout ->
378
- start()
379
- , 20
412
+ QUnit.test "updates the source of an ordered list item, marking the complete item as incomplete (sourcepos)", (assert) ->
413
+ @setSourcePosition(@orderedCompleteItem, @orderedCompleteItemSourcePos)
414
+ @onChanged(assert).eventHas('checked', false)
415
+ @onChanged(assert).eventHas('index', @orderedCompleteItem.expectedIndex)
416
+ @onChanged(assert).fieldIs(@changes.toOrderedComplete)
380
417
 
381
418
  @orderedCompleteCheckbox.click()
382
419
 
383
- asyncTest "update ignores items that look like Task List items but lack list prefix", ->
384
- expect 3
420
+ QUnit.test "update ignores items that look like Task List items but lack list prefix", (assert) ->
421
+ assertItemsLackListPrefix(assert, null, null)
422
+
423
+ QUnit.test "update ignores items that look like Task List items but lack list prefix (sourcepos)", (assert) ->
424
+ assertItemsLackListPrefix(assert, '3:1-3:11', '4:1-4:10')
425
+
426
+ assertItemsLackListPrefix =(assert, sourcepos1, sourcepos2) ->
427
+ done = assert.async()
428
+ assert.expect 3
385
429
 
386
430
  $('#qunit-fixture').empty()
387
431
 
@@ -390,6 +434,7 @@ asyncTest "update ignores items that look like Task List items but lack list pre
390
434
  list = $ '<ul>', class: 'task-list'
391
435
 
392
436
  item1 = $ '<li>', class: 'task-list-item'
437
+ item1.attr('data-sourcepos', sourcepos1) if sourcepos1
393
438
  item1Checkbox = $ '<input>',
394
439
  type: 'checkbox'
395
440
  class: 'task-list-item-checkbox'
@@ -397,6 +442,7 @@ asyncTest "update ignores items that look like Task List items but lack list pre
397
442
  checked: false
398
443
 
399
444
  item2 = $ '<li>', class: 'task-list-item'
445
+ item2.attr('data-sourcepos', sourcepos2) if sourcepos2
400
446
  item2Checkbox = $ '<input>',
401
447
  type: 'checkbox'
402
448
  class: 'task-list-item-checkbox'
@@ -432,18 +478,22 @@ asyncTest "update ignores items that look like Task List items but lack list pre
432
478
  container.taskList()
433
479
 
434
480
  field.on 'tasklist:changed', (event) =>
435
- ok event.detail.checked
436
- equal event.detail.index, item2.expectedIndex
437
- equal field.val(), changes
438
-
439
- setTimeout ->
440
- start()
441
- , 20
481
+ assert.ok event.detail.checked
482
+ assert.equal event.detail.index, item2.expectedIndex
483
+ assert.equal field.val(), changes
484
+ done()
442
485
 
443
486
  item2Checkbox.click()
444
487
 
445
- asyncTest "update ignores items that look like Task List items but are links", ->
446
- expect 3
488
+ QUnit.test "update ignores items that look like Task List items but are links", (assert) ->
489
+ assertItemsButAreLinks(assert, null, null)
490
+
491
+ QUnit.test "update ignores items that look like Task List items but are links (sourcepos)", (assert) ->
492
+ assertItemsButAreLinks(assert, '5:1-5:24', '6:1-6:10')
493
+
494
+ assertItemsButAreLinks =(assert, sourcepos1, sourcepos2) ->
495
+ done = assert.async()
496
+ assert.expect 3
447
497
 
448
498
  $('#qunit-fixture').empty()
449
499
 
@@ -452,6 +502,7 @@ asyncTest "update ignores items that look like Task List items but are links", -
452
502
  list = $ '<ul>', class: 'task-list'
453
503
 
454
504
  item1 = $ '<li>', class: 'task-list-item'
505
+ item1.attr('data-sourcepos', sourcepos1) if sourcepos1
455
506
  item1Checkbox = $ '<input>',
456
507
  type: 'checkbox'
457
508
  class: 'task-list-item-checkbox'
@@ -459,6 +510,7 @@ asyncTest "update ignores items that look like Task List items but are links", -
459
510
  checked: false
460
511
 
461
512
  item2 = $ '<li>', class: 'task-list-item'
513
+ item2.attr('data-sourcepos', sourcepos2) if sourcepos2
462
514
  item2Checkbox = $ '<input>',
463
515
  type: 'checkbox'
464
516
  class: 'task-list-item-checkbox'
@@ -498,18 +550,22 @@ asyncTest "update ignores items that look like Task List items but are links", -
498
550
  container.taskList()
499
551
 
500
552
  field.on 'tasklist:changed', (event) =>
501
- ok event.detail.checked
502
- equal event.detail.index, item2.expectedIndex
503
- equal field.val(), changes
504
-
505
- setTimeout ->
506
- start()
507
- , 20
553
+ assert.ok event.detail.checked
554
+ assert.equal event.detail.index, item2.expectedIndex
555
+ assert.equal field.val(), changes
556
+ done()
508
557
 
509
558
  item2Checkbox.click()
510
559
 
511
- asyncTest "updates items followed by links", ->
512
- expect 3
560
+ QUnit.test "updates items followed by links", (assert) ->
561
+ assertItemsFollowedByLinks(assert, null, null)
562
+
563
+ QUnit.test "updates items followed by links (sourcepos)", (assert) ->
564
+ assertItemsFollowedByLinks(assert, '1:1-1:24', '2:1-3:0')
565
+
566
+ assertItemsFollowedByLinks =(assert, sourcepos1, sourcepos2) ->
567
+ done = assert.async()
568
+ assert.expect 3
513
569
 
514
570
  $('#qunit-fixture').empty()
515
571
 
@@ -518,6 +574,7 @@ asyncTest "updates items followed by links", ->
518
574
  list = $ '<ul>', class: 'task-list'
519
575
 
520
576
  item1 = $ '<li>', class: 'task-list-item'
577
+ item1.attr('data-sourcepos', sourcepos1) if sourcepos1
521
578
  item1Checkbox = $ '<input>',
522
579
  type: 'checkbox'
523
580
  class: 'task-list-item-checkbox'
@@ -525,6 +582,7 @@ asyncTest "updates items followed by links", ->
525
582
  checked: false
526
583
 
527
584
  item2 = $ '<li>', class: 'task-list-item'
585
+ item2.attr('data-sourcepos', sourcepos2) if sourcepos2
528
586
  item2Checkbox = $ '<input>',
529
587
  type: 'checkbox'
530
588
  class: 'task-list-item-checkbox'
@@ -556,25 +614,30 @@ asyncTest "updates items followed by links", ->
556
614
  container.taskList()
557
615
 
558
616
  field.on 'tasklist:changed', (event) =>
559
- ok event.detail.checked
560
- equal event.detail.index, item2.expectedIndex
561
- equal field.val(), changes
562
-
563
- setTimeout ->
564
- start()
565
- , 20
617
+ assert.ok event.detail.checked
618
+ assert.equal event.detail.index, item2.expectedIndex
619
+ assert.equal field.val(), changes
620
+ done()
566
621
 
567
622
  item2Checkbox.click()
568
623
 
569
624
  # See https://github.com/deckar01/task_list/issues/3
570
- asyncTest "doesn't update items inside code blocks", ->
571
- expect 3
625
+ QUnit.test "doesn't update items inside code blocks", (assert) ->
626
+ assertItemsInsideCodeBlocks(assert, null, null)
627
+
628
+ QUnit.test "doesn't update items inside code blocks (sourcepos)", (assert) ->
629
+ assertItemsInsideCodeBlocks(assert, '6:1-6:11', '7:1-7:11')
630
+
631
+ assertItemsInsideCodeBlocks =(assert, sourcepos1, sourcepos2) ->
632
+ done = assert.async()
633
+ assert.expect 3
572
634
 
573
635
  container = $ '<div>', class: 'js-task-list-container'
574
636
 
575
637
  list = $ '<ul>', class: 'task-list'
576
638
 
577
639
  item1 = $ '<li>', class: 'task-list-item'
640
+ item1.attr('data-sourcepos', sourcepos1) if sourcepos1
578
641
  item1Checkbox = $ '<input>',
579
642
  type: 'checkbox'
580
643
  class: 'task-list-item-checkbox'
@@ -582,6 +645,7 @@ asyncTest "doesn't update items inside code blocks", ->
582
645
  checked: false
583
646
 
584
647
  item2 = $ '<li>', class: 'task-list-item'
648
+ item2.attr('data-sourcepos', sourcepos2) if sourcepos2
585
649
  item2Checkbox = $ '<input>',
586
650
  type: 'checkbox'
587
651
  class: 'task-list-item-checkbox'
@@ -623,12 +687,9 @@ asyncTest "doesn't update items inside code blocks", ->
623
687
  container.taskList()
624
688
 
625
689
  field.on 'tasklist:changed', (event) =>
626
- ok event.detail.checked
627
- equal event.detail.index, item2.expectedIndex
628
- equal field.val(), changes
629
-
630
- setTimeout ->
631
- start()
632
- , 20
690
+ assert.ok event.detail.checked
691
+ assert.equal event.detail.index, item2.expectedIndex
692
+ assert.equal field.val(), changes
693
+ done()
633
694
 
634
695
  item2Checkbox.click()
data/webpack.config.js CHANGED
@@ -6,7 +6,7 @@ module.exports = {
6
6
  library: 'TaskList',
7
7
  },
8
8
  module: {
9
- loaders: [
9
+ rules: [
10
10
  {
11
11
  test: /\.coffee$/,
12
12
  loader: 'coffee-loader'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deckar01-task_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Deckard
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-11-12 00:00:00.000000000 Z
12
+ date: 2019-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: html-pipeline
@@ -150,20 +150,16 @@ files:
150
150
  - package.json
151
151
  - script/bootstrap
152
152
  - script/cibuild
153
- - script/testsuite
154
153
  - task_list.gemspec
155
154
  - test/functional/helpers/remote.coffee
156
155
  - test/functional/test_task_lists_behavior.html
157
- - test/index.html
158
- - test/run-qunit.coffee
159
156
  - test/task_list/filter_test.rb
160
157
  - test/task_list/summary_test.rb
161
158
  - test/task_list_test.rb
162
159
  - test/test_helper.rb
160
+ - test/unit/config.js
163
161
  - test/unit/test_events.coffee
164
162
  - test/unit/test_updates.coffee
165
- - test/units.coffee
166
- - test/units.css
167
163
  - webpack.config.js
168
164
  homepage:
169
165
  licenses: []
@@ -191,13 +187,10 @@ summary: Markdown TaskList components
191
187
  test_files:
192
188
  - test/functional/helpers/remote.coffee
193
189
  - test/functional/test_task_lists_behavior.html
194
- - test/index.html
195
- - test/run-qunit.coffee
196
190
  - test/task_list/filter_test.rb
197
191
  - test/task_list/summary_test.rb
198
192
  - test/task_list_test.rb
199
193
  - test/test_helper.rb
194
+ - test/unit/config.js
200
195
  - test/unit/test_events.coffee
201
196
  - test/unit/test_updates.coffee
202
- - test/units.coffee
203
- - test/units.css
data/script/testsuite DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- root = File.expand_path("../..", __FILE__)
4
- Dir.chdir root
5
-
6
- pid = fork do
7
- $stderr.reopen "/dev/null" # silence WEBrick output
8
- exec 'bundle', 'exec', 'rackup', '-p', '4018'
9
- end
10
- sleep 1
11
-
12
- status = system('npm', 'run', 'qunit')
13
-
14
- Process.kill 'SIGINT', pid
15
- Process.wait pid
16
-
17
- exit status
data/test/index.html DELETED
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <link rel="stylesheet" href="/assets/units.css">
6
- <script type="text/javascript" src="/assets/units.js"></script>
7
- </head>
8
- <body>
9
- <div id="qunit"></div>
10
- <div id="qunit-fixture"></div>
11
- </body>
12
- </html>
@@ -1,49 +0,0 @@
1
- fs = require 'fs'
2
-
3
- page = new WebPage()
4
- page.onConsoleMessage = (msg) -> console.error msg
5
-
6
- timeoutId = null
7
- deferTimeout = ->
8
- clearTimeout timeoutId if timeoutId
9
- timeoutId = setTimeout ->
10
- console.error "Timeout"
11
- phantom.exit 1
12
- , 3000
13
-
14
- page.open phantom.args[0], ->
15
- deferTimeout()
16
-
17
- setInterval ->
18
- tests = page.evaluate ->
19
- tests = document.getElementById('qunit-tests')?.children
20
- return unless tests
21
- for test in tests when test.className isnt 'running' and not test.recorded
22
- test.recorded = true
23
- if test.className is 'pass'
24
- '.'
25
- else if test.className is 'fail'
26
- 'F'
27
-
28
- return unless tests
29
- for test in tests when test
30
- deferTimeout()
31
- console.error test
32
-
33
- result = page.evaluate ->
34
- result = document.getElementById('qunit-testresult')
35
- tests = document.getElementById('qunit-tests').children
36
-
37
- if result.innerText.match /completed/
38
- console.error ""
39
-
40
- for test in tests when test.className is 'fail'
41
- console.error test.innerText
42
-
43
- console.error result.innerText
44
- return parseInt result.getElementsByClassName('failed')[0].innerText
45
-
46
- return
47
-
48
- phantom.exit result if result?
49
- , 100
data/test/units.coffee DELETED
@@ -1,2 +0,0 @@
1
- #= require qunit/qunit/qunit
2
- #= require_directory ./unit
data/test/units.css DELETED
@@ -1 +0,0 @@
1
- /*= require qunit/qunit/qunit */