lundi 28 mars 2016

How to pass parameter in Jasmin Unit Test?

How do i pass list of parameters to the below unit test spec in jasmine? This is an approximate unit test spec and not an accurate one.

describe("my jasmine test suite", function() {

   var params,
       myController

   beforeEach(function() {
     module('myApp');
     mockService = jasmine.createSpyObj('mockService',['serviceCall']);

     module(function($provide) {

          $provide.value('myService',mockService);

       });

     inject(function($controller,$q,_$rootscope_) {
     mockService.serviceCall.and.callFake(function(srvcname,mthdname,params)
       {  
         var resData = {};
        if(mthdname === 'servicecall')
         {
            // assign the mockdata
          }
            return mockData;
     });

     $rootscope = _$rootscope_;
     myScope = $rootscope.$new();

    myController = $controller('myController',{$scope:myscope});
 });

});

it('my test spec',function() {

    expect(mockService.serviceCall).toHaveBeenCalled();

    expect(myscope.searchRslt[0]).toBe(mockData.searchRslt[0]);
    $rootScope.$digest();

});

});

I am not sure how do pass the parameter to the jasmine unit test spec

Aucun commentaire:

Enregistrer un commentaire