title: How to test a click event in the Jasmine Test runner in Backbone?
body: <p>I have a spec in which I want to test if a method is called when a button is clicked.</p>
  
  <p>I have registered the click event in the View file:</p>
  
  <pre><code>events: {
      'click #toggle': 'onClickToggle'
  }
  </code></pre>
  
  <p>My test file looks like:</p>
  
  <pre><code>describe('Todo Item\'s view\'s suite', function() {
  
      let view;
  
      beforeEach(function() {
          const todoItem = new TodoItem({ description: 'Some Todo ' });
          view = new TodoItemView({ model: todoItem });
  
          const html = '&lt;label&gt;&lt;input type="checkbox" id="toggle" /&gt;Some Desc&lt;/label&gt;&lt;button id="delete"&gt;Delete&lt;/button&gt;';
          view.$el.html(html);
      });
  
      it('clicking on element or checkbox should invoke the onClickToggle method', function() {
          spyOn(view, 'onClickToggle');
  
          view.$('#toggle').click();
  
          expect(view.onClickToggle).toHaveBeenCalled();
      });
  });
  </code></pre>
  
  <p>I have referenced all the required files in the test runner HTML including jQuery, Jasmine, jQuery-Jasmine. But when the spec file is run in te browser, the test fails.</p>
  
  <p>The following error is thrown:</p>
  
  <pre><code>Error: Expected spy onClickToggle to have been called.
      at &lt;Jasmine&gt;
      at UserContext.&lt;anonymous&gt; (http://127.0.0.1:5500/tests/jasmine/spec/views/TodoItemViewSpec.js:28:36)
      at &lt;Jasmine&gt;
  </code></pre>