-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Aliasbidder fix #1652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aliasbidder fix #1652
Changes from 3 commits
b7ab1c1
57c6167
3d9d2dc
9352eb7
df9a5c0
e9acb26
049a8a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { | |
getAdUnits | ||
} from 'test/fixtures/fixtures'; | ||
import { config as configObj } from 'src/config'; | ||
import { newBidder, registerBidder } from 'src/adapters/bidderFactory'; | ||
|
||
var assert = require('chai').assert; | ||
var expect = require('chai').expect; | ||
|
@@ -1288,6 +1289,18 @@ describe('Unit: Prebid Module', function () { | |
}); | ||
|
||
describe('aliasBidder', () => { | ||
let spec; | ||
const CODE = 'sampleBidder'; | ||
before(() => { | ||
spec = { | ||
code: CODE, | ||
isBidRequestValid: () => {}, | ||
buildRequests: () => {}, | ||
interpretResponse: () => {}, | ||
getUserSyncs: () => {} | ||
}; | ||
}); | ||
|
||
it('should call adaptermanager.aliasBidder', () => { | ||
const aliasBidAdapterSpy = sinon.spy(adaptermanager, 'aliasBidAdapter'); | ||
const bidderCode = 'testcode'; | ||
|
@@ -1306,6 +1319,22 @@ describe('Unit: Prebid Module', function () { | |
assert.ok(logErrorSpy.calledWith(error), 'expected error was logged'); | ||
utils.logError.restore(); | ||
}); | ||
|
||
it('should add alias to registry', () => { | ||
const bidderCode = 'appnexusAst'; | ||
const alias = 'testalias'; | ||
$$PREBID_GLOBAL$$.aliasBidder(bidderCode, alias); | ||
expect(adaptermanager.bidderRegistry).to.have.property(alias); | ||
}); | ||
|
||
it('should add alias to registry when original adapter is using bidderFactory', function() { | ||
const thisSpec = Object.assign(spec, { supportedMediaTypes: ['video'] }); | ||
registerBidder(thisSpec); | ||
const alias = 'aliasBidder'; | ||
$$PREBID_GLOBAL$$.aliasBidder(CODE, alias); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to avoid Prebid-specifics aside... strong unit tests cover the smallest amount of code possible. All your changes are in On a less important note... you could probably write these in |
||
expect(adaptermanager.bidderRegistry).to.have.property(alias); | ||
expect(adaptermanager.videoAdapters).to.include(alias); | ||
}); | ||
}); | ||
|
||
describe('setPriceGranularity', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little buggy.
The
bidderFactory
accepts aspec
, but only returns an object like:So in this code, you're using objects of the shape:
...but
newBIdder
needs a spec. Thetypedef
doesn't havecallBids
, but does require several other things which you're not giving here (interpretResponse
,buildRequests
, etc).So... if
callBids
gets called on an aliased bidder, there'll be all sorts of errors about missing functions.