angularjs - How do I test if a promise was resolved or rejected using Jasmine? -
i have function calls api service. want mimic case network call failed , rejects promise.
the method (in coffeescript):
find: (collection, query) deferred = $q.defer $http.post config.server + "/api/v1/find/#{collection}", {} .success (result, status, headers, config) -> deferred.resolve result .error (result, status, headers, config) -> deferred.reject result deferred.promise
i understand how setup successful condition:
it "should make request correct url", () -> $httpbackend.expectpost(server+"/api/v1/find/foo").respond(200) entitysvc.find "foo", {} $httpbackend.flush
1) should testing failure of network call or should tested service designer, if so, how check if promise rejected?
2) expectpost assertion testing proper url being built , called input, in previous question, don't know deferred being resolved. how can accomplish this?
Comments
Post a Comment