dimanche 6 septembre 2015

Testing directive method call with spyOn having error

I am trying to test directive method using spyOn but my spec gets failed,received this error:

Expected spy buildChart to have been called.

Mydirective method like this:

   $scope.buildChart = function (//arguments) {//statements}
   //call in directive
   $scope.buildChart(//arguments);

myspec for this :

  it('should call the buildChart function', function() {
      var buildSpy = spyOn($scope, 'buildChart');
      expect(buildSpy).toHaveBeenCalled();

    });

how can i test this function have been called?

Aucun commentaire:

Enregistrer un commentaire