<commit_before>class FakeWindow
  constructor: (@location) ->

class FakeLocation
  replace: (new_location) ->

submit_url = ->
  e = $.Event('keypress')
  e.which = 13
  $('#quick-add-url').trigger(e)

describe 'quick_add_url', ->
  fake_location = null

  beforeEach ->
    loadFixtures 'quick_add_url.html'
    fake_location = new FakeLocation
    fake_window = new FakeWindow(fake_location)
    window.quick_add_url_init(fake_window)

  describe 'loading an image from a url', ->
    describe 'when the url is empty', ->
      beforeEach ->
        $('#quick-add-url').val('')

      it 'does not submit an AJAX request', ->
        ajax_spy = spyOn($, 'ajax')

        submit_url()
        expect(ajax_spy).not.toHaveBeenCalled()

    describe 'when the url is not empty', ->
      beforeEach ->
        $('#quick-add-url').val('http://images.com/image.jpg')
<commit_msg>Shorten Event creation in submit_url<commit_after>class FakeWindow
  constructor: (@location) ->

class FakeLocation
  replace: (new_location) ->

submit_url = ->
  e = $.Event('keypress', which: 13)
  $('#quick-add-url').trigger(e)

describe 'quick_add_url', ->
  fake_location = null

  beforeEach ->
    loadFixtures 'quick_add_url.html'
    fake_location = new FakeLocation
    fake_window = new FakeWindow(fake_location)
    window.quick_add_url_init(fake_window)

  describe 'loading an image from a url', ->
    describe 'when the url is empty', ->
      beforeEach ->
        $('#quick-add-url').val('')

      it 'does not submit an AJAX request', ->
        ajax_spy = spyOn($, 'ajax')

        submit_url()
        expect(ajax_spy).not.toHaveBeenCalled()

    describe 'when the url is not empty', ->
      beforeEach ->
        $('#quick-add-url').val('http://images.com/image.jpg')

{'fraction_non_alphanumeric': 0.1422924901185771, 'fraction_numerical': 0.002258610954263128, 'mean_word_length': 3.0364464692482915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2000347', 'n_tokens_mistral': 583, 'n_tokens_neox': 570, 'n_words': 132}