2017-01-11 55 views
0

我最近更新了我的Angular應用從1.5.8到1.6.1。 在測試中,$ httpBackend.flush()開始更改路由並廣播'$ routeChangeStart'消息,該消息開始調用正在監聽事件的函數。

我是否在遷移中缺少某些東西?

//Function listening to the $routeChangeStart 
$rootScope.$on("$routeChangeStart", function (event, next) { 
    console.log('This is called'); 
}); 

//Test 
describe('Testing', function() { 
    it.only('Testing', function() { 
    //Code 
    $httpBackend.when('GET', endpoints.endpoint1).respond([]); 
    $httpBackend.flush(); 

    }); 
}); 
+0

$httpBackend.whenGET('url').respond(200, { data: "ok"});請分享 – Codesingh

+0

@Codesingh共享 – Sabby62

回答

0

請補充一點:在您的測試

+0

代碼這有什麼區別? $ httpBackend.flush()正在調用路由更改。 – Sabby62