@@ -3,7 +3,11 @@ import { Template } from "aws-cdk-lib/assertions";
33import { Alarm , Metric } from "aws-cdk-lib/aws-cloudwatch" ;
44import { Topic } from "aws-cdk-lib/aws-sns" ;
55
6- import { multipleActions , SnsAlarmActionStrategy } from "../../../../lib" ;
6+ import {
7+ isMultipleAlarmActionStrategy ,
8+ multipleActions ,
9+ SnsAlarmActionStrategy ,
10+ } from "../../../../lib" ;
711
812test ( "snapshot test: multiple actions" , ( ) => {
913 const stack = new Stack ( ) ;
@@ -15,12 +19,24 @@ test("snapshot test: multiple actions", () => {
1519 threshold : 0 ,
1620 metric : new Metric ( { namespace : "Dummy" , metricName : "Dummy" } ) ,
1721 } ) ;
18- const action = multipleActions (
19- new SnsAlarmActionStrategy ( { onAlarmTopic : topic1 } ) ,
20- new SnsAlarmActionStrategy ( { onAlarmTopic : topic2 } ) ,
21- new SnsAlarmActionStrategy ( { onAlarmTopic : topic3 } )
22- ) ;
22+
23+ const action1 = new SnsAlarmActionStrategy ( { onAlarmTopic : topic1 } ) ;
24+ const action2 = new SnsAlarmActionStrategy ( { onAlarmTopic : topic2 } ) ;
25+ const action3 = new SnsAlarmActionStrategy ( { onAlarmTopic : topic3 } ) ;
26+
27+ const action = multipleActions ( action1 , action2 , action3 ) ;
2328 action . addAlarmActions ( { alarm, action } ) ;
2429
2530 expect ( Template . fromStack ( stack ) ) . toMatchSnapshot ( ) ;
31+ expect ( action . flattenedAlarmActions ( ) ) . toEqual ( [ action1 , action2 , action3 ] ) ;
32+ } ) ;
33+
34+ test ( "isMultipleAlarmActionStrategy" , ( ) => {
35+ const stack = new Stack ( ) ;
36+ const topic1 = new Topic ( stack , "DummyTopic1" ) ;
37+ const snsAction = new SnsAlarmActionStrategy ( { onAlarmTopic : topic1 } ) ;
38+ const multipleAction = multipleActions ( snsAction ) ;
39+
40+ expect ( isMultipleAlarmActionStrategy ( multipleAction ) ) . toBe ( true ) ;
41+ expect ( isMultipleAlarmActionStrategy ( snsAction ) ) . toBe ( false ) ;
2642} ) ;
0 commit comments