Skip to content

Commit

Permalink
tests(pipes): add test for targetParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelManke committed Dec 28, 2023
1 parent 3ad2cdc commit a4b630a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/@aws-cdk/aws-pipes-alpha/lib/targetParameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export enum PipeVariables {
* Helper class to generate dynamic target parameters.
*/
export class TargetParameter {
/**
* Reserved pipe variables
*/
static pipeVariable = PipeVariables;

/**
* Target parameter based on a jsonPath expression from the incoming event.
Expand All @@ -52,11 +56,4 @@ export class TargetParameter {
return `<${jsonPath}>`;
}

/**
* Target parameter based on a reserved pipe variable.
*/
static fromPipeVariable(pipeVariable: PipeVariables): string {
return pipeVariable;
}

}
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-pipes-alpha/test/targetParameters.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { TargetParameter } from '../lib';

describe('TargetParameter', ()=>{
describe('fromJsonPath', ()=>{
it('should return a string in correct format', ()=>{
expect(TargetParameter.fromJsonPath('$.test')).toEqual('<$.test>');
});
it('should throw an error if the jsonPath does not start with "$."', ()=>{
expect(()=>TargetParameter.fromJsonPath('test')).toThrow('JsonPath must start with "$."');
});
},
);
},
);

0 comments on commit a4b630a

Please sign in to comment.