首页 新闻 会员 周边 捐助

angular 测试

0
悬赏园豆:20 [已关闭问题] 关闭于 2014-10-10 17:21

测试详情页的时候  是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 是要赋值操作的参数。有什么解决办法吗???

战马的主页 战马 | 初学一级 | 园豆:27
提问于:2014-10-09 16:07
< >
分享
所有回答(1)
0
 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 });    }));

战马 | 园豆:27 (初学一级) | 2014-10-10 17:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册