File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,34 @@ describe('Model methods', () => {
334334 } )
335335 } )
336336
337+ test ( 'nowrap().get() returns the full response with the "data" wrapper even though the wrap method is set' , async ( ) => {
338+ // Set the wrap method to 'data'
339+ Post . prototype [ 'wrap' ] = ( ) => {
340+ return 'data'
341+ }
342+
343+ axiosMock . onGet ( 'http://localhost/posts' ) . reply ( 200 , postsEmbedResponse )
344+
345+ const posts = await Post . nowrap ( ) . get ( )
346+
347+ expect ( posts ) . toEqual ( postsEmbedResponse )
348+ expect ( posts . data [ 0 ] ) . toEqual ( postsEmbedResponse . data [ 0 ] )
349+ } )
350+
351+ test ( 'wrappedBy().get() returns the full response with the "data" wrapper even though the wrap method is set to `test`' , async ( ) => {
352+ // Set the wrap method to 'data'
353+ Post . prototype [ 'wrap' ] = ( ) => {
354+ return 'test'
355+ }
356+
357+ axiosMock . onGet ( 'http://localhost/posts' ) . reply ( 200 , postsEmbedResponse )
358+
359+ const posts = await Post . wrappedBy ( 'data' ) . get ( )
360+
361+ expect ( posts ) . toEqual ( postsEmbedResponse . data )
362+ expect ( posts [ 0 ] ) . toEqual ( postsEmbedResponse . data [ 0 ] )
363+ } )
364+
337365 test ( 'save() method makes a POST request when ID of object does not exists' , async ( ) => {
338366 let post
339367 const _postResponse = {
You can’t perform that action at this time.
0 commit comments