1
- import { expect } from 'chai' ;
2
- import { spec , checkVideoPlacement , _getDomainFromURL } from 'modules/pubmaticBidAdapter.js' ;
1
+ import { expect } from 'chai' ;
2
+ import { spec , checkVideoPlacement , _getDomainFromURL , assignDealTier } from 'modules/pubmaticBidAdapter.js' ;
3
3
import * as utils from 'src/utils.js' ;
4
- import { config } from 'src/config.js' ;
4
+ import { config } from 'src/config.js' ;
5
5
import { createEidsArray } from 'modules/userId/eids.js' ;
6
6
import { bidderSettings } from 'src/bidderSettings.js' ;
7
7
const constants = require ( 'src/constants.json' ) ;
@@ -4063,9 +4063,64 @@ describe('PubMatic adapter', function () {
4063
4063
expect ( data . imp [ 0 ] [ 'video' ] [ 'h' ] ) . to . equal ( videoBidRequests [ 0 ] . mediaTypes . video . playerSize [ 1 ] ) ;
4064
4064
expect ( data . imp [ 0 ] [ 'video' ] [ 'battr' ] ) . to . equal ( undefined ) ;
4065
4065
} ) ;
4066
+
4067
+ describe ( 'Assign Deal Tier (i.e. prebidDealPriority)' , function ( ) {
4068
+ let videoSeatBid , request , newBid ;
4069
+ // let data = JSON.parse(request.data);
4070
+ beforeEach ( function ( ) {
4071
+ videoSeatBid = videoBidResponse . body . seatbid [ 0 ] . bid [ 0 ] ;
4072
+ // const adpodValidOutstreamBidRequest = validOutstreamBidRequest.bids[0].mediaTypes.video.context = 'adpod';
4073
+ request = spec . buildRequests ( bidRequests , validOutstreamBidRequest ) ;
4074
+ newBid = {
4075
+ requestId : '47acc48ad47af5'
4076
+ } ;
4077
+ videoSeatBid . ext = videoSeatBid . ext || { } ;
4078
+ videoSeatBid . ext . video = videoSeatBid . ext . video || { } ;
4079
+ // videoBidRequests[0].mediaTypes.video = videoBidRequests[0].mediaTypes.video || {};
4080
+ } ) ;
4081
+
4082
+ it ( 'should not assign video object if deal priority is missing' , function ( ) {
4083
+ assignDealTier ( newBid , videoSeatBid , request ) ;
4084
+ expect ( newBid . video ) . to . equal ( undefined ) ;
4085
+ expect ( newBid . video ) . to . not . exist ;
4086
+ } ) ;
4087
+
4088
+ it ( 'should not assign video object if context is not a adpod' , function ( ) {
4089
+ videoSeatBid . ext . prebiddealpriority = 5 ;
4090
+ assignDealTier ( newBid , videoSeatBid , request ) ;
4091
+ expect ( newBid . video ) . to . equal ( undefined ) ;
4092
+ expect ( newBid . video ) . to . not . exist ;
4093
+ } ) ;
4094
+
4095
+ describe ( 'when video deal tier object is present' , function ( ) {
4096
+ beforeEach ( function ( ) {
4097
+ videoSeatBid . ext . prebiddealpriority = 5 ;
4098
+ request . bidderRequest . bids [ 0 ] . mediaTypes . video = {
4099
+ ...request . bidderRequest . bids [ 0 ] . mediaTypes . video ,
4100
+ context : 'adpod' ,
4101
+ maxduration : 50
4102
+ } ;
4103
+ } ) ;
4104
+
4105
+ it ( 'should set video deal tier object, when maxduration is present in ext' , function ( ) {
4106
+ assignDealTier ( newBid , videoSeatBid , request ) ;
4107
+ expect ( newBid . video . durationSeconds ) . to . equal ( 50 ) ;
4108
+ expect ( newBid . video . context ) . to . equal ( 'adpod' ) ;
4109
+ expect ( newBid . video . dealTier ) . to . equal ( 5 ) ;
4110
+ } ) ;
4111
+
4112
+ it ( 'should set video deal tier object, when duration is present in ext' , function ( ) {
4113
+ videoSeatBid . ext . video . duration = 20 ;
4114
+ assignDealTier ( newBid , videoSeatBid , request ) ;
4115
+ expect ( newBid . video . durationSeconds ) . to . equal ( 20 ) ;
4116
+ expect ( newBid . video . context ) . to . equal ( 'adpod' ) ;
4117
+ expect ( newBid . video . dealTier ) . to . equal ( 5 ) ;
4118
+ } ) ;
4119
+ } ) ;
4120
+ } ) ;
4066
4121
} ) ;
4067
4122
4068
- describe ( 'Marketplace params' , function ( ) {
4123
+ describe ( 'Marketplace params' , function ( ) {
4069
4124
let sandbox , utilsMock , newBidRequests , newBidResponses ;
4070
4125
beforeEach ( ( ) => {
4071
4126
utilsMock = sinon . mock ( utils ) ;
@@ -4082,7 +4137,7 @@ describe('PubMatic adapter', function () {
4082
4137
sandbox . restore ( ) ;
4083
4138
} )
4084
4139
4085
- it ( 'Should add bidder code as groupm for marketplace groupm response' , function ( ) {
4140
+ it ( 'Should add bidder code as groupm for marketplace groupm response ' , function ( ) {
4086
4141
let request = spec . buildRequests ( newBidRequests , {
4087
4142
auctionId : 'new-auction-id'
4088
4143
} ) ;
0 commit comments