i have tried a service call using angular.js and it is working perfectly i am trying to unit test it using jasmine.js but i have come across some errors eventhough i tried so many different methods these errors cannot be recovered
describe('Myctrl', function() {
var $httpBackend, scope, createController, authRequestHandler;
// Set up the module
beforeEach(module('myApp'));
alert("Hello there!");
beforeEach(inject(function ($injector) {
// Set up the mock http service responses
alert("Hello there!");
$httpBackend = $injector.get('$httpBackend');
// backend definition common for all tests
alert("Hello there!");
authRequestHandler = $httpBackend.whenGET('GET', 'http://ift.tt/1aaNO8P')
.respond(true);
// Get hold of a scope (i.e. the root scope)
$rootScope = $injector.get('$rootScope');
// The $controller service is used to create instances of controllers
var $controller = $injector.get('$controller');
createController = function() {
return $controller('Myctrl', {'$scope' : scope});
};
})
);
/*
afterEach(function () {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});
*/
it('should fetch authentication token', function() {
//create expectation
$httpBackend.expectGET('GET','http://ift.tt/1aaNO8P')
var controller = createController()
$httpBackend.flush();
expect(scope.names).toBeTruthy(true);
});
});
what would be the solution for the error ?
Aucun commentaire:
Enregistrer un commentaire