11// tslint:disable:no-non-null-assertion
22import * as DynamoDB from 'aws-sdk/clients/dynamodb'
3- import { of } from 'rxjs'
43import { Organization , SimpleWithCompositePartitionKeyModel , SimpleWithPartitionKeyModel } from '../../../test/models'
54import { Attributes , toDb } from '../../mapper'
6- import { DynamoRx } from '../dynamo-rx '
5+ import { DynamoPromisified } from '../dynamo-promisified '
76import { getTableName } from '../get-table-name.function'
87import { BatchGetRequest } from './batch-get.request'
98
@@ -117,16 +116,16 @@ describe('batch get', () => {
117116 request = new BatchGetRequest ( )
118117 request . forModel ( SimpleWithPartitionKeyModel , [ jsItem1 , jsItem2 ] )
119118
120- batchGetItemsSpy = jasmine . createSpy ( ) . and . returnValues ( of ( output1 ) , of ( output2 ) )
121- const dynamoRx : DynamoRx = < any > { batchGetItems : batchGetItemsSpy }
119+ batchGetItemsSpy = jasmine . createSpy ( ) . and . returnValues ( Promise . resolve ( output1 ) , Promise . resolve ( output2 ) )
120+ const dynamoRx : DynamoPromisified = < any > { batchGetItems : batchGetItemsSpy }
122121
123122 Object . assign ( request , { dynamoRx } )
124123
125124 nextSpyFn = jest . fn ( ) . mockImplementation ( ( ) => ( { value : 0 } ) )
126125 } )
127126
128127 it ( '[execNoMap] should backoff and retry when UnprocessedItems are returned' , async ( ) => {
129- const result = await request . execNoMap ( generatorMock ) . toPromise ( )
128+ const result = await request . execNoMap ( generatorMock )
130129 expect ( nextSpyFn ) . toHaveBeenCalledTimes ( 1 )
131130 expect ( batchGetItemsSpy ) . toHaveBeenCalledTimes ( 2 )
132131 expect ( result ) . toBeDefined ( )
@@ -140,7 +139,7 @@ describe('batch get', () => {
140139 } )
141140
142141 it ( '[execFullResponse] should backoff and retry when UnprocessedItems are returned' , async ( ) => {
143- const result = await request . execFullResponse ( generatorMock ) . toPromise ( )
142+ const result = await request . execFullResponse ( generatorMock )
144143 expect ( nextSpyFn ) . toHaveBeenCalledTimes ( 1 )
145144 expect ( batchGetItemsSpy ) . toHaveBeenCalledTimes ( 2 )
146145 expect ( result ) . toBeDefined ( )
@@ -154,7 +153,7 @@ describe('batch get', () => {
154153 } )
155154
156155 it ( '[exec] should backoff and retry when UnprocessedItems are returned' , async ( ) => {
157- const result = await request . exec ( generatorMock ) . toPromise ( )
156+ const result = await request . exec ( generatorMock )
158157 expect ( nextSpyFn ) . toHaveBeenCalledTimes ( 1 )
159158 expect ( batchGetItemsSpy ) . toHaveBeenCalledTimes ( 2 )
160159 expect ( result ) . toBeDefined ( )
@@ -182,21 +181,21 @@ describe('batch get', () => {
182181 }
183182
184183 beforeEach ( ( ) => {
185- batchGetItemsSpy = jasmine . createSpy ( ) . and . returnValue ( of ( sampleResponse ) )
186- const dynamoRx : DynamoRx = < any > { batchGetItems : batchGetItemsSpy }
184+ batchGetItemsSpy = jasmine . createSpy ( ) . and . returnValue ( Promise . resolve ( sampleResponse ) )
185+ const dynamoRx : DynamoPromisified = < any > { batchGetItems : batchGetItemsSpy }
187186 request = new BatchGetRequest ( )
188187 Object . assign ( request , { dynamoRx } )
189188 request . forModel ( SimpleWithPartitionKeyModel , [ { id : 'idVal' } ] )
190189 } )
191190
192191 it ( 'exec' , async ( ) => {
193- const result = await request . exec ( ) . toPromise ( )
192+ const result = await request . exec ( )
194193 expect ( batchGetItemsSpy ) . toHaveBeenCalled ( )
195194 expect ( result ) . toEqual ( { [ getTableName ( SimpleWithPartitionKeyModel ) ] : [ jsItem ] } )
196195 } )
197196
198197 it ( 'execFullResponse' , async ( ) => {
199- const result = await request . execFullResponse ( ) . toPromise ( )
198+ const result = await request . execFullResponse ( )
200199 expect ( batchGetItemsSpy ) . toHaveBeenCalled ( )
201200 expect ( result ) . toEqual ( {
202201 Responses : { [ getTableName ( SimpleWithPartitionKeyModel ) ] : [ jsItem ] } ,
0 commit comments