@@ -409,6 +409,22 @@ test('transactionWrite', async () => {
409409 } )
410410} )
411411
412+ test ( 'put accepts ReturnConsumedCapacity and ReturnItemCollectionMetrics but ignores them' , async ( ) => {
413+ const db = ddb ( )
414+
415+ await db . put ( {
416+ ...PKONLY_TABLE_REQUEST ,
417+ Item : { TEST_PK : 1 , b : 2 } ,
418+ ReturnConsumedCapacity : 'TOTAL' ,
419+ ReturnItemCollectionMetrics : 'SIZE'
420+ } )
421+
422+ expect ( await db . get ( { ...PKONLY_TABLE_REQUEST , Key : { TEST_PK : 1 } } ) ) . toEqual ( {
423+ Item : { TEST_PK : 1 , b : 2 } ,
424+ ...METADATA
425+ } )
426+ } )
427+
412428test ( 'put throws error when unsupported properties are provided' , async ( ) => {
413429 const db = ddb ( )
414430
@@ -438,6 +454,23 @@ test('get accepts ConsistentRead parameter but ignores it', async () => {
438454 } )
439455} )
440456
457+ test ( 'get accepts ReturnConsumedCapacity but ignores it' , async ( ) => {
458+ const db = ddb ( )
459+
460+ await db . put ( { ...PKONLY_TABLE_REQUEST , Item : { TEST_PK : 1 , b : 2 } } )
461+
462+ const result = await db . get ( {
463+ ...PKONLY_TABLE_REQUEST ,
464+ Key : { TEST_PK : 1 } ,
465+ ReturnConsumedCapacity : 'TOTAL'
466+ } )
467+
468+ expect ( result ) . toEqual ( {
469+ Item : { TEST_PK : 1 , b : 2 } ,
470+ ...METADATA
471+ } )
472+ } )
473+
441474test ( 'get throws error when unsupported properties are provided' , async ( ) => {
442475 const db = ddb ( )
443476
@@ -453,6 +486,21 @@ test('get throws error when unsupported properties are provided', async () => {
453486 )
454487} )
455488
489+ test ( 'delete accepts ReturnConsumedCapacity and ReturnItemCollectionMetrics but ignores them' , async ( ) => {
490+ const db = ddb ( )
491+
492+ await db . put ( { ...PKONLY_TABLE_REQUEST , Item : { TEST_PK : 1 , b : 2 } } )
493+
494+ await db . delete ( {
495+ ...PKONLY_TABLE_REQUEST ,
496+ Key : { TEST_PK : 1 } ,
497+ ReturnConsumedCapacity : 'TOTAL' ,
498+ ReturnItemCollectionMetrics : 'SIZE'
499+ } )
500+
501+ expect ( await db . get ( { ...PKONLY_TABLE_REQUEST , Key : { TEST_PK : 1 } } ) ) . toEqual ( EMPTY_GET_RESPONSE )
502+ } )
503+
456504test ( 'delete throws error when unsupported properties are provided' , async ( ) => {
457505 const db = ddb ( )
458506
@@ -478,68 +526,73 @@ test('delete throws error when unsupported properties are provided', async () =>
478526 )
479527} )
480528
481- test ( 'batchWrite throws error when unsupported properties are provided ' , async ( ) => {
529+ test ( 'batchWrite accepts ReturnConsumedCapacity and ReturnItemCollectionMetrics but ignores them ' , async ( ) => {
482530 const db = ddb ( )
483531
484- await expect (
485- db . batchWrite ( {
486- RequestItems : {
487- pkOnly : [ { PutRequest : { Item : { TEST_PK : 1 , b : 2 } } } ]
488- } ,
489- ReturnConsumedCapacity : 'TOTAL'
490- } )
491- ) . rejects . toThrow (
492- 'FakeDynamoDBInterface.batchWrite does not support the following properties: ReturnConsumedCapacity'
493- )
532+ await db . batchWrite ( {
533+ RequestItems : {
534+ pkOnly : [ { PutRequest : { Item : { TEST_PK : 1 , b : 2 } } } ]
535+ } ,
536+ ReturnConsumedCapacity : 'TOTAL' ,
537+ ReturnItemCollectionMetrics : 'SIZE'
538+ } )
494539
495- await expect (
496- db . batchWrite ( {
497- RequestItems : {
498- pkOnly : [ { PutRequest : { Item : { TEST_PK : 1 , b : 2 } } } ]
499- } ,
500- ReturnItemCollectionMetrics : 'SIZE' ,
501- ReturnConsumedCapacity : 'TOTAL'
502- } )
503- ) . rejects . toThrow (
504- 'FakeDynamoDBInterface.batchWrite does not support the following properties: ReturnItemCollectionMetrics, ReturnConsumedCapacity'
505- )
540+ expect ( await db . get ( { ...PKONLY_TABLE_REQUEST , Key : { TEST_PK : 1 } } ) ) . toEqual ( {
541+ Item : { TEST_PK : 1 , b : 2 } ,
542+ ...METADATA
543+ } )
506544} )
507545
508- test ( 'transactionWrite throws error when unsupported properties are provided ' , async ( ) => {
546+ test ( 'transactionWrite accepts ReturnConsumedCapacity, ReturnItemCollectionMetrics, and ClientRequestToken but ignores them ' , async ( ) => {
509547 const db = ddb ( )
510548
511- await expect (
512- db . transactionWrite ( {
513- TransactItems : [
514- {
515- Put : {
516- TableName : 'pkOnly' ,
517- Item : { TEST_PK : 1 , b : 2 }
518- }
549+ await db . transactionWrite ( {
550+ TransactItems : [
551+ {
552+ Put : {
553+ TableName : 'pkOnly' ,
554+ Item : { TEST_PK : 1 , b : 2 }
519555 }
520- ] ,
521- ReturnConsumedCapacity : 'TOTAL'
522- } )
523- ) . rejects . toThrow (
524- 'FakeDynamoDBInterface.transactionWrite does not support the following properties: ReturnConsumedCapacity '
525- )
556+ }
557+ ] ,
558+ ReturnConsumedCapacity : 'TOTAL' ,
559+ ReturnItemCollectionMetrics : 'SIZE' ,
560+ ClientRequestToken : 'token123 '
561+ } )
526562
527- await expect (
528- db . transactionWrite ( {
529- TransactItems : [
530- {
531- Put : {
532- TableName : 'pkOnly' ,
533- Item : { TEST_PK : 1 , b : 2 }
534- }
535- }
536- ] ,
537- ClientRequestToken : 'token123' ,
538- ReturnItemCollectionMetrics : 'SIZE'
539- } )
540- ) . rejects . toThrow (
541- 'FakeDynamoDBInterface.transactionWrite does not support the following properties: ClientRequestToken, ReturnItemCollectionMetrics'
542- )
563+ expect ( await db . get ( { ...PKONLY_TABLE_REQUEST , Key : { TEST_PK : 1 } } ) ) . toEqual ( {
564+ Item : { TEST_PK : 1 , b : 2 } ,
565+ ...METADATA
566+ } )
567+ } )
568+
569+ test ( 'scanOnePage accepts ReturnConsumedCapacity but ignores it' , async ( ) => {
570+ const db = ddb ( )
571+
572+ await db . put ( { ...PKONLY_TABLE_REQUEST , Item : { TEST_PK : 1 , b : 2 } } )
573+
574+ const result = await db . scanOnePage ( {
575+ ...PKONLY_TABLE_REQUEST ,
576+ ReturnConsumedCapacity : 'TOTAL'
577+ } )
578+
579+ expect ( result . Items ) . toHaveLength ( 1 )
580+ expect ( result . Items ) . toContainEqual ( { TEST_PK : 1 , b : 2 } )
581+ } )
582+
583+ test ( 'scanAllPages accepts ReturnConsumedCapacity but ignores it' , async ( ) => {
584+ const db = ddb ( )
585+
586+ await db . put ( { ...PKONLY_TABLE_REQUEST , Item : { TEST_PK : 1 , b : 2 } } )
587+
588+ const results = await db . scanAllPages ( {
589+ ...PKONLY_TABLE_REQUEST ,
590+ ReturnConsumedCapacity : 'INDEXES'
591+ } )
592+
593+ expect ( results ) . toHaveLength ( 1 )
594+ expect ( results [ 0 ] . Items ) . toHaveLength ( 1 )
595+ expect ( results [ 0 ] . Items ) . toContainEqual ( { TEST_PK : 1 , b : 2 } )
543596} )
544597
545598test ( 'scanOnePage throws error when unsupported properties are provided' , async ( ) => {
@@ -596,6 +649,35 @@ test('scanAllPages accepts ConsistentRead parameter but ignores it', async () =>
596649 expect ( results [ 0 ] . Items ) . toContainEqual ( { TEST_PK : 2 , b : 4 } )
597650} )
598651
652+ test ( 'scanOnePage accepts ReturnConsumedCapacity but ignores it' , async ( ) => {
653+ const db = ddb ( )
654+
655+ await db . put ( { ...PKONLY_TABLE_REQUEST , Item : { TEST_PK : 1 , b : 2 } } )
656+
657+ const result = await db . scanOnePage ( {
658+ ...PKONLY_TABLE_REQUEST ,
659+ ReturnConsumedCapacity : 'TOTAL'
660+ } )
661+
662+ expect ( result . Items ) . toHaveLength ( 1 )
663+ expect ( result . Items ) . toContainEqual ( { TEST_PK : 1 , b : 2 } )
664+ } )
665+
666+ test ( 'scanAllPages accepts ReturnConsumedCapacity but ignores it' , async ( ) => {
667+ const db = ddb ( )
668+
669+ await db . put ( { ...PKONLY_TABLE_REQUEST , Item : { TEST_PK : 1 , b : 2 } } )
670+
671+ const results = await db . scanAllPages ( {
672+ ...PKONLY_TABLE_REQUEST ,
673+ ReturnConsumedCapacity : 'INDEXES'
674+ } )
675+
676+ expect ( results ) . toHaveLength ( 1 )
677+ expect ( results [ 0 ] . Items ) . toHaveLength ( 1 )
678+ expect ( results [ 0 ] . Items ) . toContainEqual ( { TEST_PK : 1 , b : 2 } )
679+ } )
680+
599681test ( 'scanAllPages throws error when unsupported properties are provided' , async ( ) => {
600682 const db = ddb ( )
601683
@@ -861,6 +943,43 @@ test('queryAllPages accepts ConsistentRead parameter but ignores it', async () =
861943 expect ( results [ 0 ] . Items ) . toContainEqual ( { TEST_PK : 1 , TEST_SK : 'B' , value : 20 } )
862944} )
863945
946+ test ( 'queryOnePage accepts ReturnConsumedCapacity but ignores it' , async ( ) => {
947+ const db = ddb ( )
948+
949+ await db . put ( { ...PKANDSK_TABLE_REQUEST , Item : { TEST_PK : 1 , TEST_SK : 'A' , value : 10 } } )
950+ await db . put ( { ...PKANDSK_TABLE_REQUEST , Item : { TEST_PK : 1 , TEST_SK : 'B' , value : 20 } } )
951+
952+ const result = await db . queryOnePage ( {
953+ ...PKANDSK_TABLE_REQUEST ,
954+ KeyConditionExpression : 'TEST_PK = :pk' ,
955+ ExpressionAttributeValues : { ':pk' : 1 } ,
956+ ReturnConsumedCapacity : 'TOTAL'
957+ } )
958+
959+ expect ( result . Items ) . toHaveLength ( 2 )
960+ expect ( result . Items ) . toContainEqual ( { TEST_PK : 1 , TEST_SK : 'A' , value : 10 } )
961+ expect ( result . Items ) . toContainEqual ( { TEST_PK : 1 , TEST_SK : 'B' , value : 20 } )
962+ } )
963+
964+ test ( 'queryAllPages accepts ReturnConsumedCapacity but ignores it' , async ( ) => {
965+ const db = ddb ( )
966+
967+ await db . put ( { ...PKANDSK_TABLE_REQUEST , Item : { TEST_PK : 1 , TEST_SK : 'A' , value : 10 } } )
968+ await db . put ( { ...PKANDSK_TABLE_REQUEST , Item : { TEST_PK : 1 , TEST_SK : 'B' , value : 20 } } )
969+
970+ const results = await db . queryAllPages ( {
971+ ...PKANDSK_TABLE_REQUEST ,
972+ KeyConditionExpression : 'TEST_PK = :pk' ,
973+ ExpressionAttributeValues : { ':pk' : 1 } ,
974+ ReturnConsumedCapacity : 'NONE'
975+ } )
976+
977+ expect ( results ) . toHaveLength ( 1 )
978+ expect ( results [ 0 ] . Items ) . toHaveLength ( 2 )
979+ expect ( results [ 0 ] . Items ) . toContainEqual ( { TEST_PK : 1 , TEST_SK : 'A' , value : 10 } )
980+ expect ( results [ 0 ] . Items ) . toContainEqual ( { TEST_PK : 1 , TEST_SK : 'B' , value : 20 } )
981+ } )
982+
864983// Condition Expression Integration Tests
865984
866985test ( 'put with ConditionExpression - attribute_not_exists' , async ( ) => {
0 commit comments