Idea is to check how some method was called. Check this example:
describe("A spy", function() { var foo = jasmine.createSpyObj("foo", ["setBar"]) it("To have been called with", function() { foo.setBar.calls.reset(); foo.setBar(123); expect(foo.setBar).toHaveBeenCalledWith(123); }); });
Notice line:
foo = jasmine.createSpyObj("foo", ["setBar"])
With that we created "mock" object named "foo", with one method "setBar".
Then notice line:
foo.setBar(123);
We that line we "called" setBar method with parameter "123". Now we want to check if that method was called with correct parameter ("123"):
expect(foo.setBar).toHaveBeenCalledWith(123);