标签:des blog http io os ar for 数据 sp
describe(‘Controllers: CheckListOverCtrl‘, function () { var $scope, ctrl, $httpBackend; var data = []; data.d = [{ name: ‘name1‘, ProjectName: "ProjectName1", I_Category: "I_Category1", uName: "uName1", dName: "dName1", D_Create: "D_Create1" }, //{ name: ‘name2‘, ProjectName: "ProjectName2", I_Category: "I_Category2", uName: "uName2", dName: "dName2", D_Create: "D_Create2" }, { name: ‘name3‘, ProjectName: "ProjectName3", I_Category: "I_Category3", uName: "uName3", dName: "dName3", D_Create: "D_Create3" }]; beforeEach(angular.mock.module(‘app.audit‘)); beforeEach(angular.mock.inject(function ($rootScope, $controller, _$httpBackend_) { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); ctrl = $controller(‘CheckListOverCtrl‘, { $scope: $scope }); })); it("标题测试", function () { expect($scope.$root.title).toBe(‘已审列表‘); }); it("取数据测试", function () { expect($scope.list.length).toBe(0); $httpBackend.expectPOST(‘/Services/AuditWebForm.aspx/GetCheckListOver‘).respond(data); $httpBackend.expectPOST(‘/Services/UserAuth.aspx/GetUidList‘).respond(‘‘); $httpBackend.flush(); expect($scope.list.length).toBe(2); }); it("链接测试", function () { expect($scope.gethref(1, 1, 1)).toBe(‘../projectView/flowChart?id=1&type=1‘); expect($scope.gethref(2, 1, 1)).toBe(‘../budgetView/flowChart?id=1&ProjectId=1&type=2‘); expect($scope.gethref(3, 1, 1)).toBe(‘../contractView/flowChart?id=1&ProjectId=1&type=3‘); expect($scope.gethref(4, 1, 1)).toBe(‘../ExpenseView/flowChart?id=1&ProjectId=1&type=4‘); expect($scope.gethref(5, 1, 1)).toBe(‘../ReceiptView/flowChart?id=1&ProjectId=1&type=5‘); expect($scope.gethref(6, 1, 1)).toBe(‘../WorkView/flowChart?id=1&ProjectId=1&type=6‘); }); it("type字符串测试", function () { expect($scope.typestring(1)).toBe(‘项目‘); expect($scope.typestring(2)).toBe(‘预算‘); expect($scope.typestring(3)).toBe(‘合同‘); expect($scope.typestring(4)).toBe(‘报销‘); expect($scope.typestring(5)).toBe(‘发票‘); expect($scope.typestring(6)).toBe(‘工单‘); }); it("时间字符串测试", function () { expect($scope.datestring(‘2014-10-09T 09:43:00‘)).toBe(‘2014-10-09‘); }); });
controller为audit。测试getlist方法。预先留好返回值,在测试的具体方法it()内,预设expectpost ,表明flush时会按预设的expensepost走。
标签:des blog http io os ar for 数据 sp
原文地址:http://www.cnblogs.com/tanpangpang/p/4013374.html