@@ -9,8 +9,10 @@ import type {
9
9
KinesisStreamEvent ,
10
10
SQSEvent ,
11
11
} from 'aws-lambda' ;
12
- import { helloworldContext as dummyContext } from '@aws-lambda-powertools/commons/lib/samples/resources/contexts' ;
13
- import { Custom as dummyEvent } from '@aws-lambda-powertools/commons/lib/samples/resources/events' ;
12
+ import {
13
+ ContextExamples as dummyContext ,
14
+ Events as dummyEvent ,
15
+ } from '@aws-lambda-powertools/commons' ;
14
16
import { BatchProcessor } from '../../src/BatchProcessor' ;
15
17
import { processPartialResponse } from '../../src/processPartialResponse' ;
16
18
import { EventType } from '../../src/constants' ;
@@ -33,7 +35,9 @@ import {
33
35
describe ( 'Function: processPartialResponse()' , ( ) => {
34
36
const ENVIRONMENT_VARIABLES = process . env ;
35
37
const context = dummyContext ;
36
- const options : BatchProcessingOptions = { context : dummyContext } ;
38
+ const options : BatchProcessingOptions = {
39
+ context : dummyContext . helloworldContext ,
40
+ } ;
37
41
38
42
beforeEach ( ( ) => {
39
43
jest . clearAllMocks ( ) ;
@@ -106,7 +110,7 @@ describe('Function: processPartialResponse()', () => {
106
110
} ;
107
111
108
112
// Act
109
- const result = await handler ( event , context ) ;
113
+ const result = await handler ( event , context . helloworldContext ) ;
110
114
111
115
// Assess
112
116
expect ( result ) . toStrictEqual ( { batchItemFailures : [ ] } ) ;
@@ -133,7 +137,7 @@ describe('Function: processPartialResponse()', () => {
133
137
} ;
134
138
135
139
// Act
136
- const result = await handler ( event , context ) ;
140
+ const result = await handler ( event , context . helloworldContext ) ;
137
141
138
142
// Assess
139
143
expect ( result ) . toStrictEqual ( { batchItemFailures : [ ] } ) ;
@@ -160,7 +164,7 @@ describe('Function: processPartialResponse()', () => {
160
164
} ;
161
165
162
166
// Act
163
- const result = await handler ( event , context ) ;
167
+ const result = await handler ( event , context . helloworldContext ) ;
164
168
165
169
// Assess
166
170
expect ( result ) . toStrictEqual ( { batchItemFailures : [ ] } ) ;
@@ -169,7 +173,7 @@ describe('Function: processPartialResponse()', () => {
169
173
test ( 'Process partial response through handler for SQS records with incorrect event type' , async ( ) => {
170
174
// Prepare
171
175
const processor = new BatchProcessor ( EventType . SQS ) ;
172
- const event = dummyEvent ;
176
+ const event = dummyEvent . Custom ;
173
177
174
178
const handler = async (
175
179
event : SQSEvent ,
@@ -184,7 +188,7 @@ describe('Function: processPartialResponse()', () => {
184
188
185
189
// Act & Assess
186
190
await expect ( ( ) =>
187
- handler ( event as unknown as SQSEvent , context )
191
+ handler ( event as unknown as SQSEvent , context . helloworldContext )
188
192
) . rejects . toThrowError (
189
193
`Unexpected batch type. Possible values are: ${ Object . keys (
190
194
EventType
@@ -216,7 +220,7 @@ describe('Function: processPartialResponse()', () => {
216
220
} ;
217
221
218
222
// Act
219
- const result = await handler ( event , context ) ;
223
+ const result = await handler ( event , context . helloworldContext ) ;
220
224
221
225
// Assess
222
226
expect ( result ) . toStrictEqual ( { batchItemFailures : [ ] } ) ;
0 commit comments