Skip to content

Commit

Permalink
fix appnexus segment field format (prebid#6013)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Lauzon authored Nov 21, 2020
1 parent e5e899d commit 022bcea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
5 changes: 2 additions & 3 deletions modules/haloRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ const segmentMappers = {
set(bid, 'params.user.segments', []);
let appnexusSegments = [];
segments.forEach(segment => {
if (typeof segment.value != 'undefined' && segment.value != null) {
let appnexusSegment = {'id': segment.id, 'value': segment.value};
appnexusSegments.push(appnexusSegment);
if (typeof segment.id != 'undefined' && segment.id != null) {
appnexusSegments.push(parseInt(segment.id));
}
})
bid.params.user.segments = bid.params.user.segments.concat(appnexusSegments);
Expand Down
24 changes: 12 additions & 12 deletions test/spec/modules/haloRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('haloRtdProvider', function() {
id: 'appnexus',
segment: [
{
id: 'apnseg0'
id: '0'
}
]
}
Expand All @@ -43,7 +43,7 @@ describe('haloRtdProvider', function() {
},
params: {
user: {
segments: [{'id': 'apnseg0', 'value': 0}]
segments: [0]
}
}
}
Expand Down Expand Up @@ -82,22 +82,22 @@ describe('haloRtdProvider', function() {
];

const data = {
appnexus: [{id: 'apnseg1', value: 0}, {id: 'apnseg2', value: 2}, {id: 'apnseg3'}],
appnexus: [{id: '1'}, {id: '2'}, {id: '3'}],
generic: [{id: 'seg1'}, {id: 'seg2'}, {id: 'seg3'}]
};

addSegmentData(adUnits, data, config);

expect(adUnits[0].bids[0].fpd.user.data[0].segment[0]).to.have.deep.property('id', 'apnseg0');
expect(adUnits[0].bids[0].fpd.user.data[0].segment[1]).to.have.deep.property('id', 'apnseg1');
expect(adUnits[0].bids[0].fpd.user.data[0].segment[2]).to.have.deep.property('id', 'apnseg2');
expect(adUnits[0].bids[0].fpd.user.data[0].segment[3]).to.have.deep.property('id', 'apnseg3');
expect(adUnits[0].bids[0].params.user).to.have.deep.property('segments', [{'id': 'apnseg0', 'value': 0}, {'id': 'apnseg1', 'value': 0}, {'id': 'apnseg2', 'value': 2}]);
expect(adUnits[0].bids[0].fpd.user.data[0].segment[0]).to.have.deep.property('id', '0');
expect(adUnits[0].bids[0].fpd.user.data[0].segment[1]).to.have.deep.property('id', '1');
expect(adUnits[0].bids[0].fpd.user.data[0].segment[2]).to.have.deep.property('id', '2');
expect(adUnits[0].bids[0].fpd.user.data[0].segment[3]).to.have.deep.property('id', '3');
expect(adUnits[0].bids[0].params.user).to.have.deep.property('segments', [0, 1, 2, 3]);

expect(adUnits[1].bids[0].fpd.user.data[0].segment[0]).to.have.deep.property('id', 'apnseg1');
expect(adUnits[1].bids[0].fpd.user.data[0].segment[1]).to.have.deep.property('id', 'apnseg2');
expect(adUnits[1].bids[0].fpd.user.data[0].segment[2]).to.have.deep.property('id', 'apnseg3');
expect(adUnits[1].bids[0].params.user).to.have.deep.property('segments', [{'id': 'apnseg1', 'value': 0}, {'id': 'apnseg2', 'value': 2}]);
expect(adUnits[1].bids[0].fpd.user.data[0].segment[0]).to.have.deep.property('id', '1');
expect(adUnits[1].bids[0].fpd.user.data[0].segment[1]).to.have.deep.property('id', '2');
expect(adUnits[1].bids[0].fpd.user.data[0].segment[2]).to.have.deep.property('id', '3');
expect(adUnits[1].bids[0].params.user).to.have.deep.property('segments', [1, 2, 3]);

expect(adUnits[1].bids[1].fpd.user.data[0].segment[0]).to.have.deep.property('id', 'seg1');
expect(adUnits[1].bids[1].fpd.user.data[0].segment[1]).to.have.deep.property('id', 'seg2');
Expand Down

0 comments on commit 022bcea

Please sign in to comment.