lundi 7 septembre 2015

Angular JS tests with Jasmine and PhantomJS, 0 Error

I need to test code of controllers, but i can't see right result, code below: "slide" array length = 4; but in test i write "toBe(2)" and i see:

PhantomJS 1.9.8 (Linux 0.0.0): Executed 0 of 0 ERROR (0.035 secs / 0 secs)

Why i see 0 errors, if i expect 2, but array length is 4 ???

app.controller('mainCtrl',['$scope', function($scope){
  $scope.slide = [1, 2, 3, 4];
}]);







describe('Tests Controllers', function() {
  beforeEach(module('app'));

  var $controller;

  beforeEach(inject(function(_$controller_, $rootScope){
   
    $controller = _$controller_;

    it('check slides length, it should be 4', function() {
      var $scope = {};
      var controller = $controller('mainCtrl', { $scope: $scope });
      expect($scope.slide.length).toBe(2);
    });



  }));


});

Aucun commentaire:

Enregistrer un commentaire