describe("Example Of jasmine Spy using spyOn()", function() { it('uses the dictionary to say "hello world"', function() { var dictionary = new Dictionary; var person = new Person; spyOn(dictionary, "hello"); //.and.returnValue('hello'); // replace hello function with a spy //console.log(r); spyOn(dictionary, "world").and.returnValue('worcld'); // replace world function with another spy var retval = person.sayHelloWorld(dictionary); console.log(retval); expect(retval).toBe('hello world'); expect(dictionary.hello).toHaveBeenCalled(); // not possible without first spy expect(dictionary.world).toHaveBeenCalled(); // not possible withoutsecond spy }); });