i am new to angularjs ,i have with my first angular app now i want to test them as well in my app i get some Json data from url and populate in a list i want to test http request but my test fails here is my controllerspec: describe('myAppCtrl', function() { var scope, controller, httpBackend;
beforeEach(module('myApp'));
beforeEach(inject(function($rootScope, $controller, $httpBackend) {
scope = $rootScope;
controller = $controller;
httpBackend = $httpBackend;
}));
it('should populate the reddit data when the HTTP request succeeds', function() {
httpBackend.when('GET','http://ift.tt/1KEkUhj').respond({names});
controller('myAppCtrl', {'$scope': scope });
httpBackend.flush();
scope.$apply();
expect(scope.names.children.length).toEqual(25);
});
it('should show the number of items in list',function() {
var data = $('#title');
expect(data).toBeTruthy();
//expect(1).toBe(1);
});
});
Aucun commentaire:
Enregistrer un commentaire