Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单元测试AngularJS控制器_Javascript_Angularjs_Unit Testing - Fatal编程技术网

Javascript 单元测试AngularJS控制器

Javascript 单元测试AngularJS控制器,javascript,angularjs,unit-testing,Javascript,Angularjs,Unit Testing,我需要用Jasmine为下面的代码编写一个单元测试。所发生的事情是,它是一个简单的bootstap ui指令,通过tabs作用域在页面上重复创建选项卡 我的问题是我需要测试什么 HTML 您需要测试getList()服务的存根,然后测试promise中的所有$scope变量。也许发布您到目前为止为测试规范提供的内容将允许我们提供更多建议。正如dcodesmith所说,在高层次上,您需要创建getList方法的模拟。然后断言它将返回解析承诺时所需的值。此外,您可以断言scope.tabs包含预期的

我需要用Jasmine为下面的代码编写一个单元测试。所发生的事情是,它是一个简单的bootstap ui指令,通过tabs作用域在页面上重复创建选项卡

我的问题是我需要测试什么

HTML


您需要测试
getList()
服务的存根,然后测试promise中的所有
$scope
变量。也许发布您到目前为止为测试规范提供的内容将允许我们提供更多建议。正如dcodesmith所说,在高层次上,您需要创建
getList
方法的模拟。然后断言它将返回解析承诺时所需的值。此外,您可以断言
scope.tabs
包含预期的数据。
<tabset type="pills" class="profile-content">
  <tab ng-repeat="tab in tabs" heading="{{tab.title}}"  active="tab.active" disabled="tab.disabled">
  <h1>{{tab.title}}</h1>
    <div ng-repeat="item in sections">
      <p>{{item[tab.title]}}</p>
    </div>
  </tab>
</tabset>
 medSelectorProfile.controller('ProfileController', [
        '$scope',
        '$routeParams',
        'localRestangular',
        '$http',
        function($scope, $routeParams, Restangular, $http) {

          Restangular.all('profile/universities/' + ($routeParams.school).toLowerCase() + '.json').getList().then(function(data) {
            $scope.schooldata = data;
            $scope.sections= data[0].sections;
            $scope.name = data[0].name;
            $scope.qualification = data[0].qualification;

          });

          $scope.tabs = [
            { title:'Grades', content: [] , active:true},
            { title:'Entrance exam', content:[]},
            { title:'Admissions policy', content:[]},
            { title:'Interviews', content:[]},
            { title:'Course info', content:[]},
            { title:'Fees', content:[]},
            { title:'Student life', content:[]},
            { title:'Teaching style', content:[]}
          ];

        }
        ]);//ProfileController