File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -41,4 +41,32 @@ describe('Transporters', function() {
4141 var re = new RegExp ( applicationName + ' ' + defaultUserAgentRE ) ;
4242 assert ( re . test ( opts . headers [ 'User-Agent' ] ) ) ;
4343 } ) ;
44+
45+ it ( 'should create a single error from multiple response errors' , function ( done ) {
46+ var firstError = {
47+ message : 'Error 1' ,
48+ code : 'ERR1' ,
49+ } ;
50+ var secondError = {
51+ message : 'Error 2' ,
52+ code : 'ERR2' ,
53+ } ;
54+ nock ( 'http://example.com' )
55+ . get ( '/api' )
56+ . reply ( 200 , {
57+ error : {
58+ errors : [ firstError , secondError ]
59+ }
60+ } ) ;
61+
62+ transporter . request ( {
63+ uri : 'http://example.com/api' ,
64+ } , function ( error ) {
65+ assert ( error . message === 'Error 1\nError 2' ) ;
66+ assert ( error . code , 'ERR1' ) ;
67+ assert ( error . errors . length , 2 ) ;
68+ assert ( error . errors [ 1 ] . code , 'ERR2' ) ;
69+ done ( ) ;
70+ } ) ;
71+ } ) ;
4472} ) ;
You can’t perform that action at this time.
0 commit comments