title: jasmine jquery test to check if correct arguments have been passed to a method
body: <p>I am new to javascript testing.
  I am using jasmine and need to test if correct arguments have been passed to a method.</p>
  
  <p>This is my method:</p>
  
  <pre><code>    function myView(){
        if($('.view').is('.list')){
            myWindow('list');
        }else{
            myWindow('random');
        }
        $('.view').toggleClass('my-list');
      }
  
      function myWindow(list) {
        var url = /test.json;
        $.post(url, {"list": list});
      }
  
  Here are my tests:
  
    describe('#myView', function() {
      beforeEach(function() {
        fixture.load('myview.html');
      });
  
      it('sets window to list', function(){
        expect(window.myWindow).toHaveBeenCalledWith('list');
      });
    });
  </code></pre>
  
  <p>I get the following error.</p>
  
  <pre><code>Error: Expected a spy, but got Function.
  </code></pre>
  
  <p>If i add this line before the expect(which seems wrong because I am specifying the correct param which should be identified by test)</p>
  
  <pre><code>spyOn(window, myWindow('list'));
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>undefined() method does not exist
  </code></pre>
  
  <p>Can someone show my a good way to write the above tests?</p>