Skip to content

Commit

Permalink
Quantcast adapter onTimeout (prebid#3239)
Browse files Browse the repository at this point in the history
* onTimeout WIP

* test for onTimeout

* some renaming

* cleanup

* cleanup

* trying to fix the test

* using ajax instead of fetch
  • Loading branch information
jacekburys-quantcast authored and AdSpacesDevelopers committed Jan 30, 2019
1 parent 7f48677 commit 228b4d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/quantcastBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as utils from 'src/utils';
import { ajax } from 'src/ajax';
import { registerBidder } from 'src/adapters/bidderFactory';

const BIDDER_CODE = 'quantcast';
Expand Down Expand Up @@ -69,7 +70,7 @@ export const spec = {
});
});

const gdprConsent = bidderRequest ? bidderRequest.gdprConsent : {};
const gdprConsent = (bidderRequest && bidderRequest.gdprConsent) ? bidderRequest.gdprConsent : {};

// Request Data Format can be found at https://wiki.corp.qc/display/adinf/QCX
const requestData = {
Expand Down Expand Up @@ -157,6 +158,10 @@ export const spec = {
});

return bidResponsesList;
},
onTimeout(timeoutData) {
const url = `${QUANTCAST_PROTOCOL}://${QUANTCAST_DOMAIN}:${QUANTCAST_PORT}/qchb_notify?type=timeout`;
ajax(url, null, null);
}
};

Expand Down
17 changes: 17 additions & 0 deletions test/spec/modules/quantcastBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as utils from 'src/utils';
import { expect } from 'chai';
import { stub, sandbox } from 'sinon';
import {
QUANTCAST_DOMAIN,
QUANTCAST_TEST_DOMAIN,
Expand All @@ -12,6 +13,7 @@ import {
} from '../../../modules/quantcastBidAdapter';
import { newBidder } from '../../../src/adapters/bidderFactory';
import { parse } from 'src/url';
import * as ajax from 'src/ajax';

describe('Quantcast adapter', function () {
const quantcastAdapter = newBidder(qcSpec);
Expand Down Expand Up @@ -211,4 +213,19 @@ describe('Quantcast adapter', function () {
expect(interpretedResponse.length).to.equal(0);
});
});

describe('`onTimeout`', function() {
it('makes a request to the notify endpoint', function() {
const sinonSandbox = sandbox.create();
const ajaxStub = sinonSandbox.stub(ajax, 'ajax').callsFake(function() {});
const timeoutData = {
bidder: 'quantcast'
};
qcSpec.onTimeout(timeoutData);
const expectedUrl = `${QUANTCAST_PROTOCOL}://${QUANTCAST_DOMAIN}:${QUANTCAST_PORT}/qchb_notify?type=timeout`;
ajaxStub.withArgs(expectedUrl, null, null).calledOnce.should.be.true;
ajaxStub.restore();
sinonSandbox.restore();
});
});
});

0 comments on commit 228b4d9

Please sign in to comment.