<commit_before>module 'Hallo Core'

test 'Hallo widget registered', ->
  equal typeof jQuery('body').hallo, 'function'

test 'Hallo instantiation and destruction', ->
  fixture = jQuery '.hallo-instance p.editable'

  # Instantiate
  do fixture.hallo
  equal fixture.attr('contentEditable'), 'true'

  # Activate to get toolbar
  do fixture.focus
  equal jQuery('.hallotoolbar').length, 1
  ok fixture.hasClass 'inEditMode'

  # Check also the instance data
  instance = fixture.data 'hallo'
  ok instance

  # Destroy
  fixture.hallo 'destroy'
  equal fixture.data('hallo'), undefined
  equal fixture.attr('contentEditable'), 'false'
  equal jQuery('.hallotoolbar').length, 0
  equal fixture.hasClass('inEditMode'), false

test 'Hallo activation events', ->
  fixture = jQuery '.hallo-instance p.editable'

  # Instantiate
  do fixture.hallo
  instance = fixture.data 'hallo'

  fixture.bind 'halloactivated', (event, data) ->
    equal data, instance
    equal jQuery('.hallotoolbar').length, 1
    ok fixture.hasClass 'inEditMode'
    do start
    do fixture.blur

  fixture.bind 'hallodeactivated', (event, data) ->
    equal data, instance
    equal fixture.hasClass('inEditMode'), false
    do start

  do stop
  do fixture.focus

test 'Hallo modification events', ->
  fixture = jQuery '.hallo-modified p.editable'
<commit_msg>Test the enabled and disabled events as well<commit_after>module 'Hallo Core'

test 'Hallo widget registered', ->
  equal typeof jQuery('body').hallo, 'function'

test 'Hallo instantiation and destruction', ->
  fixture = jQuery '.hallo-instance p.editable'

  fixture.bind 'halloenabled', ->
    equal fixture.attr('contentEditable'), 'true'
    do start

  # Instantiate
  do stop
  do fixture.hallo

  # Activate to get toolbar
  do fixture.focus
  equal jQuery('.hallotoolbar').length, 1
  ok fixture.hasClass 'inEditMode'

  # Check also the instance data
  instance = fixture.data 'hallo'
  ok instance

  fixture.bind 'hallodisabled', ->
    equal fixture.attr('contentEditable'), 'false'
    do start

  # Destroy
  do stop
  fixture.hallo 'destroy'
  equal fixture.data('hallo'), undefined
  equal jQuery('.hallotoolbar').length, 0
  equal fixture.hasClass('inEditMode'), false

test 'Hallo activation events', ->
  fixture = jQuery '.hallo-instance p.editable'

  # Instantiate
  do fixture.hallo
  instance = fixture.data 'hallo'

  fixture.bind 'halloactivated', (event, data) ->
    equal data, instance
    equal jQuery('.hallotoolbar').length, 1
    ok fixture.hasClass 'inEditMode'
    do start
    do fixture.blur

  fixture.bind 'hallodeactivated', (event, data) ->
    equal data, instance
    equal fixture.hasClass('inEditMode'), false
    do start

  do stop
  do fixture.focus

test 'Hallo modification events', ->
  fixture = jQuery '.hallo-modified p.editable'

{'fraction_non_alphanumeric': 0.1127659574468085, 'fraction_numerical': 0.002127659574468085, 'mean_word_length': 3.7813559322033896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '4778504', 'n_tokens_mistral': 879, 'n_tokens_neox': 856, 'n_words': 255}