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
Post a Comment