Skip to content

Commit

Permalink
Merged in RVR-1261-fix-tests (pull request prebid#11)
Browse files Browse the repository at this point in the history
RVR-1261 fix tests

* RVR-1261 Secured adapter from no containers configuration. And changed fetching URL.

* RVR-1261 Added event check for request and changed some names.

* Applied feedback.

Approved-by: Alessandro Di Giovanni <alessandro.digiovanni@gamegenetics.de>
  • Loading branch information
Kacper Woźniak authored and AlessandroDG committed Oct 24, 2018
1 parent 4867c9c commit c19f499
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
12 changes: 8 additions & 4 deletions modules/rivrAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function fulfillAuctionObject() {
app: {
id: null,
name: null,
domain: rivrAnalytics.context.clientURL,
domain: window.location.href,
bundle: null,
cat: [],
publisher: {
Expand All @@ -277,7 +277,7 @@ function fulfillAuctionObject() {
site: {
id: null,
name: null,
domain: rivrAnalytics.context.clientURL,
domain: window.location.href,
cat: [],
publisher: {
id: null,
Expand All @@ -293,7 +293,6 @@ function fulfillAuctionObject() {
type: null,
metro: null
},
connectiontype: navigator.connection.effectiveType,
devicetype: getPlatformType(),
osv: null,
os: null,
Expand Down Expand Up @@ -377,7 +376,12 @@ rivrAnalytics.enableAnalytics = (config) => {
clientID: config.options.clientID,
queue: new ExpiringQueue(sendImpressions, sendAuction, config.options.queueTimeout || DEFAULT_QUEUE_TIMEOUT)
};
addHandlers(config.options.bannersIds);
let bannersIds = config.options.bannersIds
if (bannersIds) {
if (bannersIds.length > 0) {
addHandlers(config.options.bannersIds);
}
}
logInfo('Rivr Analytics enabled with config', rivrAnalytics.context);
rivrAnalytics.originEnableAnalytics(config);
};
Expand Down
44 changes: 34 additions & 10 deletions test/spec/modules/rivrAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,35 @@ describe('', () => {
events.emit(CONSTANTS.EVENTS.BID_REQUESTED, REQUEST);
const sitePubcid = analyticsAdapter.context.auctionObject.site.publisher.id;
const appPubcid = analyticsAdapter.context.auctionObject.app.publisher.id;
const requestEvent = analyticsAdapter.context.auctionObject.bidRequests;
expect(sitePubcid).to.be.eql(777);
expect(sitePubcid).to.be.eql(appPubcid);
expect(requestEvent).to.have.length(1);
expect(requestEvent[0]).to.be.eql({
bidderCode: 'adapter',
auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f',
bidderRequestId: '1a6fc81528d0f6',
bids: [{
bidder: 'adapter',
params: {},
adUnitCode: 'container-1',
transactionId: 'de90df62-7fd0-4fbc-8787-92d133a7dc06',
sizes: [[300, 250]],
bidId: '208750227436c1',
bidderRequestId: '1a6fc81528d0f6',
auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f'
}],
auctionStart: 1509369418387,
timeout: 3000,
start: 1509369418389
});
});

it('should handle bid response event', () => {
events.emit(CONSTANTS.EVENTS.BID_RESPONSE, RESPONSE);
const ev = analyticsAdapter.context.auctionObject.bidResponses;
expect(ev).to.have.length(1);
expect(ev[0]).to.be.eql({
const responseEvent = analyticsAdapter.context.auctionObject.bidResponses;
expect(responseEvent).to.have.length(1);
expect(responseEvent[0]).to.be.eql({
timestamp: 1509369418832,
status: 1,
'total_duration': 443,
Expand Down Expand Up @@ -182,9 +202,9 @@ describe('', () => {

it('should handle winning bid', () => {
events.emit(CONSTANTS.EVENTS.BID_WON, RESPONSE);
const ev = analyticsAdapter.context.auctionObject.imp;
expect(ev.length).to.be.eql(1);
expect(ev[0]).to.be.eql({
const wonEvent = analyticsAdapter.context.auctionObject.imp;
expect(wonEvent.length).to.be.eql(1);
expect(wonEvent[0]).to.be.eql({
tagid: 'container-1',
displaymanager: null,
displaymanagerver: null,
Expand All @@ -203,19 +223,23 @@ describe('', () => {
it('sends request after timeout', () => {
let impressions = analyticsAdapter.context.auctionObject.imp;
let responses = analyticsAdapter.context.auctionObject.bidResponses;
let requests = analyticsAdapter.context.auctionObject.bidRequests;

expect(impressions.length).to.be.eql(1);
expect(responses.length).to.be.eql(1);
expect(requests.length).to.be.eql(1);
expect(ajaxStub.calledOnce).to.be.equal(false);

timer.tick(4500);

let impressionss = analyticsAdapter.context.auctionObject.imp;
let responsess = analyticsAdapter.context.auctionObject.bidResponses;
let impressionsAfterSend = analyticsAdapter.context.auctionObject.imp;
let responsesAfterSend = analyticsAdapter.context.auctionObject.bidResponses;
let requestsAfterSend = analyticsAdapter.context.auctionObject.bidRequests;

expect(ajaxStub.calledOnce).to.be.equal(true);
expect(impressionss.length).to.be.eql(0);
expect(responsess.length).to.be.eql(0);
expect(impressionsAfterSend.length).to.be.eql(0);
expect(responsesAfterSend.length).to.be.eql(0);
expect(requestsAfterSend.length).to.be.eql(0);
});
});
});

0 comments on commit c19f499

Please sign in to comment.