UNPKG

@dasch-swiss/dsp-js

Version:

JavaScript library that handles API requests to Knora

27 lines 1.36 kB
import { AjaxError, AjaxResponse } from "rxjs/ajax"; import { ApiResponseData } from "./api-response-data"; import { ApiResponseError } from "./api-response-error"; describe("Test class ApiResponseError", function () { describe("Test method fromAjaxError()", function () { var ajaxError = new AjaxError("Error", new XMLHttpRequest(), {}); var apiResponseError = ApiResponseError.fromAjaxError(ajaxError); it("should be an instance of ApiResponseError", function () { expect(apiResponseError).toEqual(jasmine.any(ApiResponseError)); }); it("should store the original error", function () { expect(apiResponseError.error).toBe(ajaxError); }); }); describe("Test method fromErrorString()", function () { var errorString = "Error string"; var responseData = ApiResponseData.fromAjaxResponse(new AjaxResponse({}, {}, {})); var apiResponseError = ApiResponseError.fromErrorString(errorString, responseData); it("should be an instance of ApiResponseError", function () { expect(apiResponseError).toEqual(jasmine.any(ApiResponseError)); }); it("should store the original error", function () { expect(apiResponseError.error).toBe(errorString); }); }); }); //# sourceMappingURL=api-response-error.spec.js.map