-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ba7e2d
commit a725341
Showing
2 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import test from "ava"; | ||
|
||
import { RpcResponseError } from "../lib/client"; | ||
|
||
test("RpcResponseError", (t) => { | ||
const err: any = new RpcResponseError("my_source", { | ||
type: "FooError", | ||
code: 123, | ||
expose: true, | ||
message: "foo", | ||
namespace: "foo", | ||
instance: "bar", | ||
source: ["foo", "bar"], | ||
upstreamCode: 456, | ||
upstreamMessage: "a bad thing happened", | ||
}); | ||
|
||
t.is( | ||
err.toString(), | ||
'RpcResponseError: foo [bar] upstreamCode=456 upstreamMessage="a bad thing happened"' | ||
); | ||
t.is(err.name, "RpcResponseError"); | ||
t.is(err.type, "FooError"); | ||
t.is(err.code, 123); | ||
t.is(err.expose, true); | ||
t.is(err.message, "foo"); | ||
t.is(err.namespace, "foo"); | ||
t.is(err.instance, "bar"); | ||
t.deepEqual(err.source, ["my_source", "foo", "bar"]); | ||
t.is( | ||
err.stack, | ||
'RpcResponseError: foo [bar] upstreamCode=456 upstreamMessage="a bad thing happened"\n via bar\n via foo\n via my_source' | ||
); | ||
t.is(err.upstreamCode, 456); | ||
t.is(err.upstreamMessage, "a bad thing happened"); | ||
}); |