-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prebid 1.0 Fix issue with video bid validation (#1680)
* Fix issue with video bid validation * Modified tests to stub `auctionManager.getBidsRequested` instead of `getBidRequest` * Move stub to beforeEach hook * Fix lint errors * Add bidRequests param to bid validation
- Loading branch information
1 parent
e5b703e
commit feebc17
Showing
4 changed files
with
65 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,76 @@ | ||
import { isValidVideoBid } from 'src/video'; | ||
const utils = require('src/utils'); | ||
|
||
describe('video.js', () => { | ||
afterEach(() => { | ||
utils.getBidRequest.restore(); | ||
}); | ||
|
||
it('validates valid instream bids', () => { | ||
sinon.stub(utils, 'getBidRequest', () => ({ | ||
bidder: 'appnexusAst', | ||
mediaTypes: { | ||
video: { context: 'instream' }, | ||
}, | ||
})); | ||
|
||
const valid = isValidVideoBid({ | ||
const bid = { | ||
adId: '123abc', | ||
vastUrl: 'http://www.example.com/vastUrl' | ||
}); | ||
|
||
}; | ||
const bidRequests = [{ | ||
bids: [{ | ||
bidId: '123abc', | ||
bidder: 'appnexusAst', | ||
mediaTypes: { | ||
video: { context: 'instream' } | ||
} | ||
}] | ||
}]; | ||
const valid = isValidVideoBid(bid, bidRequests); | ||
expect(valid).to.be(true); | ||
}); | ||
|
||
it('catches invalid instream bids', () => { | ||
sinon.stub(utils, 'getBidRequest', () => ({ | ||
bidder: 'appnexusAst', | ||
mediaTypes: { | ||
video: { context: 'instream' }, | ||
}, | ||
})); | ||
|
||
const valid = isValidVideoBid({}); | ||
|
||
const bid = { | ||
adId: '123abc' | ||
}; | ||
const bidRequests = [{ | ||
bids: [{ | ||
bidId: '123abc', | ||
bidder: 'appnexusAst', | ||
mediaTypes: { | ||
video: { context: 'instream' } | ||
} | ||
}] | ||
}]; | ||
const valid = isValidVideoBid(bid, bidRequests); | ||
expect(valid).to.be(false); | ||
}); | ||
|
||
it('validates valid outstream bids', () => { | ||
sinon.stub(utils, 'getBidRequest', () => ({ | ||
bidder: 'appnexusAst', | ||
mediaTypes: { | ||
video: { context: 'outstream' }, | ||
}, | ||
})); | ||
|
||
const valid = isValidVideoBid({ | ||
const bid = { | ||
adId: '123abc', | ||
renderer: { | ||
url: 'render.url', | ||
render: () => true, | ||
} | ||
}); | ||
|
||
}; | ||
const bidRequests = [{ | ||
bids: [{ | ||
bidId: '123abc', | ||
bidder: 'appnexusAst', | ||
mediaTypes: { | ||
video: { context: 'outstream' } | ||
} | ||
}] | ||
}]; | ||
const valid = isValidVideoBid(bid, bidRequests); | ||
expect(valid).to.be(true); | ||
}); | ||
|
||
it('catches invalid outstream bids', () => { | ||
sinon.stub(utils, 'getBidRequest', () => ({ | ||
bidder: 'appnexusAst', | ||
mediaTypes: { | ||
video: { context: 'outstream' }, | ||
}, | ||
})); | ||
|
||
const valid = isValidVideoBid({}); | ||
|
||
const bid = { | ||
adId: '123abc' | ||
}; | ||
const bidRequests = [{ | ||
bids: [{ | ||
bidId: '123abc', | ||
bidder: 'appnexusAst', | ||
mediaTypes: { | ||
video: { context: 'outstream' } | ||
} | ||
}] | ||
}]; | ||
const valid = isValidVideoBid(bid, bidRequests); | ||
expect(valid).to.be(false); | ||
}); | ||
}); |