From 812d9388024b6e13267d6a0c9e25ebbd3486935d Mon Sep 17 00:00:00 2001 From: Tomas Roos Date: Thu, 31 Aug 2017 17:00:49 +0200 Subject: [PATCH] Fixed imports and made adform support aliasing (#1518) * Fixed imports and made adform support aliasing * Fix the broken tests * Renamed _adapter * Updated imports --- modules/adformBidAdapter.js | 26 +++++++++++++--------- test/spec/modules/adformBidAdapter_spec.js | 14 ++++++------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/modules/adformBidAdapter.js b/modules/adformBidAdapter.js index 5d1bb98b4eca..69908e708882 100644 --- a/modules/adformBidAdapter.js +++ b/modules/adformBidAdapter.js @@ -1,14 +1,15 @@ -var utils = require('src/utils.js'); -var adloader = require('src/adloader.js'); -var bidmanager = require('src/bidmanager.js'); -var bidfactory = require('src/bidfactory.js'); +var utils = require('src/utils'); +var adloader = require('src/adloader'); +var bidmanager = require('src/bidmanager'); +var bidfactory = require('src/bidfactory'); var STATUSCODES = require('src/constants.json').STATUS; var adaptermanager = require('src/adaptermanager'); +var Adapter = require('src/adapter').default; + +const ADFORM_BIDDER_CODE = 'adform'; function AdformAdapter() { - return { - callBids: _callBids - }; + let baseAdapter = new Adapter(ADFORM_BIDDER_CODE); function _callBids(params) { var bid, _value, _key, i, j, k, l, reqParams; @@ -47,7 +48,7 @@ function AdformAdapter() { $$PREBID_GLOBAL$$[callbackName] = handleCallback(bids); adloader.loadScript(request.join('&')); - } + }; function formRequestUrl(reqData) { var key; @@ -63,7 +64,7 @@ function AdformAdapter() { function handleCallback(bids) { return function handleResponse(adItems) { var bidObject; - var bidder = 'adform'; + var bidder = baseAdapter.getBidderCode(); var adItem; var bid; for (var i = 0, l = adItems.length; i < l; i++) { @@ -160,8 +161,11 @@ function AdformAdapter() { return utftext; } -} -adaptermanager.registerBidAdapter(new AdformAdapter(), 'adform'); + return Object.assign(this, baseAdapter, { + callBids: _callBids + }); +} +adaptermanager.registerBidAdapter(new AdformAdapter(), ADFORM_BIDDER_CODE); module.exports = AdformAdapter; diff --git a/test/spec/modules/adformBidAdapter_spec.js b/test/spec/modules/adformBidAdapter_spec.js index 0d2d1e19b68e..9d77b4faca5b 100644 --- a/test/spec/modules/adformBidAdapter_spec.js +++ b/test/spec/modules/adformBidAdapter_spec.js @@ -1,11 +1,11 @@ import { assert } from 'chai'; -import * as utils from '../../../src/utils'; -import adLoader from '../../../src/adloader'; -import bidManager from '../../../src/bidmanager'; -import adapter from '../../../modules/adformBidAdapter'; +import * as utils from 'src/utils'; +import adLoader from 'src/adloader'; +import bidManager from 'src/bidmanager'; +import AdformAdapter from 'modules/adformBidAdapter'; describe('Adform adapter', () => { - let _adapter, sandbox; + let _adformAdapter, sandbox; describe('request', () => { it('should create callback method on PREBID_GLOBAL', () => { @@ -112,11 +112,11 @@ describe('Adform adapter', () => { beforeEach(() => { var transactionId = 'transactionId'; - _adapter = adapter(); + _adformAdapter = new AdformAdapter(); utils.getUniqueIdentifierStr = () => 'callback'; sandbox = sinon.sandbox.create(); sandbox.stub(adLoader, 'loadScript'); - _adapter.callBids({ + _adformAdapter.callBids({ bids: [ { bidId: 'abc',