marcoslin / angularAMD

Facilitate use of RequireJS in AngularJS
http://marcoslin.github.io/angularAMD
MIT License
734 stars 171 forks source link

$httpBackend.expectGET is not a function #159

Open randalmaia opened 8 years ago

randalmaia commented 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. screenshot from 2015-10-26 10 30 24

randalmaia commented 8 years ago

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.