<commit_before>(($) ->

  $.fn.selectorText = () ->
    selector = "%#{@[0].tagName.toLowerCase()}"
    @attr('id') && selector += "##{@.attr('id')}"
    @attr('class') && selector += ".#{@.attr('class')}"
    text = if @text().length > 20 then "#{@text().slice(0, 20)}..." else @text()
    if text then selector = selector + " with text of '#{text}'"
    selector

  $.fn.shouldEqual = ($el) ->
    ok $(this).length == 1 && $el.length == 1, 'checking for element duplication'
    equal $(this)[0], $el[0], "#{$(this).selectorText()} is equal to #{$el.selectorText()}"

  tester =
    data: ->
      @$trigger.data('windoze')
    init: (opts)->
      @$fixture = $(@fixture || '.link_trigger')
      @$trigger = @$fixture.find('a').eq(0)
      $(@$trigger).windoze(opts)

  module 'Element Creation'

  test 'it chains properly', ->
    $trigger = tester.init()
    deepEqual $trigger.hide().show(), $trigger, 'returns trigger properly'

  test 'it uses #modal and #modal_layer if none are specified', ->
    $(document.body)
      .append($('<div />').attr('id', 'modal'))
      .append($('<div />').attr('id', 'modal_layer'))
    $trigger = tester.init()
    tester.data().$modal.shouldEqual($('#modal'))

  test 'it creates a default #modal and #modal_layer if none are specified or present', ->
    $trigger = tester.init()
    tester.data().$modal.shouldEqual($('#modal'))<commit_msg>Pull out redundant test init<commit_after>(($) ->

  $.fn.selectorText = () ->
    selector = "%#{@[0].tagName.toLowerCase()}"
    @attr('id') && selector += "##{@.attr('id')}"
    @attr('class') && selector += ".#{@.attr('class')}"
    text = if @text().length > 20 then "#{@text().slice(0, 20)}..." else @text()
    if text then selector = selector + " with text of '#{text}'"
    selector

  $.fn.shouldEqual = ($el) ->
    ok $(this).length == 1 && $el.length == 1, 'checking for element duplication'
    equal $(this)[0], $el[0], "#{$(this).selectorText()} is equal to #{$el.selectorText()}"

  tester =
    data: ->
      @$trigger.data('windoze')
    createElements: (text) ->
      text ||= 'some text'
      $(document.body)
        .append($('<div />').attr('id', 'modal').text(text))
        .append($('<div />').attr('id', 'modal_layer'))
    init: (opts)->
      @$fixture = $(@fixture || '.link_trigger')
      @$trigger = @$fixture.find('a').eq(0)
      $(@$trigger).windoze(opts)

  module 'Element Creation'

  test 'it chains properly', ->
    $trigger = tester.init()
    deepEqual $trigger.hide().show(), $trigger, 'returns trigger properly'

  test 'it uses #modal and #modal_layer if present', ->
    $trigger = tester.init()
    tester.data().$modal.shouldEqual($('#modal'))

  test 'it creates a default #modal and #modal_layer if not present', ->
    $('#modal, #modal_layer').remove()
    $trigger = tester.init()
    tester.data().$modal.shouldEqual($('#modal'))
{'fraction_non_alphanumeric': 0.23410906564779438, 'fraction_numerical': 0.007641542202153525, 'mean_word_length': 3.3636363636363638, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 26, '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': '108870', 'n_tokens_mistral': 969, 'n_tokens_neox': 942, 'n_words': 227}