@@ -131,13 +131,17 @@ describe('update', () => {
131131 beforeEach ( ( ) => {
132132 server . use (
133133 http . patch ( `${ testBaseUrl } /list-type/foo` , async ( { request } ) => {
134+ const url = new URL ( request . url ) ;
135+ const statusParams = url . searchParams . get ( 'status' ) ;
134136 const body = await request . json ( ) ;
135- patchListApiMockFn ( body ) ;
137+ patchListApiMockFn ( statusParams , body ) ;
136138 return HttpResponse . json ( { id : 'foo' } , { status : 200 } ) ;
137139 } ) ,
138140 http . patch ( `${ testBaseUrl } /object-type` , async ( { request } ) => {
141+ const url = new URL ( request . url ) ;
142+ const statusParams = url . searchParams . get ( 'status' ) ;
139143 const body = await request . json ( ) ;
140- patchObjectApiMockFn ( body ) ;
144+ patchObjectApiMockFn ( statusParams , body ) ;
141145 return HttpResponse . json ( { id : 'foo' } , { status : 200 } ) ;
142146 } ) ,
143147 ) ;
@@ -156,13 +160,32 @@ describe('update', () => {
156160 } ,
157161 } ) ;
158162 expect ( data ) . toEqual ( { id : 'foo' } ) ;
159- // Confirm PUT api was called
163+ // Confirm PATCH api was called
164+ expect ( patchListApiMockFn ) . toHaveBeenCalledTimes ( 1 ) ;
165+ // Confirm that body is specified.
166+ expect ( patchListApiMockFn ) . toHaveBeenCalledWith ( null , {
167+ title : 'title' ,
168+ } ) ;
169+ } ) ;
170+
171+ test ( 'Draft list format content can be updated' , async ( ) => {
172+ const data = await client . update < ContentType > ( {
173+ endpoint : 'list-type' ,
174+ contentId : 'foo' ,
175+ content : {
176+ title : 'title' ,
177+ } ,
178+ isDraft : true ,
179+ } ) ;
180+ expect ( data ) . toEqual ( { id : 'foo' } ) ;
181+ // Confirm PATCH api was called
160182 expect ( patchListApiMockFn ) . toHaveBeenCalledTimes ( 1 ) ;
161183 // Confirm that body is specified.
162- expect ( patchListApiMockFn ) . toHaveBeenCalledWith ( {
184+ expect ( patchListApiMockFn ) . toHaveBeenCalledWith ( 'draft' , {
163185 title : 'title' ,
164186 } ) ;
165187 } ) ;
188+
166189 test ( 'Object type content can be updated' , async ( ) => {
167190 const data = await client . update < ContentType > ( {
168191 endpoint : 'object-type' ,
@@ -171,10 +194,27 @@ describe('update', () => {
171194 } ,
172195 } ) ;
173196 expect ( data ) . toEqual ( { id : 'foo' } ) ;
174- // Confirm PUT api was called
197+ // Confirm PATCH api was called
198+ expect ( patchObjectApiMockFn ) . toHaveBeenCalledTimes ( 1 ) ;
199+ // Confirm that body is specified.
200+ expect ( patchObjectApiMockFn ) . toHaveBeenCalledWith ( null , {
201+ title : 'title' ,
202+ } ) ;
203+ } ) ;
204+
205+ test ( 'Draft object type content can be updated' , async ( ) => {
206+ const data = await client . update < ContentType > ( {
207+ endpoint : 'object-type' ,
208+ content : {
209+ title : 'title' ,
210+ } ,
211+ isDraft : true ,
212+ } ) ;
213+ expect ( data ) . toEqual ( { id : 'foo' } ) ;
214+ // Confirm PATCH api was called
175215 expect ( patchObjectApiMockFn ) . toHaveBeenCalledTimes ( 1 ) ;
176216 // Confirm that body is specified.
177- expect ( patchObjectApiMockFn ) . toHaveBeenCalledWith ( {
217+ expect ( patchObjectApiMockFn ) . toHaveBeenCalledWith ( 'draft' , {
178218 title : 'title' ,
179219 } ) ;
180220 } ) ;
0 commit comments