AngularJS + Jasmine + JWT Token in $http requests -


i'm trying build test api works jwt authentication tokens, factories i'm trying test use $resouce, needs configured jwt token. in app configure in .config, in jasmine have no idea how should be, because jasmine runs before app.

i'm trying find way configure jasmine's requests or maybe run tests after app configured.

here i'm trying configure jasmine's requests.

describe("sync.remote", function () {     var remote = angular.injector(['sync.remote']).get('remote')('test', 'test')       , testingobject = { name: "mario", lastname: "lópez" }      beforeeach(inject(function (_$httpprovider_, _jwtinterceptorprovider_, _$resourceprovider_) {         $httpprovider = _$httpprovider_         jwtinterceptorprovider = _jwtinterceptorprovider_         $resourceprovider = _$resourceprovider_          jwtinterceptorprovider.authprefix = "jwt "         jwtinterceptorprovider.tokengetter = function(config) {             if(config.url.indexof("http://some.website.com") === 0) {                 return "xxxxxxx-jwt-token"             }         }          $httpprovider.interceptors.push('jwtinterceptor')         $httpprovider.defaults.withcredentials = true         $resourceprovider.defaults.striptrailingslashes = false     }))      it("#_create es capaz de crear un objeto en la nube", function (done) {         remote._create(testingobject)         .then(function (item) {             expect(item.id).not.tobe(undefined)         }, function (err) {             expect(0).toequal(1)         })         .finally(done)     }) }) 

but doesn't work because $resouce service inside remote factory, dependecy actually. ideas?


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -