[英]Angular.js promise not resolving when unit testing service with karma
[英]How to ignore a run.js in Angular / Karma unit testing?
我有一個文件run.js
具有:
window.map.run([
'$rootScope', '$location', 'cache', 'userCache',
function($rootScope, $location, cache, userCache) {
userCache.checkSession().then(function(result) {
if(result.userId) {
cache.set('login', 'successfulLogin', true);
if($location.path() !== '/patients') {
$location.path('/patients');
}
}
});
}
]);
在應用加載時運行。 這通常是很好的行為。 但是當我進行單元測試控制器時,一切都會變得一團糟。 我不知道該如何spy
或mock
它,否則它是錯誤的。 有任何想法嗎?
謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.