diff --git a/modules/quantcastBidAdapter.js b/modules/quantcastBidAdapter.js index cfeb1589aa9..0855de7a911 100644 --- a/modules/quantcastBidAdapter.js +++ b/modules/quantcastBidAdapter.js @@ -1,12 +1,12 @@ -import adapterManager from "src/adaptermanager"; -import * as utils from "src/utils"; -import { registerBidder } from "src/adapters/bidderFactory"; +import adapterManager from 'src/adaptermanager'; +import * as utils from 'src/utils'; +import { registerBidder } from 'src/adapters/bidderFactory'; -const BIDDER_CODE = "quantcast"; +const BIDDER_CODE = 'quantcast'; const DEFAULT_BID_FLOOR = 0.0000000001; -export const QUANTCAST_CALLBACK_URL = "global.qc.rtb.quantserve.com"; -export const QUANTCAST_CALLBACK_URL_TEST = "s2s-canary.quantserve.com"; -export const QUANTCAST_TEST_PUBLISHER = "test-publisher"; +export const QUANTCAST_CALLBACK_URL = 'global.qc.rtb.quantserve.com'; +export const QUANTCAST_CALLBACK_URL_TEST = 's2s-canary.quantserve.com'; +export const QUANTCAST_TEST_PUBLISHER = 'test-publisher'; /** * The documentation for Prebid.js Adapter 1.0 can be found at link below, @@ -35,7 +35,7 @@ export const spec = { return false; } - if (bid.mediaType === "video") { + if (bid.mediaType === 'video') { return false; } @@ -62,7 +62,7 @@ export const spec = { // Switch the callback URL to Quantcast Canary Endpoint for testing purpose // `//` is not used because we have different port setting at our end switch (window.location.protocol) { - case "https:": + case 'https:': publisherTagURL = `https://${QUANTCAST_CALLBACK_URL}:8443/qchb`; publisherTagURLTest = `https://${QUANTCAST_CALLBACK_URL_TEST}:8443/qchb`; break; @@ -112,7 +112,7 @@ export const spec = { return { data, - method: "POST", + method: 'POST', url, withCredentials: true }; @@ -137,10 +137,10 @@ export const spec = { if ( response === undefined || - !response.hasOwnProperty("bids") || + !response.hasOwnProperty('bids') || utils.isEmpty(response.bids) ) { - utils.logError("Sub-optimal JSON received from Quantcast server"); + utils.logError('Sub-optimal JSON received from Quantcast server'); return []; } diff --git a/test/spec/modules/quantcastBidAdapter_spec.js b/test/spec/modules/quantcastBidAdapter_spec.js index 67f8822a617..20f4e09983e 100644 --- a/test/spec/modules/quantcastBidAdapter_spec.js +++ b/test/spec/modules/quantcastBidAdapter_spec.js @@ -1,82 +1,82 @@ -import * as utils from "src/utils"; -import { expect } from "chai"; +import * as utils from 'src/utils'; +import { expect } from 'chai'; import { spec as qcSpec, QUANTCAST_CALLBACK_URL, QUANTCAST_CALLBACK_URL_TEST -} from "../../../modules/quantcastBidAdapter"; -import { newBidder } from "../../../src/adapters/bidderFactory"; +} from '../../../modules/quantcastBidAdapter'; +import { newBidder } from '../../../src/adapters/bidderFactory'; -describe("Quantcast adapter", () => { +describe('Quantcast adapter', () => { const quantcastAdapter = newBidder(qcSpec); let bidRequest; beforeEach(() => { bidRequest = { - bidder: "quantcast", - bidId: "2f7b179d443f14", - requestId: "595ffa73-d78a-46c9-b18e-f99548a5be6b", - bidderRequestId: "1cc026909c24c8", - placementCode: "div-gpt-ad-1438287399331-0", + bidder: 'quantcast', + bidId: '2f7b179d443f14', + requestId: '595ffa73-d78a-46c9-b18e-f99548a5be6b', + bidderRequestId: '1cc026909c24c8', + placementCode: 'div-gpt-ad-1438287399331-0', params: { - publisherId: "test-publisher", // REQUIRED - Publisher ID provided by Quantcast + publisherId: 'test-publisher', // REQUIRED - Publisher ID provided by Quantcast battr: [1, 2] // OPTIONAL - Array of blocked creative attributes as per OpenRTB Spec List 5.3 }, sizes: [[300, 250]] }; }); - describe("inherited functions", () => { - it("exists and is a function", () => { - expect(quantcastAdapter.callBids).to.exist.and.to.be.a("function"); + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(quantcastAdapter.callBids).to.exist.and.to.be.a('function'); }); }); - describe("`isBidRequestValid`", () => { - it("should return `false` when bid is not passed", () => { + describe('`isBidRequestValid`', () => { + it('should return `false` when bid is not passed', () => { expect(qcSpec.isBidRequestValid()).to.equal(false); }); - it("should return `false` when bid `mediaType` is `video`", () => { - const bidRequest = { mediaType: "video" }; + it('should return `false` when bid `mediaType` is `video`', () => { + const bidRequest = { mediaType: 'video' }; expect(qcSpec.isBidRequestValid(bidRequest)).to.equal(false); }); - it("should return `true` when bid contains required params", () => { - const bidRequest = { mediaType: "banner" }; + it('should return `true` when bid contains required params', () => { + const bidRequest = { mediaType: 'banner' }; expect(qcSpec.isBidRequestValid(bidRequest)).to.equal(true); }); }); - describe("`buildRequests`", () => { - it("sends bid requests to Quantcast Canary Endpoint if `publisherId` is `test-publisher`", () => { + describe('`buildRequests`', () => { + it('sends bid requests to Quantcast Canary Endpoint if `publisherId` is `test-publisher`', () => { const requests = qcSpec.buildRequests([bidRequest]); switch (window.location.protocol) { - case "https:": - expect(requests[0]["url"]).to.equal( + case 'https:': + expect(requests[0]['url']).to.equal( `https://${QUANTCAST_CALLBACK_URL_TEST}:8443/qchb` ); break; default: - expect(requests[0]["url"]).to.equal( + expect(requests[0]['url']).to.equal( `http://${QUANTCAST_CALLBACK_URL_TEST}:8080/qchb` ); break; } }); - it("sends bid requests to Quantcast Global Endpoint for regular `publisherId`", () => { + it('sends bid requests to Quantcast Global Endpoint for regular `publisherId`', () => { const bidRequest = { - bidder: "quantcast", - bidId: "2f7b179d443f14", - requestId: "595ffa73-d78a-46c9-b18e-f99548a5be6b", - bidderRequestId: "1cc026909c24c8", - placementCode: "div-gpt-ad-1438287399331-0", + bidder: 'quantcast', + bidId: '2f7b179d443f14', + requestId: '595ffa73-d78a-46c9-b18e-f99548a5be6b', + bidderRequestId: '1cc026909c24c8', + placementCode: 'div-gpt-ad-1438287399331-0', params: { - publisherId: "regular-publisher", // REQUIRED - Publisher ID provided by Quantcast + publisherId: 'regular-publisher', // REQUIRED - Publisher ID provided by Quantcast battr: [1, 2] // OPTIONAL - Array of blocked creative attributes as per OpenRTB Spec List 5.3 }, sizes: [[300, 250]] @@ -84,47 +84,47 @@ describe("Quantcast adapter", () => { const requests = qcSpec.buildRequests([bidRequest]); switch (window.location.protocol) { - case "https:": - expect(requests[0]["url"]).to.equal( + case 'https:': + expect(requests[0]['url']).to.equal( `https://${QUANTCAST_CALLBACK_URL}:8443/qchb` ); break; default: - expect(requests[0]["url"]).to.equal( + expect(requests[0]['url']).to.equal( `http://${QUANTCAST_CALLBACK_URL}:8080/qchb` ); break; } }); - it("sends bid requests to Quantcast Header Bidding Endpoints via POST", () => { + it('sends bid requests to Quantcast Header Bidding Endpoints via POST', () => { const requests = qcSpec.buildRequests([bidRequest]); - expect(requests[0].method).to.equal("POST"); + expect(requests[0].method).to.equal('POST'); }); - it("sends bid requests with `withCredentials` enabled", () => { + it('sends bid requests with `withCredentials` enabled', () => { const requests = qcSpec.buildRequests([bidRequest]); expect(requests[0].withCredentials).to.equal(true); }); - it("sends bid requests contains all the required parameters", () => { + it('sends bid requests contains all the required parameters', () => { const referrer = utils.getTopWindowUrl(); const loc = utils.getTopWindowLocation(); const domain = loc.hostname; const requests = qcSpec.buildRequests([bidRequest]); const expectedBidRequest = { - publisherId: "test-publisher", - requestId: "2f7b179d443f14", + publisherId: 'test-publisher', + requestId: '2f7b179d443f14', imp: [ { banner: { battr: [1, 2], size: [{ width: 300, height: 250 }] }, - placementCode: "div-gpt-ad-1438287399331-0", + placementCode: 'div-gpt-ad-1438287399331-0', bidFloor: 1e-10 } ], @@ -133,22 +133,22 @@ describe("Quantcast adapter", () => { referrer, domain }, - bidId: "2f7b179d443f14" + bidId: '2f7b179d443f14' }; expect(requests[0].data).to.equal(JSON.stringify(expectedBidRequest)); }); }); - describe("`interpretResponse`", () => { + describe('`interpretResponse`', () => { // The sample response is from https://wiki.corp.qc/display/adinf/QCX const response = { - bidderCode: "qcx", // Renaming it to use CamelCase since that is what is used in the Prebid.js variable name - requestId: "erlangcluster@qa-rtb002.us-ec.adtech.com-11417780270886458", // Added this field. This is not used now but could be useful in troubleshooting later on. Specially for sites using iFrames + bidderCode: 'qcx', // Renaming it to use CamelCase since that is what is used in the Prebid.js variable name + requestId: 'erlangcluster@qa-rtb002.us-ec.adtech.com-11417780270886458', // Added this field. This is not used now but could be useful in troubleshooting later on. Specially for sites using iFrames bids: [ { statusCode: 1, - placementCode: "imp1", // Changing this to placementCode to be reflective + placementCode: 'imp1', // Changing this to placementCode to be reflective cpm: 4.5, ad: '
Quantcast
', @@ -158,43 +158,43 @@ describe("Quantcast adapter", () => { ] }; - it("should return an empty array if `serverResponse` is `undefined`", () => { + it('should return an empty array if `serverResponse` is `undefined`', () => { const interpretedResponse = qcSpec.interpretResponse(); expect(interpretedResponse.length).to.equal(0); }); - it("should return an empty array if the parsed response does NOT include `bids`", () => { + it('should return an empty array if the parsed response does NOT include `bids`', () => { const interpretedResponse = qcSpec.interpretResponse({}); expect(interpretedResponse.length).to.equal(0); }); - it("should return an empty array if the parsed response has an empty `bids`", () => { + it('should return an empty array if the parsed response has an empty `bids`', () => { const interpretedResponse = qcSpec.interpretResponse({ bids: [] }); expect(interpretedResponse.length).to.equal(0); }); - it("should get correct bid response", () => { + it('should get correct bid response', () => { const expectedResponse = { ad: '
Quantcast
', cpm: 4.5, width: 300, height: 250, - requestId: "erlangcluster@qa-rtb002.us-ec.adtech.com-11417780270886458", - bidderCode: "qcx" + requestId: 'erlangcluster@qa-rtb002.us-ec.adtech.com-11417780270886458', + bidderCode: 'qcx' }; const interpretedResponse = qcSpec.interpretResponse(response); expect(interpretedResponse[0]).to.deep.equal(expectedResponse); }); - it("handles no bid response", () => { + it('handles no bid response', () => { const response = { - bidderCode: "qcx", // Renaming it to use CamelCase since that is what is used in the Prebid.js variable name - requestId: "erlangcluster@qa-rtb002.us-ec.adtech.com-11417780270886458", // Added this field. This is not used now but could be useful in troubleshooting later on. Specially for sites using iFrames + bidderCode: 'qcx', // Renaming it to use CamelCase since that is what is used in the Prebid.js variable name + requestId: 'erlangcluster@qa-rtb002.us-ec.adtech.com-11417780270886458', // Added this field. This is not used now but could be useful in troubleshooting later on. Specially for sites using iFrames bids: [] }; const expectedResponse = [];