@@ -44,39 +44,61 @@ describe('PanoramaClient', () => {
4444 const eventDetail = 'a' . repeat ( 4001 ) ;
4545 panorama . sendMetric ( { eventType : 'custom' , eventDetail } ) ;
4646
47- expect ( window . panorama ) . not . toHaveBeenCalled ( ) ;
47+ expect ( window . panorama ) . toHaveBeenCalledTimes ( 1 ) ;
48+ expect ( window . panorama ) . toHaveBeenCalledWith ( 'trackCustomEvent' , {
49+ eventName : 'awsui-metric-error' ,
50+ eventDetail : expect . stringMatching ( / E v e n t d e t a i l f o r m e t r i c i s t o o l o n g : .* / ) ,
51+ } ) ;
4852 expect ( consoleSpy ) . toHaveBeenCalledWith ( `Event detail for metric is too long: ${ eventDetail } ` ) ;
4953 } ) ;
5054
5155 test ( 'prints an error when event type is too long' , ( ) => {
5256 const eventType = 'a' . repeat ( 51 ) ;
57+ const errorMessage = `Event type for metric is too long: ${ eventType } ` ;
5358 panorama . sendMetric ( { eventType } ) ;
5459
55- expect ( window . panorama ) . not . toHaveBeenCalled ( ) ;
56- expect ( consoleSpy ) . toHaveBeenCalledWith ( `Event type for metric is too long: ${ eventType } ` ) ;
60+ expect ( window . panorama ) . toHaveBeenCalledTimes ( 1 ) ;
61+ expect ( window . panorama ) . toHaveBeenCalledWith ( 'trackCustomEvent' , {
62+ eventName : 'awsui-metric-error' ,
63+ eventDetail : errorMessage ,
64+ } ) ;
65+ expect ( consoleSpy ) . toHaveBeenCalledWith ( errorMessage ) ;
5766 } ) ;
5867
5968 test ( 'prints an error when event name is too long' , ( ) => {
6069 const eventName = 'a' . repeat ( 1001 ) ;
70+ const errorMessage = `Event name for metric is too long: ${ eventName } ` ;
6171 panorama . sendMetric ( { eventName } ) ;
6272
63- expect ( window . panorama ) . not . toHaveBeenCalled ( ) ;
64- expect ( consoleSpy ) . toHaveBeenCalledWith ( `Event name for metric is too long: ${ eventName } ` ) ;
73+ expect ( window . panorama ) . toHaveBeenCalledTimes ( 1 ) ;
74+ expect ( window . panorama ) . toHaveBeenCalledWith ( 'trackCustomEvent' , {
75+ eventName : 'awsui-metric-error' ,
76+ eventDetail : errorMessage ,
77+ } ) ;
78+ expect ( consoleSpy ) . toHaveBeenCalledWith ( errorMessage ) ;
6579 } ) ;
6680
6781 test ( 'prints an error when event value is too long' , ( ) => {
6882 const eventValue = 'a' . repeat ( 4001 ) ;
6983 panorama . sendMetric ( { eventValue } ) ;
7084
71- expect ( window . panorama ) . not . toHaveBeenCalled ( ) ;
85+ expect ( window . panorama ) . toHaveBeenCalledTimes ( 1 ) ;
86+ expect ( window . panorama ) . toHaveBeenCalledWith ( 'trackCustomEvent' , {
87+ eventName : 'awsui-metric-error' ,
88+ eventDetail : expect . stringMatching ( / E v e n t v a l u e f o r m e t r i c i s t o o l o n g : .* / ) ,
89+ } ) ;
7290 expect ( consoleSpy ) . toHaveBeenCalledWith ( `Event value for metric is too long: ${ eventValue } ` ) ;
7391 } ) ;
7492
7593 test ( 'prints an error when event context is too long' , ( ) => {
7694 const eventContext = 'a' . repeat ( 4001 ) ;
7795 panorama . sendMetric ( { eventContext } ) ;
7896
79- expect ( window . panorama ) . not . toHaveBeenCalled ( ) ;
97+ expect ( window . panorama ) . toHaveBeenCalledTimes ( 1 ) ;
98+ expect ( window . panorama ) . toHaveBeenCalledWith ( 'trackCustomEvent' , {
99+ eventName : 'awsui-metric-error' ,
100+ eventDetail : expect . stringMatching ( / E v e n t c o n t e x t f o r m e t r i c i s t o o l o n g : .* / ) ,
101+ } ) ;
80102 expect ( consoleSpy ) . toHaveBeenCalledWith ( `Event context for metric is too long: ${ eventContext } ` ) ;
81103 } ) ;
82104
0 commit comments