1 | import { expect } from "chai";
|
2 | import { HttpError, HttpParseError } from "../src/errors";
|
3 |
|
4 |
|
5 |
|
6 | describe("errors", () => {
|
7 | describe("HttpError", () => {
|
8 | it("stores properties", () => {
|
9 | let error = new HttpError(404, "not found", "bad");
|
10 | expect(error.status).to.equal(404);
|
11 | expect(error.message).to.equal("not found");
|
12 | expect(error.statusText).to.equal("bad");
|
13 | });
|
14 |
|
15 |
|
16 | it("has default values", () => {
|
17 | let error = new HttpError();
|
18 | expect(error.status).to.equal(500);
|
19 | expect(error.message).to.equal("Failed while making Http request.");
|
20 | expect(error.statusText).to.equal(undefined);
|
21 | });
|
22 | });
|
23 |
|
24 |
|
25 | describe("HttpParseError", () => {
|
26 | it("stores properties", () => {
|
27 | const parseError = new Error("Boo");
|
28 | let error = new HttpParseError("my-response", parseError);
|
29 | expect(error.message).to.equal("Failed to parse: \"my-response\"");
|
30 | expect(error.responseText).to.equal("my-response");
|
31 | expect(error.parseError).to.equal(parseError);
|
32 | });
|
33 | });
|
34 | });
|