@@ -11,19 +11,35 @@ describe('OBCError', () => {
1111 expect ( e . name ) . toBe ( 'OBCError' ) ;
1212 } ) ;
1313
14- it ( 'accepts all six error codes' , ( ) => {
14+ it ( 'accepts all seven error codes' , ( ) => {
1515 const codes : OBCErrorCode [ ] = [
1616 'CAPABILITIES_FETCH_FAILED' ,
1717 'NO_MATCHING_CAPABILITY' ,
1818 'IFRAME_TIMEOUT' ,
1919 'WS_CONNECTION_FAILED' ,
2020 'INTENT_CANCELLED' ,
2121 'SAME_ORIGIN_CAPABILITY' ,
22+ 'DESTROYED' ,
2223 ] ;
2324 for ( const code of codes ) {
2425 const e = new OBCError ( code , 'x' ) ;
2526 expect ( e . code ) . toBe ( code ) ;
2627 }
28+ expect ( codes . length ) . toBe ( 7 ) ;
29+ } ) ;
30+
31+ it ( 'constructs with DESTROYED code' , ( ) => {
32+ const err = new OBCError ( 'DESTROYED' , 'OpenBuroClient has been destroyed' ) ;
33+ expect ( err . code ) . toBe ( 'DESTROYED' ) ;
34+ expect ( err . message ) . toBe ( 'OpenBuroClient has been destroyed' ) ;
35+ expect ( err ) . toBeInstanceOf ( OBCError ) ;
36+ expect ( err ) . toBeInstanceOf ( Error ) ;
37+ } ) ;
38+
39+ it ( 'carries cause on DESTROYED errors' , ( ) => {
40+ const cause = new Error ( 'underlying' ) ;
41+ const err = new OBCError ( 'DESTROYED' , 'x' , cause ) ;
42+ expect ( err . cause ) . toBe ( cause ) ;
2743 } ) ;
2844
2945 it ( 'preserves cause when provided' , ( ) => {
0 commit comments