@@ -31,7 +31,7 @@ describe('responseBuilder unit tests', () => {
3131 it ( 'returns ok response with different code' , async ( ) => {
3232 const responseBuilder = new ResponseBuilder ( ) ;
3333 const res = { status : sinon . stub ( ) . returns ( { json : sinon . stub ( ) } ) } ;
34- const dataPromise = new Promise ( ( resolve ) => resolve ( { foo : 'bar' } ) ) ;
34+ const dataPromise = Promise . resolve ( { foo : 'bar' } ) ;
3535
3636 await responseBuilder . route ( dataPromise , VError . HTTP_STATUS . NO_CONTENT ) ( { originalUrl : '/test' } , res ) ;
3737
@@ -89,7 +89,7 @@ describe('responseBuilder unit tests', () => {
8989 it ( 'returns bad response with overridden code' , async ( ) => {
9090 const responseBuilder = new ResponseBuilder ( ) ;
9191 const res = { status : sinon . stub ( ) . returns ( { json : sinon . stub ( ) } ) } ;
92- const dataPromise = new Promise ( ( resolve , reject ) => reject ( new VError ( 'boom' ) ) ) ;
92+ const dataPromise = Promise . reject ( new VError ( 'boom' ) ) ;
9393
9494 await responseBuilder . route ( dataPromise , undefined , VError . HTTP_STATUS . BAD_REQUEST ) ( { originalUrl : '/test' } , res ) ;
9595
@@ -130,7 +130,7 @@ describe('responseBuilder unit tests', () => {
130130 it ( 'returns bad response with Error' , async ( ) => {
131131 const responseBuilder = new ResponseBuilder ( ) ;
132132 const res = { status : sinon . stub ( ) . returns ( { json : sinon . stub ( ) } ) } ;
133- const dataPromise = new Promise ( ( resolve , reject ) => reject ( new Error ( 'boom' ) ) ) ;
133+ const dataPromise = Promise . reject ( new VError ( 'boom' ) ) ;
134134
135135 await responseBuilder . route ( dataPromise ) ( { originalUrl : '/test' } , res ) ;
136136
@@ -153,7 +153,7 @@ describe('responseBuilder unit tests', () => {
153153 it ( 'returns bad response with code 503' , async ( ) => {
154154 const responseBuilder = new ResponseBuilder ( ) ;
155155 const res = { status : sinon . stub ( ) . returns ( { json : sinon . stub ( ) } ) } ;
156- const dataPromise = new Promise ( ( resolve , reject ) => reject ( new VError ( 'boom' , HttpStatus . SERVICE_UNAVAILABLE ) ) ) ;
156+ const dataPromise = Promise . reject ( new VError ( 'boom' , HttpStatus . SERVICE_UNAVAILABLE ) ) ;
157157
158158 await responseBuilder . route ( dataPromise ) ( { originalUrl : '/test' } , res ) ;
159159
@@ -176,7 +176,7 @@ describe('responseBuilder unit tests', () => {
176176 it ( 'returns bad response with data' , async ( ) => {
177177 const responseBuilder = new ResponseBuilder ( ) ;
178178 const res = { status : sinon . stub ( ) . returns ( { json : sinon . stub ( ) } ) } ;
179- const dataPromise = new Promise ( ( resolve , reject ) => reject ( new VError ( 'boom' , undefined , { foo : 'bar' } ) ) ) ;
179+ const dataPromise = Promise . reject ( new VError ( 'boom' , undefined , { foo : 'bar' } ) ) ;
180180
181181 await responseBuilder . route ( dataPromise ) ( { originalUrl : '/test' } , res ) ;
182182
@@ -189,27 +189,4 @@ describe('responseBuilder unit tests', () => {
189189
190190 expect ( res . status ( ) . json . args [ 0 ] [ 0 ] ) . to . eql ( { foo : 'bar' } ) ;
191191 } ) ;
192-
193- it ( 'returns bad response with data from message' , async ( ) => {
194- const responseBuilder = new ResponseBuilder ( ) ;
195- const res = { status : sinon . stub ( ) . returns ( { json : sinon . stub ( ) } ) } ;
196- const dataPromise = new Promise ( ( resolve , reject ) => reject ( new VError ( 'boom' ) ) ) ;
197-
198- await responseBuilder . route ( dataPromise ) ( { originalUrl : '/test' } , res ) ;
199-
200- const expected = {
201- code : 500 ,
202- status : 'Internal Server Error' ,
203- data : 'boom' ,
204- } ;
205-
206- expect ( res . status . args [ 0 ] [ 0 ] ) . to . eql ( expected . code ) ;
207-
208- expect ( res . status ( ) . json . args [ 0 ] [ 0 ] . code ) . to . eql ( expected . code ) ;
209- expect ( res . status ( ) . json . args [ 0 ] [ 0 ] . data ) . to . eql ( expected . data ) ;
210- expect ( res . status ( ) . json . args [ 0 ] [ 0 ] . status ) . to . eql ( expected . status ) ;
211-
212- expect ( res . status ( ) . json . args [ 0 ] [ 0 ] . dateTime ) . to . not . be . undefined ;
213- expect ( res . status ( ) . json . args [ 0 ] [ 0 ] . timestamp ) . to . not . be . undefined ;
214- } ) ;
215192} ) ;
0 commit comments