Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update yuktamediaAnalyticsAdapter_spec.js to separate tests #3

Merged
merged 1 commit into from
Aug 23, 2020
Merged
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
176 changes: 172 additions & 4 deletions test/spec/modules/yuktamediaAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ describe('yuktamedia analytics adapter', function () {
yuktamediaAnalyticsAdapter.track.restore();
});

it('should catch all events', function () {
it('should catch all events 1', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
Expand All @@ -403,12 +403,82 @@ describe('yuktamedia analytics adapter', function () {
}
});
events.emit(constants.EVENTS.AUCTION_INIT, prebidAuction[constants.EVENTS.AUCTION_INIT]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch all events 2', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.BID_REQUESTED, prebidAuction[constants.EVENTS.BID_REQUESTED]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch all events 3', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.NO_BID, prebidAuction[constants.EVENTS.NO_BID]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch all events 4', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.BID_TIMEOUT, prebidAuction[constants.EVENTS.BID_TIMEOUT]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch all events 5', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.BID_RESPONSE, prebidAuction[constants.EVENTS.BID_RESPONSE]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch all events 6', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.AUCTION_END, prebidAuction[constants.EVENTS.AUCTION_END]);
sinon.assert.callCount(yuktamediaAnalyticsAdapter.track, 6);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch no events if no pubKey and pubId', function () {
Expand All @@ -427,7 +497,7 @@ describe('yuktamedia analytics adapter', function () {
sinon.assert.callCount(yuktamediaAnalyticsAdapter.track, 0);
});

it('should catch nobid, timeout and biwon event events', function () {
it('should catch nobid, timeout and bidwon event events one of eight', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
Expand All @@ -439,14 +509,112 @@ describe('yuktamedia analytics adapter', function () {
}
});
events.emit(constants.EVENTS.AUCTION_INIT, prebidNativeAuction[constants.EVENTS.AUCTION_INIT]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch nobid, timeout and bidwon event events two of eight', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.BID_REQUESTED, prebidNativeAuction[constants.EVENTS.BID_REQUESTED]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch nobid, timeout and bidwon event events three of eight', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.BID_REQUESTED, prebidNativeAuction[constants.EVENTS.BID_REQUESTED + '1']);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch nobid, timeout and bidwon event events four of eight', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.NO_BID, prebidNativeAuction[constants.EVENTS.NO_BID]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch nobid, timeout and bidwon event events five of eight', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.BID_TIMEOUT, prebidNativeAuction[constants.EVENTS.BID_TIMEOUT]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch nobid, timeout and bidwon event events six of eight', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.BID_RESPONSE, prebidNativeAuction[constants.EVENTS.BID_RESPONSE]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch nobid, timeout and bidwon event events seven of eight', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.AUCTION_END, prebidNativeAuction[constants.EVENTS.AUCTION_END]);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});

it('should catch nobid, timeout and bidwon event events eight of eight', function () {
yuktamediaAnalyticsAdapter.enableAnalytics({
provider: 'yuktamedia',
options: {
pubId: '1',
pubKey: 'ZXlKaGJHY2lPaUpJVXpJMU5pSjkuT==',
enableUTMCollection: true,
enableSession: true,
enableUserIdCollection: true
}
});
events.emit(constants.EVENTS.AUCTION_END, prebidNativeAuction[constants.EVENTS.BID_WON]);
sinon.assert.callCount(yuktamediaAnalyticsAdapter.track, 9);
sinon.assert.called(yuktamediaAnalyticsAdapter.track);
});
});

Expand Down