Add test for #67

This commit is contained in:
Elian Doran 2024-05-06 21:45:53 +03:00
parent 64146c8990
commit 4df6cabd0e
No known key found for this signature in database
2 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,12 @@
import etapiUtils = require("./etapi_utils");
const EtapiError = etapiUtils.EtapiError;
describe("EtapiError", () => {
it("should support instanceof", () => {
const anError = new etapiUtils.EtapiError(404, "123", "test");
expect(anError instanceof EtapiError).toBeTruthy();
expect(anError instanceof Error).toBeTruthy();
expect(new Error("Test") instanceof EtapiError).toBeFalsy();
anError.foo();
});
});

View File

@ -23,6 +23,10 @@ class EtapiError extends Error {
this.code = code; this.code = code;
this.message = message; this.message = message;
} }
foo() {
console.log("bar");
}
} }
function sendError(res: Response, statusCode: number, code: string, message: string) { function sendError(res: Response, statusCode: number, code: string, message: string) {