Skip to content

Commit

Permalink
ogury Bid Adapter: fix getusersync method (prebid#7472)
Browse files Browse the repository at this point in the history
  • Loading branch information
jogury authored and Chris Pabst committed Jan 10, 2022
1 parent ec992d0 commit 6804598
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/oguryBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) {

return [{
type: 'image',
url: `${MS_COOKIE_SYNC_DOMAIN}/v1/init-sync/bid-switch?iab_string=${gdprConsent.consentString}&source=prebid`
url: `${MS_COOKIE_SYNC_DOMAIN}/v1/init-sync/bid-switch?iab_string=${(gdprConsent && gdprConsent.consentString) || ''}&source=prebid`
}]
}

Expand Down
66 changes: 66 additions & 0 deletions test/spec/modules/oguryBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,72 @@ describe('OguryBidAdapter', function () {
syncOptions.pixelEnabled = false;
expect(spec.getUserSyncs(syncOptions, [], gdprConsent)).to.have.lengthOf(0);
});

it('should return syncs array with an element of type image when consentString is undefined', () => {
gdprConsent = {
gdprApplies: true,
consentString: undefined
};

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid');
});

it('should return syncs array with an element of type image when consentString is null', () => {
gdprConsent = {
gdprApplies: true,
consentString: null
};

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid');
});

it('should return syncs array with an element of type image when gdprConsent is undefined', () => {
gdprConsent = undefined;

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid');
});

it('should return syncs array with an element of type image when gdprConsent is null', () => {
gdprConsent = null;

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid');
});

it('should return syncs array with an element of type image when gdprConsent is null and gdprApplies is false', () => {
gdprConsent = {
gdprApplies: false,
consentString: null
};

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid');
});

it('should return syncs array with an element of type image when gdprConsent is empty string and gdprApplies is false', () => {
gdprConsent = {
gdprApplies: false,
consentString: ''
};

const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
expect(userSyncs).to.have.lengthOf(1);
expect(userSyncs[0].type).to.equal('image');
expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid');
});
});

describe('buildRequests', function () {
Expand Down

0 comments on commit 6804598

Please sign in to comment.