这是我的控制器代码。
但它正在获取浏览器的当前URL,因此会引发错误。
$scope.loadApplications = function () {
var cacheKey = { key: cacheKeys.appList() };
dataFactory.get("/Application/All", { cache: cacheKey })
.then(function (result) {
$scope.count++;
$scope.applications = result.data.data;
$scope.filteredApplicationsList = $scope.applications;
if ($scope.applications.length===0){
$window.location.href = '/Account/WelCome'
}
else {
$scope.isLoad = true;
}
});
};
这是我针对以上函数编写的Jasmine测试用例:
it('should redirect to welcome page', function () {
scope.applications = {};
scope.loadApplications();
expect(window.location.href).toContain('/Account/WelCome');
});
但它正在获取浏览器的当前URL,因此会引发错误。
Expected 'http://localhost:49363/Scripts/app/test/SpecRunner.html' to contain '/Account/WelCome'.
请问有谁可以告诉我如何测试 URL?