<commit_before>require '/assets/mercury/mercury.js'

describe "Mercury.modalHandlers.htmlEditor", ->

  template 'mercury/modals/htmleditor.html'

  beforeEach ->
    @modal =
      element: $('#test')
      hide: ->
    Mercury.region =
      content: -> '<span>html \ncontent</span>'
    Mercury.modalHandlers.htmleditor.call(@modal)

  describe "loading", ->

    it "sets the value of the textarea", ->
      expect($('#test textarea').val()).toEqual('<span>html \ncontent</span>')


  describe "submitting", ->

    it "triggers a replaceHTML action", ->
      spy = spyOn(Mercury, 'trigger').andCallFake(=>)
      jasmine.simulate.click($('#submit').get(0))
      expect(spy.callCount).toEqual(1)
      expect(spy.argsForCall[0]).toEqual(['action', {action: 'replaceHTML', value: '<span>html content</span>'}])

    it "hides the modal", ->
      spy = spyOn(@modal, 'hide').andCallFake(=>)
      jasmine.simulate.click($('#submit').get(0))
      expect(spy.callCount).toEqual(1)<commit_msg>fixed the htmleditor spec (missed previously?)<commit_after>require '/assets/mercury/mercury.js'

describe "Mercury.modalHandlers.htmlEditor", ->

  template 'mercury/modals/htmleditor.html'

  beforeEach ->
    @modal =
      element: $('#test')
      hide: ->
    Mercury.region =
      content: -> '<span>html \ncontent</span>'
    Mercury.modalHandlers.htmlEditor.call(@modal)

  describe "loading", ->

    it "sets the value of the textarea", ->
      expect($('#test textarea').val()).toEqual('<span>html \ncontent</span>')


  describe "submitting", ->

    it "triggers a replaceHTML action", ->
      spy = spyOn(Mercury, 'trigger').andCallFake(=>)
      jasmine.simulate.click($('#submit').get(0))
      expect(spy.callCount).toEqual(1)
      expect(spy.argsForCall[0]).toEqual(['action', {action: 'replaceHTML', value: '<span>html content</span>'}])

    it "hides the modal", ->
      spy = spyOn(@modal, 'hide').andCallFake(=>)
      jasmine.simulate.click($('#submit').get(0))
      expect(spy.callCount).toEqual(1)
{'fraction_non_alphanumeric': 0.1879625061667489, 'fraction_numerical': 0.00493339911198816, 'mean_word_length': 3.609090909090909, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 37, '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': '1459632', 'n_tokens_mistral': 678, 'n_tokens_neox': 675, 'n_words': 114}