Sha256: bed5ed787251216258fbbaaf7a5e73ad7c3cd440ca8dbb10a3270f06b0208397
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
describe "services", -> beforeEach module("mb.alerts") beforeEach module("mb.services") beforeEach module("mocks") describe "httpErrorsInterceptor", -> $http = null promise = null interceptor = null alerts = null $q = null errorHandler = null beforeEach inject ($injector) -> $http = $injector.get("$http") interceptor = $injector.get("httpErrorsInterceptor") alerts = $injector.get("alerts") $q = $injector.get("$q") promise = then: jasmine.createSpy("then").andReturn({}) interceptor(promise) spyOn(alerts, "push") spyOn($q, "reject") errorHandler = promise.then.mostRecentCall.args[1] it "alerts an error on failed http request", -> httpResponse = status: 500 errorHandler(httpResponse) expect(alerts.push).toHaveBeenCalledWith("error", "Unexpected HTTP error") expect($q.reject).toHaveBeenCalledWith(httpResponse) describe "when http response includes an error message", -> it "alerts this error", -> httpResponse = status: 500, data: error: "The custom message" errorHandler(httpResponse) expect(alerts.push).toHaveBeenCalledWith("error", "The custom message") expect($q.reject).toHaveBeenCalledWith(httpResponse)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongo_browser-0.2.5 | spec/javascripts/app/services_spec.js.coffee |