2017-03-14 4 views
0

私はAngularJSとそのユニットテストの初心者です。現在、私は、テンプレートファイルにそのコントローラとディレクティブをテストしようとしています:ユニットテストで指示文をコントローラに渡す方法

それはテンプレートです:

<div ng-controller = "SomeController" > 
<select ng-model="data.selectedOption" 
     ng-options="data.code for data in data.availableOptions track by data.code"> 
</select> 
</div> 

それはJSファイルです:

angular.module('application.directives') 
    .directive('selector', function() { 
    return { 
     restrict: 'E', 
     templateUrl: 'templates.html' 
    }; 
    }); 

今、私のようなユニットテストを持っています

describe('selector', function() { 
    beforeEach(module('application.directives','application.templates')); 

    it('render the correct number of items', inject(function ($rootScope, $compile) { 
    var element = $compile('<selector></selector>')($rootScope); 
    $rootScope.$digest(); 
    //I'd like to register the selector's controller here. 
    })); 
}); 

テストコードでは、コントローラを登録するにはどうすればよいでしょうか?私は偽のものを作る必要がありますか?

おかげ

答えて

関連する問題