You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
782 B
20 lines
782 B
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
|
|
});
|
|
});
|