@@ -192,6 +192,8 @@ test('exports', () => {
192192} )
193193
194194describe ( 'createActionParametersFromRequest' , ( ) => {
195+ const methodsWithBody = [ 'PUT' , 'PATCH' , 'DELETE' ]
196+
195197 /** @private */
196198 async function createAsyncFnCall ( { isRaw, mimeType, body, method } ) {
197199 const is = jest . fn ( ( _type ) => _type === mimeType )
@@ -243,6 +245,16 @@ describe('createActionParametersFromRequest', () => {
243245 expect ( actionParams . __ow_body ) . not . toBeDefined ( )
244246 } )
245247
248+ test . each ( methodsWithBody ) ( 'non-raw: %s application/json' , async ( method ) => {
249+ const isRaw = false
250+ const mimeType = 'application/json'
251+ const body = { some : 'json' }
252+
253+ const actionParams = await createAsyncFnCall ( { isRaw, mimeType, body, method } )
254+ expect ( actionParams ) . toMatchObject ( body )
255+ expect ( actionParams . __ow_body ) . not . toBeDefined ( )
256+ } )
257+
246258 test ( 'non-raw: POST application/x-www-form-urlencoded' , async ( ) => {
247259 const isRaw = false
248260 const method = 'POST'
@@ -295,6 +307,15 @@ describe('createActionParametersFromRequest', () => {
295307 expect ( actionParams . __ow_body ) . toEqual ( Buffer . from ( JSON . stringify ( body ) ) . toString ( 'base64' ) ) // raw body will be base64'ed
296308 } )
297309
310+ test . each ( methodsWithBody ) ( 'raw: %s application/json' , async ( method ) => {
311+ const isRaw = true
312+ const mimeType = 'application/json'
313+ const body = { some : 'json' } // simulate middleware processing
314+
315+ const actionParams = await createAsyncFnCall ( { isRaw, mimeType, body, method } )
316+ expect ( actionParams . __ow_body ) . toEqual ( Buffer . from ( JSON . stringify ( body ) ) . toString ( 'base64' ) ) // raw body will be base64'ed
317+ } )
318+
298319 test ( 'raw: POST application/x-www-form-urlencoded' , async ( ) => {
299320 const isRaw = true
300321 const method = 'POST'
0 commit comments