Skip to content

Commit

Permalink
fix lint for test
Browse files Browse the repository at this point in the history
  • Loading branch information
JulieLorin committed Nov 29, 2022
1 parent 2326ebf commit 8252391
Showing 1 changed file with 64 additions and 62 deletions.
126 changes: 64 additions & 62 deletions test/spec/auctionmanager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1277,78 +1277,80 @@ describe('auctionmanager.js', function () {
});
});

describe('addBidResponse native', function () {
let makeRequestsStub;
let ajaxStub;
let spec;
let auction;
if (FEATURES.NATIVE) {
describe('addBidResponse native', function () {
let makeRequestsStub;
let ajaxStub;
let spec;
let auction;

beforeEach(function () {
makeRequestsStub = sinon.stub(adapterManager, 'makeBidRequests');
ajaxStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(mockAjaxBuilder);
beforeEach(function () {
makeRequestsStub = sinon.stub(adapterManager, 'makeBidRequests');
ajaxStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(mockAjaxBuilder);

const adUnits = [{
code: ADUNIT_CODE,
transactionId: ADUNIT_CODE,
bids: [
{bidder: BIDDER_CODE, params: {placementId: 'id'}},
],
nativeOrtbRequest: ortbNativeRequest.ortb,
mediaTypes: { native: { type: 'image' } }
}];
auction = auctionModule.newAuction({adUnits, adUnitCodes: [ADUNIT_CODE], callback: function() {}, cbTimeout: 3000});
indexAuctions = [auction];
const createAuctionStub = sinon.stub(auctionModule, 'newAuction');
createAuctionStub.returns(auction);
const adUnits = [{
code: ADUNIT_CODE,
transactionId: ADUNIT_CODE,
bids: [
{bidder: BIDDER_CODE, params: {placementId: 'id'}},
],
nativeOrtbRequest: ortbNativeRequest.ortb,
mediaTypes: { native: { type: 'image' } }
}];
auction = auctionModule.newAuction({adUnits, adUnitCodes: [ADUNIT_CODE], callback: function() {}, cbTimeout: 3000});
indexAuctions = [auction];
const createAuctionStub = sinon.stub(auctionModule, 'newAuction');
createAuctionStub.returns(auction);

spec = mockBidder(BIDDER_CODE);
registerBidder(spec);
});
spec = mockBidder(BIDDER_CODE);
registerBidder(spec);
});

afterEach(function () {
ajaxStub.restore();
auctionModule.newAuction.restore();
adapterManager.makeBidRequests.restore();
});
afterEach(function () {
ajaxStub.restore();
auctionModule.newAuction.restore();
adapterManager.makeBidRequests.restore();
});

it('should add legacy fields to native response', function () {
let nativeBid = mockBid();
nativeBid.mediaType = 'native';
nativeBid.native = {
ortb: {
ver: '1.2',
assets: [
{ id: 2, title: { text: 'Sample title' } },
{ id: 4, data: { value: 'Sample body' } },
{ id: 3, data: { value: 'Sample sponsoredBy' } },
{ id: 1, img: { url: 'https://www.example.com/image.png', w: 200, h: 200 } },
{ id: 5, img: { url: 'https://www.example.com/icon.png', w: 32, h: 32 } }
],
link: { url: 'http://www.click.com' },
eventtrackers: [
{ event: 1, method: 1, url: 'http://www.imptracker.com'},
{ event: 1, method: 2, url: 'http://www.jstracker.com/file.js'}
]
it('should add legacy fields to native response', function () {
let nativeBid = mockBid();
nativeBid.mediaType = 'native';
nativeBid.native = {
ortb: {
ver: '1.2',
assets: [
{ id: 2, title: { text: 'Sample title' } },
{ id: 4, data: { value: 'Sample body' } },
{ id: 3, data: { value: 'Sample sponsoredBy' } },
{ id: 1, img: { url: 'https://www.example.com/image.png', w: 200, h: 200 } },
{ id: 5, img: { url: 'https://www.example.com/icon.png', w: 32, h: 32 } }
],
link: { url: 'http://www.click.com' },
eventtrackers: [
{ event: 1, method: 1, url: 'http://www.imptracker.com' },
{ event: 1, method: 2, url: 'http://www.jstracker.com/file.js' }
]
}
}
}

let bidRequest = mockBidRequest(nativeBid, { mediaType: { native: ortbNativeRequest } });
makeRequestsStub.returns([bidRequest]);
let bidRequest = mockBidRequest(nativeBid, { mediaType: { native: ortbNativeRequest } });
makeRequestsStub.returns([bidRequest]);

spec.interpretResponse.returns(nativeBid);
auction.callBids();
spec.interpretResponse.returns(nativeBid);
auction.callBids();

const addedBid = auction.getBidsReceived().pop();
assert.equal(addedBid.native.body, 'Sample body')
assert.equal(addedBid.native.title, 'Sample title')
assert.equal(addedBid.native.sponsoredBy, 'Sample sponsoredBy')
assert.equal(addedBid.native.clickUrl, 'http://www.click.com')
assert.equal(addedBid.native.image, 'https://www.example.com/image.png')
assert.equal(addedBid.native.icon, 'https://www.example.com/icon.png')
assert.equal(addedBid.native.impressionTrackers[0], 'http://www.imptracker.com')
assert.equal(addedBid.native.javascriptTrackers, '<script async src=\"http://www.jstracker.com/file.js\"></script>')
const addedBid = auction.getBidsReceived().pop();
assert.equal(addedBid.native.body, 'Sample body')
assert.equal(addedBid.native.title, 'Sample title')
assert.equal(addedBid.native.sponsoredBy, 'Sample sponsoredBy')
assert.equal(addedBid.native.clickUrl, 'http://www.click.com')
assert.equal(addedBid.native.image, 'https://www.example.com/image.png')
assert.equal(addedBid.native.icon, 'https://www.example.com/icon.png')
assert.equal(addedBid.native.impressionTrackers[0], 'http://www.imptracker.com')
assert.equal(addedBid.native.javascriptTrackers, '<script async src="http://www.jstracker.com/file.js"></script>')
});
});
});
}

describe('getMediaTypeGranularity', function () {
it('video', function () {
Expand Down

0 comments on commit 8252391

Please sign in to comment.