Skip to content

Commit

Permalink
add one more get param to be forwarded (prebid#7745)
Browse files Browse the repository at this point in the history
  • Loading branch information
kodi authored and Chris Pabst committed Jan 10, 2022
1 parent aa733b1 commit 61fc68b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions modules/cwireBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const RENDERER_URL = 'https://cdn.cwi.re/prebid/renderer/LATEST/renderer.
export const CW_PAGE_VIEW_ID = generateUUID();
const LS_CWID_KEY = 'cw_cwid';
const CW_GROUPS_QUERY = 'cwgroups';
const CW_CREATIVE_QUERY = 'cwcreative';

const storage = getStorageManager();

Expand Down Expand Up @@ -161,6 +162,7 @@ export const spec = {

let refgroups = [];

const cwCreativeId = getQueryVariable(CW_CREATIVE_QUERY);
const rgQuery = getQueryVariable(CW_GROUPS_QUERY);
if (rgQuery !== null) {
refgroups = rgQuery.split(',');
Expand All @@ -171,6 +173,7 @@ export const spec = {
const payload = {
cwid: localStorageCWID,
refgroups,
cwcreative: cwCreativeId,
slots: slots,
httpRef: referer || '',
pageViewId: CW_PAGE_VIEW_ID,
Expand Down
18 changes: 10 additions & 8 deletions test/spec/modules/cwireBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ const BidderRequestBuilder = function BidderRequestBuilder(options) {
bidderRequestId: BID_DEFAULTS.request.bidderRequestId,
transactionId: BID_DEFAULTS.request.transactionId,
timeout: 3000,
refererInfo: {
numIframes: 0,
reachedTop: true,
referer: 'http://test.io/index.html?pbjs_debug=true'
}
};

const request = {
Expand Down Expand Up @@ -82,16 +77,13 @@ const BidRequestBuilder = function BidRequestBuilder(options, deleteKeys) {
};

describe('C-WIRE bid adapter', () => {
let utilsMock;
let sandbox;

beforeEach(() => {
utilsMock = sinon.mock(utils);
sandbox = sinon.createSandbox();
});

afterEach(() => {
utilsMock.restore();
sandbox.restore();
});

Expand Down Expand Up @@ -146,19 +138,29 @@ describe('C-WIRE bid adapter', () => {

describe('C-WIRE - buildRequests()', function () {
it('creates a valid request', function () {
// for whatever reason stub for getWindowLocation does not work
// so this was the closest way to test for get params
const params = sandbox.stub(utils, 'getParameterByName');
params.withArgs('cwgroups').returns('group_1');
params.withArgs('cwcreative').returns('54321');

const bid01 = new BidRequestBuilder({
mediaTypes: {
banner: {
sizes: [[1, 1]],
}
}
}).withParams().build();

const bidderRequest01 = new BidderRequestBuilder().build();

const requests = spec.buildRequests([bid01], bidderRequest01);

expect(requests.data.slots.length).to.equal(1);
expect(requests.data.cwid).to.be.null;
expect(requests.data.slots[0].sizes[0]).to.equal('1x1');
expect(requests.data.cwcreative).to.equal('54321');
expect(requests.data.refgroups[0]).to.equal('group_1');
});
});

Expand Down

0 comments on commit 61fc68b

Please sign in to comment.