is it possible to use Jasmine unit testing framework\'s spyon method upon a classes private methods?
The documentation gives this example but can this be flexivble for a
if you use Typescript for your objects, the function isn't really private.
All you need is to save the value that returned from spyOn
call and then query it's calls
property.
At the end this code should work fine for you (at least it worked for me):
describe("Person", function() {
it("calls the sayHello() function", function() {
var fakePerson = new Person();
// save the return value:
var spiedFunction = spyOn(fakePerson, "sayHello");
fakePerson.helloSomeone("world");
// query the calls property:
expect(spiedFunction.calls.any()).toBeFalsy();
});
});