-
Notifications
You must be signed in to change notification settings - Fork 990
/
Copy patherror.spec.ts
41 lines (33 loc) · 1.22 KB
/
error.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { expect } from "chai";
import { FirebaseError } from "./error";
describe("error", () => {
describe("FirebaseError", () => {
it("should be an instance of Error", () => {
const error = new FirebaseError("test-message");
expect(error).to.be.instanceOf(Error);
});
it("should apply default options", () => {
const error = new FirebaseError("test-message");
expect(error).to.deep.include({ children: [], exit: 1, name: "FirebaseError", status: 500 });
});
it("should persist all options", () => {
/**
* All possible options that might be provided to `FirebaseError`.
*/
type FirebaseErrorOptions = ConstructorParameters<typeof FirebaseError>[1];
/*
* The following `Required` ensures all options are defined, so the test
* covers all properties.
*/
const allOptions: Required<FirebaseErrorOptions> = {
children: ["test-child-1", "test-child-2"],
context: "test-context",
exit: 123,
original: new Error("test-original-error-message"),
status: 456,
};
const error = new FirebaseError("test-message", allOptions);
expect(error).to.deep.include(allOptions);
});
});
});