@@ -4904,6 +4904,64 @@ describe("promises -", function () {
49044904 } ) ;
49054905 } ) ;
49064906
4907+ describe ( "update / delete passing a request parameter" , function ( ) {
4908+ var scope ;
4909+ var rBody = mocks . data . batchUpdateDelete ;
4910+ var rBodys = rBody . split ( '\n' ) ;
4911+ var checkBody = '' ;
4912+ for ( var i = 0 ; i < rBodys . length ; i ++ ) {
4913+ checkBody += rBodys [ i ] ;
4914+ }
4915+ before ( function ( ) {
4916+ var response = mocks . responses . batchUpdateDelete ;
4917+ scope = nock ( mocks . webApiUrl + '$batch' , {
4918+ reqheaders : {
4919+ Authorization : "Bearer 123"
4920+ }
4921+ } )
4922+ . filteringRequestBody ( function ( body ) {
4923+ body = body . replace ( / d w a _ b a t c h _ [ \d \w ] { 8 } - [ \d \w ] { 4 } - [ \d \w ] { 4 } - [ \d \w ] { 4 } - [ \d \w ] { 12 } / g, 'dwa_batch_XXX' ) ;
4924+ body = body . replace ( / c h a n g e s e t _ [ \d \w ] { 8 } - [ \d \w ] { 4 } - [ \d \w ] { 4 } - [ \d \w ] { 4 } - [ \d \w ] { 12 } / g, 'changeset_XXX' ) ;
4925+ var bodys = body . split ( '\n' ) ;
4926+
4927+ var resultBody = '' ;
4928+ for ( var i = 0 ; i < bodys . length ; i ++ ) {
4929+ resultBody += bodys [ i ] ;
4930+ }
4931+ return resultBody ;
4932+ } )
4933+ . post ( "" , checkBody )
4934+ . reply ( response . status , response . responseText , response . responseHeaders ) ;
4935+ } ) ;
4936+
4937+ after ( function ( ) {
4938+ nock . cleanAll ( ) ;
4939+ } ) ;
4940+
4941+ it ( "returns a correct response" , function ( done ) {
4942+ dynamicsWebApiTest . startBatch ( ) ;
4943+
4944+ dynamicsWebApiTest . update ( mocks . data . testEntityId2 , 'records' , { firstname : "Test" , lastname : "Batch!" } ) ;
4945+ dynamicsWebApiTest . deleteRecord ( mocks . data . testEntityId2 , 'records' , 'firstname' ) ;
4946+
4947+ dynamicsWebApiTest . executeBatch ( { token : '123' } )
4948+ . then ( function ( object ) {
4949+ expect ( object . length ) . to . be . eq ( 2 ) ;
4950+
4951+ expect ( object [ 0 ] ) . to . be . true ;
4952+ expect ( object [ 1 ] ) . to . be . undefined ;
4953+
4954+ done ( ) ;
4955+ } ) . catch ( function ( object ) {
4956+ done ( object ) ;
4957+ } ) ;
4958+ } ) ;
4959+
4960+ it ( "all requests have been made" , function ( ) {
4961+ expect ( scope . isDone ( ) ) . to . be . true ;
4962+ } ) ;
4963+ } ) ;
4964+
49074965 describe ( "update / delete - returns an error" , function ( ) {
49084966 var scope ;
49094967 var rBody = mocks . data . batchUpdateDelete ;
0 commit comments