angularjs - Test Cases for methods written in Angular js -


i'm absolute newbie angularjs. i've written below functions in angular js.

$scope.clickoncegetprofilesbyenv = function () {          $scope.ptpprofilelist = undefined;         $scope.ptpperson = undefined;          var params = {             environment: $scope.ptpenvironment,             searchcriteria: null,             catalogname: null,             catalogid: null,             profileid: null,             identityid: null          };         channelservice.doapicall(channelapp.configdata.basedirectory + '/api/testharness/getprofiles/', 'post', params)                  .success(function (data) {                      if (data) {                          $scope.ptpprofiles = data;                      } else {                          $scope.ptpprofiles = {};                      }                  }).error(function (data) {                      $scope.ptpprofiles = {};                  });      };      $scope.clickoncegetidentities = function () {         $scope.ptpperson = undefined;         var profileid = $scope.ptpprofilelist.profileid;         var params = {             environment: $scope.ptpenvironment,             searchcriteria: null,             catalogname: null,             catalogid: null,             profileid: profileid,             identityid: null         };          channelservice.doapicall(channelapp.configdata.basedirectory + '/api/testharness/getidentities/', 'post', params)                   .success(function (data) {                       if (data) {                           $scope.ptpidentity = undefined;                           $scope.ptpidentitys = data;                       } else {                           $scope.ptpidentity = {};                       }                   }).error(function (data) {                       $scope.ptpidentity = {};                   });     }      $scope.publishtoprocessor = function () {         $scope.setloading(true);         var params = {};         params = {             environment: $scope.parnewenvironment,             profileid: $scope.ptpprofilelist.profileid,             identityid: $scope.ptpperson.identity_id,             catalogtype: $scope.parcatalogtype         };         $http.post(channelapp.configdata.basedirectory + "/catalog/publishtoprocessor", params).success(function (data) {              $scope.setloading(false);         }).error(function (error) {             alert('error while publishing processor');             $scope.setloading(false);         });     }; 

for above methods, i've written below test methods.

it('should profiles based on environment', function() {         cataloglist.scope.$apply();         cataloglist.scope.clickoncegetprofilesbyenv();         $timeout.flush();         expect(cataloglist.scope.ptpprofiles);     });      it('should identities environment', function() {         cataloglist.scope.$apply();         cataloglist.scope.clickoncegetprofilesbyenv();         cataloglist.scope.clickoncegetidentities();         $timeout.flush();     });      it('should publish processor', function () {         cataloglist.scope.$apply();         cataloglist.scope.clickoncegetprofilesbyenv();         cataloglist.scope.clickoncegetidentities();         cataloglist.scope.publishtoprocessor();         $timeout.flush();     }); 

kindly advise me whether i'm right or wrong. let me know if further changes required.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -