I'm new to unit testing and trying to write a unit test for my app. My Route is :
{
name: 'details',
url: '/accounts/company/:companyId',
controller: 'controllere',
templateUrl: 'templateurl',
}
My Controller :
if (!$stateParams.companyId) {
$scope.promise = $state.go('home');
} else {
// get company details
}
In my unit test I need to test if "companyId" is present in the URL, then only proceed with the rest else redirect to "home". I tried this code but it fails everytime. I don't know what wrong I'm doing.
it('should respond to URL with params', function() {
expect($state.href('/accounts/company/', { companyId: 'test-company' })).toEqual('#/accounts/company/test-company');
});
Everytime I run this test it says : Expected null to equal '#/accounts/company/test-company'.