2016-04-04 8 views
9

जब मैं 1.5.1 करने के लिए कोणीय मार्ग 1.5.0 अद्यतन करने के लिए, मैं एक त्रुटि हैकर्म करते समय त्रुटि अद्यतन कोणीय मार्ग 1.5.0 1.5.1

1) Call getAll method [App Category] Error: Unexpected request: GET http://myapp.com/app-category?is_active=true No more request expected in /node_modules/angular-mocks/angular-mocks.js

app_category.model.test.js

describe('[App Category]', function() { 

    beforeEach(module('myApp')); 

    var $httpBackend, HttpService, AppCategory; 

    beforeEach(inject(function (_$httpBackend_, _HttpService_, _AppCategory_) { 
     $httpBackend = _$httpBackend_; 
     HttpService = _HttpService_; 

     AppCategory = _AppCategory_; 
    })); 

    it('Call getAll method', function() { 
     var app_category = new AppCategory(); 

     HttpService.mock('GET', 'app-category?is_active=true', 200, [{ code: 'TRAVEL', name: 'Travel' }]); 

     app_category.getAll({ is_active: true }).then(function (request) { 
      expect(request.data[0].code).toBe('TRAVEL'); 
      expect(request.data[0].name).toBe('Travel'); 
     }); 

     $httpBackend.flush(); 
    }); 

}); 

कोणीय मीटर:

जब मैं कर्म लॉन्च करते हैं, मुझे एक त्रुटि संदेश है

case 'GET': 
    $httpBackend 
     .expectGET(this.endpoint + url) 
     .respond(status, response); 
break; 

इस द्वारा: ockHTTP.js

(function (angular) { 
    'use strict'; 

    angular.module('ngMockHTTP', []).service('HttpService', function ($httpBackend, config) { 
     this.endpoint = config.api.endpoint; 

     this.mock = function (method, url, status, response) { 
      switch (method) { 
       case 'GET': 
        $httpBackend 
         .expectGET(this.endpoint + url) 
         .respond(status, response); 
       break; 
       case 'POST': 
        $httpBackend 
         .expectPOST(this.endpoint + url) 
         .respond(status, response); 
       break; 
       case 'PUT': 
        $httpBackend 
         .expectPUT(this.endpoint + url) 
         .respond(status, response); 
       break; 
       case 'PATCH': 
        $httpBackend 
         .expectPATCH(this.endpoint + url) 
         .respond(status, response); 
       break; 
       case 'DELETE': 
        $httpBackend 
         .expectDELETE(this.endpoint + url) 
         .respond(status, response); 
       break; 
      } 
     }; 
    }); 
})(angular); 

मैं remplace करने की कोशिश की

case 'GET': 
    $httpBackend 
     .whenGET(this.endpoint + url, { 
    }).respond(function(){ return [200, response]}); 
break; 

लेकिन मैं एक ही त्रुटि

मैं उपयोग चमेली 2.4.1 है, AngularJS 1.5.3, कर्म 0.13.0

+1

ही यहां मुद्दा। इसे समझ में नहीं आया इसलिए मैं फिर से 1.5.0 तक डाउनग्रेड कर दिया। – cgcladera

+1

1.5.1 और 1.5.3 दोनों के साथ यहां एक ही समस्या है। 1.5.0 तक डाउनग्रेडिंग ... – lucassp

+0

कोणीय मार्ग 1.5.1, 1.5.2 और 1.5.3 ... एक ही समस्या ... –

उत्तर

1

मैंने angularjs 1.5.5 के साथ अद्यतन किया, यह काम करता है!

CHANGELOG.md 1.5.5 (जारी 2016/04/18) से

:

"ngRoute: allow ngView to be included in an asynchronously loaded template Eagerly loading $route, could break tests, because it might request the root or default route template (something $httpBackend would know nothing about).

It will be re-applied for v1.6.x, with a breaking change notice and possibly a way to disable the feature in tests."

2

यह त्रुटि पहले से ही कोणीय टीम द्वारा जानी जाती है। इस बग के लिए वर्कअराउंड $ टेम्पलेट कैश में एक डमी टेम्पलेट को परिभाषित करना है।
अधिक जानकारी के लिए: link

+0

हाँ मुझे पता है लेकिन मैं इस समस्या को ठीक करना चाहता था –

संबंधित मुद्दे