[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert FirebaseError to TypeScript #1521

Merged
merged 16 commits into from
Jul 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add basic tests for FirestoreError
  • Loading branch information
merlinnot committed Jul 17, 2019
commit 5b25ee0d6e89a7e49467ff79eba747861e622389
32 changes: 32 additions & 0 deletions src/test/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { expect } from "chai";
merlinnot marked this conversation as resolved.
Show resolved Hide resolved
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", () => {
const allOptions: Required<ConstructorParameters<typeof FirebaseError>[1]> = {
merlinnot marked this conversation as resolved.
Show resolved Hide resolved
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);
});
});
});