I have a ui-select field
{
  key: 'data_id',
  type: 'ui-select',
  templateOptions: {
    required: true,
    label: 'Select label',
    options: [],
    valueProp: 'id',
    labelProp: 'name'
  },
  controller: function($scope, DataService) {
    DataService.getSelectData().then(function(response) {
      $scope.to.options = response.data;
    });
  }
}
How can I access that inner controller in my unit tests and check that data loading for the select field actually works ?
UPDATE: An example of a test could be as such:
var initializePageController = function() {
  return $controller('PageCtrl', {
    '$state': $state,
    '$stateParams': $stateParams
  });
};
var initializeSelectController = function(selectElement) {
  return $controller(selectElement.controller, {
    '$scope': $scope
  });
};
Then test case looks like:
it('should be able to get list of data....', function() {
   $scope.to = {};
   var vm = initializePageController();
   $httpBackend.expectGET(/\/api\/v1\/data...../).respond([
     {id: 1, name: 'Data 1'},
     {id: 2, name: 'Data 2'}
   ]);
   initializeSelectController(vm.fields[1]);
   $httpBackend.flush();
   expect($scope.to.options.length).to.equal(2);
});
 
                        
You could do it a few ways. One option would be to test the controller that contains this configuration. So, if you have the field configuration set to
$scope.fieldslike so:Then in your test you could do something like:
Then do your assertions.