angularjs - UI Router resolve throws Unexpected Get request in Angular -


i'm using ui router , define site-wide resolve.

$stateprovider   .state('site', {     abstract: true,     resolve: {       exampleresolve: function(myapiservice) {         return myapiservice.get();       }     },     views: {       'site': {         template: '<ui-view/>'       }     }   }) 

however, have custom directive, , when unit test it, i'm getting 'error: unexpected request: /api/example' (which `myapiservice.get()).

it('should something', function() {   scope.example.data = '123';   scope.$digest();   element.triggerhandler('blur');   console.log(element); }) 

somehow throws error: unexpected request: /api/example

try mocking myapiservice call should not delegate actual implementation.

it( 'should something', inject( function( myapiservice ) { spyon( myapiservice, 'get' ).and.callfake( function() {     return true; } ); scope.example.data = '123'; scope.$digest(); element.triggerhandler( 'blur' ); console.log( element );} ) ); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -