Como simular uma função window.location no Karma / jasmine

Gostaria de zombar de uma funcionalidade no Karma que retorna um arquivo depois de clicar no botão de download. Eu tenho o seguinte controlador AngularJS:

var secure = angular.module('secure', []);
secure.controller('ProcedureController', ProcedureController);
ProcedureController.$inject = ['$controller', '$rootScope', '$scope', '$http'];

function ProcedureController($controller, $rootScope, $scope, $http) {

  ... // Controller does more stuff

  var href = window.location.href.split('/');
  var baseUrl = href[0] + '//' + href[2];
  var url = baseUrl + "/secure/regulations";

  $http.get(url)
    .success(function (data) {
        $scope.questions = data[0];
    })

  $scope.download = function (msg) {
    window.location = url + "/" + msg + "/attachment";
  }
}

O objeto window.location chama um serviço RESTful que fornece diretamente o arquivo desejado. E este é, basicamente, o meu teste de teste:

describe('ProcedureController', function () {
  beforeEach(module('secure'));

  beforeEach(inject(function ($rootScope, $http, $controller, $injector) {
    scope = $rootScope.$new();
    ProcedureController = $controller('ProcedureController', {
        $scope: scope,
        $http: $http
    });
  }));

  it ('should download something', function() {
    expect(scope.download(1)).toBeDefined();
  });

 });

Então, minha ideia é verificar quandoscope.download é chamada, se retornar o URL correto, ou seja, quando tentoscope.download (1), a resposta esperada seria/ seguro / regulamentos / 1 / anexoaproximadamente.

Como devo zombar? Qualquer ajuda é apreciada!

questionAnswers(2)

yourAnswerToTheQuestion