<commit_before>dom = Quill.Lib.DOM

describe('Toolbar', ->
  beforeEach( ->
    jasmine.resetEditor()
    @editorContainer = $('#editor-container').html('
      <div>
        <div>
          <b>01</b>23<i>45</i><span style="font-size: 18px;">67</span><span style="font-size: 32px;">89</span>
        </div>
      </div>
    ').get(0)
    @toolbarContainer = $('#toolbar-container').get(0)
    @toolbarContainer.innerHTML = @toolbarContainer.innerHTML   # Remove child listeners
    @quill = new Quill(@editorContainer.firstChild)
    @toolbar = @quill.addModule('toolbar', { container: @toolbarContainer })
    @button = @toolbarContainer.querySelector('.ql-bold')
    @select = @toolbarContainer.querySelector('.ql-size')
  )

  afterEach((done) ->
    clearInterval(@quill.editor.timer)
    _.defer(done)
  )

  describe('format', ->
    it('button add', ->
      range = new Quill.Lib.Range(2, 4)
      @quill.setSelection(range)
      dom(@button).trigger('click')
      expect(@quill.getContents(range)).toEqualDelta(new Quill.Delta().insert('23', { bold: true }))
    )

    it('button remove', ->
      range = new Quill.Lib.Range(0, 2)
      @quill.setSelection(range)
      dom(@button).trigger('click')
      expect(@quill.getContents(range)).toEqualDelta(new Quill.Delta().insert('01'))
    )
<commit_msg>CREATE-1432 Change unit tests to trigger mousedown event instead of click event, to match the changed code.<commit_after>dom = Quill.Lib.DOM

describe('Toolbar', ->
  beforeEach( ->
    jasmine.resetEditor()
    @editorContainer = $('#editor-container').html('
      <div>
        <div>
          <b>01</b>23<i>45</i><span style="font-size: 18px;">67</span><span style="font-size: 32px;">89</span>
        </div>
      </div>
    ').get(0)
    @toolbarContainer = $('#toolbar-container').get(0)
    @toolbarContainer.innerHTML = @toolbarContainer.innerHTML   # Remove child listeners
    @quill = new Quill(@editorContainer.firstChild)
    @toolbar = @quill.addModule('toolbar', { container: @toolbarContainer })
    @button = @toolbarContainer.querySelector('.ql-bold')
    @select = @toolbarContainer.querySelector('.ql-size')
  )

  afterEach((done) ->
    clearInterval(@quill.editor.timer)
    _.defer(done)
  )

  describe('format', ->
    it('button add', ->
      range = new Quill.Lib.Range(2, 4)
      @quill.setSelection(range)
      dom(@button).trigger('mousedown')
      expect(@quill.getContents(range)).toEqualDelta(new Quill.Delta().insert('23', { bold: true }))
    )

    it('button remove', ->
      range = new Quill.Lib.Range(0, 2)
      @quill.setSelection(range)
      dom(@button).trigger('mousedown')
      expect(@quill.getContents(range)).toEqualDelta(new Quill.Delta().insert('01'))
    )

{'fraction_non_alphanumeric': 0.17885881492318947, 'fraction_numerical': 0.019019751280175568, 'mean_word_length': 3.432739059967585, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1343177', 'n_tokens_mistral': 904, 'n_tokens_neox': 866, 'n_words': 138}