The following spy on location.path is failing with an error:
Attempted to wrap undefined property path as function
it('should redirect location.path', function() { sinon.spy(location, 'path'); scope.create(); expect(location.path).to.have.been.calledOnce; location.path.restore();
Mock Controller:
describe('AdminUsersController', function() {
var Users;
beforeEach(inject(function(_$controller_, $rootScope, $location, _Users_, _$httpBackend_) {
var location;
scope = $rootScope.$new();
location = $location;
controller = _$controller_('AdminUsersController', {
$scope: scope,
$location: location
});
Line that I'm trying to test:
$scope.create = function() {
return $location.path("admin/users/newuser?create");
};