@@ -24,7 +24,6 @@ import fixture from '../../fixtures/report.json'
2424const API_URL = 'http://foobar:8080'
2525
2626describe ( 'Report' , function ( ) {
27-
2827 afterEach ( fetchMock . reset )
2928 afterEach ( fetchMock . restore )
3029
@@ -38,26 +37,34 @@ describe('Report', function() {
3837 } )
3938
4039 beforeEach ( function ( ) {
41- fetchMock . mock (
42- `begin:${ API_URL } /attask/api` ,
43- fixture ,
44- {
45- name : 'report'
46- }
47- )
40+ fetchMock . mock ( `begin:${ API_URL } /attask/api` , fixture , {
41+ name : 'report'
42+ } )
4843 } )
44+ const objCode = 'TASK' ,
45+ query = {
46+ [ 'status' + GROUPBY ] : true
47+ }
4948 it ( 'makes a request with proper params, url and method' , function ( ) {
50- const objCode = 'TASK' ,
51- query = {
52- [ 'status' + GROUPBY ] : true
53- }
5449 return this . api . report ( objCode , query ) . then ( function ( data ) {
5550 const [ url , opts ] = fetchMock . lastCall ( 'report' )
5651 should ( opts . method ) . equal ( 'GET' )
5752 should ( opts . body ) . be . null ( )
5853 should ( url ) . endWith ( `${ objCode } /report?status${ GROUPBY } =true` )
59- should ( data ) . have . propertyByPath ( 'CPL' , 'dcount_ID' ) . be . Number ( )
60- should ( data . CPL ) . have . property ( 'status' ) . be . equal ( 'CPL' )
54+ should ( data )
55+ . have . propertyByPath ( 'CPL' , 'dcount_ID' )
56+ . be . Number ( )
57+ should ( data . CPL )
58+ . have . property ( 'status' )
59+ . be . equal ( 'CPL' )
60+ } )
61+ } )
62+ it ( 'should do a request with POST method when the useHttpPost=true' , function ( ) {
63+ return this . api . report ( objCode , query , true ) . then ( function ( ) {
64+ const [ url , opts ] = fetchMock . lastCall ( 'report' )
65+ should ( url ) . endWith ( `${ objCode } /report` )
66+ should ( opts . method ) . equal ( 'POST' )
67+ should ( opts . body ) . equals ( `status${ GROUPBY } =true&method=GET` )
6168 } )
6269 } )
6370} )
0 commit comments