File tree Expand file tree Collapse file tree
libs/shared/cms/src/lib/queries/churn-intervention-by-product-id Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,28 @@ describe('ChurnInterventionByProductIdResultUtil', () => {
4242 expect ( transformed ?. churnInterventionId ) . toBeDefined ( ) ;
4343 } ) ;
4444
45+ it ( 'should not capture sentry message if no offering is returned' , ( ) => {
46+ const result = ChurnInterventionByProductIdRawResultFactory ( {
47+ offerings : [ ] ,
48+ } ) ;
49+ const util = new ChurnInterventionByProductIdResultUtil ( result ) ;
50+ util . getTransformedChurnInterventionByProductId ( ) ;
51+
52+ expect ( Sentry . captureMessage ) . toHaveBeenCalledTimes ( 0 ) ;
53+ } ) ;
54+
55+ it ( 'should not capture sentry message if one offering is returned' , ( ) => {
56+ const result = ChurnInterventionByProductIdRawResultFactory ( {
57+ offerings : [
58+ ChurnInterventionByProductIdRawResultFactory ( ) . offerings [ 0 ] ,
59+ ] ,
60+ } ) ;
61+ const util = new ChurnInterventionByProductIdResultUtil ( result ) ;
62+ util . getTransformedChurnInterventionByProductId ( ) ;
63+
64+ expect ( Sentry . captureMessage ) . toHaveBeenCalledTimes ( 0 ) ;
65+ } ) ;
66+
4567 it ( 'should capture sentry message if more than one offering is returned' , ( ) => {
4668 const result = ChurnInterventionByProductIdRawResultFactory ( {
4769 offerings : [
Original file line number Diff line number Diff line change @@ -13,7 +13,10 @@ export class ChurnInterventionByProductIdResultUtil {
1313 constructor ( private rawResult : ChurnInterventionByProductIdRawResult ) { }
1414
1515 getTransformedChurnInterventionByProductId ( ) {
16- if ( this . rawResult . offerings . length !== 1 ) {
16+ if ( this . rawResult . offerings . length === 0 ) {
17+ return [ ] ;
18+ }
19+ if ( this . rawResult . offerings . length > 1 ) {
1720 Sentry . captureMessage (
1821 'Unexpected number of offerings found for product and interval' ,
1922 { extra : { offeringsCount : this . rawResult . offerings . length } }
You can’t perform that action at this time.
0 commit comments