Is there a way to correctly pass the following parameters to the unit test spec in jasmine?
params - "userId" : "user1", "location" : "london", "salary" : "33333", "hobby" : "swimming"
Please note that this is an approximation of a unit test spec and may not be entirely accurate.
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 seeking guidance on how to properly pass parameters to a jasmine unit test spec