@@ -1304,24 +1304,25 @@ describe("Tests for single attachment entity", () => {
13041304 const filepath = join ( __dirname , "content/sample.pdf" )
13051305 const fileContent = readFileSync ( filepath )
13061306
1307- const postRes = await POST (
1307+ const putRes = await PUT (
13081308 `/odata/v4/processor/SingleAttachment(ID=${ singleAttachment . ID } ,IsActiveEntity=false)/myAttachment` ,
13091309 {
1310- filename : basename ( filepath ) ,
1311- mimeType : "application/pdf" ,
1310+ filename : basename ( filepath ) ,
1311+ mimeType : "application/pdf" ,
13121312 } ,
13131313 )
1314+ expect ( putRes . status ) . toEqual ( 200 )
13141315
1315- const putRes = await PUT (
1316- `/odata/v4/processor/SingleAttachment_myAttachment(up__ID =${ singleAttachment . ID } ,ID= ${ postRes . data . ID } , IsActiveEntity=false)/content` ,
1316+ const putContentRes = await PUT (
1317+ `/odata/v4/processor/SingleAttachment(ID =${ singleAttachment . ID } ,IsActiveEntity=false)/myAttachment /content` ,
13171318 fileContent ,
13181319 {
13191320 headers : {
13201321 "Content-Type" : "application/pdf" ,
13211322 } ,
13221323 } ,
13231324 )
1324- expect ( putRes . status ) . toEqual ( 204 )
1325+ expect ( putContentRes . status ) . toEqual ( 204 )
13251326
13261327 // Activate the draft
13271328 await POST (
@@ -1332,7 +1333,7 @@ describe("Tests for single attachment entity", () => {
13321333 const getRes = await GET (
13331334 `/odata/v4/processor/SingleAttachment(ID=${ singleAttachment . ID } ,IsActiveEntity=true)/myAttachment` ,
13341335 )
1335- expect ( getRes . data . ID ) . toBeDefined ( )
1336+ expect ( getRes . data . filename ) . toBe ( basename ( filepath ) )
13361337 } )
13371338
13381339 it ( "should delete a SingleAttachment and its attachment" , async ( ) => {
@@ -1345,15 +1346,21 @@ describe("Tests for single attachment entity", () => {
13451346 )
13461347 const filepath = join ( __dirname , "content/sample.pdf" )
13471348 const fileContent = readFileSync ( filepath )
1348- const postRes = await POST (
1349+
1350+ await PUT (
13491351 `/odata/v4/processor/SingleAttachment(ID=${ singleAttachment . ID } ,IsActiveEntity=false)/myAttachment` ,
1350- { filename : basename ( filepath ) } ,
1352+ {
1353+ filename : basename ( filepath ) ,
1354+ mimeType : "application/pdf" ,
1355+ } ,
13511356 )
1357+
13521358 await PUT (
1353- `/odata/v4/processor/SingleAttachment_myAttachment(up__ID =${ singleAttachment . ID } ,ID= ${ postRes . data . ID } , IsActiveEntity=false)/content` ,
1359+ `/odata/v4/processor/SingleAttachment(ID =${ singleAttachment . ID } ,IsActiveEntity=false)/myAttachment /content` ,
13541360 fileContent ,
13551361 { headers : { "Content-Type" : "application/pdf" } } ,
13561362 )
1363+
13571364 await POST (
13581365 `/odata/v4/processor/SingleAttachment(ID=${ singleAttachment . ID } ,IsActiveEntity=false)/ProcessorService.draftActivate` ,
13591366 )
@@ -1376,7 +1383,6 @@ describe("Tests for single attachment entity", () => {
13761383 SELECT . one
13771384 . from ( "sap.attachments.Attachments" )
13781385 . where ( { url : attachmentUrl } )
1379- . columns ( "content" ) ,
13801386 )
13811387 expect ( content . content ) . toBeNull ( )
13821388 } )
0 commit comments