D
D
Dmitry2016-04-11 20:45:32
Angular
Dmitry, 2016-04-11 20:45:32

How to test this in Angular?

There is a controller.

function CustomersController(Customer) {
  var vm = this;
  Customer.getAll().success(function(data) {
    vm.allCustomers = data;
  });
}

and service:
function UserService($http, $timeout, $q) {
  this.getAll = getAll;
  function getAll() {
    return $http.get('./users.json');
  }
}

How in the controller to test receiving data from the service with this approach?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-04-11
Protko @Fesor

Can you specify what exactly you want to test, service or controller?
Service - $httpBackend mock (available in the dock). Controller - we mock UserService.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question