AngularJS - How to test if a function is called from within another function?
问题 I'm trying to get started with karma-jasmine and I'm wondering why this test fails: it("should call fakeFunction", function() { spyOn(controller, 'addNew'); spyOn(controller, 'fakeFunction'); controller.addNew(); expect(controller.fakeFunction).toHaveBeenCalled(); }); In my controller that I've previously set up for this test I have the following: function addNew() { fakeFunction(3); } function fakeFunction(number) { return number; } both addNew and fakeFunction are exposed using: vm.addNew =