Angular 1.x - Unit Testing a function that returns Promise
var app = angular.module("app");
app.controller("studentController", function($q, studentDataService){
var vm = this;
vm.students = undefined;
activate();
function activate (){
vm.students = getAllStudents();
}
function getAllStudents(){
return studentDataService
.getAll();
}
});
it("should get students on activation", function(done){
// Fixture Setup
// Exercise Systcode
var sut = $controller("studentController");
// Verify Outcome
sut.students.then(function(data){
expect(data).toBeDefined();
done();
});
$rootScope.$apply();
// Fixture Teardown
});