vendredi 28 août 2015

Angularjs test function declared in $promise.then block

I want to test function f1 my code looks like:

$rootScope.aaa.$promise.then(
  function (aaa){ 
    $scope.f1 = function(x){ 
      return aaa + x;
    }
  }
);

my tests looks like:

it('f1 should be defined', function(){
  expect(scope.f1).toBeDefined();
  expect(scope.f1(5)).toEqual(6);
};

What I should do to make karma wait for scope load?

Aucun commentaire:

Enregistrer un commentaire