Here is my appSpec.js
code:
describe('working app', function () {
var ctrl, scope;
describe('check the number of books', function () {
var httpBackend;
beforeEach(inject(function ($rootScope, $controller, $httpBackend, $http) {
httpBackend = $httpBackend;
scope = $rootScope.$new();
controller = $controller;
// books.json - array of objects(8 items). It is situated in the directory with my appSpec.js
httpBackend.when("GET", "/books.json'").respond([{}, {}, {}, {}, {}, {}, {}, {}]);
$controller('appCtrl', {
$scope: scope,
$http: $http
});
}));
it("should have 8 books", function () {
httpBackend.flush();
expect(scope.books.length).toBe(8);
});
});
});
But jasmine gives an error No pending request to flush ! What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire