I'm facing a challenge with creating a unit test for the child controller. In the child controller, I made a function call to the parent.
Child Controller
$scope.clickMe = function(){
$scope.parentMethod();
})
Parent Controller
$scope.parentMethod = function(item){
//perform actions in the parent
})
Unit Test
var childCtrl;
beforeEach(module('myApp'));
beforeEach(inject(function (_$controller_, _$rootScope_) {
scope = _$rootScope_.$new();
childCtrl = _$controller_('childCtrl', {
$scope: scope
});
}));
describe('testing parent method', function() {
it('should invoke parent method', function() {
$scope.clickMe();
$httpBackend.flush();
});
});
});
Currently encountering an issue:
TypeError: 'undefined' is not a function (evaluating '$scope.parentMethod()')
Seeking assistance on resolving this matter. Any help would be greatly appreciated. Thank you!