@@ -17,7 +17,7 @@ const output = {
1717} ;
1818
1919describe ( 'Index' , ( ) => {
20- it ( 'should call get endpoints' , ( done ) => {
20+ it ( 'should call get endpoints' , async ( ) => {
2121 const validator = ( url , options ) => {
2222 url . should . contain ( `${ common . config . apiURL } /testurl` ) ;
2323 options . method . should . be . equal ( 'GET' ) ;
@@ -27,58 +27,36 @@ describe('Index', () => {
2727 [ 'two' , params . two ] ,
2828 ] ) ;
2929 } ;
30- lib ( common . config )
31- . then ( ( z ) => {
32- const stubs = common . getStubs ( validator , output ) ;
33- z . callEndpoint (
34- '/testurl' ,
35- 'GET' ,
36- params
37- ) . should . eventually . have . property ( 'result' , 'success' ) ;
38- common . restoreStubs ( stubs ) ;
39- return lib ( common . config ) ;
40- } )
41- . then ( ( z ) => {
42- const stubs = common . getStubs ( validator , output ) ;
43- z . callEndpoint (
44- 'testurl' ,
45- 'GET' ,
46- params
47- ) . should . eventually . have . property ( 'result' , 'success' ) ;
48- common . restoreStubs ( stubs ) ;
49- done ( ) ;
50- } )
51- . catch ( done ) ;
30+ const z = await lib ( common . config ) ;
31+ const stubs = common . getStubs ( validator , output ) ;
32+ z . callEndpoint ( '/testurl' , 'GET' , params ) . should . eventually . have . property (
33+ 'result' ,
34+ 'success'
35+ ) ;
36+ z . callEndpoint ( 'testurl' , 'GET' , params ) . should . eventually . have . property (
37+ 'result' ,
38+ 'success'
39+ ) ;
40+ common . restoreStubs ( stubs ) ;
5241 } ) ;
53- it ( 'should call post endpoints' , ( done ) => {
42+ it ( 'should call post endpoints' , async ( ) => {
5443 const validator = ( url , options ) => {
5544 url . should . contain ( `${ common . config . apiURL } /testurl` ) ;
5645 options . method . should . be . equal ( 'POST' ) ;
5746 Object . keys ( options . body . data ) . length . should . equal ( 2 ) ;
5847 options . body . data . one . should . equal ( params . one ) ;
5948 options . body . data . two . should . equal ( params . two ) ;
6049 } ;
61- lib ( common . config )
62- . then ( ( z ) => {
63- const stubs = common . getStubs ( validator , output ) ;
64- z . callEndpoint (
65- '/testurl' ,
66- 'POST' ,
67- params
68- ) . should . eventually . have . property ( 'result' , 'success' ) ;
69- common . restoreStubs ( stubs ) ;
70- return lib ( common . config ) ;
71- } )
72- . then ( ( z ) => {
73- const stubs = common . getStubs ( validator , output ) ;
74- z . callEndpoint (
75- 'testurl' ,
76- 'POST' ,
77- params
78- ) . should . eventually . have . property ( 'result' , 'success' ) ;
79- common . restoreStubs ( stubs ) ;
80- done ( ) ;
81- } )
82- . catch ( done ) ;
50+ const z = await lib ( common . config ) ;
51+ const stubs = common . getStubs ( validator , output ) ;
52+ z . callEndpoint ( '/testurl' , 'POST' , params ) . should . eventually . have . property (
53+ 'result' ,
54+ 'success'
55+ ) ;
56+ z . callEndpoint ( 'testurl' , 'POST' , params ) . should . eventually . have . property (
57+ 'result' ,
58+ 'success'
59+ ) ;
60+ common . restoreStubs ( stubs ) ;
8361 } ) ;
8462} ) ;
0 commit comments