summaryrefslogtreecommitdiff
path: root/spec/javascripts/notes_spec.js.coffee
blob: de2e8e7f6c8ab001e4dbbf0f9e5632e501136646 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#= require jquery
#= require jasmine-fixture
#= require notes

window.gon = {}
window.disableButtonIfEmptyField = -> null

describe 'Notes', ->
  describe 'task lists', ->
    selectors = {
      container: 'li.note .js-task-list-container'
      item:      '.note-text ul.task-list li.task-list-item input.task-list-item-checkbox[type=checkbox] {Task List Item}'
      textarea:  '.note-edit-form form textarea.js-task-list-field{- [ ] Task List Item}'
    }

    beforeEach ->
      $container = affix(selectors.container)

      # These two elements are siblings inside the container
      $container.find('.js-task-list-container').append(affix(selectors.item))
      $container.find('.js-task-list-container').append(affix(selectors.textarea))

      @notes = new Notes()

    it 'submits the form on tasklist:changed', ->
      submitted = false
      $('form').on 'submit', (e) -> submitted = true; e.preventDefault()

      $('.js-task-list-field').trigger('tasklist:changed')
      expect(submitted).toBe(true)