Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ describe('ChurnInterventionByProductIdResultUtil', () => {
expect(transformed?.churnInterventionId).toBeDefined();
});

it('should not capture sentry message if no offering is returned', () => {
const result = ChurnInterventionByProductIdRawResultFactory({
offerings: [],
});
const util = new ChurnInterventionByProductIdResultUtil(result);
util.getTransformedChurnInterventionByProductId();

expect(Sentry.captureMessage).toHaveBeenCalledTimes(0);
});

it('should not capture sentry message if one offering is returned', () => {
const result = ChurnInterventionByProductIdRawResultFactory({
offerings: [
ChurnInterventionByProductIdRawResultFactory().offerings[0],
],
});
const util = new ChurnInterventionByProductIdResultUtil(result);
util.getTransformedChurnInterventionByProductId();

expect(Sentry.captureMessage).toHaveBeenCalledTimes(0);
});

it('should capture sentry message if more than one offering is returned', () => {
const result = ChurnInterventionByProductIdRawResultFactory({
offerings: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export class ChurnInterventionByProductIdResultUtil {
constructor(private rawResult: ChurnInterventionByProductIdRawResult) {}

getTransformedChurnInterventionByProductId() {
if (this.rawResult.offerings.length !== 1) {
if (this.rawResult.offerings.length === 0) {
return [];
}
if (this.rawResult.offerings.length > 1) {
Sentry.captureMessage(
'Unexpected number of offerings found for product and interval',
{ extra: { offeringsCount: this.rawResult.offerings.length } }
Expand Down
Loading