1- import { KinesisClient } from ' @aws-sdk/client-kinesis' ;
1+ import { KinesisClient } from " @aws-sdk/client-kinesis" ;
22import * as pino from "pino" ;
3- import { mockDeep } from 'jest-mock-extended' ;
4- import { DynamoDBStreamEvent , Context } from 'aws-lambda' ;
5- import { Deps } from '../deps' ;
6- import { EnvVars } from '../env' ;
7- import { createHandler } from '../mi-stream-forwarder' ;
8-
9-
10- describe ( 'mi-stream-forwarder Lambda' , ( ) => {
3+ import { mockDeep } from "jest-mock-extended" ;
4+ import { Context , DynamoDBStreamEvent } from "aws-lambda" ;
5+ import { Deps } from "../deps" ;
6+ import { EnvVars } from "../env" ;
7+ import createHandler from "../mi-stream-forwarder" ;
118
9+ describe ( "mi-stream-forwarder Lambda" , ( ) => {
1210 const mockedDeps : jest . Mocked < Deps > = {
13- kinesisClient : { send : jest . fn ( ) } as unknown as KinesisClient ,
14- logger : { info : jest . fn ( ) , warn : jest . fn ( ) , error : jest . fn ( ) } as unknown as pino . Logger ,
11+ kinesisClient : { send : jest . fn ( ) } as unknown as KinesisClient ,
12+ logger : {
13+ info : jest . fn ( ) ,
14+ warn : jest . fn ( ) ,
15+ error : jest . fn ( ) ,
16+ } as unknown as pino . Logger ,
1517 env : {
1618 MI_CHANGE_STREAM_ARN : "test-stream" ,
17- } as unknown as EnvVars
19+ } as unknown as EnvVars ,
1820 } as Deps ;
1921
2022 beforeEach ( ( ) => {
2123 jest . clearAllMocks ( ) ;
2224 } ) ;
2325
24- it ( ' forwards INSERT records to Kinesis' , async ( ) => {
26+ it ( " forwards INSERT records to Kinesis" , async ( ) => {
2527 const event : DynamoDBStreamEvent = {
2628 Records : [
2729 {
28- eventName : ' INSERT' ,
30+ eventName : " INSERT" ,
2931 dynamodb : {
30- NewImage : { id : { S : ' mi-123' } , foo : { S : ' bar' } } ,
32+ NewImage : { id : { S : " mi-123" } , foo : { S : " bar" } } ,
3133 } ,
3234 } ,
3335 ] ,
@@ -38,20 +40,20 @@ describe('mi-stream-forwarder Lambda', () => {
3840 expect ( mockedDeps . kinesisClient . send ) . toHaveBeenCalledWith (
3941 expect . objectContaining ( {
4042 input : expect . objectContaining ( {
41- StreamARN : ' test-stream' ,
42- PartitionKey : ' mi-123' ,
43+ StreamARN : " test-stream" ,
44+ PartitionKey : " mi-123" ,
4345 } ) ,
44- } )
46+ } ) ,
4547 ) ;
4648 } ) ;
4749
48- it ( ' does not forward non-INSERT records' , async ( ) => {
50+ it ( " does not forward non-INSERT records" , async ( ) => {
4951 const event : DynamoDBStreamEvent = {
5052 Records : [
5153 {
52- eventName : ' MODIFY' ,
54+ eventName : " MODIFY" ,
5355 dynamodb : {
54- NewImage : { id : { S : ' mi-123' } , foo : { S : ' baz' } } ,
56+ NewImage : { id : { S : " mi-123" } , foo : { S : " baz" } } ,
5557 } ,
5658 } ,
5759 ] ,
0 commit comments