Unit testing the AngularJS $window service
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I would like to unit test the following AngularJs service: . factory ( 'httpResponseInterceptor' , [ '$q' , '$location' , '$window' , 'CONTEXT_PATH' , function ( $q , $location , $window , contextPath ){ return { response : function ( response ) { //Will only be called for HTTP up to 300 return response ; }, responseError : function ( rejection ) { if ( rejection . status === 405 || rejection . status === 401 ) { $window . location . href = contextPath + '/signin' ; } return $q . reject ( rejection ); } }; }]); I have tried with