diff --git a/src/adapters/smartadserver.js b/src/adapters/smartadserver.js index c0c80dbbe3b..f35923411bb 100644 --- a/src/adapters/smartadserver.js +++ b/src/adapters/smartadserver.js @@ -14,6 +14,7 @@ var SmartAdServer = function SmartAdServer() { bidObject = bidfactory.createBid(1); bidObject.bidderCode = 'smartadserver'; bidObject.cpm = adUnit.cpm; + bidObject.currency = adUnit.currency; bidObject.ad = adUnit.ad; bidObject.width = adUnit.width; bidObject.height = adUnit.height; @@ -40,6 +41,7 @@ var SmartAdServer = function SmartAdServer() { "siteid": bid.params.siteId, "pgid": bid.params.pageId, "fmtid": bid.params.formatId, + "ccy": bid.params.currency || "USD", "tgt": encodeURIComponent(bid.params.target || ''), "tag": bid.placementCode, "sizes": bid.sizes.map(size => size[0] + "x" + size[1]).join(","), diff --git a/test/spec/adapters/smartadserver_spec.js b/test/spec/adapters/smartadserver_spec.js index d5989d679b1..f48f10d9cb5 100644 --- a/test/spec/adapters/smartadserver_spec.js +++ b/test/spec/adapters/smartadserver_spec.js @@ -18,7 +18,8 @@ describe("smartadserver adapter tests", function () { siteId: "1234", pageId: "5678", formatId: "90", - target: "test=prebid" + target: "test=prebid", + currency: "EUR" }, requestId: "efgh5678", placementCode: "sas_42" @@ -26,6 +27,24 @@ describe("smartadserver adapter tests", function () { ] }; + var DEFAULT_PARAMS_WO_OPTIONAL = { + bidderCode: "smartadserver", + bids: [{ + bidId: "abcd1234", + sizes: [[300, 250], [300, 200]], + bidder: "smartadserver", + params: { + domain: "http://www.smartadserver.com", + siteId: "1234", + pageId: "5678", + formatId: "90" + }, + requestId: "efgh5678", + placementCode: "sas_42" + } + ] + }; + var BID_RESPONSE = { cpm: 0.42, ad: "fake ad content", @@ -58,6 +77,7 @@ describe("smartadserver adapter tests", function () { expect(parsedBidUrlQueryString).to.have.property("pgid").and.to.equal("5678"); expect(parsedBidUrlQueryString).to.have.property("fmtid").and.to.equal("90"); expect(parsedBidUrlQueryString).to.have.property("tgt").and.to.equal("test=prebid"); + expect(parsedBidUrlQueryString).to.have.property("ccy").and.to.equal("EUR"); expect(parsedBidUrlQueryString).to.have.property("tag").and.to.equal("sas_42"); expect(parsedBidUrlQueryString).to.have.property("sizes").and.to.equal("300x250,300x200"); expect(parsedBidUrlQueryString).to.have.property("async").and.to.equal("1"); @@ -65,6 +85,21 @@ describe("smartadserver adapter tests", function () { stubLoadScript.restore(); }); + it("test optional parameters default value", function () { + var stubLoadScript = sinon.stub(adLoader, "loadScript"); + + adapter().callBids(DEFAULT_PARAMS_WO_OPTIONAL); + + var bidUrl = stubLoadScript.getCall(0).args[0]; + var parsedBidUrl = urlParse(bidUrl); + var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); + + expect(parsedBidUrlQueryString).to.have.property("tgt").and.to.equal(""); + expect(parsedBidUrlQueryString).to.have.property("ccy").and.to.equal("USD"); + + stubLoadScript.restore(); + }); + it("creates an empty bid response if no bids", function() { var stubLoadScript = sinon.stub(adLoader, "loadScript", function(url) { var bidUrl = stubLoadScript.getCall(0).args[0];