Open randalmaia opened 8 years ago
_app.js_
var initApp = function initApp(angularAMD) { var modules = [ 'ngRoute', 'ngResource', 'ngMock', 'tourModule']; var App = angular.module( 'App', modules ); return angularAMD.bootstrap( App ); };
_tourModuleTest.js_
define( [ 'app', 'angularAMD','tourModule' ], function(app, angularAMD) { describe( 'tourModule', function() { var service,tourService,$httpBackend, $rootScope; beforeEach( function() { angularAMD.inject( function($injector) { service = $injector.get('tourInvoiceService'); $rootScope = $injector.get('$rootScope'); $httpBackend = $injector.get('$httpBackend'); $httpBackend.expectGET('.../url/',{}) $httpBackend.whenGET('.../url/',{}); } ); } ); ... it( 'Verify tourService.start has been called', function() { service(); $httpBackend.flush(); } ); } ); } );
My app.js is exclusive for karma run. TourModule is app dependency.
This is the _$httpBackend object_ on debug.
If I inject $httpBackend without AngularAMD.inject and with default inject the methods(get, whenGet) exist, but the $httpBackend.flush dont find none http request to mock.
_app.js_
_tourModuleTest.js_
My app.js is exclusive for karma run. TourModule is app dependency.
This is the _$httpBackend object_ on debug.