@@ -60,12 +60,12 @@ describe("CardsConcern", () => {
6060 test ( "update puts with partial body" , async ( ) => {
6161 const mock = createMockFetch ( ) ;
6262 const restore = withMock ( mock ) ;
63- mock . registerPut ( "/cards/card_1" , { publicId : "card_1" , title : "Updated" , listPublicId : "lst_1" , boardPublicId : "brd_1" , position : 1 , createdAt : "" , updatedAt : "" } ) ;
63+ mock . registerPut ( "/cards/card_1" , { publicId : "card_1" , title : "Updated" , listPublicId : "lst_1" , boardPublicId : "brd_1" , index : 1 , createdAt : "" , updatedAt : "" } ) ;
6464
6565 const kan = createKan ( { apiKey : "kan_test" } ) ;
66- await kan . cards . update ( "card_1" , { title : "Updated" , position : 1 } ) ;
66+ await kan . cards . update ( "card_1" , { title : "Updated" , index : 1 } ) ;
6767
68- expect ( mock . calls [ 0 ] . body ) . toEqual ( { title : "Updated" , position : 1 } ) ;
68+ expect ( mock . calls [ 0 ] . body ) . toEqual ( { title : "Updated" , index : 1 } ) ;
6969 expect ( mock . calls [ 0 ] . method ) . toBe ( "PUT" ) ;
7070 restore ( ) ;
7171 } ) ;
@@ -155,28 +155,67 @@ describe("CardsConcern", () => {
155155 restore ( ) ;
156156 } ) ;
157157
158- test ( "updateChecklistItem patches nested item path " , async ( ) => {
158+ test ( "updateChecklist puts /checklists/:id " , async ( ) => {
159159 const mock = createMockFetch ( ) ;
160160 const restore = withMock ( mock ) ;
161- mock . registerPatch ( "/cards/card_1/ checklists/chk_1/items/item_1 " , { publicId : "item_1 " , checklistPublicId : "chk_1 " , text : "Done" , isChecked : true , position : 0 , createdAt : "" , updatedAt : "" } ) ;
161+ mock . registerPut ( "/checklists/chk_1" , { publicId : "chk_1 " , cardPublicId : "card_1 " , name : "Renamed" , createdAt : "" , updatedAt : "" } ) ;
162162
163163 const kan = createKan ( { apiKey : "kan_test" } ) ;
164- await kan . cards . updateChecklistItem ( "card_1" , " chk_1", "item_1" , { text : "Done" , isChecked : true } ) ;
164+ await kan . cards . updateChecklist ( " chk_1", { name : "Renamed" } ) ;
165165
166- expect ( mock . calls [ 0 ] . url ) . toContain ( "/cards/card_1/ checklists/chk_1/items/item_1 " ) ;
167- expect ( mock . calls [ 0 ] . body ) . toEqual ( { text : "Done" , isChecked : true } ) ;
166+ expect ( mock . calls [ 0 ] . url ) . toContain ( "/checklists/chk_1" ) ;
167+ expect ( mock . calls [ 0 ] . body ) . toEqual ( { name : "Renamed" } ) ;
168168 restore ( ) ;
169169 } ) ;
170170
171- test ( "deleteChecklistItem calls DELETE on nested item path " , async ( ) => {
171+ test ( "deleteChecklist calls DELETE /checklists/:id " , async ( ) => {
172172 const mock = createMockFetch ( ) ;
173173 const restore = withMock ( mock ) ;
174- mock . registerDelete ( "/cards/card_1/ checklists/chk_1/items/item_1 " , undefined , 204 ) ;
174+ mock . registerDelete ( "/checklists/chk_1" , undefined , 204 ) ;
175175
176176 const kan = createKan ( { apiKey : "kan_test" } ) ;
177- await expect ( kan . cards . deleteChecklistItem ( "card_1" , " chk_1" , "item_1 ") ) . resolves . toBeUndefined ( ) ;
177+ await expect ( kan . cards . deleteChecklist ( " chk_1") ) . resolves . toBeUndefined ( ) ;
178178
179- expect ( mock . calls [ 0 ] . url ) . toContain ( "/cards/card_1/checklists/chk_1/items/item_1" ) ;
179+ expect ( mock . calls [ 0 ] . url ) . toContain ( "/checklists/chk_1" ) ;
180+ expect ( mock . calls [ 0 ] . method ) . toBe ( "DELETE" ) ;
181+ restore ( ) ;
182+ } ) ;
183+
184+ test ( "addChecklistItem posts to /checklists/:id/items" , async ( ) => {
185+ const mock = createMockFetch ( ) ;
186+ const restore = withMock ( mock ) ;
187+ mock . registerPost ( "/checklists/chk_1/items" , { publicId : "item_1" , checklistPublicId : "chk_1" , title : "Do" , completed : false , index : 0 , createdAt : "" , updatedAt : "" } ) ;
188+
189+ const kan = createKan ( { apiKey : "kan_test" } ) ;
190+ await kan . cards . addChecklistItem ( "chk_1" , { title : "Do" } ) ;
191+
192+ expect ( mock . calls [ 0 ] . url ) . toContain ( "/checklists/chk_1/items" ) ;
193+ expect ( mock . calls [ 0 ] . body ) . toEqual ( { title : "Do" } ) ;
194+ restore ( ) ;
195+ } ) ;
196+
197+ test ( "updateChecklistItem patches /checklists/items/:id" , async ( ) => {
198+ const mock = createMockFetch ( ) ;
199+ const restore = withMock ( mock ) ;
200+ mock . registerPatch ( "/checklists/items/item_1" , { publicId : "item_1" , checklistPublicId : "chk_1" , title : "Done" , completed : true , index : 0 , createdAt : "" , updatedAt : "" } ) ;
201+
202+ const kan = createKan ( { apiKey : "kan_test" } ) ;
203+ await kan . cards . updateChecklistItem ( "item_1" , { title : "Done" , completed : true } ) ;
204+
205+ expect ( mock . calls [ 0 ] . url ) . toContain ( "/checklists/items/item_1" ) ;
206+ expect ( mock . calls [ 0 ] . body ) . toEqual ( { title : "Done" , completed : true } ) ;
207+ restore ( ) ;
208+ } ) ;
209+
210+ test ( "deleteChecklistItem calls DELETE /checklists/items/:id" , async ( ) => {
211+ const mock = createMockFetch ( ) ;
212+ const restore = withMock ( mock ) ;
213+ mock . registerDelete ( "/checklists/items/item_1" , undefined , 204 ) ;
214+
215+ const kan = createKan ( { apiKey : "kan_test" } ) ;
216+ await expect ( kan . cards . deleteChecklistItem ( "item_1" ) ) . resolves . toBeUndefined ( ) ;
217+
218+ expect ( mock . calls [ 0 ] . url ) . toContain ( "/checklists/items/item_1" ) ;
180219 expect ( mock . calls [ 0 ] . method ) . toBe ( "DELETE" ) ;
181220 restore ( ) ;
182221 } ) ;
@@ -257,38 +296,40 @@ describe("CardsConcern", () => {
257296 restore ( ) ;
258297 } ) ;
259298
260- test ( "confirmAttachment posts key, filename , contentType, size" , async ( ) => {
299+ test ( "confirmAttachment posts s3Key, filenames , contentType, size" , async ( ) => {
261300 const mock = createMockFetch ( ) ;
262301 const restore = withMock ( mock ) ;
263302 mock . registerPost ( "/cards/card_1/attachments/confirm" , { } ) ;
264303
265304 const kan = createKan ( { apiKey : "kan_test" } ) ;
266305 await kan . cards . confirmAttachment ( "card_1" , {
267- key : "uploads/ file.pdf" ,
306+ s3Key : "ws_1/card_1/abc- file.pdf" ,
268307 filename : "file.pdf" ,
308+ originalFilename : "original-file.pdf" ,
269309 contentType : "application/pdf" ,
270310 size : 1024 ,
271311 } ) ;
272312
273313 expect ( mock . calls [ 0 ] . url ) . toContain ( "/cards/card_1/attachments/confirm" ) ;
274314 expect ( mock . calls [ 0 ] . body ) . toEqual ( {
275- key : "uploads/ file.pdf" ,
315+ s3Key : "ws_1/card_1/abc- file.pdf" ,
276316 filename : "file.pdf" ,
317+ originalFilename : "original-file.pdf" ,
277318 contentType : "application/pdf" ,
278319 size : 1024 ,
279320 } ) ;
280321 restore ( ) ;
281322 } ) ;
282323
283- test ( "deleteAttachment calls DELETE /cards/:id/ attachments/:attId" , async ( ) => {
324+ test ( "deleteAttachment calls DELETE /attachments/:attId" , async ( ) => {
284325 const mock = createMockFetch ( ) ;
285326 const restore = withMock ( mock ) ;
286- mock . registerDelete ( "/cards/card_1/ attachments/att_1" , undefined , 204 ) ;
327+ mock . registerDelete ( "/attachments/att_1" , undefined , 204 ) ;
287328
288329 const kan = createKan ( { apiKey : "kan_test" } ) ;
289- await expect ( kan . cards . deleteAttachment ( "card_1" , " att_1") ) . resolves . toBeUndefined ( ) ;
330+ await expect ( kan . cards . deleteAttachment ( "att_1" ) ) . resolves . toBeUndefined ( ) ;
290331
291- expect ( mock . calls [ 0 ] . url ) . toContain ( "/cards/card_1/ attachments/att_1" ) ;
332+ expect ( mock . calls [ 0 ] . url ) . toContain ( "/attachments/att_1" ) ;
292333 expect ( mock . calls [ 0 ] . method ) . toBe ( "DELETE" ) ;
293334 restore ( ) ;
294335 } ) ;
0 commit comments