77
88import { assert } from "chai" ;
99
10+ import { GraphError } from "../../src" ;
1011import { GraphErrorHandler } from "../../src/GraphErrorHandler" ;
1112
1213describe ( "GraphErrorHandler.ts" , ( ) => {
@@ -41,6 +42,7 @@ describe("GraphErrorHandler.ts", () => {
4142
4243 it ( "Should construct error for error response without innerError property" , ( ) => {
4344 const gError = GraphErrorHandler [ "constructErrorFromResponse" ] ( error , statusCode ) ;
45+ assert . isTrue ( gError instanceof GraphError ) ;
4446 assert . equal ( gError . statusCode , statusCode ) ;
4547 assert . equal ( gError . requestId , null ) ;
4648 } ) ;
@@ -50,6 +52,7 @@ describe("GraphErrorHandler.ts", () => {
5052 "request-id" : "some random id" ,
5153 } ;
5254 const gError = GraphErrorHandler [ "constructErrorFromResponse" ] ( error , statusCode ) ;
55+ assert . isTrue ( gError instanceof GraphError ) ;
5356 assert . equal ( gError . statusCode , statusCode ) ;
5457 assert . equal ( gError . requestId , "some random id" ) ;
5558 } ) ;
@@ -62,6 +65,7 @@ describe("GraphErrorHandler.ts", () => {
6265 date,
6366 } ;
6467 const gError = GraphErrorHandler [ "constructErrorFromResponse" ] ( error , statusCode ) ;
68+ assert . isTrue ( gError instanceof GraphError ) ;
6569 assert . equal ( gError . statusCode , statusCode ) ;
6670 assert . equal ( gError . requestId , "some random id" ) ;
6771 assert . equal ( gError . date . toUTCString ( ) , date . toUTCString ( ) ) ;
@@ -81,6 +85,7 @@ describe("GraphErrorHandler.ts", () => {
8185 } ,
8286 } ;
8387 const gError = await GraphErrorHandler . getError ( errorResponse ) ;
88+ assert . isTrue ( gError instanceof GraphError ) ;
8489 assert . equal ( gError . requestId , "some random id" ) ;
8590 assert . equal ( gError . code , "500" ) ;
8691 assert . equal ( gError . message , "Internal Server Error" ) ;
@@ -90,13 +95,15 @@ describe("GraphErrorHandler.ts", () => {
9095 const error = new Error ( "Some Error" ) ;
9196 error . name = "InvalidError" ;
9297 const gError = await GraphErrorHandler . getError ( error ) ;
98+ assert . isTrue ( gError instanceof GraphError ) ;
9399 assert . equal ( gError . requestId , null ) ;
94100 assert . equal ( gError . message , "Some Error" ) ;
95101 assert . equal ( gError . code , "InvalidError" ) ;
96102 } ) ;
97103
98104 it ( "Should construct some default error" , async ( ) => {
99105 const gError = await GraphErrorHandler . getError ( ) ;
106+ assert . isTrue ( gError instanceof GraphError ) ;
100107 assert . equal ( gError . message , "" ) ;
101108 assert . equal ( gError . statusCode , - 1 ) ;
102109 assert . equal ( gError . code , null ) ;
0 commit comments