测试详情页的时候 是url带参数过去处理的 。
我在写测试spec文件我要怎么处理可以对url参数赋值操作。
describe('Controllers: CheckInfoCtrl', function () { var $scope, ctrl, $httpBackend; beforeEach(module('app.audit')); beforeEach(inject(function ($rootScope, $controller, _$httpBackend_) { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); ctrl = $controller('CheckInfoCtrl', { $scope: $scope }); $scope.Id = "13049734/3"; })); it('title测试', function () { expect($scope.$root.title).toBe('审核'); }); });
$scope.Id 是要赋值操作的参数。有什么解决办法吗???
beforeEach(angular.mock.inject(function ($rootScope, $controller, _$httpBackend_) { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); location.search = "?Id=13049395&ProjectId=13040953"; ctrl = $controller('WorkCreateCtrl', { $scope: $scope }); }));
beforeEach(angular.mock.inject(function ($rootScope, $controller, _$httpBackend_) { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); location.search = "?Id=13049395&ProjectId=13040953"; ctrl = $controller('WorkCreateCtrl', { $scope: $scope }); }));