diff --git a/modules/quantcastBidAdapter.js b/modules/quantcastBidAdapter.js index e6f4d27bdbb..79128a834a4 100644 --- a/modules/quantcastBidAdapter.js +++ b/modules/quantcastBidAdapter.js @@ -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'; @@ -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 = { @@ -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); } }; diff --git a/test/spec/modules/quantcastBidAdapter_spec.js b/test/spec/modules/quantcastBidAdapter_spec.js index f5a7602c7ab..e64294e87e2 100644 --- a/test/spec/modules/quantcastBidAdapter_spec.js +++ b/test/spec/modules/quantcastBidAdapter_spec.js @@ -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, @@ -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); @@ -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(); + }); + }); });