I have a code snippet that I need to test in my controller:
$scope.fbLogin = function() {
console.log('Start FB login');
facebookConnectPlugin.login(["public_profile", "email", "user_friends"], FacebookServices.fbLoginSuccess, FacebookServices.fbLoginFailure);
};
The facebookConnectPlugin
does not require injection into the controller. By adding
cordova plugin add cordova-plugin-facebook4
, the facebookConnectPlugin
becomes globally accessible.
In unit tests, the facebookConnectPlugin
is not available for mocking since it doesn't need to be injected using the $provide.value()
method anymore.
Here is the error message displayed in both the source code and specs:
ReferenceError: facebookConnectPlugin is not defined at Scope.$scope.fbLogin (/app/signup-and-login/controllers.js:9:6120)
ReferenceError: facebookConnectPlugin is not defined at Object. (/app/signup-and-login/signup-specs.js:93:9)
Could someone help me understand how to mock the plugin and provide it in the unit testing environment?