title: How to test if method has been called only once and not the second time in Jasmine?
body: <p>I am testing mechanism that should call method once and prevent any subsequent calls with jasmine, I can see by attaching breakpoints that method is NOT being called second time however jasmine test fails. I would assume it has to do with <code>spy</code> not being designed to be used for multiple checks.<br>
  <strong>What would be proper solution to given situation?</strong></p>
  
  <p><a href="http://jsfiddle.net/wzAyL/124/" rel="noreferrer">JSfiddle of Code that is being tested</a> I could not figure out how to do jasmine test jsfiddle properly (Jasmine version I am using is 1.3.1 while test template is on 1.2.0).</p>
  
  <p>Test looks like this:</p>
  
  <pre><code> it("Invoking OnPreQuery will add event listener for OnTheMoveViewPreLoad event. Triggering OnTheMoveViewPreLoad twice will call getChildrenForMasterRecordList only first time", function () {
              AddTreeSettingsObjectToBC({ bc: bc, Tree: { IncludeChildren: true} });
              ComposeMockPageObjWithObservableFieldsWithChildren();
              var preQuerySpy = spyOnEvent(onTheMove.PageDataRoles, 'OnPreQuery');
              $(onTheMove.PageDataRoles).trigger('OnPreQuery', { knockoutContextName: 'bc' });
              expect('OnPreQuery').toHaveBeenTriggeredOn(onTheMove.PageDataRoles);
              expect(preQuerySpy).toHaveBeenTriggered();
              var getChildrenForMasterRecordListSpy = spyOn(window, 'getChildrenForMasterRecordList');
              $(onTheMove.PageDataRoles).trigger('OnTheMoveViewPreLoad', { knockoutContextName: 'bc' });
              expect(getChildrenForMasterRecordListSpy).toHaveBeenCalled();
              $(onTheMove.PageDataRoles).trigger('OnTheMoveViewPreLoad', { knockoutContextName: 'bc' });
              expect(getChildrenForMasterRecordListSpy).not.toHaveBeenCalled();
          });
  </code></pre>
  
  <p>Code that is being tested: 
  HTML</p>
  
  <pre><code>&lt;div data-role="page"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Javascript</p>
  
  <pre><code>var onTheMove = function(){};
  $.extend(onTheMove,{
      NullValue : "null",
      PageDataRoles : 'div[data-role="page"], div[data-role="dialog"]',
      OnTheMovePrefix : 'OnTheMove_'
      });
  
  $(document).on('OnPreQuery', onTheMove.PageDataRoles, function (e, options) {
      var isChildAttachmentQueued = true;
      var knockoutContextName = options.knockoutContextName;
      if (TreeEnabled(knockoutContextName)) {
          var isModelReadyToAttachChildren = function () {
              var isReady = false;
              if (PageObj[knockoutContextName] != undefined) {
                  isReady = (PageObj[knockoutContextName]().length &gt; 0) &amp;&amp; isChildAttachmentQueued;
              }
  
              return isReady;
          };
          var treeSettings = eval(knockoutContextName).Tree;
          treeSettings.knockoutContextName = knockoutContextName;
          $(onTheMove.PageDataRoles).on('OnTheMoveViewPreLoad', function (e, options) {
              if (isModelReadyToAttachChildren()) {
                  getChildrenForMasterRecordList({
                      parentTable: eval(knockoutContextName).primaryTableName,
                      knockoutContextName: treeSettings.knockoutContextName,
                      parentIdColumn: treeSettings.ParentIdColumn,
                      masterIdColumn: treeSettings.MasterIdColumn
                  });
                  isChildAttachmentQueued = false;
              }
          });
      }
  });
  function getChildrenForMasterRecordList(options) {
      console.log('beep');
  }
  </code></pre>