Jasmine Controller test: $ timeout.flush () throws error "Unexpected GET request"

I have the following test:

it('should load productGroups into the scope', function(){
  scope._section = 'modifiers';
  scope.userData = {method: 'manual'};
  scope.$digest();
  timeout.flush();//causes the error

  expect(scope.productGroups).toEqual(productGroupService.getProductGroups());
});

Now the action that I am trying to check occurs during a timeout of 0, due to some problems that I had with synchronizing the data stored in cookies.

Now, without a marked line, test runs are found, except that the expected result is not obtained. With the marked line, I get the following error:

    Error: Unexpected request: GET views/main.html
    No more request expected
        at $httpBackend (/home/oleg/dev/vita-webapp-new/bower_components/angular-mocks/angular-mocks.js:1178:9)
        at sendReq (/home/oleg/dev/vita-webapp-new/bower_components/angular/angular.js:8180:9)
        at $http.serverRequest (/home/oleg/dev/vita-webapp-new/bower_components/angular/angular.js:7921:16)
        at wrappedCallback (/home/oleg/dev/vita-webapp-new/bower_components/angular/angular.js:11319:81)
        at wrappedCallback (/home/oleg/dev/vita-webapp-new/bower_components/angular/angular.js:11319:81)
        at /home/oleg/dev/vita-webapp-new/bower_components/angular/angular.js:11405:26
        at Scope.$eval (/home/oleg/dev/vita-webapp-new/bower_components/angular/angular.js:12412:28)
        at Scope.$digest (/home/oleg/dev/vita-webapp-new/bower_components/angular/angular.js:12224:31)
        at Scope.$apply (/home/oleg/dev/vita-webapp-new/bower_components/angular/angular.js:12516:24)
        at Object.fn (/home/oleg/dev/vita-webapp-new/bower_components/angular/angular.js:14023:36)


Process finished with exit code 0

main.html is obviously a view of this controller, tried to put it in templateCache with the following code, but this did not help:

$templateCache.put('views/main.html', $templateCache.get('app/views/views/main.html'));

Any help would be greatly appreciated.

+4
source share
1

, , :

$httpBackend.when('GET', 'views/main.html').respond('');

beforeEach

.

, , E2E.

+3

All Articles