I have a controller that has a callback inside:
angular.module('controllers').controller('MainCtrl', function() {
var result = {};
var self = this;
this.test = function(data) {
jsonld.expand(data, function(err, expanded) {
self.result = expanded
});
}
})
My problem is that I need to check the value of "result" in an unit test, but if I just call ctrl.test(data) and then ctrl.result, the value of ctrl.result is {} and it should be what was returned by the test function (inside jsonld.expand). Is there a way to test this behavior (test the self.result when the callback occurs)?
I already searched about this, but everything I found is related to custom services, but in this case this is an external library (http://ift.tt/1KC6Zqs)
Aucun commentaire:
Enregistrer un commentaire