Skip to content

Commit

Permalink
Add one more test case
Browse files Browse the repository at this point in the history
  • Loading branch information
wasp898 committed Nov 26, 2024
1 parent 90741ab commit 2a3959e
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions spec/tests/ConvivaAnalyticsTracker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,27 @@ describe(ConvivaAnalyticsTracker, () => {
expect(reportAdBreakEndedSpy).toHaveBeenCalledTimes(1);
})

it('should not report ad break ended if AdFinished is followed by a new AdStarted', () => {
it('should not report ad break ended twice if AdBreakFinished is emitted after the ad finished timer has already expired', () => {
convivaAnalyticsTracker.trackAdBreakStarted(Conviva.Constants.AdType.CLIENT_SIDE);
convivaAnalyticsTracker.trackAdStarted({}, Conviva.Constants.AdType.CLIENT_SIDE);
convivaAnalyticsTracker.trackAdFinished();

jest.runAllTimers();

expect(reportAdBreakEndedSpy).toHaveBeenCalledTimes(1);

convivaAnalyticsTracker.trackAdBreakFinished();

expect(reportAdBreakEndedSpy).toHaveBeenCalledTimes(1);
})

it('should not report ad break ended if AdFinished is followed by a new AdStarted', () => {
convivaAnalyticsTracker.trackAdBreakStarted(Conviva.Constants.AdType.CLIENT_SIDE);
convivaAnalyticsTracker.trackAdStarted({}, Conviva.Constants.AdType.CLIENT_SIDE);

expect(reportAdBreakStartedSpy).toHaveBeenCalledTimes(1);

convivaAnalyticsTracker.trackAdFinished();
convivaAnalyticsTracker.trackAdStarted({}, Conviva.Constants.AdType.CLIENT_SIDE);

jest.runAllTimers();
Expand All @@ -184,11 +200,13 @@ describe(ConvivaAnalyticsTracker, () => {
it('should report ad break started again after wrongly reporting ad break ended', () => {
convivaAnalyticsTracker.trackAdBreakStarted(Conviva.Constants.AdType.CLIENT_SIDE);
convivaAnalyticsTracker.trackAdStarted({}, Conviva.Constants.AdType.CLIENT_SIDE);

expect(reportAdBreakStartedSpy).toHaveBeenCalledTimes(1);

convivaAnalyticsTracker.trackAdFinished();
jest.runAllTimers();

expect(reportAdBreakEndedSpy).toHaveBeenCalledTimes(1);
expect(reportAdBreakStartedSpy).toHaveBeenCalledTimes(1);

convivaAnalyticsTracker.trackAdStarted({}, Conviva.Constants.AdType.CLIENT_SIDE);

Expand Down

0 comments on commit 2a3959e

Please sign in to comment.