From 0799a6402a35bc200b66df37a6e9583188d514e0 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Tue, 16 May 2017 18:32:43 -0700 Subject: [PATCH] Upgrade linters to ESLint with stricter code style (#1111) * Upgraded to ESLint with stricter code style, for both sources and tests * Updated some dependencies and the yarn.lock file --- .eslintrc | 42 + .jscsrc | 11 - .jshintrc | 39 - README.md | 4 +- gulpfile.js | 56 +- package.json | 11 +- src/adaptermanager.js | 30 +- src/adapters/aardvark.js | 202 +- src/adapters/adblade.js | 26 +- src/adapters/adbund.js | 4 +- src/adapters/adbutler.js | 116 +- src/adapters/adequant.js | 22 +- src/adapters/adform.js | 18 +- src/adapters/adkernel.js | 20 +- src/adapters/admedia.js | 38 +- src/adapters/admixer.js | 5 +- src/adapters/analytics/AnalyticsAdapter.js | 8 +- src/adapters/analytics/appnexus.js | 9 +- src/adapters/analytics/example2.js | 10 +- src/adapters/analytics/ga.js | 36 +- src/adapters/analytics/libraries/example.js | 6 +- src/adapters/analytics/libraries/example2.js | 6 +- src/adapters/analytics/pubwiseanalytics.js | 3 +- src/adapters/analytics/pulsepoint.js | 9 +- src/adapters/analytics/roxot.js | 10 +- .../analytics/sharethrough_analytics.js | 90 +- src/adapters/aol.js | 14 +- src/adapters/appnexus.js | 76 +- src/adapters/appnexusAst.js | 16 +- src/adapters/audienceNetwork.js | 10 +- src/adapters/beachfront.js | 19 +- src/adapters/bidfluence.js | 10 +- src/adapters/brightcom.js | 25 +- src/adapters/centro.js | 49 +- src/adapters/conversant.js | 28 +- src/adapters/criteo.js | 18 +- src/adapters/districtmDMX.js | 23 +- src/adapters/fidelity.js | 29 +- src/adapters/getintent.js | 4 +- src/adapters/gumgum.js | 34 +- src/adapters/hiromedia.js | 138 +- src/adapters/huddledmasses.js | 32 +- src/adapters/indexExchange.js | 105 +- src/adapters/inneractive.js | 102 +- src/adapters/innity.js | 11 +- src/adapters/jcm.js | 19 +- src/adapters/komoona.js | 5 +- src/adapters/lifestreet.js | 8 +- src/adapters/mantis.js | 7 +- src/adapters/memeglobal.js | 3 +- src/adapters/nginad.js | 27 +- src/adapters/openx.js | 16 +- src/adapters/piximedia.js | 35 +- src/adapters/prebidServer.js | 76 +- src/adapters/pubgears.js | 25 +- src/adapters/pubmatic.js | 13 +- src/adapters/pulsepoint.js | 10 +- src/adapters/pulsepointLite.js | 10 +- src/adapters/quantcast.js | 61 +- src/adapters/rhythmone.js | 267 +- src/adapters/roxot.js | 4 +- src/adapters/rubicon.js | 145 +- src/adapters/sekindoUM.js | 32 +- src/adapters/serverbid.js | 70 +- src/adapters/sharethrough.js | 13 +- src/adapters/smartadserver.js | 34 +- src/adapters/smartyads.js | 33 +- src/adapters/sonobi.js | 52 +- src/adapters/sovrn.js | 40 +- src/adapters/springserve.js | 24 +- src/adapters/stickyadstv.js | 251 +- src/adapters/tapsense.js | 33 +- src/adapters/thoughtleadr.js | 26 +- src/adapters/trion.js | 22 +- src/adapters/triplelift.js | 12 +- src/adapters/twenga.js | 44 +- src/adapters/underdogmedia.js | 16 +- src/adapters/vertamedia.js | 5 +- src/adapters/vertoz.js | 45 +- src/adapters/wideorbit.js | 24 +- src/adapters/widespace.js | 24 +- src/adapters/xhb.js | 111 +- src/adapters/yieldbot.js | 4 - src/adloader.js | 15 +- src/adserver.js | 20 +- src/ajax.js | 12 +- src/bidfactory.js | 3 +- src/bidmanager.js | 54 +- src/cookie.js | 18 +- src/cpmBucketManager.js | 62 +- src/events.js | 15 +- src/polyfill.js | 2 +- src/prebid.js | 68 +- src/secure-creatives.js | 3 +- src/sizeMapping.js | 17 +- src/targeting.js | 25 +- src/url.js | 8 +- src/utils.js | 58 +- test/.eslintrc | 50 + test/fixtures/fixtures.js | 1562 +++++----- test/helpers/index_adapter_utils.js | 548 ++-- test/spec/adUnits_spec.js | 62 +- test/spec/adapters/aardvark_spec.js | 174 +- test/spec/adapters/adblade_spec.js | 38 +- test/spec/adapters/adbund_spec.js | 126 +- test/spec/adapters/adbutler_spec.js | 1048 ++++--- test/spec/adapters/adform_spec.js | 9 +- test/spec/adapters/adkernel_spec.js | 119 +- test/spec/adapters/admixer_spec.js | 4 +- test/spec/adapters/adsupply_spec.js | 697 +++-- .../analytics/pubwiseanalytics_spec.js | 2 - .../adapters/analytics/roxot_analytic_spec.js | 3 - test/spec/adapters/aol_spec.js | 232 +- test/spec/adapters/appnexusAst_spec.js | 144 +- test/spec/adapters/appnexus_spec.js | 4 +- test/spec/adapters/atomx_spec.js | 8 +- test/spec/adapters/audienceNetwork_spec.js | 11 +- test/spec/adapters/beachfront_spec.js | 186 +- test/spec/adapters/bidfluence_spec.js | 115 +- test/spec/adapters/centro_spec.js | 428 ++- test/spec/adapters/conversant_spec.js | 69 +- test/spec/adapters/criteo_spec.js | 119 +- test/spec/adapters/districtm_spec.js | 424 ++- test/spec/adapters/fidelity_spec.js | 38 +- test/spec/adapters/getintent_spec.js | 79 +- test/spec/adapters/gumgum_spec.js | 31 +- test/spec/adapters/hiromedia_spec.js | 114 +- test/spec/adapters/huddledmasses_spec.js | 175 +- .../adapters/indexExchange_request_spec.js | 666 +++-- .../adapters/indexExchange_response_spec.js | 2065 +++++++------ .../adapters/indexExchange_validation_spec.js | 2605 ++++++++--------- test/spec/adapters/inneractive_spec.js | 116 +- test/spec/adapters/innity_spec.js | 309 +- test/spec/adapters/jcm_spec.js | 469 ++- test/spec/adapters/komoona_spec.js | 72 +- test/spec/adapters/lifestreet_spec.js | 6 +- test/spec/adapters/mantis_spec.js | 290 +- test/spec/adapters/memeglobal_spec.js | 83 +- test/spec/adapters/openx_spec.js | 117 +- test/spec/adapters/piximedia_spec.js | 793 +++-- test/spec/adapters/prebidServer_spec.js | 85 +- test/spec/adapters/pubgears_spec.js | 573 ++-- test/spec/adapters/pulsepointLite_spec.js | 36 +- test/spec/adapters/pulsepoint_spec.js | 38 +- test/spec/adapters/quantcast_spec.js | 81 +- test/spec/adapters/rhythmone_spec.js | 157 +- test/spec/adapters/roxot_spec.js | 27 +- test/spec/adapters/rubicon_spec.js | 109 +- test/spec/adapters/sekindoUM_spec.js | 142 +- test/spec/adapters/serverbid_spec.js | 94 +- test/spec/adapters/sharethrough_spec.js | 63 +- test/spec/adapters/smartadserver_spec.js | 144 +- test/spec/adapters/smartyads_spec.js | 177 +- test/spec/adapters/sonobi_spec.js | 127 +- test/spec/adapters/sovrn_spec.js | 28 +- test/spec/adapters/stickyadstv_spec.js | 408 ++- test/spec/adapters/tapsense_spec.js | 145 +- test/spec/adapters/thoughtleadr_spec.js | 75 +- test/spec/adapters/trion_spec.js | 70 +- test/spec/adapters/triplelift_spec.js | 56 +- test/spec/adapters/twenga_spec.js | 219 +- test/spec/adapters/underdogmedia_spec.js | 85 +- test/spec/adapters/vertamedia_spec.js | 206 +- test/spec/adapters/vertoz_spec.js | 245 +- test/spec/adapters/wideorbit_spec.js | 548 ++-- test/spec/adapters/widespace_spec.js | 127 +- test/spec/adapters/yieldbot_spec.js | 4 +- test/spec/aliasBidder_spec.js | 5 - test/spec/api_spec.js | 4 - test/spec/bidmanager_spec.js | 161 +- test/spec/cookie_spec.js | 4 +- test/spec/cpmBucketManager_spec.js | 52 +- test/spec/e2e/common/globals.js | 8 +- test/spec/e2e/common/utils.js | 4 +- test/spec/e2e/custom-assertions/first.js | 9 +- .../e2e/custom-reporter/pbjs-html-reporter.js | 24 +- .../dom-group/allbidders_dom_spec.js | 42 +- test/spec/e2e/testcase1/dom-group/dom_spec.js | 14 +- .../pbjsapi-group/adservertargeting_spec.js | 33 +- .../pbjsapi-group/getbidresponses_spec.js | 18 +- test/spec/ga_spec.js | 2 - test/spec/integration/faker/fixtures.js | 2 +- test/spec/loaders/adapterLoader_spec.js | 14 +- test/spec/loaders/getAdapters_spec.js | 12 - test/spec/sizeMapping_spec.js | 62 +- .../analytics/AnalyticsAdapter_spec.js | 225 +- .../analytics/sharethrough_analytics_spec.js | 81 +- test/spec/unit/pbjs_api_spec.js | 620 ++-- test/spec/url_spec.js | 6 - test/spec/utils_spec.js | 65 +- yarn.lock | 1402 ++++----- 191 files changed, 11863 insertions(+), 12885 deletions(-) create mode 100644 .eslintrc delete mode 100644 .jscsrc delete mode 100644 .jshintrc create mode 100644 test/.eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000000..cd5dd0cb267 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,42 @@ +{ + "env": { + "browser": true, + "commonjs": true + }, + "extends": "standard", + "globals": { + "$$PREBID_GLOBAL$$": false + }, + "parserOptions": { + "sourceType": "module" + }, + "rules": { + "comma-dangle": "off", + "semi": "off", + "space-before-function-paren": "off", + + // Exceptions below this line are temporary, so that eslint can be added into the CI process. + // Violations of these styles should be fixed, and the exceptions removed over time. + // + // See Issue #1111. + "brace-style": "off", + "camelcase": "off", + "eqeqeq": "off", + "import/first": "off", + "no-control-regex": "off", + "no-mixed-operators": "off", + "no-multiple-empty-lines": "off", + "no-redeclare": "off", + "no-return-assign": "off", + "no-throw-literal": "off", + "no-undef": "off", + "no-unused-vars": "off", + "no-use-before-define": "off", + "no-useless-call": "off", + "no-useless-escape": "off", + "one-var": "off", + "standard/no-callback-literal": "off", + "standard/object-curly-even-spacing": "off", + "valid-typeof": "off" + } +} diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index a74740263ff..00000000000 --- a/.jscsrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "maxErrors": 1000, - "requireTrailingComma": null, - "requireCamelCaseOrUpperCaseIdentifiers": null, - "requireSpacesInAnonymousFunctionExpression": null, - "validateIndentation": 2, - "disallowSpacesInFunctionDeclaration": { - "beforeOpeningRoundBrace": true - }, - "disallowNewlineBeforeBlockStatements": true -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index a51c32f4328..00000000000 --- a/.jshintrc +++ /dev/null @@ -1,39 +0,0 @@ -{ - "bitwise": false, - "browser": true, - "curly": false, - "devel": true, - "eqeqeq": true, - "freeze": true, - "immed": true, - "maxdepth": 5, - "newcap": true, - "noarg": true, - "node": true, - "notypeof": true, - "esnext": true, - "trailing": true, - "undef": true, - "unused": true, - "strict": false, - "scripturl": true, - "globals": { - "before": true, - "after": true, - "exports": true, - "$$PREBID_GLOBAL$$": true, - "pbjsTestOnly": true, - "assert": false, - "expect": false, - "dump": false, - "describe": false, - "it": false, - "xit": false, - "pkg": false, - "sinon": false, - "beforeEach": false, - "afterEach": false, - "JSON": true, - "Criteo": true - } -} diff --git a/README.md b/README.md index e9e95f68161..2aa136065f6 100644 --- a/README.md +++ b/README.md @@ -158,9 +158,9 @@ Please **do NOT load Prebid.js inside your adapter**. If you do this, we will re ### Code Quality -Code quality is defined by `.jscs` and `.jshint` files and errors are reported in the terminal. +Code quality is defined by `.eslintrc` and errors are reported in the terminal. -If you are contributing code, you should configure your editor with the provided `.jscs` and `.jshint` settings. +If you are contributing code, you should [configure your editor](http://eslint.org/docs/user-guide/integrations#editors) with the provided `.eslintrc` settings. ### Unit Testing with Karma diff --git a/gulpfile.js b/gulpfile.js index d343068d165..8450283c704 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,12 +1,9 @@ -'use strict'; - -var argv = require('yargs').argv; var gulp = require('gulp'); +var argv = require('yargs').argv; var gutil = require('gulp-util'); var connect = require('gulp-connect'); var webpack = require('webpack-stream'); var uglify = require('gulp-uglify'); -var jshint = require('gulp-jshint'); var clean = require('gulp-clean'); var karma = require('gulp-karma'); var mocha = require('gulp-mocha'); @@ -16,12 +13,12 @@ var helpers = require('./gulpHelpers'); var del = require('del'); var gulpJsdoc2md = require('gulp-jsdoc-to-markdown'); var concat = require('gulp-concat'); -var jscs = require('gulp-jscs'); var header = require('gulp-header'); var zip = require('gulp-zip'); var replace = require('gulp-replace'); var shell = require('gulp-shell'); var optimizejs = require('gulp-optimize-js'); +const eslint = require('gulp-eslint'); var CI_MODE = process.env.NODE_ENV === 'ci'; var prebid = require('./package.json'); @@ -32,13 +29,13 @@ var analyticsDirectory = '../analytics'; var port = 9999; // Tasks -gulp.task('default', ['clean', 'quality', 'webpack']); +gulp.task('default', ['clean', 'lint', 'webpack']); -gulp.task('serve', ['clean', 'quality', 'devpack', 'webpack', 'watch', 'test']); +gulp.task('serve', ['clean', 'lint', 'devpack', 'webpack', 'watch', 'test']); -gulp.task('serve-nw', ['clean', 'quality', 'devpack', 'webpack', 'watch', 'e2etest']); +gulp.task('serve-nw', ['clean', 'lint', 'devpack', 'webpack', 'watch', 'e2etest']); -gulp.task('run-tests', ['clean', 'quality', 'webpack', 'test', 'mocha']); +gulp.task('run-tests', ['clean', 'lint', 'webpack', 'test', 'mocha']); gulp.task('build', ['webpack']); @@ -59,7 +56,7 @@ gulp.task('devpack', function () { .pipe(connect.reload()); }); -gulp.task('webpack', function () { +gulp.task('webpack', ['clean'], function () { // change output filename if argument --tag given if (argv.tag && argv.tag.length) { @@ -80,7 +77,7 @@ gulp.task('webpack', function () { }); //zip up for release -gulp.task('zip', ['jscs', 'clean', 'webpack'], function () { +gulp.task('zip', ['clean', 'webpack'], function () { return gulp.src(['build/dist/*', 'integrationExamples/gpt/*']) .pipe(zip(packageNameVersion + '.zip')) .pipe(gulp.dest('./')); @@ -89,7 +86,7 @@ gulp.task('zip', ['jscs', 'clean', 'webpack'], function () { // Karma Continuous Testing // Pass your browsers by using --browsers=chrome,firefox,ie9 // Run CI by passing --watch -gulp.task('test', function () { +gulp.task('test', ['clean'], function () { var defaultBrowsers = CI_MODE ? ['PhantomJS'] : ['Chrome']; var browserArgs = helpers.parseBrowserArgs(argv).map(helpers.toCapitalCase); @@ -137,7 +134,16 @@ gulp.task('test', function () { })); }); -gulp.task('mocha', ['webpack'], function() { +// +// Making this task depend on lint is a bit of a hack. The `run-tests` command is the entrypoint for the CI process, +// and it needs to run all these tasks together. However, the "lint" and "mocha" tasks explode when used in parallel, +// resulting in some mysterious "ShellJS: internal error TypeError: Cannot read property 'isFile' of undefined" +// errors. +// +// Gulp doesn't support serial dependencies (until gulp 4.0... which is most likely never coming out)... so we have +// to trick it by declaring 'lint' as a dependency here. See https://github.com/gulpjs/gulp/blob/master/docs/recipes/running-tasks-in-series.md +// +gulp.task('mocha', ['webpack', 'lint'], function() { return gulp.src(['test/spec/loaders/**/*.js'], { read: false }) .pipe(mocha({ reporter: 'spec', @@ -175,11 +181,11 @@ gulp.task('watch', function () { 'src/**/*.js', 'test/spec/**/*.js', '!test/spec/loaders/**/*.js' - ], ['quality', 'webpack', 'devpack', 'test']); + ], ['lint', 'webpack', 'devpack', 'test']); gulp.watch([ 'loaders/**/*.js', 'test/spec/loaders/**/*.js' - ], ['quality', 'mocha']); + ], ['lint', 'mocha']); gulp.watch(['integrationExamples/gpt/*.html'], ['test']); connect.server({ https: argv.https, @@ -189,21 +195,11 @@ gulp.task('watch', function () { }); }); -gulp.task('quality', ['hint', 'jscs']); - -gulp.task('hint', function () { - return gulp.src('src/**/*.js') - .pipe(jshint('.jshintrc')) - .pipe(jshint.reporter('jshint-stylish')) - .pipe(jshint.reporter('fail')); -}); - -gulp.task('jscs', function () { - return gulp.src('src/**/*.js') - .pipe(jscs({ - configPath: '.jscsrc' - })) - .pipe(jscs.reporter()); +gulp.task('lint', () => { + return gulp.src(['src/**/*.js', 'test/**/*.js']) + .pipe(eslint()) + .pipe(eslint.format('stylish')) + .pipe(eslint.failAfterError()); }); gulp.task('clean-docs', function () { diff --git a/package.json b/package.json index b81bdb97ebb..d40838752a9 100644 --- a/package.json +++ b/package.json @@ -31,17 +31,21 @@ "del": "^2.2.0", "ejs": "^2.5.1", "es5-shim": "^4.5.2", + "eslint-config-standard": "^10.2.0", + "eslint-plugin-import": "^2.2.0", + "eslint-plugin-node": "^4.2.2", + "eslint-plugin-promise": "^3.5.0", + "eslint-plugin-standard": "^3.0.1", "faker": "^3.1.0", "fs.extra": "^1.3.2", "gulp": "^3.8.7", "gulp-babel": "^6.1.2", - "gulp-clean": "^0.3.1", + "gulp-clean": "^0.3.2", "gulp-concat": "^2.6.0", "gulp-connect": "^2.0.6", + "gulp-eslint": "^3.0.1", "gulp-header": "^1.7.1", - "gulp-jscs": "^3.0.2", "gulp-jsdoc-to-markdown": "^1.2.1", - "gulp-jshint": "^1.8.4", "gulp-karma": "0.0.4", "gulp-mocha": "^2.2.0", "gulp-optimize-js": "^1.1.0", @@ -54,7 +58,6 @@ "gulp-zip": "^3.1.0", "istanbul": "^0.3.2", "istanbul-instrumenter-loader": "^0.1.2", - "jshint-stylish": "^2.2.1", "json-loader": "^0.5.1", "karma": "^0.13.2", "karma-babel-preprocessor": "^6.0.1", diff --git a/src/adaptermanager.js b/src/adaptermanager.js index 27c5ddca30b..1082b1441c4 100644 --- a/src/adaptermanager.js +++ b/src/adaptermanager.js @@ -11,7 +11,7 @@ import { BaseAdapter } from './adapters/baseAdapter'; var _bidderRegistry = {}; exports.bidderRegistry = _bidderRegistry; -//create s2s settings objectType_function +// create s2s settings objectType_function let _s2sConfig = {}; var _analyticsRegistry = {}; let _bidderSequence = null; @@ -31,7 +31,7 @@ function getBids({bidderCode, requestId, bidderRequestId, adUnits}) { return Object.assign({}, bid, { placementCode: adUnit.code, mediaType: adUnit.mediaType, - transactionId : adUnit.transactionId, + transactionId: adUnit.transactionId, sizes: sizes, bidId: bid.bid_id || utils.getUniqueIdentifierStr(), bidderRequestId, @@ -57,17 +57,17 @@ exports.callBids = ({adUnits, cbTimeout}) => { bidderCodes = shuffle(bidderCodes); } - if(_s2sConfig.enabled) { - //these are called on the s2s adapter + if (_s2sConfig.enabled) { + // these are called on the s2s adapter let adaptersServerSide = _s2sConfig.bidders; - //don't call these client side + // don't call these client side bidderCodes = bidderCodes.filter((elm) => { return !adaptersServerSide.includes(elm); }); let adUnitsCopy = utils.cloneJson(adUnits); - //filter out client side bids + // filter out client side bids adUnitsCopy.forEach((adUnit) => { if (adUnit.sizeMapping) { adUnit.sizes = mapSizes(adUnit); @@ -90,17 +90,17 @@ exports.callBids = ({adUnits, cbTimeout}) => { requestId, bidderRequestId, tid, - bids: getBids({bidderCode, requestId, bidderRequestId, 'adUnits' : adUnitsCopy}), + bids: getBids({bidderCode, requestId, bidderRequestId, 'adUnits': adUnitsCopy}), start: new Date().getTime(), auctionStart: auctionStart, timeout: _s2sConfig.timeout }; - //Pushing server side bidder + // Pushing server side bidder $$PREBID_GLOBAL$$._bidsRequested.push(bidderRequest); }); - let s2sBidRequest = {tid, 'ad_units' : adUnitsCopy}; - let s2sAdapter = _bidderRegistry[_s2sConfig.adapter]; //jshint ignore:line + let s2sBidRequest = {tid, 'ad_units': adUnitsCopy}; + let s2sAdapter = _bidderRegistry[_s2sConfig.adapter]; // jshint ignore:line utils.logMessage(`CALLING S2S HEADER BIDDERS ==== ${adaptersServerSide.join(',')}`); s2sAdapter.setConfig(_s2sConfig); s2sAdapter.callBids(s2sBidRequest); @@ -138,8 +138,8 @@ function transformHeightWidth(adUnit) { sizes.forEach(size => { let heightWidth = size.split('x'); let sizeObj = { - 'w' : parseInt(heightWidth[0]), - 'h' : parseInt(heightWidth[1]) + 'w': parseInt(heightWidth[0]), + 'h': parseInt(heightWidth[1]) }; sizesObj.push(sizeObj); }); @@ -148,14 +148,11 @@ function transformHeightWidth(adUnit) { exports.registerBidAdapter = function (bidAdaptor, bidderCode) { if (bidAdaptor && bidderCode) { - if (typeof bidAdaptor.callBids === CONSTANTS.objectType_function) { _bidderRegistry[bidderCode] = bidAdaptor; - } else { utils.logError('Bidder adaptor error for bidder code: ' + bidderCode + 'bidder must implement a callBids() function'); } - } else { utils.logError('bidAdaptor or bidderCode not specified'); } @@ -173,7 +170,7 @@ exports.aliasBidAdapter = function (bidderCode, alias) { try { let newAdapter = null; if (bidAdaptor instanceof BaseAdapter) { - //newAdapter = new bidAdaptor.constructor(alias); + // newAdapter = new bidAdaptor.constructor(alias); utils.logError(bidderCode + ' bidder does not currently support aliasing.', 'adaptermanager.aliasBidAdapter'); } else { newAdapter = bidAdaptor.createNew(); @@ -191,7 +188,6 @@ exports.aliasBidAdapter = function (bidderCode, alias) { exports.registerAnalyticsAdapter = function ({adapter, code}) { if (adapter && code) { - if (typeof adapter.enableAnalytics === CONSTANTS.objectType_function) { adapter.code = code; _analyticsRegistry[code] = adapter; diff --git a/src/adapters/aardvark.js b/src/adapters/aardvark.js index b89a8266ddd..e8a3cc5ab38 100644 --- a/src/adapters/aardvark.js +++ b/src/adapters/aardvark.js @@ -4,141 +4,123 @@ * or for additional integration support please contact sales@rtk.io */ -var utils = require('../utils.js'); +var utils = require('../utils.js'); var bidfactory = require('../bidfactory.js'); var bidmanager = require('../bidmanager.js'); -var adloader = require('../adloader.js'); -var adapter = require('./adapter.js'); -var constants = require('../constants.json'); +var adloader = require('../adloader.js'); +var adapter = require('./adapter.js'); +var constants = require('../constants.json'); var AARDVARK_CALLBACK_NAME = 'aardvarkResponse', - AARDVARK_REQUESTS_MAP = 'aardvarkRequests', - AARDVARK_BIDDER_CODE = 'aardvark', - DEFAULT_REFERRER = 'thor.rtk.io', - DEFAULT_ENDPOINT = 'thor.rtk.io', + AARDVARK_REQUESTS_MAP = 'aardvarkRequests', + AARDVARK_BIDDER_CODE = 'aardvark', + DEFAULT_REFERRER = 'thor.rtk.io', + DEFAULT_ENDPOINT = 'thor.rtk.io', - endpoint = DEFAULT_ENDPOINT, + endpoint = DEFAULT_ENDPOINT, - requestBids = function(bidderCode, callbackName, bidReqs) { - var ref = utils.getTopWindowLocation(), - ai = '', - scs = [], - bidIds = []; + requestBids = function(bidderCode, callbackName, bidReqs) { + var ref = utils.getTopWindowLocation(), + ai = '', + scs = [], + bidIds = []; - ref = ref ? ref.host : DEFAULT_REFERRER; + ref = ref ? ref.host : DEFAULT_REFERRER; - for (var i = 0, l = bidReqs.length, bid, _ai, _sc, _endpoint; i < l; i += 1) { - bid = bidReqs[i]; - _ai = utils.getBidIdParameter('ai', bid.params); - _sc = utils.getBidIdParameter('sc', bid.params); - if (!_ai || !_ai.length || !_sc || !_sc.length) - continue; + for (var i = 0, l = bidReqs.length, bid, _ai, _sc, _endpoint; i < l; i += 1) { + bid = bidReqs[i]; + _ai = utils.getBidIdParameter('ai', bid.params); + _sc = utils.getBidIdParameter('sc', bid.params); + if (!_ai || !_ai.length || !_sc || !_sc.length) { continue; } - _endpoint = utils.getBidIdParameter('host', bid.params); - if (_endpoint) - endpoint = _endpoint; + _endpoint = utils.getBidIdParameter('host', bid.params); + if (_endpoint) { endpoint = _endpoint; } - if (!ai.length) - ai = _ai; - if (_sc) - scs.push(_sc); + if (!ai.length) { ai = _ai; } + if (_sc) { scs.push(_sc); } - bidIds.push(_sc + "=" + bid.bidId); + bidIds.push(_sc + '=' + bid.bidId); // Create the bidIdsMap for easier mapping back later - $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode][bid.bidId] = bid; - } - - if (!ai.length || !scs.length) - return utils.logWarn("Bad bid request params given for adapter $" + bidderCode + " (" + AARDVARK_BIDDER_CODE + ")"); - - adloader.loadScript([ - '//' + endpoint + '/', ai, '/', scs.join('_'), - '/aardvark/?jsonp=$$PREBID_GLOBAL$$.', callbackName, - '&rtkreferer=', ref, '&', bidIds.join('&') - ].join('')); - }, - - - - registerBidResponse = function(bidderCode, rawBidResponse) { - if (rawBidResponse.error) - return utils.logWarn("Aardvark bid received with an error, ignoring... [" + rawBidResponse.error + "]"); - - if (!rawBidResponse.cid) - return utils.logWarn("Aardvark bid received without a callback id, ignoring..."); - - var bidObj = $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode][rawBidResponse.cid]; - if (!bidObj) - return utils.logWarn("Aardvark request not found: " + rawBidResponse.cid); - - if (bidObj.params.sc !== rawBidResponse.id) - return utils.logWarn("Aardvark bid received with a non matching shortcode " + rawBidResponse.id + " instead of " + bidObj.params.sc); - - var bidResponse = bidfactory.createBid(constants.STATUS.GOOD, bidObj); - bidResponse.bidderCode = bidObj.bidder; - bidResponse.cpm = rawBidResponse.cpm; - bidResponse.ad = rawBidResponse.adm + utils.createTrackPixelHtml(decodeURIComponent(rawBidResponse.nurl)); - bidResponse.width = bidObj.sizes[0][0]; - bidResponse.height = bidObj.sizes[0][1]; - - bidmanager.addBidResponse(bidObj.placementCode, bidResponse); - $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode][rawBidResponse.cid].responded = true; - }, - - - - registerAardvarkCallback = function(bidderCode, callbackName) { - $$PREBID_GLOBAL$$[callbackName] = function(rtkResponseObj) { - - rtkResponseObj.forEach(function(bidResponse) { - registerBidResponse(bidderCode, bidResponse); - }); - - for (var bidRequestId in $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode]) - if ($$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode].hasOwnProperty(bidRequestId)) { - var bidRequest = $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode][bidRequestId]; - if (!bidRequest.responded) { - var bidResponse = bidfactory.createBid(constants.STATUS.NO_BID, bidRequest); - bidResponse.bidderCode = bidRequest.bidder; - bidmanager.addBidResponse(bidRequest.placementCode, bidResponse); - } + $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode][bid.bidId] = bid; + } + + if (!ai.length || !scs.length) { return utils.logWarn('Bad bid request params given for adapter $' + bidderCode + ' (' + AARDVARK_BIDDER_CODE + ')'); } + + adloader.loadScript([ + '//' + endpoint + '/', ai, '/', scs.join('_'), + '/aardvark/?jsonp=$$PREBID_GLOBAL$$.', callbackName, + '&rtkreferer=', ref, '&', bidIds.join('&') + ].join('')); + }, + + registerBidResponse = function(bidderCode, rawBidResponse) { + if (rawBidResponse.error) { return utils.logWarn('Aardvark bid received with an error, ignoring... [' + rawBidResponse.error + ']'); } + + if (!rawBidResponse.cid) { return utils.logWarn('Aardvark bid received without a callback id, ignoring...'); } + + var bidObj = $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode][rawBidResponse.cid]; + if (!bidObj) { return utils.logWarn('Aardvark request not found: ' + rawBidResponse.cid); } + + if (bidObj.params.sc !== rawBidResponse.id) { return utils.logWarn('Aardvark bid received with a non matching shortcode ' + rawBidResponse.id + ' instead of ' + bidObj.params.sc); } + + var bidResponse = bidfactory.createBid(constants.STATUS.GOOD, bidObj); + bidResponse.bidderCode = bidObj.bidder; + bidResponse.cpm = rawBidResponse.cpm; + bidResponse.ad = rawBidResponse.adm + utils.createTrackPixelHtml(decodeURIComponent(rawBidResponse.nurl)); + bidResponse.width = bidObj.sizes[0][0]; + bidResponse.height = bidObj.sizes[0][1]; + + bidmanager.addBidResponse(bidObj.placementCode, bidResponse); + $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode][rawBidResponse.cid].responded = true; + }, + + registerAardvarkCallback = function(bidderCode, callbackName) { + $$PREBID_GLOBAL$$[callbackName] = function(rtkResponseObj) { + rtkResponseObj.forEach(function(bidResponse) { + registerBidResponse(bidderCode, bidResponse); + }); + + for (var bidRequestId in $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode]) { + if ($$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode].hasOwnProperty(bidRequestId)) { + var bidRequest = $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode][bidRequestId]; + if (!bidRequest.responded) { + var bidResponse = bidfactory.createBid(constants.STATUS.NO_BID, bidRequest); + bidResponse.bidderCode = bidRequest.bidder; + bidmanager.addBidResponse(bidRequest.placementCode, bidResponse); } - }; - }, - - - - AardvarkAdapter = function() { - var baseAdapter = adapter.createNew(AARDVARK_BIDDER_CODE); + } + } + }; + }, - $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP] = $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP] || {}; + AardvarkAdapter = function() { + var baseAdapter = adapter.createNew(AARDVARK_BIDDER_CODE); - baseAdapter.callBids = function (params) { - var bidderCode = baseAdapter.getBidderCode(), - callbackName = AARDVARK_CALLBACK_NAME; + $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP] = $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP] || {}; - if (bidderCode !== AARDVARK_BIDDER_CODE) - callbackName = [AARDVARK_CALLBACK_NAME, bidderCode].join('_'); + baseAdapter.callBids = function (params) { + var bidderCode = baseAdapter.getBidderCode(), + callbackName = AARDVARK_CALLBACK_NAME; - $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode] = {}; + if (bidderCode !== AARDVARK_BIDDER_CODE) { callbackName = [AARDVARK_CALLBACK_NAME, bidderCode].join('_'); } - registerAardvarkCallback(bidderCode, callbackName); + $$PREBID_GLOBAL$$[AARDVARK_REQUESTS_MAP][bidderCode] = {}; - return requestBids(bidderCode, callbackName, params.bids || []); - }; + registerAardvarkCallback(bidderCode, callbackName); - return { - callBids: baseAdapter.callBids, - setBidderCode: baseAdapter.setBidderCode, - createNew: exports.createNew - }; + return requestBids(bidderCode, callbackName, params.bids || []); }; - + return { + callBids: baseAdapter.callBids, + setBidderCode: baseAdapter.setBidderCode, + createNew: exports.createNew + }; + }; exports.createNew = function() { return new AardvarkAdapter(); }; -module.exports = AardvarkAdapter; \ No newline at end of file +module.exports = AardvarkAdapter; diff --git a/src/adapters/adblade.js b/src/adapters/adblade.js index 9c1d6ff3764..9e781561dc3 100644 --- a/src/adapters/adblade.js +++ b/src/adapters/adblade.js @@ -12,17 +12,17 @@ var adloader = require('../adloader'); var AdbladeAdapter = function AdbladeAdapter() { 'use strict'; - const BIDDER_CODE = 'adblade'; - const BASE_URI = '//rtb.adblade.com/prebidjs/bid?'; + const BIDDER_CODE = 'adblade'; + const BASE_URI = '//rtb.adblade.com/prebidjs/bid?'; const DEFAULT_BID_FLOOR = 0.0000000001; function _callBids(params) { - var bids = params.bids || [], - referrer = utils.getTopWindowUrl(), - loc = utils.getTopWindowLocation(), - domain = loc.hostname, - partnerId = 0, - bidRequests = {}; + var bids = params.bids || [], + referrer = utils.getTopWindowUrl(), + loc = utils.getTopWindowLocation(), + domain = loc.hostname, + partnerId = 0, + bidRequests = {}; if (bids.length > 0) { partnerId = '' + bids[0].params.partnerId; @@ -87,11 +87,11 @@ var AdbladeAdapter = function AdbladeAdapter() { } $$PREBID_GLOBAL$$.adbladeResponse = function (response) { - var auctionIdRe = /\$(%7B|\{)AUCTION_ID(%7D|\})/gi, - auctionPriceRe = /\$(%7B|\{)AUCTION_PRICE(%7D|\})/gi, - clickUrlRe = /\$(%7B|\{)CLICK_URL(%7D|\})/gi; + var auctionIdRe = /\$(%7B|\{)AUCTION_ID(%7D|\})/gi, + auctionPriceRe = /\$(%7B|\{)AUCTION_PRICE(%7D|\})/gi, + clickUrlRe = /\$(%7B|\{)CLICK_URL(%7D|\})/gi; - if (typeof(response) === 'undefined' || !response.hasOwnProperty('seatbid') || utils.isEmpty(response.seatbid)) { + if (typeof (response) === 'undefined' || !response.hasOwnProperty('seatbid') || utils.isEmpty(response.seatbid)) { // handle empty bids var bidsRequested = $$PREBID_GLOBAL$$._bidsRequested.find(bidSet => bidSet.bidderCode === BIDDER_CODE).bids; if (bidsRequested.length > 0) { @@ -106,7 +106,7 @@ var AdbladeAdapter = function AdbladeAdapter() { utils._each(response.seatbid, function(seatbid) { utils._each(seatbid.bid, function(seatbidBid) { var bidRequest = utils.getBidRequest(seatbidBid.impid), - ad = seatbidBid.adm + utils.createTrackPixelHtml(seatbidBid.nurl); + ad = seatbidBid.adm + utils.createTrackPixelHtml(seatbidBid.nurl); ad = ad.replace(auctionIdRe, seatbidBid.impid); ad = ad.replace(clickUrlRe, ''); diff --git a/src/adapters/adbund.js b/src/adapters/adbund.js index 74809aa5e04..19630ce7007 100644 --- a/src/adapters/adbund.js +++ b/src/adapters/adbund.js @@ -10,7 +10,7 @@ var adBundAdapter = function adBundAdapter() { 'http://us-east-engine.adbund.xyz/prebid/ad/get', 'http://us-west-engine.adbund.xyz/prebid/ad/get' ]; - //Based on the time zone to select the interface to the server + // Based on the time zone to select the interface to the server var bidAPI = bidAPIs[timezone < 0 ? 0 : 1]; function _stringify(param) { @@ -63,4 +63,4 @@ var adBundAdapter = function adBundAdapter() { }; }; -module.exports = adBundAdapter; \ No newline at end of file +module.exports = adBundAdapter; diff --git a/src/adapters/adbutler.js b/src/adapters/adbutler.js index a0005e89e4f..428f7b3831a 100644 --- a/src/adapters/adbutler.js +++ b/src/adapters/adbutler.js @@ -11,138 +11,126 @@ var bidmanager = require('../bidmanager.js'); var bidfactory = require('../bidfactory.js'); var AdButlerAdapter = function AdButlerAdapter() { - function _callBids(params) { - var bids = params.bids || [], - callbackData = {}, - zoneCount = {}, - pageID = Math.floor(Math.random() * 10e6); + callbackData = {}, + zoneCount = {}, + pageID = Math.floor(Math.random() * 10e6); - //Build and send bid requests + // Build and send bid requests for (var i = 0; i < bids.length; i++) { var bid = bids[i], zoneID = utils.getBidIdParameter('zoneID', bid.params), - callbackID; - - if(!(zoneID in zoneCount)){ + callbackID; + + if (!(zoneID in zoneCount)) { zoneCount[zoneID] = 0; } - - //build callbackID to get placementCode later - callbackID = zoneID + '_' +zoneCount[zoneID]; + + // build callbackID to get placementCode later + callbackID = zoneID + '_' + zoneCount[zoneID]; callbackData[callbackID] = {}; callbackData[callbackID].bidId = bid.bidId; - - var adRequest = buildRequest(bid,zoneCount[zoneID],pageID); + + var adRequest = buildRequest(bid, zoneCount[zoneID], pageID); zoneCount[zoneID]++; adloader.loadScript(adRequest); } - - //Define callback function for bid responses - $$PREBID_GLOBAL$$.adbutlerCB = function(aBResponseObject){ - + + // Define callback function for bid responses + $$PREBID_GLOBAL$$.adbutlerCB = function(aBResponseObject) { var bidResponse = {}, - callbackID = aBResponseObject.zone_id+'_'+aBResponseObject.place, + callbackID = aBResponseObject.zone_id + '_' + aBResponseObject.place, width = parseInt(aBResponseObject.width), height = parseInt(aBResponseObject.height), isCorrectSize = false, isCorrectCPM = true, - CPM,minCPM,maxCPM, + CPM, minCPM, maxCPM, bidObj = callbackData[callbackID] ? utils.getBidRequest(callbackData[callbackID].bidId) : null; - + if (bidObj) { - - if(aBResponseObject.status === 'SUCCESS'){ + if (aBResponseObject.status === 'SUCCESS') { CPM = aBResponseObject.cpm; - minCPM = utils.getBidIdParameter('minCPM',bidObj.params); - maxCPM = utils.getBidIdParameter('maxCPM',bidObj.params); + minCPM = utils.getBidIdParameter('minCPM', bidObj.params); + maxCPM = utils.getBidIdParameter('maxCPM', bidObj.params); - //Ensure response CPM is within the given bounds - if(minCPM !== '' && CPM < parseFloat(minCPM)){ + // Ensure response CPM is within the given bounds + if (minCPM !== '' && CPM < parseFloat(minCPM)) { isCorrectCPM = false; } - if(maxCPM !== '' && CPM > parseFloat(maxCPM)){ + if (maxCPM !== '' && CPM > parseFloat(maxCPM)) { isCorrectCPM = false; } - //Ensure that response ad matches one of the placement sizes. - utils._each(bidObj.sizes,function(size){ - if(width === size[0] && height === size[1]){ + // Ensure that response ad matches one of the placement sizes. + utils._each(bidObj.sizes, function(size) { + if (width === size[0] && height === size[1]) { isCorrectSize = true; } }); - if(isCorrectCPM && isCorrectSize){ - - bidResponse = bidfactory.createBid(1,bidObj); + if (isCorrectCPM && isCorrectSize) { + bidResponse = bidfactory.createBid(1, bidObj); bidResponse.bidderCode = 'adbutler'; bidResponse.cpm = CPM; bidResponse.width = width; bidResponse.height = height; bidResponse.ad = aBResponseObject.ad_code; bidResponse.ad += addTrackingPixels(aBResponseObject.tracking_pixels); - } else { - - bidResponse = bidfactory.createBid(2,bidObj); + bidResponse = bidfactory.createBid(2, bidObj); bidResponse.bidderCode = 'adbutler'; - } } else { - - bidResponse = bidfactory.createBid(2,bidObj); + bidResponse = bidfactory.createBid(2, bidObj); bidResponse.bidderCode = 'adbutler'; + } - } - bidmanager.addBidResponse(bidObj.placementCode, bidResponse); - } }; } - - function buildRequest(bid,adIndex,pageID){ + + function buildRequest(bid, adIndex, pageID) { var accountID = utils.getBidIdParameter('accountID', bid.params), - zoneID = utils.getBidIdParameter('zoneID', bid.params), - keyword = utils.getBidIdParameter('keyword', bid.params), - domain = utils.getBidIdParameter('domain', bid.params); + zoneID = utils.getBidIdParameter('zoneID', bid.params), + keyword = utils.getBidIdParameter('keyword', bid.params), + domain = utils.getBidIdParameter('domain', bid.params); - if(typeof domain === 'undefined' || domain.length === 0){ + if (typeof domain === 'undefined' || domain.length === 0) { domain = 'servedbyadbutler.com'; } var requestURI = location.protocol + '//' + domain + '/adserve/;type=hbr;'; - requestURI += 'ID='+encodeURIComponent(accountID)+';'; - requestURI += 'setID='+encodeURIComponent(zoneID)+';'; - requestURI += 'pid='+encodeURIComponent(pageID)+';'; - requestURI += 'place='+encodeURIComponent(adIndex)+';'; - - //append the keyword for targeting if one was passed in - if(keyword !== ''){ - requestURI +='kw='+encodeURIComponent(keyword)+';'; + requestURI += 'ID=' + encodeURIComponent(accountID) + ';'; + requestURI += 'setID=' + encodeURIComponent(zoneID) + ';'; + requestURI += 'pid=' + encodeURIComponent(pageID) + ';'; + requestURI += 'place=' + encodeURIComponent(adIndex) + ';'; + + // append the keyword for targeting if one was passed in + if (keyword !== '') { + requestURI += 'kw=' + encodeURIComponent(keyword) + ';'; } requestURI += 'jsonpfunc=$$PREBID_GLOBAL$$.adbutlerCB;'; requestURI += 'click=CLICK_MACRO_PLACEHOLDER'; - + return requestURI; } - - function addTrackingPixels(trackingPixels){ + + function addTrackingPixels(trackingPixels) { var trackingPixelMarkup = ''; - utils._each(trackingPixels,function(pixelURL){ - + utils._each(trackingPixels, function(pixelURL) { var trackingPixel = ''; - + trackingPixelMarkup += trackingPixel; }); return trackingPixelMarkup; } - + // Export the callBids function, so that prebid.js can execute this function // when the page asks to send out bid requests. return { diff --git a/src/adapters/adequant.js b/src/adapters/adequant.js index 25bd77b72cb..f756b7e9aaa 100644 --- a/src/adapters/adequant.js +++ b/src/adapters/adequant.js @@ -21,30 +21,30 @@ module.exports = function() { var br_params = bid_request.params || {}; placements[bid_request.placementCode] = true; - publisher_id = br_params.publisher_id.toString() || publisher_id; - var bidfloor = br_params.bidfloor || 0.01; - cats = br_params.cats || cats; - if (typeof(cats) === utils.objectType_string) { cats = cats.split(' '); } + publisher_id = br_params.publisher_id.toString() || publisher_id; + var bidfloor = br_params.bidfloor || 0.01; + cats = br_params.cats || cats; + if (typeof (cats) === utils.objectType_string) { cats = cats.split(' '); } var br_sizes = utils.parseSizesInput(bid_request.sizes); for (var j = 0; j < br_sizes.length; j++) { - sizes.push(br_sizes[j]+'_'+bidfloor); + sizes.push(br_sizes[j] + '_' + bidfloor); replies.push(bid_request.placementCode); } } // send out 1 bid request for all bids - if (publisher_id) { req_url.push('a='+publisher_id); } - if (cats) { req_url.push('c='+cats.join('+')); } - if (sizes) { req_url.push('s='+sizes.join('+')); } + if (publisher_id) { req_url.push('a=' + publisher_id); } + if (cats) { req_url.push('c=' + cats.join('+')); } + if (sizes) { req_url.push('s=' + sizes.join('+')); } - adloader.loadScript(req_url_base+req_url.join('&'), function() { process_bids(replies, placements); }); + adloader.loadScript(req_url_base + req_url.join('&'), function() { process_bids(replies, placements); }); } function process_bids(replies, placements) { var placement_code, bid, adequant_creatives = window.adequant_creatives; if (adequant_creatives && adequant_creatives.seatbid) { - for (var i=0; i { if (!validateBidParams(bid.params)) { utils.logError(`Incorrect configuration for adkernel bidder: ${bid.params}`); @@ -160,7 +160,7 @@ const AdKernelAdapter = function AdKernelAdapter() { dispatcher.addImp(bid); } }); - //process bids grouped into bidrequests + // process bids grouped into bidrequests dispatcher.dispatch((bid, imp, bidResp) => { let adUnitId = bid.placementCode; if (bidResp) { @@ -217,15 +217,15 @@ const AdKernelAdapter = function AdKernelAdapter() { var location = utils.getTopWindowLocation(); return { 'domain': location.hostname, - 'page' : location.href.split('?')[0] + 'page': location.href.split('?')[0] }; } return { callBids: baseAdapter.callBids, setBidderCode: baseAdapter.setBidderCode, - getBidderCode : baseAdapter.getBidderCode, - createNew : AdKernelAdapter.createNew + getBidderCode: baseAdapter.getBidderCode, + createNew: AdKernelAdapter.createNew }; }; diff --git a/src/adapters/admedia.js b/src/adapters/admedia.js index 18c17c2c179..7fb81868cfd 100644 --- a/src/adapters/admedia.js +++ b/src/adapters/admedia.js @@ -10,9 +10,8 @@ var CONSTANTS = require('../constants.json'); * */ var AdmediaAdapter = function AdmediaAdapter() { - - function _callBids(params){ - var bids, bidderUrl = (window.location.protocol) + "//b.admedia.com/banner/prebid/bidder/?"; + function _callBids(params) { + var bids, bidderUrl = (window.location.protocol) + '//b.admedia.com/banner/prebid/bidder/?'; bids = params.bids || []; for (var i = 0; i < bids.length; i++) { var request_obj = {}; @@ -20,18 +19,17 @@ var AdmediaAdapter = function AdmediaAdapter() { if (bid.params.aid) { request_obj.aid = bid.params.aid; - } - else{ - utils.logError('required param aid is missing', "admedia"); + } else { + utils.logError('required param aid is missing', 'admedia'); continue; } - //optional page_url macro + // optional page_url macro if (bid.params.page_url) { request_obj.page_url = bid.params.page_url; } - //if set, return a test ad for all aids + // if set, return a test ad for all aids if (bid.params.test_ad === 1) { request_obj.test_ad = 1; } @@ -39,21 +37,20 @@ var AdmediaAdapter = function AdmediaAdapter() { var parsedSizes = utils.parseSizesInput(bid.sizes); var parsedSizesLength = parsedSizes.length; if (parsedSizesLength > 0) { - //first value should be "size" + // first value should be "size" request_obj.size = parsedSizes[0]; if (parsedSizesLength > 1) { - //any subsequent values should be "promo_sizes" + // any subsequent values should be "promo_sizes" var promo_sizes = []; for (var j = 1; j < parsedSizesLength; j++) { promo_sizes.push(parsedSizes[j]); } - request_obj.promo_sizes = promo_sizes.join(","); - + request_obj.promo_sizes = promo_sizes.join(','); } } - //detect urls + // detect urls request_obj.siteDomain = window.location.host; request_obj.sitePage = window.location.href; request_obj.siteRef = document.referrer; @@ -61,16 +58,16 @@ var AdmediaAdapter = function AdmediaAdapter() { request_obj.callbackId = bid.bidId; - var endpoint = bidderUrl+utils.parseQueryStringParameters(request_obj); + var endpoint = bidderUrl + utils.parseQueryStringParameters(request_obj); - //utils.logMessage('Admedia request built: ' + endpoint); + // utils.logMessage('Admedia request built: ' + endpoint); adloader.loadScript(endpoint); } } - //expose the callback to global object - $$PREBID_GLOBAL$$.admediaHandler = function(response){ + // expose the callback to global object + $$PREBID_GLOBAL$$.admediaHandler = function(response) { var bidObject = {}; var callback_id = response.callback_id; var placementCode = ''; @@ -79,25 +76,22 @@ var AdmediaAdapter = function AdmediaAdapter() { placementCode = bidObj.placementCode; } - if(bidObj && response.cpm>0 && !!response.ad){ + if (bidObj && response.cpm > 0 && !!response.ad) { bidObject = bidfactory.createBid(CONSTANTS.STATUS.GOOD); bidObject.bidderCode = bidObj.bidder; bidObject.cpm = parseFloat(response.cpm); bidObject.ad = response.ad; bidObject.width = response.width; bidObject.height = response.height; - } - else{ + } else { bidObject = bidfactory.createBid(CONSTANTS.STATUS.NO_BID); bidObject.bidderCode = bidObj.bidder; utils.logMessage('No prebid response from Admedia for placement code ' + placementCode); } bidmanager.addBidResponse(placementCode, bidObject); - }; - // Export the callBids function, so that prebid.js can execute this function // when the page asks to send out bid requests. return { diff --git a/src/adapters/admixer.js b/src/adapters/admixer.js index 2aed4994083..944aed276ce 100644 --- a/src/adapters/admixer.js +++ b/src/adapters/admixer.js @@ -22,8 +22,7 @@ var AdmixerAdapter = function AdmixerAdapter() { }; if (params.zone) { _requestBid(invUrl, params); - } - else { + } else { var bidObject = bidfactory.createBid(2); bidObject.bidderCode = 'admixer'; bidmanager.addBidResponse(params.callback_uid, bidObject); @@ -65,4 +64,4 @@ var AdmixerAdapter = function AdmixerAdapter() { }; }; -module.exports = AdmixerAdapter; \ No newline at end of file +module.exports = AdmixerAdapter; diff --git a/src/adapters/analytics/AnalyticsAdapter.js b/src/adapters/analytics/AnalyticsAdapter.js index 2c177621047..34357ecb1d1 100644 --- a/src/adapters/analytics/AnalyticsAdapter.js +++ b/src/adapters/analytics/AnalyticsAdapter.js @@ -83,7 +83,7 @@ export default function AnalyticsAdapter({ url, analyticsType, global, handler } if (_sampled) { - //first send all events fired before enableAnalytics called + // first send all events fired before enableAnalytics called events.getEvents().forEach(event => { if (!event) { return; @@ -98,11 +98,11 @@ export default function AnalyticsAdapter({ url, analyticsType, global, handler } } }); - //Next register event listeners to send data immediately + // Next register event listeners to send data immediately _handlers = { [BID_REQUESTED]: args => this.enqueue({ eventType: BID_REQUESTED, args }), - [BID_RESPONSE]: args => this.enqueue({ eventType: BID_RESPONSE, args }), + [BID_RESPONSE]: args => this.enqueue({ eventType: BID_RESPONSE, args }), [BID_TIMEOUT]: args => this.enqueue({ eventType: BID_TIMEOUT, args }), [BID_WON]: args => this.enqueue({ eventType: BID_WON, args }), [BID_ADJUSTMENT]: args => this.enqueue({ eventType: BID_ADJUSTMENT, args }), @@ -139,7 +139,7 @@ export default function AnalyticsAdapter({ url, analyticsType, global, handler } _queue[i](); } - //override push to execute the command immediately from now on + // override push to execute the command immediately from now on _queue.push = function (fn) { fn(); }; diff --git a/src/adapters/analytics/appnexus.js b/src/adapters/analytics/appnexus.js index 972fee986ff..2c862ba16c1 100644 --- a/src/adapters/analytics/appnexus.js +++ b/src/adapters/analytics/appnexus.js @@ -5,8 +5,7 @@ import adapter from 'AnalyticsAdapter'; export default adapter({ - global: 'AppNexusPrebidAnalytics', - handler: 'on', - analyticsType: 'bundle' - }); - + global: 'AppNexusPrebidAnalytics', + handler: 'on', + analyticsType: 'bundle' +}); diff --git a/src/adapters/analytics/example2.js b/src/adapters/analytics/example2.js index b9586b5c59a..b55a02d4cb6 100644 --- a/src/adapters/analytics/example2.js +++ b/src/adapters/analytics/example2.js @@ -17,8 +17,8 @@ export default Object.assign(adapter( ), { // Override AnalyticsAdapter functions by supplying custom methods - track({ eventType, args }) { - console.log('track function override for Example2 Analytics'); - ajax(url, (result) => console.log('Analytics Endpoint Example2: result = ' + result), JSON.stringify({ eventType, args })); - } -}); + track({ eventType, args }) { + console.log('track function override for Example2 Analytics'); + ajax(url, (result) => console.log('Analytics Endpoint Example2: result = ' + result), JSON.stringify({ eventType, args })); + } + }); diff --git a/src/adapters/analytics/ga.js b/src/adapters/analytics/ga.js index e17a4832c07..13b852427fa 100644 --- a/src/adapters/analytics/ga.js +++ b/src/adapters/analytics/ga.js @@ -28,10 +28,9 @@ var _sampled = true; * @return {[type]} [description] */ exports.enableAnalytics = function ({ provider, options }) { - _gaGlobal = provider || 'ga'; _trackerSend = options && options.trackerName ? options.trackerName + '.send' : 'send'; - _sampled = typeof options === "undefined" || typeof options.sampling === "undefined" || + _sampled = typeof options === 'undefined' || typeof options.sampling === 'undefined' || Math.random() < parseFloat(options.sampling); if (options && typeof options.global !== 'undefined') { @@ -43,13 +42,13 @@ exports.enableAnalytics = function ({ provider, options }) { var bid = null; - if(_sampled) { - //first send all events fired before enableAnalytics called + if (_sampled) { + // first send all events fired before enableAnalytics called var existingEvents = events.getEvents(); utils._each(existingEvents, function (eventObj) { - if (typeof eventObj !== "object") { + if (typeof eventObj !== 'object') { return; } var args = eventObj.args; @@ -58,10 +57,9 @@ exports.enableAnalytics = function ({ provider, options }) { bid = args; sendBidRequestToGa(bid); } else if (eventObj.eventType === BID_RESPONSE) { - //bid is 2nd args + // bid is 2nd args bid = args; sendBidResponseToGa(bid); - } else if (eventObj.eventType === BID_TIMEOUT) { const bidderArray = args; sendBidTimeouts(bidderArray); @@ -71,30 +69,29 @@ exports.enableAnalytics = function ({ provider, options }) { } }); - //Next register event listeners to send data immediately + // Next register event listeners to send data immediately - //bidRequests + // bidRequests events.on(BID_REQUESTED, function (bidRequestObj) { sendBidRequestToGa(bidRequestObj); }); - //bidResponses + // bidResponses events.on(BID_RESPONSE, function (bid) { sendBidResponseToGa(bid); }); - //bidTimeouts + // bidTimeouts events.on(BID_TIMEOUT, function (bidderArray) { sendBidTimeouts(bidderArray); }); - //wins + // wins events.on(BID_WON, function (bid) { sendBidWonToGa(bid); }); - } else { - utils.logMessage("Prebid.js google analytics disabled by sampling"); + utils.logMessage('Prebid.js google analytics disabled by sampling'); } // finally set this function to return log message, prevents multiple adapter listeners @@ -112,17 +109,16 @@ exports.getTrackerSend = function getTrackerSend() { */ function checkAnalytics() { if (_enableCheck && typeof window[_gaGlobal] === 'function') { - for (var i = 0; i < _analyticsQueue.length; i++) { _analyticsQueue[i].call(); } - //override push to execute the command immediately from now on + // override push to execute the command immediately from now on _analyticsQueue.push = function (fn) { fn.call(); }; - //turn check into NOOP + // turn check into NOOP _enableCheck = false; } @@ -201,12 +197,11 @@ function sendBidRequestToGa(bid) { }); } - //check the queue + // check the queue checkAnalytics(); } function sendBidResponseToGa(bid) { - if (bid && bid.bidderCode) { _analyticsQueue.push(function () { var cpmCents = convertToCents(bid.cpm); @@ -231,12 +226,11 @@ function sendBidResponseToGa(bid) { }); } - //check the queue + // check the queue checkAnalytics(); } function sendBidTimeouts(timedOutBidders) { - _analyticsQueue.push(function () { utils._each(timedOutBidders, function (bidderCode) { _eventCount++; diff --git a/src/adapters/analytics/libraries/example.js b/src/adapters/analytics/libraries/example.js index e9daf12a5a9..55ef2b8ca45 100644 --- a/src/adapters/analytics/libraries/example.js +++ b/src/adapters/analytics/libraries/example.js @@ -6,9 +6,9 @@ window.ExampleAnalyticsGlobalObject = function(hander, type, data) { window[window.ExampleAnalyticsGlobalObject] = function() {}; -//var utils = require('utils'); -//var events = require('events'); -//var pbjsHandlers = require('prebid-event-handlers'); +// var utils = require('utils'); +// var events = require('events'); +// var pbjsHandlers = require('prebid-event-handlers'); var utils = { errorless: function(fn) { return fn; } }; var events = { init: function() { return arguments; } }; diff --git a/src/adapters/analytics/libraries/example2.js b/src/adapters/analytics/libraries/example2.js index 8cf81bf72aa..913f21177d0 100644 --- a/src/adapters/analytics/libraries/example2.js +++ b/src/adapters/analytics/libraries/example2.js @@ -6,9 +6,9 @@ window.ExampleAnalyticsGlobalObject2 = function(hander, type, data) { window[window.ExampleAnalyticsGlobalObject2] = function() {}; -//var utils = require('utils'); -//var events = require('events'); -//var pbjsHandlers = require('prebid-event-handlers'); +// var utils = require('utils'); +// var events = require('events'); +// var pbjsHandlers = require('prebid-event-handlers'); var utils = { errorless: function(fn) { return fn; } }; var events = { init: function() { return arguments; } }; diff --git a/src/adapters/analytics/pubwiseanalytics.js b/src/adapters/analytics/pubwiseanalytics.js index d77ab379fa5..5a2cb348f3b 100644 --- a/src/adapters/analytics/pubwiseanalytics.js +++ b/src/adapters/analytics/pubwiseanalytics.js @@ -42,4 +42,5 @@ let pubwiseAnalytics = Object.assign(adapter( ); } }); -export default pubwiseAnalytics; \ No newline at end of file +export default pubwiseAnalytics; + diff --git a/src/adapters/analytics/pulsepoint.js b/src/adapters/analytics/pulsepoint.js index 28f4e7f1c78..f334c0f042f 100644 --- a/src/adapters/analytics/pulsepoint.js +++ b/src/adapters/analytics/pulsepoint.js @@ -5,8 +5,7 @@ import adapter from 'AnalyticsAdapter'; export default adapter({ - global: 'PulsePointPrebidAnalytics', - handler: 'on', - analyticsType: 'bundle' - }); - + global: 'PulsePointPrebidAnalytics', + handler: 'on', + analyticsType: 'bundle' +}); diff --git a/src/adapters/analytics/roxot.js b/src/adapters/analytics/roxot.js index 7668d0ba050..e74aee712cd 100644 --- a/src/adapters/analytics/roxot.js +++ b/src/adapters/analytics/roxot.js @@ -1,6 +1,6 @@ -import {ajax} from "src/ajax"; -import adapter from "AnalyticsAdapter"; -import CONSTANTS from "src/constants.json"; +import {ajax} from 'src/ajax'; +import adapter from 'AnalyticsAdapter'; +import CONSTANTS from 'src/constants.json'; const utils = require('../../utils'); @@ -62,7 +62,7 @@ let roxotAdapter = Object.assign(adapter({url, analyticsType}), let info = Object.assign({}, args); if (info && info.ad) { - info.ad = ""; + info.ad = ''; } if (eventType === auctionInitConst) { @@ -71,7 +71,7 @@ let roxotAdapter = Object.assign(adapter({url, analyticsType}), } if ((eventType === bidWonConst) && auctionStatus === 'not_started') { - buildBidWon(eventType,info); + buildBidWon(eventType, info); send(eventType, bidWon, 'bidWon'); return; } diff --git a/src/adapters/analytics/sharethrough_analytics.js b/src/adapters/analytics/sharethrough_analytics.js index 6eadcbcf60c..a7c17cc525f 100644 --- a/src/adapters/analytics/sharethrough_analytics.js +++ b/src/adapters/analytics/sharethrough_analytics.js @@ -3,8 +3,8 @@ const utils = require('../../utils'); const emptyUrl = ''; const analyticsType = 'endpoint'; -const STR_BIDDER_CODE = "sharethrough"; -const STR_VERSION = "0.1.0"; +const STR_BIDDER_CODE = 'sharethrough'; +const STR_VERSION = '0.1.0'; export default Object.assign(adapter( { @@ -13,51 +13,51 @@ export default Object.assign(adapter( } ), { - STR_BEACON_HOST: document.location.protocol + "//b.sharethrough.com/butler?", - placementCodeSet: {}, - - track({ eventType, args }) { - if(eventType === 'bidRequested' && args.bidderCode === 'sharethrough') { - var bids = args.bids; - var keys = Object.keys(bids); - for(var i = 0; i < keys.length; i++) { - this.placementCodeSet[bids[keys[i]].placementCode] = args.bids[keys[i]]; + STR_BEACON_HOST: document.location.protocol + '//b.sharethrough.com/butler?', + placementCodeSet: {}, + + track({ eventType, args }) { + if (eventType === 'bidRequested' && args.bidderCode === 'sharethrough') { + var bids = args.bids; + var keys = Object.keys(bids); + for (var i = 0; i < keys.length; i++) { + this.placementCodeSet[bids[keys[i]].placementCode] = args.bids[keys[i]]; + } } - } - if(eventType === 'bidWon') { - this.bidWon(args); - } - }, + if (eventType === 'bidWon') { + this.bidWon(args); + } + }, - bidWon(args) { - const curBidderCode = args.bidderCode; + bidWon(args) { + const curBidderCode = args.bidderCode; - if(curBidderCode !== STR_BIDDER_CODE && (args.adUnitCode in this.placementCodeSet)) { - let strBid = this.placementCodeSet[args.adUnitCode]; - this.fireLoseBeacon(curBidderCode, args.cpm, strBid.adserverRequestId, "headerBidLose"); + if (curBidderCode !== STR_BIDDER_CODE && (args.adUnitCode in this.placementCodeSet)) { + let strBid = this.placementCodeSet[args.adUnitCode]; + this.fireLoseBeacon(curBidderCode, args.cpm, strBid.adserverRequestId, 'headerBidLose'); + } + }, + + fireLoseBeacon(winningBidderCode, winningCPM, arid, type) { + let loseBeaconUrl = this.STR_BEACON_HOST; + loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, 'winnerBidderCode', winningBidderCode); + loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, 'winnerCpm', winningCPM); + loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, 'arid', arid); + loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, 'type', type); + loseBeaconUrl = this.appendEnvFields(loseBeaconUrl); + + this.fireBeacon(loseBeaconUrl); + }, + appendEnvFields(url) { + url = utils.tryAppendQueryString(url, 'hbVersion', '$prebid.version$'); + url = utils.tryAppendQueryString(url, 'strVersion', STR_VERSION); + url = utils.tryAppendQueryString(url, 'hbSource', 'prebid'); + + return url; + }, + fireBeacon(theUrl) { + const img = new Image(); + img.src = theUrl; } - }, - - fireLoseBeacon(winningBidderCode, winningCPM, arid, type) { - let loseBeaconUrl = this.STR_BEACON_HOST; - loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, "winnerBidderCode", winningBidderCode); - loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, "winnerCpm", winningCPM); - loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, "arid", arid); - loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, "type", type); - loseBeaconUrl = this.appendEnvFields(loseBeaconUrl); - - this.fireBeacon(loseBeaconUrl); - }, - appendEnvFields(url) { - url = utils.tryAppendQueryString(url, 'hbVersion', '$prebid.version$'); - url = utils.tryAppendQueryString(url, 'strVersion', STR_VERSION); - url = utils.tryAppendQueryString(url, 'hbSource', 'prebid'); - - return url; - }, - fireBeacon(theUrl) { - const img = new Image(); - img.src = theUrl; - } -}); + }); diff --git a/src/adapters/aol.js b/src/adapters/aol.js index d0b6c702bbf..ee7a60e9b80 100644 --- a/src/adapters/aol.js +++ b/src/adapters/aol.js @@ -5,7 +5,6 @@ const bidmanager = require('../bidmanager.js'); const constants = require('../constants.json'); const AolAdapter = function AolAdapter() { - let showCpmAdjustmentWarning = true; const pubapiTemplate = template`${'protocol'}://${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'}${'bidfloor'};misc=${'misc'}`; const nexageBaseApiTemplate = template`${'protocol'}://${'host'}/bidRequest?`; @@ -33,12 +32,12 @@ const AolAdapter = function AolAdapter() { return fn(); }; - if (document.readyState === "complete") { + if (document.readyState === 'complete') { return idempotentFn(); } - document.addEventListener("DOMContentLoaded", idempotentFn, false); - window.addEventListener("load", idempotentFn, false); + document.addEventListener('DOMContentLoaded', idempotentFn, false); + window.addEventListener('load', idempotentFn, false); }; })(); @@ -144,8 +143,8 @@ const AolAdapter = function AolAdapter() { pageid: params.pageId || 0, sizeid: params.sizeId || 0, alias: params.alias || utils.getUniqueIdentifierStr(), - bidfloor: (typeof params.bidFloor !== 'undefined') ? - `;bidfloor=${params.bidFloor.toString()}` : '', + bidfloor: (typeof params.bidFloor !== 'undefined') + ? `;bidfloor=${params.bidFloor.toString()}` : '', misc: new Date().getTime() // cache busting }); } @@ -242,7 +241,7 @@ const AolAdapter = function AolAdapter() { let isNexageRequestPost = _isNexageRequestPost(bid); if (bid.params.placement && bid.params.network) { apiUrl = _buildMarketplaceUrl(bid); - } else if(bid.params.dcn && bid.params.pos || isNexageRequestPost) { + } else if (bid.params.dcn && bid.params.pos || isNexageRequestPost) { apiUrl = _buildNexageApiUrl(bid); if (isNexageRequestPost) { data = bid.params; @@ -282,7 +281,6 @@ const AolAdapter = function AolAdapter() { } _addBidResponse(bid, response); - }, data, options); } }); diff --git a/src/adapters/appnexus.js b/src/adapters/appnexus.js index 4dc1a368cbc..0dea42daf41 100644 --- a/src/adapters/appnexus.js +++ b/src/adapters/appnexus.js @@ -13,31 +13,30 @@ AppNexusAdapter = function AppNexusAdapter() { var usersync = false; baseAdapter.callBids = function (params) { - //var bidCode = baseAdapter.getBidderCode(); + // var bidCode = baseAdapter.getBidderCode(); var anArr = params.bids; - //var bidsCount = anArr.length; + // var bidsCount = anArr.length; - //set expected bids count for callback execution - //bidmanager.setExpectedBidsCount(bidCode, bidsCount); + // set expected bids count for callback execution + // bidmanager.setExpectedBidsCount(bidCode, bidsCount); for (var i = 0; i < anArr.length; i++) { var bidRequest = anArr[i]; var callbackId = bidRequest.bidId; adloader.loadScript(buildJPTCall(bidRequest, callbackId)); - //store a reference to the bidRequest from the callback id - //bidmanager.pbCallbackMap[callbackId] = bidRequest; + // store a reference to the bidRequest from the callback id + // bidmanager.pbCallbackMap[callbackId] = bidRequest; } }; function buildJPTCall(bid, callbackId) { - - //determine tag params + // determine tag params var placementId = utils.getBidIdParameter('placementId', bid.params); - //memberId will be deprecated, use member instead + // memberId will be deprecated, use member instead var memberId = utils.getBidIdParameter('memberId', bid.params); var member = utils.getBidIdParameter('member', bid.params); var inventoryCode = utils.getBidIdParameter('invCode', bid.params); @@ -45,7 +44,7 @@ AppNexusAdapter = function AppNexusAdapter() { var referrer = utils.getBidIdParameter('referrer', bid.params); var altReferrer = utils.getBidIdParameter('alt_referrer', bid.params); - //build our base tag, based on if we are http or https + // build our base tag, based on if we are http or https var jptCall = 'http' + (document.location.protocol === 'https:' ? 's://secure.adnxs.com/jpt?' : '://ib.adnxs.com/jpt?'); @@ -63,23 +62,23 @@ AppNexusAdapter = function AppNexusAdapter() { jptCall = utils.tryAppendQueryString(jptCall, 'code', inventoryCode); jptCall = utils.tryAppendQueryString(jptCall, 'traffic_source_code', (utils.getBidIdParameter('trafficSourceCode', bid.params))); - //sizes takes a bit more logic + // sizes takes a bit more logic var sizeQueryString = ''; var parsedSizes = utils.parseSizesInput(bid.sizes); - //combine string into proper querystring for impbus + // combine string into proper querystring for impbus var parsedSizesLength = parsedSizes.length; if (parsedSizesLength > 0) { - //first value should be "size" + // first value should be "size" sizeQueryString = 'size=' + parsedSizes[0]; if (parsedSizesLength > 1) { - //any subsequent values should be "promo_sizes" + // any subsequent values should be "promo_sizes" sizeQueryString += '&promo_sizes='; for (var j = 1; j < parsedSizesLength; j++) { sizeQueryString += parsedSizes[j] += ','; } - //remove trailing comma + // remove trailing comma if (sizeQueryString && sizeQueryString.charAt(sizeQueryString.length - 1) === ',') { sizeQueryString = sizeQueryString.slice(0, sizeQueryString.length - 1); } @@ -90,18 +89,18 @@ AppNexusAdapter = function AppNexusAdapter() { jptCall += sizeQueryString + '&'; } - //this will be deprecated soon + // this will be deprecated soon var targetingParams = utils.parseQueryStringParameters(query); if (targetingParams) { - //don't append a & here, we have already done it in parseQueryStringParameters + // don't append a & here, we have already done it in parseQueryStringParameters jptCall += targetingParams; } - //append custom attributes: + // append custom attributes: var paramsCopy = Object.assign({}, bid.params); - //delete attributes already used + // delete attributes already used delete paramsCopy.placementId; delete paramsCopy.memberId; delete paramsCopy.invCode; @@ -110,15 +109,15 @@ AppNexusAdapter = function AppNexusAdapter() { delete paramsCopy.alt_referrer; delete paramsCopy.member; - //get the reminder + // get the reminder var queryParams = utils.parseQueryStringParameters(paramsCopy); - //append + // append if (queryParams) { jptCall += queryParams; } - //append referrer + // append referrer if (referrer === '') { referrer = utils.getTopWindowUrl(); } @@ -126,7 +125,7 @@ AppNexusAdapter = function AppNexusAdapter() { jptCall = utils.tryAppendQueryString(jptCall, 'referrer', referrer); jptCall = utils.tryAppendQueryString(jptCall, 'alt_referrer', altReferrer); - //remove the trailing "&" + // remove the trailing "&" if (jptCall.lastIndexOf('&') === jptCall.length - 1) { jptCall = jptCall.substring(0, jptCall.length - 1); } @@ -136,31 +135,27 @@ AppNexusAdapter = function AppNexusAdapter() { // @endif - //append a timer here to track latency + // append a timer here to track latency bid.startTime = new Date().getTime(); return jptCall; - } - //expose the callback to the global object: + // expose the callback to the global object: $$PREBID_GLOBAL$$.handleAnCB = function (jptResponseObj) { - var bidCode; if (jptResponseObj && jptResponseObj.callback_uid) { - var responseCPM; var id = jptResponseObj.callback_uid; var placementCode = ''; var bidObj = getBidRequest(id); if (bidObj) { - bidCode = bidObj.bidder; placementCode = bidObj.placementCode; - //set the status + // set the status bidObj.status = CONSTANTS.STATUS.GOOD; } @@ -172,13 +167,13 @@ AppNexusAdapter = function AppNexusAdapter() { if (jptResponseObj.result && jptResponseObj.result.cpm && jptResponseObj.result.cpm !== 0) { responseCPM = parseInt(jptResponseObj.result.cpm, 10); - //CPM response from /jpt is dollar/cent multiplied by 10000 - //in order to avoid using floats - //switch CPM to "dollar/cent" + // CPM response from /jpt is dollar/cent multiplied by 10000 + // in order to avoid using floats + // switch CPM to "dollar/cent" responseCPM = responseCPM / 10000; - //store bid response - //bid status is good (indicating 1) + // store bid response + // bid status is good (indicating 1) var adId = jptResponseObj.result.creative_id; bid = bidfactory.createBid(1, bidObj); bid.creative_id = adId; @@ -190,14 +185,13 @@ AppNexusAdapter = function AppNexusAdapter() { bid.dealId = jptResponseObj.result.deal_id; bidmanager.addBidResponse(placementCode, bid); - } else { - //no response data + // no response data // @if NODE_ENV='debug' utils.logMessage('No prebid response from AppNexus for placement code ' + placementCode); // @endif - //indicate that there is no bid for this placement + // indicate that there is no bid for this placement bid = bidfactory.createBid(2, bidObj); bid.bidderCode = bidCode; bidmanager.addBidResponse(placementCode, bid); @@ -213,17 +207,13 @@ AppNexusAdapter = function AppNexusAdapter() { } usersync = true; } - - } else { - //no response data + // no response data // @if NODE_ENV='debug' utils.logMessage('No prebid response for placement %%PLACEMENT%%'); // @endif - } - }; return { diff --git a/src/adapters/appnexusAst.js b/src/adapters/appnexusAst.js index 3293cc4d5a9..a51446313f6 100644 --- a/src/adapters/appnexusAst.js +++ b/src/adapters/appnexusAst.js @@ -19,7 +19,6 @@ const USER_PARAMS = [ * to Prebid.js. This adapter supports alias bidding. */ function AppnexusAstAdapter() { - let baseAdapter = Adapter.createNew('appnexusAst'); let bidRequests = {}; let usersync = false; @@ -39,7 +38,7 @@ function AppnexusAstAdapter() { tag.sizes = getSizes(bid.sizes); tag.primary_size = tag.sizes[0]; tag.uuid = bid.bidId; - if(bid.params.placementId) { + if (bid.params.placementId) { tag.id = parseInt(bid.params.placementId, 10); } else { tag.code = bid.params.invCode; @@ -76,7 +75,7 @@ function AppnexusAstAdapter() { tag.keywords = getKeywords(bid.params.keywords); } - if (bid.mediaType === 'video') {tag.require_asset_url = true;} + if (bid.mediaType === 'video') { tag.require_asset_url = true; } if (bid.params.video) { tag.video = {}; // place any valid video params on the tag @@ -103,7 +102,7 @@ function AppnexusAstAdapter() { const payload = JSON.stringify(payloadJson); ajax(ENDPOINT, handleResponse, payload, { contentType: 'text/plain', - withCredentials : true + withCredentials: true }); } }; @@ -120,7 +119,7 @@ function AppnexusAstAdapter() { if (!parsed || parsed.error) { let errorMessage = `in response for ${baseAdapter.getBidderCode()} adapter`; - if (parsed && parsed.error) {errorMessage += `: ${parsed.error}`;} + if (parsed && parsed.error) { errorMessage += `: ${parsed.error}`; } utils.logError(errorMessage); // signal this response is complete @@ -186,13 +185,12 @@ function AppnexusAstAdapter() { let values = []; utils._each(v, (val) => { val = utils.getValueString('keywords.' + k, val); - if (val) {values.push(val);} + if (val) { values.push(val); } }); v = values; } else { v = utils.getValueString('keywords.' + k, v); - if (utils.isStr(v)) {v = [v];} - else {return;} // unsuported types - don't send a key + if (utils.isStr(v)) { v = [v]; } else { return; } // unsuported types - don't send a key } arrs.push({key: k, value: v}); }); @@ -265,7 +263,6 @@ function AppnexusAstAdapter() { bid.vastUrl = ad.rtb.video.asset_url; bid.descriptionUrl = ad.rtb.video.asset_url; if (ad.renderer_url) { - // outstream video bid.adResponse = tag; @@ -316,7 +313,6 @@ function AppnexusAstAdapter() { callBids: baseAdapter.callBids, setBidderCode: baseAdapter.setBidderCode, }; - } AppnexusAstAdapter.createNew = function() { diff --git a/src/adapters/audienceNetwork.js b/src/adapters/audienceNetwork.js index aafc3bb9edb..61cdbb97ec6 100644 --- a/src/adapters/audienceNetwork.js +++ b/src/adapters/audienceNetwork.js @@ -152,7 +152,7 @@ const callBids = bidRequest => { bidRequest.bids .map(flattenBidRequestSizes) .filter(validateBidRequest) - .forEach( bid => bid.sizes.forEach( size => { + .forEach(bid => bid.sizes.forEach(size => { adUnitCodes.push(bid.placementCode); placementids.push(bid.params.placementId); adformats.push(size); @@ -178,17 +178,17 @@ const callBids = bidRequest => { const data = parseJson(res); if (data.errors && data.errors.length) { const noBid = createFailureBidResponse(); - adUnitCodes.forEach( adUnitCode => addBidResponse(adUnitCode, noBid) ); + adUnitCodes.forEach(adUnitCode => addBidResponse(adUnitCode, noBid)); data.errors.forEach(logError); } else { // For each placementId in bids Object Object.keys(data.bids) // extract Array of bid responses - .map( placementId => data.bids[placementId] ) + .map(placementId => data.bids[placementId]) // flatten - .reduce( (a, b) => a.concat(b), [] ) + .reduce((a, b) => a.concat(b), []) // call addBidResponse - .forEach( (bid, i) => + .forEach((bid, i) => addBidResponse(adUnitCodes[i], createSuccessBidResponse( bid.placement_id, adformats[i], bid.bid_id, bid.bid_price_cents )) diff --git a/src/adapters/beachfront.js b/src/adapters/beachfront.js index b10eb00517e..192ba856235 100644 --- a/src/adapters/beachfront.js +++ b/src/adapters/beachfront.js @@ -16,7 +16,7 @@ function BeachfrontAdapter() { var bidRequest = getBidRequest(bid); var RTBDataParams = prepareAndSaveRTBRequestParams(bid); if (!RTBDataParams) { - var error = "No bid params"; + var error = 'No bid params'; utils.logError(error); if (bid && bid.placementCode) { bidmanager.addBidResponse(bid.placementCode, createBid(bid, STATUS.NO_BID)); @@ -29,7 +29,6 @@ function BeachfrontAdapter() { withCredentials: true }); }); - }; function getBidRequest(bid) { @@ -52,22 +51,22 @@ function BeachfrontAdapter() { return ((/(ios|ipod|ipad|iphone|android)/i).test(global.navigator.userAgent) ? 1 : ((/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(global.navigator.userAgent) ? 1 : 2)); } - var bidRequestObject = { + var bidRequestObject = { isPrebid: true, appId: bid.params.appId, domain: document.location.hostname, - imp:[{ - video:{}, + imp: [{ + video: {}, bidfloor: bid.params.bidfloor }], - site:{ + site: { page: utils.getTopWindowLocation().host }, - device:{ + device: { ua: navigator.userAgent, devicetype: fetchDeviceType() }, - cur:["USD"] + cur: ['USD'] }; return bidRequestObject; } @@ -83,11 +82,11 @@ function BeachfrontAdapter() { utils.logError(error); } } else { - utils.logWarn("No bid response"); + utils.logWarn('No bid response'); } if (!parsed || parsed.error || !parsed.url || !parsed.bidPrice) { - utils.logWarn("No Valid Bid"); + utils.logWarn('No Valid Bid'); bidmanager.addBidResponse(bidRequest.placementCode, createBid(bidRequest, STATUS.NO_BID)); return; } diff --git a/src/adapters/bidfluence.js b/src/adapters/bidfluence.js index bd3790e8652..c3c32c579f1 100644 --- a/src/adapters/bidfluence.js +++ b/src/adapters/bidfluence.js @@ -3,9 +3,8 @@ const bidfactory = require('../bidfactory.js'); const utils = require('../utils.js'); const adloader = require('../adloader'); -var BidfluenceAdapter = function BidfluenceAdapter() { - - const scriptUrl = "//cdn.bidfluence.com/forge.js"; +var BidfluenceAdapter = function BidfluenceAdapter() { + const scriptUrl = '//cdn.bidfluence.com/forge.js'; $$PREBID_GLOBAL$$.bfPbjsCB = function (bfr) { var bidRequest = utils.getBidRequest(bfr.cbID); @@ -32,15 +31,14 @@ var BidfluenceAdapter = function BidfluenceAdapter() { call(bid); } } - function call(bid) { - + function call(bid) { var adunitId = utils.getBidIdParameter('adunitId', bid.params); var publisherId = utils.getBidIdParameter('pubId', bid.params); var reservePrice = utils.getBidIdParameter('reservePrice', bid.params); var pbjsBfobj = { placementCode: bid.placementCode, cbID: bid.bidId - }; + }; var cb = function () { /* globals FORGE */ diff --git a/src/adapters/brightcom.js b/src/adapters/brightcom.js index 9df4a872d47..23cd6269b40 100644 --- a/src/adapters/brightcom.js +++ b/src/adapters/brightcom.js @@ -8,7 +8,6 @@ var adloader = require('../adloader'); * Adapter for requesting bids from Brightcom */ var BrightcomAdapter = function BrightcomAdapter() { - // Set Brightcom Bidder URL var brightcomUrl = 'hb.iselephant.com/auc/ortb'; @@ -20,10 +19,9 @@ var BrightcomAdapter = function BrightcomAdapter() { // Manage the requested and received ad units' codes, to know which are invalid (didn't return) var reqAdUnitsCode = [], - resAdUnitsCode = []; + resAdUnitsCode = []; function _callBids(params) { - var bidRequests = params.bids || []; // Get page data @@ -38,12 +36,11 @@ var BrightcomAdapter = function BrightcomAdapter() { // Go through the requests and build array of impressions utils._each(bidRequests, function(bid) { - // Get impression details var tagId = utils.getBidIdParameter('tagId', bid.params); var ref = utils.getBidIdParameter('ref', bid.params); - var adWidth=0; - var adHeight=0; + var adWidth = 0; + var adHeight = 0; // If no publisher id is set, use the current if (pubId === '') { @@ -83,18 +80,17 @@ var BrightcomAdapter = function BrightcomAdapter() { // Add current impression to collection brightcomImps.push(imp); // Add mapping to current bid via impression id - //bidmanager.pbCallbackMap[imp.id] = bid; + // bidmanager.pbCallbackMap[imp.id] = bid; // Add current ad unit's code to tracking reqAdUnitsCode.push(bid.placementCode); - }); // Build the bid request var brightcomBidReq = { id: utils.getUniqueIdentifierStr(), imp: brightcomImps, - site:{ + site: { publisher: { id: pubId }, @@ -119,9 +115,8 @@ var BrightcomAdapter = function BrightcomAdapter() { adloader.loadScript(bidRequestCallUrl); } - //expose the callback to the global object: + // expose the callback to the global object: $$PREBID_GLOBAL$$.brightcomResponse = function(brightcomResponseObj) { - var bid = {}; // Make sure response is valid @@ -130,16 +125,13 @@ var BrightcomAdapter = function BrightcomAdapter() { (brightcomResponseObj.seatbid) && (brightcomResponseObj.seatbid.length !== 0) && (brightcomResponseObj.seatbid[0].bid) && (brightcomResponseObj.seatbid[0].bid.length !== 0) ) { - // Go through the received bids - brightcomResponseObj.seatbid[0].bid.forEach( function(curBid) { - + brightcomResponseObj.seatbid[0].bid.forEach(function(curBid) { // Get the bid request data var bidRequest = $$PREBID_GLOBAL$$._bidsRequested.find(bidSet => bidSet.bidderCode === 'brightcom').bids[0]; // this assumes a single request only // Make sure the bid exists if (bidRequest) { - var placementCode = bidRequest.placementCode; bidRequest.status = CONSTANTS.STATUS.GOOD; @@ -185,10 +177,8 @@ var BrightcomAdapter = function BrightcomAdapter() { // Add current ad unit's code to tracking resAdUnitsCode.push(placementCode); - } }); - } // Define all unreceived ad unit codes as invalid (if Brightcom don't want to bid on an impression, it won't include it in the response) @@ -202,7 +192,6 @@ var BrightcomAdapter = function BrightcomAdapter() { bidmanager.addBidResponse(adUnitCode, bid); } } - }; return { diff --git a/src/adapters/centro.js b/src/adapters/centro.js index 85303afc823..903d475d712 100644 --- a/src/adapters/centro.js +++ b/src/adapters/centro.js @@ -5,24 +5,24 @@ var adloader = require('../adloader'); var CentroAdapter = function CentroAdapter() { var baseUrl = '//t.brand-server.com/hb', - devUrl = '//staging.brand-server.com/hb', - bidderCode = 'centro', - handlerPrefix = 'adCentroHandler_', + devUrl = '//staging.brand-server.com/hb', + bidderCode = 'centro', + handlerPrefix = 'adCentroHandler_', - LOG_ERROR_MESS = { - noUnit: 'Bid has no unit', - noAdTag: 'Bid has missmatch format.', - noBid: 'Response has no bid.', - anotherCode: 'Bid has another bidderCode - ', - undefBid: 'Bid is undefined', - unitNum: 'Requested unit is ' - }; + LOG_ERROR_MESS = { + noUnit: 'Bid has no unit', + noAdTag: 'Bid has missmatch format.', + noBid: 'Response has no bid.', + anotherCode: 'Bid has another bidderCode - ', + undefBid: 'Bid is undefined', + unitNum: 'Requested unit is ' + }; function _makeHandler(handlerName, unit, placementCode) { - return function(response){ + return function(response) { try { delete window[handlerName]; - } catch(err) {//catching for old IE + } catch (err) { // catching for old IE window[handlerName] = undefined; } _responseProcessing(response, unit, placementCode); @@ -31,37 +31,37 @@ var CentroAdapter = function CentroAdapter() { function _sendBidRequest(bid) { var placementCode = bid.placementCode, - size = bid.sizes && bid.sizes[0]; + size = bid.sizes && bid.sizes[0]; bid = bid.params; if (!bid.unit) { - //throw exception, or call utils.logError + // throw exception, or call utils.logError utils.logError(LOG_ERROR_MESS.noUnit, bidderCode); return; } - var query = ['s=' + bid.unit, 'adapter=prebid'];//,'url=www.abc15.com','sz=320x50']; + var query = ['s=' + bid.unit, 'adapter=prebid'];//, 'url=www.abc15.com','sz=320x50']; var isDev = bid.unit.toString() === '28136'; query.push('url=' + encodeURIComponent(bid.page_url || location.href)); - //check size format + // check size format if ( size instanceof Array && - size.length===2 && + size.length === 2 && typeof size[0] === 'number' && typeof size[1] === 'number' ) { query.push('sz=' + size.join('x')); } - //make handler name for JSONP request + // make handler name for JSONP request var handlerName = handlerPrefix + bid.unit + size.join('x') + encodeURIComponent(placementCode); query.push('callback=' + encodeURIComponent('window["' + handlerName + '"]')); - //maybe is needed add some random parameter to disable cache - //query.push('r='+Math.round(Math.random() * 1e5)); + // maybe is needed add some random parameter to disable cache + // query.push('r='+Math.round(Math.random() * 1e5)); window[handlerName] = _makeHandler(handlerName, bid.unit, placementCode); - adloader.loadScript((document.location.protocol === 'https:'? 'https:' : 'http:') + (isDev? devUrl : baseUrl) + '?' + query.join('&')); + adloader.loadScript((document.location.protocol === 'https:' ? 'https:' : 'http:') + (isDev ? devUrl : baseUrl) + '?' + query.join('&')); } /* @@ -82,8 +82,8 @@ var CentroAdapter = function CentroAdapter() { bidObject.width = bid.width; bidObject.height = bid.height; } else { - //throw exception, or call utils.logError with resp.statusMessage - utils.logError(LOG_ERROR_MESS.unitNum + unit + '. ' + (bid? bid.statusMessage || LOG_ERROR_MESS.noAdTag : LOG_ERROR_MESS.noBid), bidderCode); + // throw exception, or call utils.logError with resp.statusMessage + utils.logError(LOG_ERROR_MESS.unitNum + unit + '. ' + (bid ? bid.statusMessage || LOG_ERROR_MESS.noAdTag : LOG_ERROR_MESS.noBid), bidderCode); bidObject = bidfactory.createBid(2); } bidObject.bidderCode = bidderCode; @@ -114,5 +114,4 @@ var CentroAdapter = function CentroAdapter() { }; }; - module.exports = CentroAdapter; diff --git a/src/adapters/conversant.js b/src/adapters/conversant.js index 3fbada26b95..d8c15c1d7e7 100644 --- a/src/adapters/conversant.js +++ b/src/adapters/conversant.js @@ -1,11 +1,11 @@ 'use strict'; var VERSION = '2.0.1', - CONSTANTS = require('../constants.json'), - utils = require('../utils.js'), - bidfactory = require('../bidfactory.js'), - bidmanager = require('../bidmanager.js'), - adloader = require('../adloader'), - ajax = require('../ajax').ajax; + CONSTANTS = require('../constants.json'), + utils = require('../utils.js'), + bidfactory = require('../bidfactory.js'), + bidmanager = require('../bidmanager.js'), + adloader = require('../adloader'), + ajax = require('../ajax').ajax; /** * Adapter for requesting bids from Conversant @@ -61,7 +61,7 @@ var ConversantAdapter = function () { conversantBidReqs, secure = 0; - //build impression array for conversant + // build impression array for conversant utils._each(bidReqs, function (bid) { var bidfloor = utils.getBidIdParameter('bidfloor', bid.params), adW = 0, @@ -89,7 +89,7 @@ var ConversantAdapter = function () { h: adH }, secure: secure, - bidfloor: bidfloor ? bidfloor : 0, + bidfloor: bidfloor || 0, displaymanager: 'Prebid.js', displaymanagerver: VERSION }; @@ -113,14 +113,14 @@ var ConversantAdapter = function () { var url = secure ? 'https:' + conversantUrl : location.protocol + conversantUrl; ajax(url, appendScript, JSON.stringify(conversantBidReqs), { - withCredentials : true + withCredentials: true }); }; var addEmptyBidResponses = function (placementsWithBidsBack) { var allConversantBidRequests = $$PREBID_GLOBAL$$._bidsRequested.find(bidSet => bidSet.bidderCode === 'conversant'); - if (allConversantBidRequests && allConversantBidRequests.bids){ + if (allConversantBidRequests && allConversantBidRequests.bids) { utils._each(allConversantBidRequests.bids, function (conversantBid) { if (!utils.contains(placementsWithBidsBack, conversantBid.placementCode)) { // Add a no-bid response for this placement. @@ -191,19 +191,19 @@ var ConversantAdapter = function () { if (conversantResponseObj.seatbid && conversantResponseObj.seatbid.length > 0 && conversantResponseObj.seatbid[0].bid && conversantResponseObj.seatbid[0].bid.length > 0) { utils._each(conversantResponseObj.seatbid, parseSeatbid); } else { - //no response data for any placements + // no response data for any placements addEmptyBidResponses([]); } } else { - //no response data for any placements + // no response data for any placements addEmptyBidResponses([]); } // for debugging purposes - if (path){ + if (path) { adloader.loadScript(path, function () { var allConversantBidRequests = $$PREBID_GLOBAL$$._bidsRequested.find(bidSet => bidSet.bidderCode === 'conversant'); - if ($$PREBID_GLOBAL$$.conversantDebugResponse){ + if ($$PREBID_GLOBAL$$.conversantDebugResponse) { $$PREBID_GLOBAL$$.conversantDebugResponse(allConversantBidRequests); } }); diff --git a/src/adapters/criteo.js b/src/adapters/criteo.js index eb1c522350a..aeea56f0851 100644 --- a/src/adapters/criteo.js +++ b/src/adapters/criteo.js @@ -3,7 +3,6 @@ var bidmanager = require('../bidmanager.js'); var adloader = require('../adloader'); var CriteoAdapter = function CriteoAdapter() { - var _publisherTagUrl = window.location.protocol + '//static.criteo.net/js/ld/publishertag.js'; var _bidderCode = 'criteo'; var _profileId = 125; @@ -18,8 +17,7 @@ var CriteoAdapter = function CriteoAdapter() { function () {}, true ); - } - else { + } else { // publisherTag already loaded _pushBidRequestEvent(params); } @@ -27,14 +25,12 @@ var CriteoAdapter = function CriteoAdapter() { // send bid request to criteo direct bidder handler function _pushBidRequestEvent(params) { - // if we want to be fully asynchronous, we must first check window.criteo_pubtag in case publishertag.js is not loaded yet. window.Criteo = window.Criteo || {}; window.Criteo.events = window.Criteo.events || []; // generate the bidding event var biddingEventFunc = function () { - var bids = params.bids || []; var slots = []; @@ -70,14 +66,12 @@ var CriteoAdapter = function CriteoAdapter() { }; window.Criteo.events.push(biddingEventFunc); - } function parseBidResponse(bidsResponse) { try { return JSON.parse(bidsResponse); - } - catch (error) { + } catch (error) { return {}; } } @@ -90,8 +84,7 @@ var CriteoAdapter = function CriteoAdapter() { return function (bidsResponse) { var jsonbidsResponse = parseBidResponse(bidsResponse); - if (isNoBidResponse(jsonbidsResponse)) - return _callbackError(slots)(); + if (isNoBidResponse(jsonbidsResponse)) { return _callbackError(slots)(); } for (var i = 0; i < slots.length; i++) { var bidResponse = null; @@ -113,8 +106,7 @@ var CriteoAdapter = function CriteoAdapter() { bidObject.ad = bidResponse.creative; bidObject.width = bidResponse.width; bidObject.height = bidResponse.height; - } - else { + } else { bidObject = _invalidBidResponse(); } bidmanager.addBidResponse(slots[i].impId, bidObject); @@ -141,4 +133,4 @@ var CriteoAdapter = function CriteoAdapter() { }; }; -module.exports = CriteoAdapter; \ No newline at end of file +module.exports = CriteoAdapter; diff --git a/src/adapters/districtmDMX.js b/src/adapters/districtmDMX.js index 9dd6bf4c36d..d8e78d97401 100644 --- a/src/adapters/districtmDMX.js +++ b/src/adapters/districtmDMX.js @@ -2,23 +2,22 @@ var bidfactory = require('../bidfactory.js'); var bidmanager = require('../bidmanager.js'); var adLoader = require('../adloader'); -var DistrictmAdaptor = function districtmAdaptor(){ +var DistrictmAdaptor = function districtmAdaptor() { let districtmUrl = window.location.protocol + '//prebid.districtm.ca/lib.js'; - this.callBids = params =>{ - if(!window.hb_dmx_res){ - adLoader.loadScript(districtmUrl,()=>{ + this.callBids = params => { + if (!window.hb_dmx_res) { + adLoader.loadScript(districtmUrl, () => { this.sendBids(params); }); - }else{ + } else { this.sendBids(params); } return params; }; - - this.handlerRes = function(response, bidObject){ + this.handlerRes = function(response, bidObject) { let bid; - if(parseFloat(response.result.cpm) > 0){ + if (parseFloat(response.result.cpm) > 0) { bid = bidfactory.createBid(1); bid.bidderCode = bidObject.bidder; bid.cpm = response.result.cpm; @@ -26,7 +25,7 @@ var DistrictmAdaptor = function districtmAdaptor(){ bid.height = response.result.height; bid.ad = response.result.banner; bidmanager.addBidResponse(bidObject.placementCode, bid); - }else{ + } else { bid = bidfactory.createBid(2); bid.bidderCode = bidObject.bidder; bidmanager.addBidResponse(bidObject.placementCode, bid); @@ -35,17 +34,15 @@ var DistrictmAdaptor = function districtmAdaptor(){ return bid; }; - - this.sendBids = function(params){ + this.sendBids = function(params) { var bids = params.bids; - for(var i = 0; i < bids.length; i++){ + for (var i = 0; i < bids.length; i++) { bids[i].params.sizes = window.hb_dmx_res.auction.fixSize(bids[i].sizes); } window.hb_dmx_res.auction.run(window.hb_dmx_res.ssp, bids, this.handlerRes); return bids; }; - return { callBids: this.callBids, sendBids: this.sendBids, diff --git a/src/adapters/fidelity.js b/src/adapters/fidelity.js index 66550219561..0d623bfd162 100644 --- a/src/adapters/fidelity.js +++ b/src/adapters/fidelity.js @@ -12,13 +12,13 @@ var FidelityAdapter = function FidelityAdapter() { var bids = params.bids || []; bids.forEach(function (currentBid) { var server = currentBid.params.server || FIDELITY_SERVER_NAME; - var m3_u = window.location.protocol + '//'+server+'/delivery/hb.php?'; + var m3_u = window.location.protocol + '//' + server + '/delivery/hb.php?'; m3_u += 'callback=window.$$PREBID_GLOBAL$$.fidelityResponse'; - m3_u += '&requestid='+utils.getUniqueIdentifierStr(); - m3_u += '&impid='+currentBid.bidId; - m3_u += '&zoneid='+currentBid.params.zoneid; - m3_u += '&cb='+Math.floor(Math.random()*99999999999); - m3_u += document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''); + m3_u += '&requestid=' + utils.getUniqueIdentifierStr(); + m3_u += '&impid=' + currentBid.bidId; + m3_u += '&zoneid=' + currentBid.params.zoneid; + m3_u += '&cb=' + Math.floor(Math.random() * 99999999999); + m3_u += document.charset ? '&charset=' + document.charset : (document.characterSet ? '&charset=' + document.characterSet : ''); var loc; try { @@ -39,25 +39,25 @@ var FidelityAdapter = function FidelityAdapter() { }); } - function getFlashVersion(){ + function getFlashVersion() { var plugins, plugin, result; if (navigator.plugins && navigator.plugins.length > 0) { plugins = navigator.plugins; for (var i = 0; i < plugins.length && !result; i++) { plugin = plugins[i]; - if (plugin.name.indexOf("Shockwave Flash") > -1) { - result = plugin.description.split("Shockwave Flash ")[1]; + if (plugin.name.indexOf('Shockwave Flash') > -1) { + result = plugin.description.split('Shockwave Flash ')[1]; } } } - return result ? result : ""; + return result || ''; } function addBlankBidResponses(placementsWithBidsBack) { var allFidelityBidRequests = $$PREBID_GLOBAL$$._bidsRequested.find(bidSet => bidSet.bidderCode === FIDELITY_BIDDER_NAME); - if (allFidelityBidRequests && allFidelityBidRequests.bids){ + if (allFidelityBidRequests && allFidelityBidRequests.bids) { utils._each(allFidelityBidRequests.bids, function (fidelityBid) { if (!utils.contains(placementsWithBidsBack, fidelityBid.placementCode)) { // Add a no-bid response for this placement. @@ -68,11 +68,10 @@ var FidelityAdapter = function FidelityAdapter() { }); } } - - $$PREBID_GLOBAL$$.fidelityResponse = function(responseObj) { + $$PREBID_GLOBAL$$.fidelityResponse = function(responseObj) { if (!responseObj || !responseObj.seatbid || responseObj.seatbid.length === 0 || !responseObj.seatbid[0].bid || responseObj.seatbid[0].bid.length === 0) { - addBlankBidResponses([]); + addBlankBidResponses([]); return; } @@ -97,4 +96,4 @@ var FidelityAdapter = function FidelityAdapter() { }; }; -module.exports = FidelityAdapter; \ No newline at end of file +module.exports = FidelityAdapter; diff --git a/src/adapters/getintent.js b/src/adapters/getintent.js index a98fab952ae..e8cbb837e72 100644 --- a/src/adapters/getintent.js +++ b/src/adapters/getintent.js @@ -1,4 +1,4 @@ -/*jshint loopfunc: true */ +/* jshint loopfunc: true */ import { STATUS } from 'src/constants'; @@ -37,7 +37,7 @@ var GetIntentAdapter = function GetIntentAdapter() { known: bidRequest.params.known || 1, is_video: bidRequest.mediaType === 'video', video: bidRequest.params.video || {}, - size: bidRequest.sizes[0].join("x"), + size: bidRequest.sizes[0].join('x'), }; addOptional(bidRequest.params, request, ['cur', 'floor']); (function (r, br) { diff --git a/src/adapters/gumgum.js b/src/adapters/gumgum.js index d9a08d96b97..1d589fa7041 100644 --- a/src/adapters/gumgum.js +++ b/src/adapters/gumgum.js @@ -1,13 +1,12 @@ const bidfactory = require('../bidfactory'); const bidmanager = require('../bidmanager'); -const utils = require('../utils'); -const adloader = require('../adloader'); +const utils = require('../utils'); +const adloader = require('../adloader'); const BIDDER_CODE = 'gumgum'; const CALLBACKS = {}; const GumgumAdapter = function GumgumAdapter() { - const bidEndpoint = `https://g2.gumgum.com/hbid/imp`; let topWindow; @@ -43,18 +42,18 @@ const GumgumAdapter = function GumgumAdapter() { , params = {} , placementCode } = bidRequest; - const timestamp = _getTimeStamp(); + const timestamp = _getTimeStamp(); const trackingId = params.inScreen; - const nativeId = params.native; - const slotId = params.inSlot; - const bid = { tmax: $$PREBID_GLOBAL$$.cbTimeout }; + const nativeId = params.native; + const slotId = params.inSlot; + const bid = { tmax: $$PREBID_GLOBAL$$.cbTimeout }; /* slot/native ads need the placement id */ switch (true) { - case !!(params.inImage): bid.pi = 1; break; + case !!(params.inImage): bid.pi = 1; break; case !!(params.inScreen): bid.pi = 2; break; - case !!(params.inSlot): bid.pi = 3; break; - case !!(params.native): bid.pi = 5; break; + case !!(params.inSlot): bid.pi = 3; break; + case !!(params.native): bid.pi = 5; break; default: return utils.logWarn( `[GumGum] No product selected for the placement ${placementCode}` + ', please check your implementation.' @@ -62,14 +61,14 @@ const GumgumAdapter = function GumgumAdapter() { } /* throttle based on the latest request for this product */ - const productId = bid.pi; - const requestKey = productId + '|' + placementCode; - const throttle = throttleTable[productId]; + const productId = bid.pi; + const requestKey = productId + '|' + placementCode; + const throttle = throttleTable[productId]; const latestRequest = requestCache[requestKey]; if (latestRequest && throttle && (timestamp - latestRequest) < throttle) { return utils.logWarn( - `[GumGum] The refreshes for "${ placementCode }" with the params ` + - `${ JSON.stringify(params) } should be at least ${ throttle / 1e3 }s apart.` + `[GumGum] The refreshes for "${placementCode}" with the params ` + + `${JSON.stringify(params)} should be at least ${throttle / 1e3}s apart.` ); } /* update the last request */ @@ -90,7 +89,7 @@ const GumgumAdapter = function GumgumAdapter() { id: bidId }, bid); - const callback = { jsonp: `$$PREBID_GLOBAL$$.handleGumGumCB['${ bidId }']` }; + const callback = { jsonp: `$$PREBID_GLOBAL$$.handleGumGumCB['${bidId}']` }; CALLBACKS[bidId] = _handleGumGumResponse(cachedBid); const query = Object.assign(callback, browserParams, bid); const bidCall = `${bidEndpoint}?${utils.parseQueryStringParameters(query)}`; @@ -121,7 +120,7 @@ const GumgumAdapter = function GumgumAdapter() { G = topWindow.GUMGUM; d = topWindow.document; function loadAd() { - topWindow.GUMGUM.pbjs("${ trackingId }", ${ productId }, "${ encodedResponse }" , context); + topWindow.GUMGUM.pbjs("${trackingId}", ${productId}, "${encodedResponse}" , context); } if (G) { loadAd(); @@ -151,7 +150,6 @@ const GumgumAdapter = function GumgumAdapter() { return { callBids: _callBids }; - }; module.exports = GumgumAdapter; diff --git a/src/adapters/hiromedia.js b/src/adapters/hiromedia.js index 3d37acc0f45..856ee629060 100644 --- a/src/adapters/hiromedia.js +++ b/src/adapters/hiromedia.js @@ -1,5 +1,5 @@ -/*jslint white:true, browser:true, single: true*/ -/*global $$PREBID_GLOBAL$$, require, module*/ +/* jslint white:true, browser:true, single: true */ +/* global $$PREBID_GLOBAL$$, require, module */ /** * Adapter for HIRO Media @@ -18,8 +18,7 @@ var bidmanager = require('src/bidmanager'); var utils = require('src/utils'); var STATUS = require('src/constants').STATUS; -var HiroMediaAdapter = function HiroMediaAdapter() { - +var HiroMediaAdapter = function HiroMediaAdapter() { 'use strict'; /** @@ -85,8 +84,7 @@ var HiroMediaAdapter = function HiroMediaAdapter() { * @param {object|boolean} [bidResponse] response object for bid, if not * set the response will be an empty bid response. */ - function addBidResponse(bidInfo, bidResponse) { - + function addBidResponse(bidInfo, bidResponse) { var placementCode = bidInfo.bid.placementCode; var bidStatus = bidResponse ? STATUS.GOOD : STATUS.NO_BID; var bidObject = bidfactory.createBid(bidStatus, bidInfo.bid); @@ -101,8 +99,7 @@ var HiroMediaAdapter = function HiroMediaAdapter() { } utils.logMessage('hiromedia.callBids, addBidResponse for ' + placementCode + ' status: ' + bidStatus); - bidmanager.addBidResponse(placementCode, bidObject); - + bidmanager.addBidResponse(placementCode, bidObject); } /** @@ -126,22 +123,18 @@ var HiroMediaAdapter = function HiroMediaAdapter() { * * @param {object} response [description] */ - function handleResponse(response) { - + function handleResponse(response) { _bidStorage.filter(function (bidInfo) { return bidInfo.batchKey === response.batchKey; - }).forEach(function (bidInfo) { - + }).forEach(function (bidInfo) { // Sample the bid responses according to `response.chance`, // if `response.chance` is not provided, sample at 100%. if (response.chance === undefined || checkChance(response.chance)) { addBidResponse(bidInfo, response); } else { addBidResponse(bidInfo, false); - } - - }); - + } + }); } /** @@ -151,12 +144,10 @@ var HiroMediaAdapter = function HiroMediaAdapter() { * * @param {object} [response] the response from the server */ - $$PREBID_GLOBAL$$.hiromedia_callback = function (response) { - + $$PREBID_GLOBAL$$.hiromedia_callback = function (response) { if (response && response.batchKey) { handleResponse(response); - } - + } }; /** @@ -170,8 +161,7 @@ var HiroMediaAdapter = function HiroMediaAdapter() { * @return {module:HiroMediaAdapter~browserInfo} object containing name and version of browser * or empty strings. */ - function getBrowser() { - + function getBrowser() { var ua = navigator.userAgent; var browsers = [{ name: 'Mobile', @@ -194,8 +184,7 @@ var HiroMediaAdapter = function HiroMediaAdapter() { var name = ''; var version = ''; - browsers.some(function (browser) { - + browsers.some(function (browser) { var nameSearch = browser.stringSearch || browser.name; var defaultVersionSearch = nameSearch + '\\/(\\d+)'; var versionSearch = browser.versionSearch || defaultVersionSearch; @@ -208,15 +197,13 @@ var HiroMediaAdapter = function HiroMediaAdapter() { version = versionMatch && versionMatch[1]; } return true; - } - + } }); return { name: name, version: version - }; - + }; } /** @@ -227,12 +214,10 @@ var HiroMediaAdapter = function HiroMediaAdapter() { * * @return {string} domain of top context url. */ - function getDomain() { - + function getDomain() { var a = document.createElement('a'); a.href = utils.getTopWindowUrl(); - return a.hostname; - + return a.hostname; } /** @@ -262,8 +247,7 @@ var HiroMediaAdapter = function HiroMediaAdapter() { * @param {module:HiroMediaAdapter~bidInfo} bidInfo bid information * @return {string} batch key for bid */ - function getBatchKey(bidInfo) { - + function getBatchKey(bidInfo) { var bidParams = bidInfo.bidParams; var batchParams = [ bidParams.bidUrl, @@ -272,8 +256,7 @@ var HiroMediaAdapter = function HiroMediaAdapter() { bidInfo.additionalSizes ]; - return batchParams.join('-'); - + return batchParams.join('-'); } /** @@ -286,16 +269,13 @@ var HiroMediaAdapter = function HiroMediaAdapter() { * @param {object} bids bids sent from `Prebid.js` * @return {array.} wrapped bids */ - function processBids(bids) { - + function processBids(bids) { var result = []; - if (bids) { - + if (bids) { utils.logMessage('hiromedia.processBids, processing ' + bids.length + ' bids'); - bids.forEach(function (bid) { - + bids.forEach(function (bid) { var sizes = utils.parseSizesInput(bid.sizes); var bidParams = defaultParams(bid.params); var hasValidBidRequest = utils.hasValidBidRequest(bidParams, REQUIRED_BID_PARAMS, BIDDER_CODE); @@ -312,14 +292,11 @@ var HiroMediaAdapter = function HiroMediaAdapter() { bidInfo.batchKey = getBatchKey(bidInfo); } - result.push(bidInfo); - - }); - + result.push(bidInfo); + }); } - return result; - + return result; } /** @@ -333,10 +310,8 @@ var HiroMediaAdapter = function HiroMediaAdapter() { * @param {string} url base url, can already contain query parameters * @param {object} requestParams parameters to add to query */ - function sendBidRequest(url,requestParams) { - - if (requestParams) { - + function sendBidRequest(url, requestParams) { + if (requestParams) { if (url.indexOf('?') !== -1) { url = url + '&'; } else { @@ -345,14 +320,12 @@ var HiroMediaAdapter = function HiroMediaAdapter() { Object.keys(requestParams).forEach(function (key) { url = utils.tryAppendQueryString(url, key, requestParams[key]); - }); - + }); } utils.logMessage('hiromedia.callBids, url:' + url); - adloader.loadScript(url); - + adloader.loadScript(url); } /** @@ -362,47 +335,38 @@ var HiroMediaAdapter = function HiroMediaAdapter() { * * @param {object} params placement and bid data from `Prebid.js` */ - function _callBids(params) { - + function _callBids(params) { var browser = getBrowser(); var domain = getDomain(); var bidsRequested = {}; utils.logMessage('hiromedia.callBids'); - if (params) { - + if (params) { // Processed bids are stored in the adapter scope - _bidStorage = processBids(params.bids); - - } else { - + _bidStorage = processBids(params.bids); + } else { // Ensure we don't run on stale data - _bidStorage = []; - + _bidStorage = []; } - if (_bidStorage.length) { - + if (_bidStorage.length) { // Loop over processed bids and send a request if a request for the bid // batchKey has not been sent. - _bidStorage.forEach(function (bidInfo) { - + _bidStorage.forEach(function (bidInfo) { var bid = bidInfo.bid; var batchKey = bidInfo.batchKey; var bidParams = bidInfo.bidParams; utils.logMessage('hiromedia.callBids, bidInfo ' + bid.placementCode + ' ' + bidInfo.shouldBid); - if (bidInfo.shouldBid) { - + if (bidInfo.shouldBid) { var url = bidParams.bidUrl; - if (!bidsRequested[batchKey]) { - + if (!bidsRequested[batchKey]) { bidsRequested[batchKey] = true; - sendBidRequest(url,{ + sendBidRequest(url, { adapterVersion: ADAPTER_VERSION, callback: '$$PREBID_GLOBAL$$.hiromedia_callback', batchKey: batchKey, @@ -413,21 +377,14 @@ var HiroMediaAdapter = function HiroMediaAdapter() { domain: domain, selectedSize: bidInfo.selectedSize, additionalSizes: bidInfo.additionalSizes - }); - - } - - } else { - + }); + } + } else { // No bid - addBidResponse(bidInfo, false); - - } - - }); - - } - + addBidResponse(bidInfo, false); + } + }); + } } return { @@ -468,8 +425,7 @@ var HiroMediaAdapter = function HiroMediaAdapter() { * * @property {string} name browser name (e.g. `'Chrome'` or `'Firefox'`) * @property {string} version browser major version (e.g. `'53'`) - */ - + */ }; module.exports = HiroMediaAdapter; diff --git a/src/adapters/huddledmasses.js b/src/adapters/huddledmasses.js index b529614a0f4..8fdfee0fc4d 100644 --- a/src/adapters/huddledmasses.js +++ b/src/adapters/huddledmasses.js @@ -48,7 +48,7 @@ function HuddledMassesAdapter() { utils.logMessage('XHR callback function called for ad ID: ' + bid.bidId); handleRpCB(responseText, bid); } catch (err) { - if (typeof err === "string") { + if (typeof err === 'string') { utils.logWarn(`${err} when processing huddledmasses response for placement code ${bid.placementCode}`); } else { utils.logError('Error processing huddledmasses response for placement code ' + bid.placementCode, null, err); @@ -76,7 +76,7 @@ function HuddledMassesAdapter() { ); if (parsedSizes.length < 1) { - throw "no valid sizes"; + throw 'no valid sizes'; } var secure = 0; @@ -91,23 +91,23 @@ function HuddledMassesAdapter() { var deviceHeight = window.screen.height; var queryString = [ - 'banner_id', bid.params.placement_id, - 'size_ad', parsedSizes[0], - 'alt_size_ad', parsedSizes.slice(1).join(',') || [], - 'host', host, - "page", page, - "language", language, - "deviceWidth", deviceWidth, - "deviceHeight", deviceHeight, - "secure", secure, - "bidId", bid.bidId, - "checkOn", 'rf' + 'banner_id', bid.params.placement_id, + 'size_ad', parsedSizes[0], + 'alt_size_ad', parsedSizes.slice(1).join(',') || [], + 'host', host, + 'page', page, + 'language', language, + 'deviceWidth', deviceWidth, + 'deviceHeight', deviceHeight, + 'secure', secure, + 'bidId', bid.bidId, + 'checkOn', 'rf' ]; return queryString.reduce( (memo, curr, index) => - index % 2 === 0 && queryString[index + 1] !== undefined ? - memo + curr + '=' + encodeURIComponent(queryString[index + 1]) + '&' + index % 2 === 0 && queryString[index + 1] !== undefined + ? memo + curr + '=' + encodeURIComponent(queryString[index + 1]) + '&' : memo, '//huddledmassessupply.com/?' ).slice(0, -1); @@ -166,4 +166,4 @@ HuddledMassesAdapter.createNew = function () { return new HuddledMassesAdapter(); }; -module.exports = HuddledMassesAdapter; \ No newline at end of file +module.exports = HuddledMassesAdapter; diff --git a/src/adapters/indexExchange.js b/src/adapters/indexExchange.js index 7f6888e974e..d9b464cb62c 100644 --- a/src/adapters/indexExchange.js +++ b/src/adapters/indexExchange.js @@ -1,4 +1,4 @@ -//Factory for creating the bidderAdaptor +// Factory for creating the bidderAdaptor // jshint ignore:start var utils = require('../utils.js'); var bidfactory = require('../bidfactory.js'); @@ -9,13 +9,13 @@ var ADAPTER_NAME = 'INDEXEXCHANGE'; var ADAPTER_CODE = 'indexExchange'; var CONSTANTS = { - "INDEX_DEBUG_MODE": { - "queryParam": "pbjs_ix_debug", - "mode": { - "sandbox": { - "topFrameLimit": 10, - "queryValue": "sandbox", - "siteID": "999990" + 'INDEX_DEBUG_MODE': { + 'queryParam': 'pbjs_ix_debug', + 'mode': { + 'sandbox': { + 'topFrameLimit': 10, + 'queryValue': 'sandbox', + 'siteID': '999990' } } } @@ -27,16 +27,16 @@ var PRIVATE_MARKET = 'IPM'; window.cygnus_index_parse_res = function(response) { try { if (response) { - if (typeof _IndexRequestData !== "object" || typeof _IndexRequestData.impIDToSlotID !== "object" || typeof _IndexRequestData.impIDToSlotID[response.id] === "undefined") { + if (typeof _IndexRequestData !== 'object' || typeof _IndexRequestData.impIDToSlotID !== 'object' || typeof _IndexRequestData.impIDToSlotID[response.id] === 'undefined') { return; } var targetMode = 1; var callbackFn; if (typeof _IndexRequestData.reqOptions === 'object' && typeof _IndexRequestData.reqOptions[response.id] === 'object') { - if (typeof _IndexRequestData.reqOptions[response.id].callback === "function") { + if (typeof _IndexRequestData.reqOptions[response.id].callback === 'function') { callbackFn = _IndexRequestData.reqOptions[response.id].callback; } - if (typeof _IndexRequestData.reqOptions[response.id].targetMode === "number") { + if (typeof _IndexRequestData.reqOptions[response.id].targetMode === 'number') { targetMode = _IndexRequestData.reqOptions[response.id].targetMode; } } @@ -47,25 +47,25 @@ window.cygnus_index_parse_res = function(response) { _IndexRequestData.targetIDToCreative = {}; var allBids = []; - var seatbidLength = typeof response.seatbid === "undefined" ? 0 : response.seatbid.length; + var seatbidLength = typeof response.seatbid === 'undefined' ? 0 : response.seatbid.length; for (var i = 0; i < seatbidLength; i++) { for (var j = 0; j < response.seatbid[i].bid.length; j++) { var bid = response.seatbid[i].bid[j]; - if (typeof bid.ext !== "object" || typeof bid.ext.pricelevel !== "string") { + if (typeof bid.ext !== 'object' || typeof bid.ext.pricelevel !== 'string') { continue; } - if (typeof _IndexRequestData.impIDToSlotID[response.id][bid.impid] === "undefined") { + if (typeof _IndexRequestData.impIDToSlotID[response.id][bid.impid] === 'undefined') { continue; } var slotID = _IndexRequestData.impIDToSlotID[response.id][bid.impid]; var targetID; var noTargetModeTargetID; var targetPrefix; - if (typeof bid.ext.dealid === "string") { + if (typeof bid.ext.dealid === 'string') { if (targetMode === 1) { targetID = slotID + bid.ext.pricelevel; } else { - targetID = slotID + "_" + bid.ext.dealid; + targetID = slotID + '_' + bid.ext.dealid; } noTargetModeTargetID = slotID + '_' + bid.ext.dealid; targetPrefix = PRIVATE_MARKET + '_'; @@ -97,14 +97,13 @@ window.cygnus_index_parse_res = function(response) { allBids.push(impBid); } } - if (typeof callbackFn === "function") { + if (typeof callbackFn === 'function') { if (allBids.length === 0) { callbackFn(response.id); } else { callbackFn(response.id, allBids); } } - } } catch (e) {} @@ -141,7 +140,7 @@ window.headertag_render = function(doc, targetID, slotID) { window.cygnus_index_args = {}; -var cygnus_index_adunits = [[728, 90], [120, 600], [300, 250], [160, 600], [336, 280], [234, 60], [300, 600], [300, 50], [320, 50], [970, 250], [300, 1050], [970, 90], [180, 150]]; // jshint ignore:line +var cygnus_index_adunits = [[728, 90], [120, 600], [300, 250], [160, 600], [336, 280], [234, 60], [300, 600], [300, 50], [320, 50], [970, 250], [300, 1050], [970, 90], [180, 150]]; // jshint ignore:line var getIndexDebugMode = function() { return getParameterByName(CONSTANTS.INDEX_DEBUG_MODE.queryParam).toUpperCase(); @@ -242,7 +241,7 @@ var cygnus_index_start = function () { OpenRTBRequest.prototype.serialize = function () { var json = '{"id":"' + this.requestID + '","site":{"page":"' + quote(this.sitePage) + '"'; - if (typeof document.referrer === 'string' && document.referrer !== "") { + if (typeof document.referrer === 'string' && document.referrer !== '') { json += ',"ref":"' + quote(document.referrer) + '"'; } @@ -352,7 +351,7 @@ var cygnus_index_start = function () { } else { scriptSrc = window.location.protocol === 'https:' ? 'https://as-sec.casalemedia.com' : 'http://as.casalemedia.com'; } - var prebidVersion = encodeURIComponent("$prebid.version$"); + var prebidVersion = encodeURIComponent('$prebid.version$'); scriptSrc += '/cygnus?v=7&fn=cygnus_index_parse_res&s=' + this.siteID + '&r=' + jsonURI + '&pid=pb' + prebidVersion; if (typeof this.timeoutDelay === 'number' && this.timeoutDelay % 1 === 0 && this.timeoutDelay >= 0) { scriptSrc += '&t=' + this.timeoutDelay; @@ -417,18 +416,18 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() { window._IndexRequestData.reqOptions = {}; } // clear custom targets at the beginning of every request - _IndexRequestData.targetAggregate = {'open':{},'private':{}}; + _IndexRequestData.targetAggregate = {'open': {}, 'private': {}}; if (!utils.hasValidBidRequest(bidArr[0].params, requiredParams, ADAPTER_NAME)) { return; } - //Our standard is to always bid for all known slots. + // Our standard is to always bid for all known slots. cygnus_index_args.slots = []; var expectedBids = 0; - //Grab the slot level data for cygnus_index_args + // Grab the slot level data for cygnus_index_args for (var i = 0; i < bidArr.length; i++) { var bid = bidArr[i]; var sizeID = 0; @@ -454,15 +453,14 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() { } if (!validSize) { - utils.logMessage(ADAPTER_NAME + " slot excluded from request due to no valid sizes"); + utils.logMessage(ADAPTER_NAME + ' slot excluded from request due to no valid sizes'); continue; } var usingSizeSpecificSiteID = false; - // Check for size defined in bidder params + // Check for size defined in bidder params if (bid.params.size && bid.params.size instanceof Array) { - if (!(bid.sizes[j][0] == bid.params.size[0] && bid.sizes[j][1] == bid.params.size[1])) - continue; + if (!(bid.sizes[j][0] == bid.params.size[0] && bid.sizes[j][1] == bid.params.size[1])) { continue; } usingSizeSpecificSiteID = true; } @@ -470,10 +468,9 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() { cygnus_index_args.timeout = bid.params.timeout; } - var siteID = Number(bid.params.siteID); - if (typeof siteID !== "number" || siteID % 1 != 0 || siteID <= 0) { - utils.logMessage(ADAPTER_NAME + " slot excluded from request due to invalid siteID"); + if (typeof siteID !== 'number' || siteID % 1 != 0 || siteID <= 0) { + utils.logMessage(ADAPTER_NAME + ' slot excluded from request due to invalid siteID'); continue; } if (siteID && typeof cygnus_index_args.siteID === 'undefined') { @@ -483,8 +480,8 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() { if (utils.hasValidBidRequest(bid.params, requiredParams, ADAPTER_NAME)) { firstAdUnitCode = bid.placementCode; var slotID = bid.params[requiredParams[0]]; - if ( typeof slotID !== 'string' && typeof slotID !== 'number' ){ - utils.logError(ADAPTER_NAME + " bid contains invalid slot ID from " + bid.placementCode + ". Discarding slot"); + if (typeof slotID !== 'string' && typeof slotID !== 'number') { + utils.logError(ADAPTER_NAME + ' bid contains invalid slot ID from ' + bid.placementCode + '. Discarding slot'); continue } @@ -497,7 +494,7 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() { var slotName = usingSizeSpecificSiteID ? String(slotID) : slotID + '_' + sizeID; slotIdMap[slotName] = bid; - //Doesn't need the if(primary_request) conditional since we are using the mergeSlotInto function which is safe + // Doesn't need the if(primary_request) conditional since we are using the mergeSlotInto function which is safe cygnus_index_args.slots = mergeSlotInto({ id: slotName, width: size.width, @@ -540,7 +537,7 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() { utils.logError('Too many unique sizes on slots, will use the first 20.', ADAPTER_NAME); } - //bidmanager.setExpectedBidsCount(ADAPTER_CODE, expectedBids); + // bidmanager.setExpectedBidsCount(ADAPTER_CODE, expectedBids); adloader.loadScript(cygnus_index_start()); var responded = false; @@ -567,8 +564,8 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() { for (var cpmAndSlotId in indexObj) { var match = /^(T\d_)?(.+)_(\d+)$/.exec(cpmAndSlotId); // if parse fail, move to next bid - if (!(match)){ - utils.logError("Unable to parse " + cpmAndSlotId + ", skipping slot", ADAPTER_NAME); + if (!(match)) { + utils.logError('Unable to parse ' + cpmAndSlotId + ', skipping slot', ADAPTER_NAME); continue; } var tier = match[1] || ''; @@ -585,21 +582,19 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() { bid.width = slotObj.width; bid.height = slotObj.height; bid.siteID = slotObj.siteID; - if ( typeof _IndexRequestData.targetIDToResp === 'object' && typeof _IndexRequestData.targetIDToResp[cpmAndSlotId] === 'object' && typeof _IndexRequestData.targetIDToResp[cpmAndSlotId].dealID !== 'undefined' ) { - if (typeof _IndexRequestData.targetAggregate['private'][adUnitCode] === 'undefined') - _IndexRequestData.targetAggregate['private'][adUnitCode] = []; + if (typeof _IndexRequestData.targetIDToResp === 'object' && typeof _IndexRequestData.targetIDToResp[cpmAndSlotId] === 'object' && typeof _IndexRequestData.targetIDToResp[cpmAndSlotId].dealID !== 'undefined') { + if (typeof _IndexRequestData.targetAggregate['private'][adUnitCode] === 'undefined') { _IndexRequestData.targetAggregate['private'][adUnitCode] = []; } bid.dealId = _IndexRequestData.targetIDToResp[cpmAndSlotId].dealID; - _IndexRequestData.targetAggregate['private'][adUnitCode].push( slotID + "_" + _IndexRequestData.targetIDToResp[cpmAndSlotId].dealID ); + _IndexRequestData.targetAggregate['private'][adUnitCode].push(slotID + '_' + _IndexRequestData.targetIDToResp[cpmAndSlotId].dealID); } else { - if (typeof _IndexRequestData.targetAggregate['open'][adUnitCode] === 'undefined') - _IndexRequestData.targetAggregate['open'][adUnitCode] = []; - _IndexRequestData.targetAggregate['open'][adUnitCode].push( slotID + "_" + currentCPM ); + if (typeof _IndexRequestData.targetAggregate['open'][adUnitCode] === 'undefined') { _IndexRequestData.targetAggregate['open'][adUnitCode] = []; } + _IndexRequestData.targetAggregate['open'][adUnitCode].push(slotID + '_' + currentCPM); } bids.push(bid); } } - var currentBid = undefined; + var currentBid; if (bids.length > 0) { // Add all bid responses @@ -613,29 +608,27 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() { currentBid = bid; bidmanager.addBidResponse(adUnitCode, currentBid); } - } } catch (e) { utils.logError('Error calling index adapter', ADAPTER_NAME, e); logErrorBidResponse(); - } - finally { + } finally { // ensure that previous targeting mapping is cleared _IndexRequestData.targetIDToBid = {}; } - //slotIdMap is used to determine which slots will be bid on in a given request. - //Therefore it needs to be blanked after the request is handled, else we will submit 'bids' for the wrong ads. - slotIdMap={}; + // slotIdMap is used to determine which slots will be bid on in a given request. + // Therefore it needs to be blanked after the request is handled, else we will submit 'bids' for the wrong ads. + slotIdMap = {}; }; } /* Function in order to add a slot into the list if it hasn't been created yet, else it returns the same list. */ - function mergeSlotInto(slot,slotList){ - for(var i = 0; i < slotList.length; i++){ - if(slot.id === slotList[i].id){ + function mergeSlotInto(slot, slotList) { + for (var i = 0; i < slotList.length; i++) { + if (slot.id === slotList[i].id) { return slotList; } } @@ -656,11 +649,11 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() { } function logErrorBidResponse() { - //no bid response + // no bid response var bid = bidfactory.createBid(2); bid.bidderCode = ADAPTER_CODE; - //log error to first add unit + // log error to first add unit bidmanager.addBidResponse(firstAdUnitCode, bid); } diff --git a/src/adapters/inneractive.js b/src/adapters/inneractive.js index a4b24eeceec..77fb3999834 100644 --- a/src/adapters/inneractive.js +++ b/src/adapters/inneractive.js @@ -12,7 +12,7 @@ import {formatQS} from '../url'; const CONSTANTS = { ADAPTER_NAME: 'inneractive', V: 'IA-JS-HB-PBJS-1.0', - RECTANGLE_SIZE:{W: 300, H: 250}, + RECTANGLE_SIZE: {W: 300, H: 250}, SPOT_TYPES: { INTERSTITIAL: 'interstitial', @@ -32,9 +32,9 @@ const CONSTANTS = { }; let iaRef; -try{ +try { iaRef = window.top.document.referrer; -}catch(e){ +} catch (e) { iaRef = window.document.referrer; } @@ -43,23 +43,23 @@ try{ * @type {{defaultsQsParams: {v: (string|string), page: string, mw: boolean, hb: string}, stringToCamel: (function(*)), objectToCamel: (function(*=))}} */ const Helpers = { - defaultsQsParams: {v: CONSTANTS.V,page: encodeURIComponent(utils.getTopWindowUrl()),mw: true, hb: 'prebidjs'}, + defaultsQsParams: {v: CONSTANTS.V, page: encodeURIComponent(utils.getTopWindowUrl()), mw: true, hb: 'prebidjs'}, /** * Change string format from underscore to camelcase (e.g., APP_ID to appId) * @param str: string * @returns string */ - stringToCamel(str){ - if(str.indexOf('_') === -1){ + stringToCamel(str) { + if (str.indexOf('_') === -1) { const first = str.charAt(0); - if(first !== first.toLowerCase()){ + if (first !== first.toLowerCase()) { str = str.toLowerCase(); } return str; } str = str.toLowerCase(); - return str.replace(/(\_[a-z])/g, $1 => $1.toUpperCase().replace('_','')); + return str.replace(/(\_[a-z])/g, $1 => $1.toUpperCase().replace('_', '')); }, /** @@ -67,10 +67,10 @@ const Helpers = { * @param params: object * @returns object */ - objectToCamel(params){ + objectToCamel(params) { Object.keys(params).forEach(key => { const keyCamelCase = this.stringToCamel(key); - if(keyCamelCase !== key){ + if (keyCamelCase !== key) { params[keyCamelCase] = params[key]; delete params[key]; } @@ -88,8 +88,8 @@ const Tracker = { * Creates a tracking pixel * @param urls: Array */ - fire(urls){ - urls.forEach(url => url && ((new Image(1,1)).src = encodeURI(url))); + fire(urls) { + urls.forEach(url => url && ((new Image(1, 1)).src = encodeURI(url))); } }; @@ -109,14 +109,14 @@ const Reporter = { * The returned string is either http:// or https:// * @returns {string} */ - getPageProtocol(){ - if(!this.pageProtocol){ - this.pageProtocol = ('http:' === utils.getTopWindowLocation().protocol ? 'http:' : 'https:'); + getPageProtocol() { + if (!this.pageProtocol) { + this.pageProtocol = (utils.getTopWindowLocation().protocol === 'http:' ? 'http:' : 'https:'); } return this.pageProtocol; }, - getEventUrl(evtName, extraDetails){ + getEventUrl(evtName, extraDetails) { let eventsEndpoint = CONSTANTS.EVENTS_ENDPOINT_URL + '?table=' + ((evtName === this.errorEventName) ? 'mbwError' : 'mbwEvent'); let queryStringParams = this.eventQueryStringParams(extraDetails); const appId = extraDetails && extraDetails.appId; @@ -160,7 +160,7 @@ const Reporter = { * @type {{defaultsParams: *, serverParamNameBySettingParamName: {referrer: string, keywords: string, appId: string, portal: string, age: string, gender: string, isSecured: (boolean|null)}, toServerParams: (function(*)), unwantedValues: *[], getUrlParams: (function(*=))}} */ const Url = { - defaultsParams: Object.assign({}, Helpers.defaultsQsParams, {f: CONSTANTS.DISPLAY_AD,fs: false,ref: iaRef}), + defaultsParams: Object.assign({}, Helpers.defaultsQsParams, {f: CONSTANTS.DISPLAY_AD, fs: false, ref: iaRef}), serverParamNameBySettingParamName: { referrer: 'ref', keywords: 'k', @@ -176,12 +176,12 @@ const Url = { * @param params: object {k:v} * @returns object {k:v} */ - toServerParams(params){ + toServerParams(params) { const serverParams = {}; - for(const paramName in params){ - if(params.hasOwnProperty(paramName) && this.serverParamNameBySettingParamName.hasOwnProperty(paramName)){ + for (const paramName in params) { + if (params.hasOwnProperty(paramName) && this.serverParamNameBySettingParamName.hasOwnProperty(paramName)) { serverParams[this.serverParamNameBySettingParamName[paramName]] = params[paramName]; - }else{ + } else { serverParams[paramName] = params[paramName]; } } @@ -195,17 +195,17 @@ const Url = { * @param params: object {k:v} * @returns : object {k:v} */ - getUrlParams(params){ + getUrlParams(params) { const serverParams = this.toServerParams(params); const toQueryString = Object.assign({}, this.defaultsParams, serverParams); - for(const paramName in toQueryString){ - if(toQueryString.hasOwnProperty(paramName) && this.unwantedValues.indexOf(toQueryString[paramName]) !== -1){ + for (const paramName in toQueryString) { + if (toQueryString.hasOwnProperty(paramName) && this.unwantedValues.indexOf(toQueryString[paramName]) !== -1) { delete toQueryString[paramName]; } } toQueryString.fs = params.spotType === CONSTANTS.SPOT_TYPES.INTERSTITIAL; - if(params.spotType === CONSTANTS.SPOT_TYPES.RECTANGLE){ + if (params.spotType === CONSTANTS.SPOT_TYPES.RECTANGLE) { toQueryString.rw = CONSTANTS.RECTANGLE_SIZE.W; toQueryString.rh = CONSTANTS.RECTANGLE_SIZE.H; } @@ -236,20 +236,19 @@ const Http = { * @param xhr: XMLHttpRequest * @returns {} */ - getBidHeaders(xhr){ + getBidHeaders(xhr) { const headersData = {}; this.headers.forEach(headerName => headersData[headerName] = xhr.getResponseHeader(headerName)); return headersData; } }; - /** * InnerActiveAdapter for requesting bids * @class */ -class InnerActiveAdapter{ - constructor(){ +class InnerActiveAdapter { + constructor() { this.iaAdapter = Adapter.createNew(CONSTANTS.ADAPTER_NAME); this.bidByBidId = {}; } @@ -260,8 +259,8 @@ class InnerActiveAdapter{ * @returns {boolean} * @private */ - _isValidRequest(adSettings){ - if(adSettings && adSettings.appId && adSettings.spotType){ + _isValidRequest(adSettings) { + if (adSettings && adSettings.appId && adSettings.spotType) { return true; } utils.logError('bid requires appId'); @@ -274,7 +273,7 @@ class InnerActiveAdapter{ * @returns bid object * @private */ - _storeBidRequestDetails(bid){ + _storeBidRequestDetails(bid) { this.bidByBidId[bid.bidId] = bid; return bid; } @@ -285,7 +284,7 @@ class InnerActiveAdapter{ * @returns {type[]} * @private */ - _getBidDetails(bidStatus, bidResponse, bidId){ + _getBidDetails(bidStatus, bidResponse, bidId) { let bid = bidFactory.createBid(bidStatus, bidResponse); bid.code = CONSTANTS.ADAPTER_NAME; bid.bidderCode = bid.code; @@ -296,9 +295,9 @@ class InnerActiveAdapter{ return bid; } - _setBidCpm(bid, bidId){ + _setBidCpm(bid, bidId) { const storedBid = this.bidByBidId[bidId]; - if(storedBid){ + if (storedBid) { bid.cpm = storedBid.params && storedBid.params.qa && storedBid.params.qa.cpm || bid.cpm; bid.cpm = (bid.cpm !== null && !isNaN(bid.cpm)) ? parseFloat(bid.cpm) : 0.0; } @@ -311,7 +310,7 @@ class InnerActiveAdapter{ * @returns {boolean} * @private */ - _isValidBidResponse(responseAsJson, headersData){ + _isValidBidResponse(responseAsJson, headersData) { return (responseAsJson && responseAsJson.ad && responseAsJson.ad.html && headersData && headersData[CONSTANTS.RESPONSE_HEADERS_NAME.PRICING_VALUE] > 0); } @@ -322,7 +321,7 @@ class InnerActiveAdapter{ * @param bidId: string * @private */ - _onResponse(response, xhr, bidId){ + _onResponse(response, xhr, bidId) { const bid = this.bidByBidId[bidId]; const [w, h] = bid.sizes[0]; const size = {w, h}; @@ -338,14 +337,14 @@ class InnerActiveAdapter{ let errorMessage = `response failed for ${CONSTANTS.ADAPTER_NAME} adapter`; utils.logError(errorMessage); const passback = responseAsJson && responseAsJson.config && responseAsJson.config.passback; - if(passback) { + if (passback) { Tracker.fire([passback]); } Reporter.reportEvent('HBPreBidNoAd', bid.params); return bidManager.addBidResponse(bid.placementCode, this._getBidDetails(STATUS.NO_BID)); } const bidResponse = { - cpm: headersData[CONSTANTS.RESPONSE_HEADERS_NAME.PRICING_VALUE]*1000, + cpm: headersData[CONSTANTS.RESPONSE_HEADERS_NAME.PRICING_VALUE] * 1000, width: parseFloat(headersData[CONSTANTS.RESPONSE_HEADERS_NAME.AD_W]) || size.w, ad: this._getAd(responseAsJson.ad.html, responseAsJson.config.tracking, bid.params), height: parseFloat(headersData[CONSTANTS.RESPONSE_HEADERS_NAME.AD_H]) || size.h @@ -364,17 +363,16 @@ class InnerActiveAdapter{ * @returns {string}: create template * @private */ - _getAd(adHtml, tracking, bidParams){ - + _getAd(adHtml, tracking, bidParams) { let impressionsHtml = ''; - if(tracking && Array.isArray(tracking.impressions)){ + if (tracking && Array.isArray(tracking.impressions)) { let impressions = tracking.impressions; impressions.push(Reporter.getEventUrl('HBPreBidImpression', bidParams, false)); impressions.forEach(impression => impression && (impressionsHtml += utils.createTrackPixelHtml(impression))); } adHtml = impressionsHtml + adHtml.replace(/ this._toIaBidParams(bid)); bids @@ -428,14 +426,14 @@ class InnerActiveAdapter{ .forEach(bid => ajax(this._getEndpointUrl(bid.params), (response, xhr) => this._onResponse(response, xhr, bid.bidId), Url.getUrlParams(bid.params), {method: 'GET'})); } - _getEndpointUrl(params){ + _getEndpointUrl(params) { return params && params.qa && params.qa.url || Reporter.getPageProtocol() + CONSTANTS.ENDPOINT_URL; } - _getStoredBids(){ + _getStoredBids() { const storedBids = []; - for(const bidId in this.bidByBidId){ - if(this.bidByBidId.hasOwnProperty(bidId)) { + for (const bidId in this.bidByBidId) { + if (this.bidByBidId.hasOwnProperty(bidId)) { storedBids.push(this.bidByBidId[bidId]); } } @@ -447,7 +445,7 @@ class InnerActiveAdapter{ * @returns {{Reporter: {errorEventName: string, pageProtocol: string, getPageProtocol: (function(): string), getEventUrl: (function(*, *=)), reportEvent: (function(string, Object)), defaults: {v: (string|string), page: string, mw: boolean, hb: string}, eventQueryStringParams: (function(Object): string), createTrackingPixel: (function(string))}}} * @private */ - static _getUtils(){ + static _getUtils() { return {Reporter}; } @@ -455,7 +453,7 @@ class InnerActiveAdapter{ * Creates new instance of InnerActiveAdapter for prebid auction * @returns {InnerActiveAdapter} */ - static createNew(){ + static createNew() { return new InnerActiveAdapter(); } } diff --git a/src/adapters/innity.js b/src/adapters/innity.js index 0f877f6f8a1..b49f297e8e6 100644 --- a/src/adapters/innity.js +++ b/src/adapters/innity.js @@ -5,9 +5,8 @@ var utils = require('../utils.js'); var CONSTANTS = require('../constants.json'); var InnityAdapter = function InnityAdapter() { - function _callBids(params) { - var bidURL, bids = params.bids || [], requestURL = window.location.protocol + '//as.innity.com/synd/?cb=' + new Date().getTime() + '&ver=2&hb=1&output=js&'; + var bidURL, bids = params.bids || [], requestURL = window.location.protocol + '//as.innity.com/synd/?cb=' + new Date().getTime() + '&ver=2&hb=1&output=js&'; for (var i = 0; i < bids.length; i++) { var requestParams = {}, bid = bids[i]; requestParams.pub = bid.params.pub; @@ -19,7 +18,7 @@ var InnityAdapter = function InnityAdapter() { requestParams.width = arrSize[0]; requestParams.height = arrSize[1]; // Callback function - requestParams.callback = "$$PREBID_GLOBAL$$._doInnityCallback"; + requestParams.callback = '$$PREBID_GLOBAL$$._doInnityCallback'; // Callback ID requestParams.callback_uid = bid.bidId; // Load Bidder URL @@ -28,9 +27,9 @@ var InnityAdapter = function InnityAdapter() { adloader.loadScript(bidURL); } } - + $$PREBID_GLOBAL$$._doInnityCallback = function(response) { - var bidObject, bidRequest, callbackID, libURL = window.location.protocol + "//cdn.innity.net/frame_util.js"; + var bidObject, bidRequest, callbackID, libURL = window.location.protocol + '//cdn.innity.net/frame_util.js'; callbackID = response.callback_uid; bidRequest = utils.getBidRequest(callbackID); if (response.cpm > 0) { @@ -53,4 +52,4 @@ var InnityAdapter = function InnityAdapter() { }; }; -module.exports = InnityAdapter; \ No newline at end of file +module.exports = InnityAdapter; diff --git a/src/adapters/jcm.js b/src/adapters/jcm.js index 54c24839a70..cb429156dac 100644 --- a/src/adapters/jcm.js +++ b/src/adapters/jcm.js @@ -3,9 +3,7 @@ var bidmanager = require('src/bidmanager.js'); var adloader = require('src/adloader.js'); var utils = require('src/utils.js'); - var JCMAdapter = function JCMAdapter() { - window.pbjs = window.pbjs || {}; window.pbjs.processJCMResponse = function(JCMResponse) { if (JCMResponse) { @@ -23,8 +21,7 @@ var JCMAdapter = function JCMAdapter() { bidObject.width = bid.width; bidObject.height = bid.height; bidmanager.addBidResponse(utils.getBidRequest(bid.callbackId).placementCode, bidObject); - } - else { + } else { bidObject = bidfactory.createBid(2); bidObject.bidderCode = 'jcm'; bidmanager.addBidResponse(utils.getBidRequest(bid.callbackId).placementCode, bidObject); @@ -35,14 +32,12 @@ var JCMAdapter = function JCMAdapter() { }; function _callBids(params) { - var BidRequest = { bids: [] }; for (var i = 0; i < params.bids.length; i++) { - - var adSizes = ""; + var adSizes = ''; var bid = params.bids[i]; for (var x = 0; x < bid.sizes.length; x++) { adSizes += utils.parseGPTSingleSizeArray(bid.sizes[x]); @@ -51,23 +46,21 @@ var JCMAdapter = function JCMAdapter() { } } - BidRequest.bids.push({ - "callbackId" : bid.bidId, - "siteId" : bid.params.siteId, - "adSizes" : adSizes + 'callbackId': bid.bidId, + 'siteId': bid.params.siteId, + 'adSizes': adSizes }); } var JSONStr = JSON.stringify(BidRequest); - var reqURL = document.location.protocol+"//media.adfrontiers.com/pq?t=hb&bids=" + encodeURIComponent(JSONStr); + var reqURL = document.location.protocol + '//media.adfrontiers.com/pq?t=hb&bids=' + encodeURIComponent(JSONStr); adloader.loadScript(reqURL); } return { callBids: _callBids }; - }; module.exports = JCMAdapter; diff --git a/src/adapters/komoona.js b/src/adapters/komoona.js index 318c69bd24a..33fb798facb 100644 --- a/src/adapters/komoona.js +++ b/src/adapters/komoona.js @@ -8,7 +8,6 @@ import { STATUS } from 'src/constants'; const ENDPOINT = '//bidder.komoona.com/v1/GetSBids'; function KomoonaAdapter() { - let baseAdapter = Adapter.createNew('komoona'); let bidRequests = {}; @@ -35,7 +34,7 @@ function KomoonaAdapter() { ajax(ENDPOINT, handleResponse, payload, { contentType: 'text/plain', - withCredentials : true + withCredentials: true }); } }; @@ -52,7 +51,7 @@ function KomoonaAdapter() { if (!parsed || parsed.error) { let errorMessage = `in response for ${baseAdapter.getBidderCode()} adapter`; - if (parsed && parsed.error) {errorMessage += `: ${parsed.error}`;} + if (parsed && parsed.error) { errorMessage += `: ${parsed.error}`; } utils.logError(errorMessage); // signal this response is complete diff --git a/src/adapters/lifestreet.js b/src/adapters/lifestreet.js index a28b2da7e0c..f1a5f14669d 100644 --- a/src/adapters/lifestreet.js +++ b/src/adapters/lifestreet.js @@ -52,7 +52,7 @@ const LifestreetAdapter = function LifestreetAdapter() { function _callJSTag(bid, jstagUrl, timeout) { adloader.loadScript(jstagUrl, () => { - /*global LSM_Slot */ + /* global LSM_Slot */ if (LSM_Slot && typeof LSM_Slot === 'function') { let slotTagParams = { _preload: 'wait', @@ -82,7 +82,7 @@ const LifestreetAdapter = function LifestreetAdapter() { slotTagParams[property] = bid.params[property]; } } - /*jshint newcap: false */ + /* jshint newcap: false */ LSM_Slot(slotTagParams); window.addEventListener('message', (ev) => { let key = ev.message ? 'message' : 'data'; @@ -149,7 +149,7 @@ const LifestreetAdapter = function LifestreetAdapter() { window.addEventListener('message', receivedLSMMessage, false); window.parent.postMessage(JSON.stringify({ message: '` + PREBID_REQUEST_MESSAGE + `', - slotName: '` + slotName +`' + slotName: '` + slotName + `' }), '*'); `; } @@ -161,4 +161,4 @@ const LifestreetAdapter = function LifestreetAdapter() { }; }; -module.exports = LifestreetAdapter; \ No newline at end of file +module.exports = LifestreetAdapter; diff --git a/src/adapters/mantis.js b/src/adapters/mantis.js index 6ca3faa0bca..f4bb2f56e41 100644 --- a/src/adapters/mantis.js +++ b/src/adapters/mantis.js @@ -51,11 +51,11 @@ module.exports = function () { } function isAmp() { - return typeof window.context === "object" && (window.context.tagName === "AMP-AD" || window.context.tagName === "AMP-EMBED"); + return typeof window.context === 'object' && (window.context.tagName === 'AMP-AD' || window.context.tagName === 'AMP-EMBED'); } function isSecure() { - return document.location.protocol === "https:"; + return document.location.protocol === 'https:'; } function isArray(value) { @@ -109,7 +109,6 @@ module.exports = function () { return parts.join('&'); } - function buildMantisUrl(path, data, domain) { var params = { referrer: document.referrer, @@ -221,4 +220,4 @@ module.exports = function () { }; return new Prebid(bidfactory, bidmanager, adloader, constants); -}; \ No newline at end of file +}; diff --git a/src/adapters/memeglobal.js b/src/adapters/memeglobal.js index 9eb7f297d97..1f70d18e666 100644 --- a/src/adapters/memeglobal.js +++ b/src/adapters/memeglobal.js @@ -79,11 +79,10 @@ var MemeGlobalAdapter = function MemeGlobalAdapter() { // expose the callback to the global object: $$PREBID_GLOBAL$$.mgres = function (bidResp) { - // valid object? if ((!bidResp || !bidResp.id) || (!bidResp.seatbid || bidResp.seatbid.length === 0 || !bidResp.seatbid[0].bid || bidResp.seatbid[0].bid.length === 0)) { - return ; + return; } bidResp.seatbid[0].bid.forEach(function (bidderBid) { diff --git a/src/adapters/nginad.js b/src/adapters/nginad.js index 8488fa513cb..f13d8340d69 100644 --- a/src/adapters/nginad.js +++ b/src/adapters/nginad.js @@ -10,7 +10,6 @@ var defaultPlacementForBadBid = null; * Adapter for requesting bids from NginAd */ var NginAdAdapter = function NginAdAdapter() { - var rtbServerDomain = 'placeholder.for.nginad.server.com'; function _callBids(params) { @@ -40,7 +39,6 @@ var NginAdAdapter = function NginAdAdapter() { } function getWidthAndHeight(bid) { - var adW = null; var adH = null; @@ -63,11 +61,10 @@ var NginAdAdapter = function NginAdAdapter() { var nginadImps = []; - //assign the first adUnit (placement) for bad bids; + // assign the first adUnit (placement) for bad bids; defaultPlacementForBadBid = bidReqs[0].placementCode; - - //build impression array for nginad + // build impression array for nginad utils._each(bidReqs, function(bid) { var tagId = utils.getBidIdParameter('pzoneid', bid.params); var bidFloor = utils.getBidIdParameter('bidfloor', bid.params); @@ -85,10 +82,9 @@ var NginAdAdapter = function NginAdAdapter() { }; nginadImps.push(imp); - //bidmanager.pbCallbackMap[imp.id] = bid; + // bidmanager.pbCallbackMap[imp.id] = bid; rtbServerDomain = bid.params.nginadDomain; - }); // build bid request with impressions @@ -108,7 +104,7 @@ var NginAdAdapter = function NginAdAdapter() { } function handleErrorResponse(bidReqs, defaultPlacementForBadBid) { - //no response data + // no response data if (defaultPlacementForBadBid === null) { // no id with which to create an dummy bid return; @@ -119,7 +115,7 @@ var NginAdAdapter = function NginAdAdapter() { bidmanager.addBidResponse(defaultPlacementForBadBid, bid); } - //expose the callback to the global object: + // expose the callback to the global object: $$PREBID_GLOBAL$$.nginadResponse = function(nginadResponseObj) { var bid = {}; var key; @@ -134,7 +130,6 @@ var NginAdAdapter = function NginAdAdapter() { } for (key in nginadResponseObj.seatbid[0].bid) { - var nginadBid = nginadResponseObj.seatbid[0].bid[key]; var responseCPM; @@ -142,7 +137,7 @@ var NginAdAdapter = function NginAdAdapter() { var id = nginadBid.impid; // try to fetch the bid request we sent NginAd - /*jshint -W083 */ + /* jshint -W083 */ var bidObj = $$PREBID_GLOBAL$$._bidsRequested.find(bidSet => bidSet.bidderCode === 'nginad').bids .find(bid => bid.bidId === id); if (!bidObj) { @@ -152,7 +147,7 @@ var NginAdAdapter = function NginAdAdapter() { placementCode = bidObj.placementCode; bidObj.status = CONSTANTS.STATUS.GOOD; - //place ad response on bidmanager._adResponsesByBidderId + // place ad response on bidmanager._adResponsesByBidderId responseCPM = parseFloat(nginadBid.price); if (responseCPM === 0) { @@ -163,14 +158,14 @@ var NginAdAdapter = function NginAdAdapter() { nginadBid.size = bidObj.sizes; var responseAd = nginadBid.adm; - //store bid response - //bid status is good (indicating 1) + // store bid response + // bid status is good (indicating 1) bid = bidfactory.createBid(1); bid.creative_id = nginadBid.Id; bid.bidderCode = 'nginad'; bid.cpm = responseCPM; - //The bid is a mock bid, the true bidding process happens after the publisher tag is called + // The bid is a mock bid, the true bidding process happens after the publisher tag is called bid.ad = decodeURIComponent(responseAd); var whArr = getWidthAndHeight(bidObj); @@ -178,9 +173,7 @@ var NginAdAdapter = function NginAdAdapter() { bid.height = whArr[1]; bidmanager.addBidResponse(placementCode, bid); - } - }; // nginadResponse return { diff --git a/src/adapters/openx.js b/src/adapters/openx.js index 42314e7f286..009dde53707 100644 --- a/src/adapters/openx.js +++ b/src/adapters/openx.js @@ -29,7 +29,7 @@ const OpenxAdapter = function OpenxAdapter() { // find the adunit in the response for (let j = 0; j < adUnits.length; j++) { adUnit = adUnits[j]; - if (String(bid.params.unit) === String(adUnit.adunitid) && adUnitHasValidSizeFromBid(adUnit,bid) && !adUnit.used) { + if (String(bid.params.unit) === String(adUnit.adunitid) && adUnitHasValidSizeFromBid(adUnit, bid) && !adUnit.used) { auid = adUnit.adunitid; break; } @@ -38,7 +38,7 @@ const OpenxAdapter = function OpenxAdapter() { let beaconParams = { bd: +(new Date()) - startTime, br: '0', // maybe 0, t, or p - bt: $$PREBID_GLOBAL$$.cbTimeout || $$PREBID_GLOBAL$$.bidderTimeout , // For the timeout per bid request + bt: $$PREBID_GLOBAL$$.cbTimeout || $$PREBID_GLOBAL$$.bidderTimeout, // For the timeout per bid request bs: window.location.hostname }; @@ -69,8 +69,7 @@ const OpenxAdapter = function OpenxAdapter() { try { tWin = window.top; tDoc = window.top.document; - } - catch (e) { + } catch (e) { return; } docEl = tDoc.documentElement; @@ -90,8 +89,8 @@ const OpenxAdapter = function OpenxAdapter() { function makePDCall(pixelsUrl) { let pdFrame = utils.createInvisibleIframe(); let name = 'openx-pd'; - pdFrame.setAttribute("id", name); - pdFrame.setAttribute("name", name); + pdFrame.setAttribute('id', name); + pdFrame.setAttribute('name', name); let rootNode = document.body; if (!rootNode) { @@ -182,7 +181,7 @@ const OpenxAdapter = function OpenxAdapter() { bids.forEach(function (bid) { for (let customParam in bid.params.customParams) { if (bid.params.customParams.hasOwnProperty(customParam)) { - params["c." + customParam] = bid.params.customParams[customParam]; + params['c.' + customParam] = bid.params.customParams[customParam]; } } }); @@ -200,8 +199,7 @@ const OpenxAdapter = function OpenxAdapter() { currentURL = currentURL && encodeURIComponent(currentURL); try { isIfr = window.self !== window.top; - } - catch (e) { + } catch (e) { isIfr = false; } if (bids.length === 0) { diff --git a/src/adapters/piximedia.js b/src/adapters/piximedia.js index f0d9c1e8143..b075259fae9 100644 --- a/src/adapters/piximedia.js +++ b/src/adapters/piximedia.js @@ -11,16 +11,14 @@ var PiximediaAdapter = function PiximediaAdapter() { var bidStash = {}; var tryAppendPixiQueryString = function(url, name, value) { - return url + "/" + encodeURIComponent(name) + "=" + value; + return url + '/' + encodeURIComponent(name) + '=' + value; }; baseAdapter.callBids = function callBidsPiximedia(params) { utils._each(params.bids, function(bid) { - // valid bids must include a siteId and an placementId if (bid.placementCode && bid.sizes && bid.params && bid.params.siteId && bid.params.placementId) { - - var sizes = bid.params.hasOwnProperty('sizes')? bid.params.sizes: bid.sizes; + var sizes = bid.params.hasOwnProperty('sizes') ? bid.params.sizes : bid.sizes; sizes = utils.parseSizesInput(sizes); var cbid = utils.getUniqueIdentifierStr(); @@ -29,32 +27,32 @@ var PiximediaAdapter = function PiximediaAdapter() { var url = bid.params.prebidUrl || PREBID_URL; // params are passed to the Piximedia endpoint, including custom params - for(var key in bid.params) { + for (var key in bid.params) { /* istanbul ignore else */ - if(bid.params.hasOwnProperty(key)) { + if (bid.params.hasOwnProperty(key)) { var value = bid.params[key]; - switch(key) { - case "siteId": + switch (key) { + case 'siteId': url = tryAppendPixiQueryString(url, 'site_id', encodeURIComponent(value)); break; - case "placementId": + case 'placementId': url = tryAppendPixiQueryString(url, 'placement_id', encodeURIComponent(value)); break; - case "dealId": + case 'dealId': url = tryAppendPixiQueryString(url, 'l_id', encodeURIComponent(value)); break; - case "sizes": - case "prebidUrl": + case 'sizes': + case 'prebidUrl': break; default: - if(typeof value === "function") { - url = tryAppendPixiQueryString(url, key, encodeURIComponent((value(baseAdapter, params, bid) || "").toString())); + if (typeof value === 'function') { + url = tryAppendPixiQueryString(url, key, encodeURIComponent((value(baseAdapter, params, bid) || '').toString())); } else { - url = tryAppendPixiQueryString(url, key, encodeURIComponent((value || "").toString())); + url = tryAppendPixiQueryString(url, key, encodeURIComponent((value || '').toString())); } break; } @@ -62,7 +60,7 @@ var PiximediaAdapter = function PiximediaAdapter() { } url = tryAppendPixiQueryString(url, 'jsonp', '$$PREBID_GLOBAL$$.handlePiximediaCallback'); - url = tryAppendPixiQueryString(url, 'sizes', encodeURIComponent(sizes.join(","))); + url = tryAppendPixiQueryString(url, 'sizes', encodeURIComponent(sizes.join(','))); url = tryAppendPixiQueryString(url, 'cbid', encodeURIComponent(cbid)); url = tryAppendPixiQueryString(url, 'rand', String(Math.floor(Math.random() * 1000000000))); @@ -92,7 +90,7 @@ var PiximediaAdapter = function PiximediaAdapter() { * */ $$PREBID_GLOBAL$$.handlePiximediaCallback = function(bidResponse) { - if (bidResponse && bidResponse.hasOwnProperty("foundbypm")) { + if (bidResponse && bidResponse.hasOwnProperty('foundbypm')) { var stash = bidStash[bidResponse.cbid]; // retrieve our stashed data, by using the cbid var bid; @@ -102,7 +100,6 @@ var PiximediaAdapter = function PiximediaAdapter() { timelapsed = timelapsed - stash.start; if (bidResponse.foundbypm && bidResponse.width && bidResponse.height && bidResponse.html && bidResponse.cpm && bidResponse.currency) { - /* we have a valid ad to display */ bid = bidfactory.createBid(CONSTANTS.STATUS.GOOD); bid.bidderCode = bidObj.bidder; @@ -126,7 +123,6 @@ var PiximediaAdapter = function PiximediaAdapter() { ' CPM: ' + String(bid.cpm) + ' ' + bid.currency + ' Format: ' + String(bid.width) + 'x' + String(bid.height)); } else { - /* we have no ads to display */ bid = bidfactory.createBid(CONSTANTS.STATUS.NO_BID); bid.bidderCode = bidObj.bidder; @@ -139,7 +135,6 @@ var PiximediaAdapter = function PiximediaAdapter() { // We should no longer need this stashed object, so drop reference: bidStash[bidResponse.cbid] = null; - } else { utils.logMessage("[Piximedia] Couldn't find stash for cbid=" + bidResponse.cbid); } diff --git a/src/adapters/prebidServer.js b/src/adapters/prebidServer.js index b646d8735d2..3acb7d67965 100644 --- a/src/adapters/prebidServer.js +++ b/src/adapters/prebidServer.js @@ -11,25 +11,25 @@ const cookiePersistMessage = `Your browser may be blocking 3rd party cookies. By const cookiePersistUrl = '//ib.adnxs.com/seg?add=1&redir='; const paramTypes = { - "appnexus" : { - "member" : "string", - "invCode" : "string", - "placementId" : "number" + 'appnexus': { + 'member': 'string', + 'invCode': 'string', + 'placementId': 'number' }, - "rubicon" : { - "accountId" : "number", - "siteId" : "number", - "zoneId" : "number" + 'rubicon': { + 'accountId': 'number', + 'siteId': 'number', + 'zoneId': 'number' }, - "indexExchange" : { - "siteID" : "number" + 'indexExchange': { + 'siteID': 'number' }, - "audienceNetwork" : { - "placementId" : "string" + 'audienceNetwork': { + 'placementId': 'string' }, - "pubmatic" : { - "publisherId" : "string", - "adSlot" : "string" + 'pubmatic': { + 'publisherId': 'string', + 'adSlot': 'string' } }; @@ -37,7 +37,6 @@ const paramTypes = { * Bidder adapter for Prebid Server */ function PrebidServer() { - let baseAdapter = Adapter.createNew('prebidServer'); let config; @@ -50,12 +49,12 @@ function PrebidServer() { adUnit.bids.forEach(bid => { const types = paramTypes[bid.bidder] || []; Object.keys(types).forEach(key => { - if(bid.params[key] && typeof bid.params[key] !== types[key]) { - //mismatch type. Try to fix + if (bid.params[key] && typeof bid.params[key] !== types[key]) { + // mismatch type. Try to fix utils.logMessage(`Mismatched type for Prebid Server : ${bid.bidder} : ${key}. Required Type:${types[key]}`); bid.params[key] = tryConvertType(types[key], bid.params[key]); - //don't send invalid values - if(isNaN(bid.params[key])) { + // don't send invalid values + if (isNaN(bid.params[key])) { delete bid.params.key; } } @@ -65,10 +64,10 @@ function PrebidServer() { } function tryConvertType(typeToConvert, value) { - if(typeToConvert === 'string') { + if (typeToConvert === 'string') { return value && value.toString(); } - if(typeToConvert === 'number') { + if (typeToConvert === 'number') { return Number(value); } } @@ -78,20 +77,20 @@ function PrebidServer() { const isDebug = !!$$PREBID_GLOBAL$$.logging; convertTypes(bidRequest.ad_units); let requestJson = { - account_id : config.accountId, - tid : bidRequest.tid, + account_id: config.accountId, + tid: bidRequest.tid, max_bids: config.maxBids, - timeout_millis : config.timeout, + timeout_millis: config.timeout, url: utils.getTopWindowUrl(), - prebid_version : '$prebid.version$', - ad_units : bidRequest.ad_units.filter(hasSizes), - is_debug : isDebug + prebid_version: '$prebid.version$', + ad_units: bidRequest.ad_units.filter(hasSizes), + is_debug: isDebug }; const payload = JSON.stringify(requestJson); ajax(config.endpoint, handleResponse, payload, { contentType: 'text/plain', - withCredentials : true + withCredentials: true }); }; @@ -106,10 +105,10 @@ function PrebidServer() { try { result = JSON.parse(response); - if(result.status === 'OK') { - if(result.bidder_status) { + if (result.status === 'OK') { + if (result.bidder_status) { result.bidder_status.forEach(bidder => { - if(bidder.no_bid) { + if (bidder.no_bid) { // store a "No Bid" bid response let bidObject = bidfactory.createBid(STATUS.NO_BID, { @@ -119,13 +118,13 @@ function PrebidServer() { bidObject.bidderCode = bidder.bidder; bidmanager.addBidResponse(bidObject.adUnitCode, bidObject); } - if(bidder.no_cookie) { + if (bidder.no_cookie) { // if no cookie is present then no bids were made, we don't store a bid response - queueSync({bidder: bidder.bidder, url : bidder.usersync.url, type : bidder.usersync.type}); + queueSync({bidder: bidder.bidder, url: bidder.usersync.url, type: bidder.usersync.type}); } }); } - if(result.bids) { + if (result.bids) { result.bids.forEach(bidObj => { let bidRequest = utils.getBidRequest(bidObj.bid_id); let cpm = bidObj.price; @@ -149,7 +148,7 @@ function PrebidServer() { } } else if (result.status === 'no_cookie') { - //cookie sync + // cookie sync persist(cookiePersistUrl, cookiePersistMessage); } } catch (error) { @@ -162,13 +161,12 @@ function PrebidServer() { } return { - setConfig : baseAdapter.setConfig, + setConfig: baseAdapter.setConfig, createNew: PrebidServer.createNew, callBids: baseAdapter.callBids, setBidderCode: baseAdapter.setBidderCode, - type : TYPE + type: TYPE }; - } PrebidServer.createNew = function() { diff --git a/src/adapters/pubgears.js b/src/adapters/pubgears.js index 6d487826a75..2da723606c0 100644 --- a/src/adapters/pubgears.js +++ b/src/adapters/pubgears.js @@ -43,20 +43,19 @@ function PubGearsAdapter() { function callBids(params) { var bids = params[consts.JSON_MAPPING.PL_BIDS]; - var slots = bids.map(getSlotFromBidParam) ; - if(slots.length <= 0) - return; + var slots = bids.map(getSlotFromBidParam); + if (slots.length <= 0) + { return; } publisher = bids[0][PARAMS][PUBLISHER_PARAM]; bids.forEach(function(bid) { - var name = getSlotFromBidParam(bid); pendingSlots[ name ] = bid; }); proxy = proxy || getScript(SCRIPT_ID) || makeScript(slots, publisher, SCRIPT_ID, TAG_URL); - if(!initialized) - registerEventListeners(proxy); + if (!initialized) + { registerEventListeners(proxy); } initialized = true; } function loadScript(script) { @@ -74,7 +73,7 @@ function PubGearsAdapter() { } function getSlotFromResource(resource) { var size = resource[SIZE]; - var key = [ resource[PUB_ZONE], size ].join('@'); + var key = [ resource[PUB_ZONE], size ].join('@'); return key; } function getSize(bid) { @@ -85,7 +84,7 @@ function PubGearsAdapter() { function makeScript(slots, publisher, id, url) { var script = d.createElement(SCRIPT); script.src = url; - script.id = id ; + script.id = id; script.setAttribute(ATTRIBUTE_PREFIX + SLOT_LIST_ATTRIBUTE, slots.join(' ')); script.setAttribute(ATTRIBUTE_PREFIX + FLAG_ATTRIBUTE, 'true'); script.setAttribute(ATTRIBUTE_PREFIX + PUBLISHER_ATTRIBUTE, publisher); @@ -106,11 +105,11 @@ function PubGearsAdapter() { var adUnitCode = bidRequest[PLACEMENT_CODE]; var bid = null; - if(bidRequest) { + if (bidRequest) { bid = buildResponse(data, bidRequest); bidmanager.addBidResponse(adUnitCode, bid); utils.logMessage('adding bid respoonse to "' + adUnitCode + '" for bid request "' + bidRequest[BID_ID] + '"'); - }else { + } else { utils.logError('Cannot get placement id for slot "' + slotKey + '"'); } } @@ -123,12 +122,12 @@ function PubGearsAdapter() { var response = bidfactory.createBid(status, bidRequest); response[BIDDER_CODE_RESPONSE_KEY] = BIDDER_CODE; - if(status !== 1) - return response; + if (status !== 1) + { return response; } response[AD] = getCreative(resource); - response[CPM] = price / 1e3 ; + response[CPM] = price / 1e3; response[WIDTH] = dims[0]; response[HEIGHT] = dims[1]; return response; diff --git a/src/adapters/pubmatic.js b/src/adapters/pubmatic.js index 3f0a54be2cb..44fb9bf97fc 100644 --- a/src/adapters/pubmatic.js +++ b/src/adapters/pubmatic.js @@ -9,7 +9,6 @@ var bidmanager = require('../bidmanager.js'); * @constructor */ var PubmaticAdapter = function PubmaticAdapter() { - var bids; var _pm_pub_id; var _pm_optimize_adslots = []; @@ -20,7 +19,7 @@ var PubmaticAdapter = function PubmaticAdapter() { _pm_optimize_adslots = []; for (var i = 0; i < bids.length; i++) { var bid = bids[i]; - //bidmanager.pbCallbackMap['' + bid.params.adSlot] = bid; + // bidmanager.pbCallbackMap['' + bid.params.adSlot] = bid; _pm_pub_id = _pm_pub_id || bid.params.publisherId; _pm_optimize_adslots.push(bid.params.adSlot); } @@ -30,14 +29,12 @@ var PubmaticAdapter = function PubmaticAdapter() { } function _getBids() { - - - //create the iframe + // create the iframe iframe = utils.createInvisibleIframe(); var elToAppend = document.getElementsByTagName('head')[0]; - //insert the iframe into document + // insert the iframe into document elToAppend.insertBefore(iframe, elToAppend.firstChild); var iframeDoc = utils.getIframeDocument(iframe); @@ -78,8 +75,7 @@ var PubmaticAdapter = function PubmaticAdapter() { try { bidDetailsMap = iframe.contentWindow.bidDetailsMap; progKeyValueMap = iframe.contentWindow.progKeyValueMap; - } - catch(e) { + } catch (e) { utils.logError(e, 'Error parsing Pubmatic response'); } @@ -137,7 +133,6 @@ var PubmaticAdapter = function PubmaticAdapter() { return { callBids: _callBids }; - }; module.exports = PubmaticAdapter; diff --git a/src/adapters/pulsepoint.js b/src/adapters/pulsepoint.js index e206c32550a..9a426bc5815 100644 --- a/src/adapters/pulsepoint.js +++ b/src/adapters/pulsepoint.js @@ -4,7 +4,6 @@ var adloader = require('../adloader.js'); var utils = require('../utils.js'); var PulsePointAdapter = function PulsePointAdapter() { - var getJsStaticUrl = window.location.protocol + '//tag-st.contextweb.com/getjs.static.js'; var bidUrl = window.location.protocol + '//bid.contextweb.com/header/tag'; @@ -28,8 +27,8 @@ var PulsePointAdapter = function PulsePointAdapter() { try { var ppBidRequest = new window.pp.Ad(bidRequestOptions(bidRequest)); ppBidRequest.display(); - } catch(e) { - //register passback on any exceptions while attempting to fetch response. + } catch (e) { + // register passback on any exceptions while attempting to fetch response. utils.logError('pulsepoint.requestBid', 'ERROR', e); bidResponseAvailable(bidRequest); } @@ -44,8 +43,8 @@ var PulsePointAdapter = function PulsePointAdapter() { adUnitId: bidRequest.placementCode, callback: callback }; - for(var param in bidRequest.params) { - if(bidRequest.params.hasOwnProperty(param)) { + for (var param in bidRequest.params) { + if (bidRequest.params.hasOwnProperty(param)) { options[param] = bidRequest.params[param]; } } @@ -78,7 +77,6 @@ var PulsePointAdapter = function PulsePointAdapter() { return { callBids: _callBids }; - }; module.exports = PulsePointAdapter; diff --git a/src/adapters/pulsepointLite.js b/src/adapters/pulsepointLite.js index 49900bc2c08..be2fc01934a 100644 --- a/src/adapters/pulsepointLite.js +++ b/src/adapters/pulsepointLite.js @@ -1,11 +1,10 @@ import {createBid} from 'src/bidfactory'; import {addBidResponse} from 'src/bidmanager'; -import {logError,getTopWindowLocation} from 'src/utils'; +import {logError, getTopWindowLocation} from 'src/utils'; import {ajax} from 'src/ajax'; import {STATUS} from 'src/constants'; function PulsePointLiteAdapter() { - const bidUrl = window.location.protocol + '//bid.contextweb.com/header/tag?'; const ajaxOptions = { method: 'GET', @@ -21,8 +20,8 @@ function PulsePointLiteAdapter() { ajax(url, (bidResponse) => { bidResponseAvailable(bidRequest, bidResponse); }, null, ajaxOptions); - } catch(e) { - //register passback on any exceptions while attempting to fetch response. + } catch (e) { + // register passback on any exceptions while attempting to fetch response. logError('pulsepoint.requestBid', 'ERROR', e); bidResponseAvailable(bidRequest); } @@ -55,7 +54,7 @@ function PulsePointLiteAdapter() { function bidResponseAvailable(bidRequest, rawResponse) { if (rawResponse) { var bidResponse = parse(rawResponse); - if(bidResponse) { + if (bidResponse) { var adSize = bidRequest.params.cf.toUpperCase().split('X'); var bid = createBid(STATUS.GOOD, bidRequest); bid.bidderCode = bidRequest.bidder; @@ -84,7 +83,6 @@ function PulsePointLiteAdapter() { return { callBids: _callBids }; - } module.exports = PulsePointLiteAdapter; diff --git a/src/adapters/quantcast.js b/src/adapters/quantcast.js index cbf6f1c9028..1cdbbac00c1 100644 --- a/src/adapters/quantcast.js +++ b/src/adapters/quantcast.js @@ -6,47 +6,45 @@ const CONSTANTS = require('../constants.json'); const QUANTCAST_CALLBACK_URL = 'http://global.qc.rtb.quantserve.com:8080/qchb'; var QuantcastAdapter = function QuantcastAdapter() { - const BIDDER_CODE = 'quantcast'; const DEFAULT_BID_FLOOR = 0.0000000001; let bidRequests = {}; let returnEmptyBid = function(bidId) { - var bidRequested = utils.getBidRequest(bidId); - if (!utils.isEmpty(bidRequested)) { - let bid = bidfactory.createBid(CONSTANTS.STATUS.NO_BID, bidRequested); - bid.bidderCode = BIDDER_CODE; - bidmanager.addBidResponse(bidRequested.placementCode, bid); - } - return; - }; + var bidRequested = utils.getBidRequest(bidId); + if (!utils.isEmpty(bidRequested)) { + let bid = bidfactory.createBid(CONSTANTS.STATUS.NO_BID, bidRequested); + bid.bidderCode = BIDDER_CODE; + bidmanager.addBidResponse(bidRequested.placementCode, bid); + } + }; - //expose the callback to the global object: + // expose the callback to the global object: $$PREBID_GLOBAL$$.handleQuantcastCB = function (responseText) { - if(utils.isEmpty(responseText)) { + if (utils.isEmpty(responseText)) { return; } let response = null; try { response = JSON.parse(responseText); - } catch(e) { + } catch (e) { // Malformed JSON utils.logError("Malformed JSON received from server - can't do anything here"); return; } - if(response === null || !response.hasOwnProperty('bids') || utils.isEmpty(response.bids)) { + if (response === null || !response.hasOwnProperty('bids') || utils.isEmpty(response.bids)) { utils.logError("Sub-optimal JSON received from server - can't do anything here"); return; } - for(let i = 0; i < response.bids.length; i++) { + for (let i = 0; i < response.bids.length; i++) { let seatbid = response.bids[i]; let key = seatbid.placementCode; var request = bidRequests[key]; - if(request === null || request === undefined) { + if (request === null || request === undefined) { return returnEmptyBid(seatbid.placementCode); } // This line is required since this is the field @@ -64,7 +62,6 @@ var QuantcastAdapter = function QuantcastAdapter() { bidmanager.addBidResponse(request.bidId, responseBid); } - }; function callBids(params) { @@ -84,34 +81,34 @@ var QuantcastAdapter = function QuantcastAdapter() { var bidSizes = []; utils._each(bid.sizes, function (size) { bidSizes.push({ - 'width' : size[0], - 'height' : size[1] + 'width': size[0], + 'height': size[1] }); }); bidRequests[key] = bidRequests[key] || { - 'publisherId' : publisherId, - 'requestId' : bid.bidId, - 'bidId' : bid.bidId, - 'site' : { - 'page' : loc.href, - 'referrer' : referrer, - 'domain' : domain, + 'publisherId': publisherId, + 'requestId': bid.bidId, + 'bidId': bid.bidId, + 'site': { + 'page': loc.href, + 'referrer': referrer, + 'domain': domain, }, - 'imp' : [{ + 'imp': [{ - 'banner' : { - 'battr' : bid.params.battr, - 'sizes' : bidSizes, + 'banner': { + 'battr': bid.params.battr, + 'sizes': bidSizes, }, - 'placementCode' : bid.placementCode, - 'bidFloor' : bid.params.bidFloor || DEFAULT_BID_FLOOR, + 'placementCode': bid.placementCode, + 'bidFloor': bid.params.bidFloor || DEFAULT_BID_FLOOR, }] }; utils._each(bidRequests, function (bidRequest) { ajax.ajax(QUANTCAST_CALLBACK_URL, $$PREBID_GLOBAL$$.handleQuantcastCB, JSON.stringify(bidRequest), { - method : 'POST', + method: 'POST', withCredentials: true }); }); diff --git a/src/adapters/rhythmone.js b/src/adapters/rhythmone.js index c8e81d110e3..17264350009 100644 --- a/src/adapters/rhythmone.js +++ b/src/adapters/rhythmone.js @@ -2,93 +2,92 @@ var bidmanager = require('../bidmanager.js'), bidfactory = require('../bidfactory.js'), CONSTANTS = require('../constants.json'); -import {ajax as ajax} from '../ajax'; +import {ajax} from '../ajax'; -module.exports = function(bidManager, global, loader){ - - var version = "0.9.0.0", - defaultZone = "1r", - defaultPath = "mvo", +module.exports = function(bidManager, global, loader) { + var version = '0.9.0.0', + defaultZone = '1r', + defaultPath = 'mvo', debug = false, requestCompleted = false, placementCodes = {}, - loadStart, - configuredPlacements = [], - fat = /(^v|(\.0)+$)/gi; + loadStart, + configuredPlacements = [], + fat = /(^v|(\.0)+$)/gi; - if(typeof global === "undefined") - global = window; + if (typeof global === 'undefined') + { global = window; } - if(typeof bidManager === "undefined") - bidManager = bidmanager; + if (typeof bidManager === 'undefined') + { bidManager = bidmanager; } - if(typeof loader === "undefined") - loader = ajax; + if (typeof loader === 'undefined') + { loader = ajax; } - function applyMacros(txt, values){ - return txt.replace(/\{([^\}]+)\}/g, function(match){ - var v = values[match.replace(/[\{\}]/g, "").toLowerCase()]; - if(typeof v !== "undefined") return v; + function applyMacros(txt, values) { + return txt.replace(/\{([^\}]+)\}/g, function(match) { + var v = values[match.replace(/[\{\}]/g, '').toLowerCase()]; + if (typeof v !== 'undefined') return v; return match; }); } - function load(bidParams, url, callback){ - loader(url, function(responseText, response){ - if(response.status === 200) - callback(200, "success", response.responseText); + function load(bidParams, url, callback) { + loader(url, function(responseText, response) { + if (response.status === 200) + { callback(200, 'success', response.responseText); } else - callback(-1, "http error "+response.status, response.responseText); - }, false, {method:"GET", withCredentials: true}); + { callback(-1, 'http error ' + response.status, response.responseText); } + }, false, {method: 'GET', withCredentials: true}); } - function flashInstalled(){ + function flashInstalled() { var n = global.navigator, p = n.plugins, m = n.mimeTypes, - t = "application/x-shockwave-flash", + t = 'application/x-shockwave-flash', x = global.ActiveXObject; - if(p && - p["Shockwave Flash"] && + if (p && + p['Shockwave Flash'] && m && m[t] && m[t].enabledPlugin) - return true; + { return true; } - if(x){ - try{if((new global.ActiveXObject("ShockwaveFlash.ShockwaveFlash"))) return true;} - catch(e){} + if (x) { + try { if ((new global.ActiveXObject('ShockwaveFlash.ShockwaveFlash'))) return true; } + catch (e) {} } return false; } - var bidderCode = "rhythmone"; + var bidderCode = 'rhythmone'; - function attempt(valueFunction, defaultValue){ - try{ + function attempt(valueFunction, defaultValue) { + try { return valueFunction(); - }catch(ex){} + } catch (ex) {} return defaultValue; } - function logToConsole(txt){ - if(debug) - console.log(txt); + function logToConsole(txt) { + if (debug) + { console.log(txt); } } - function getBidParameters(bids){ - for(var i=0;i 0) - return d[d.length-1]; - return global.top.document.location.hostname; // try/catch is in the attempt function - },"")); - p("title", attempt(function(){return global.top.document.title;},"")); // try/catch is in the attempt function - p("url", attempt(function(){ - var l; - try{l = global.top.document.location.href.toString();} // try/catch is in the attempt function - catch(ex){l = global.document.location.href.toString();} - return l; - },"")); - p("dsh", (global.screen ? global.screen.height : "")); - p("dsw", (global.screen ? global.screen.width : "")); - p("tz", (new Date()).getTimezoneOffset()); - p("dtype", ((/(ios|ipod|ipad|iphone|android)/i).test(global.navigator.userAgent) ? 1 : ((/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(global.navigator.userAgent) ? 3 : 2))); - p("flash", (flashInstalled() ? 1 : 0)); + p('domain', attempt(function() { + var d = global.document.location.ancestorOrigins; + if (d && d.length > 0) + { return d[d.length - 1]; } + return global.top.document.location.hostname; // try/catch is in the attempt function + }, '')); + p('title', attempt(function() { return global.top.document.title; }, '')); // try/catch is in the attempt function + p('url', attempt(function() { + var l; + try { l = global.top.document.location.href.toString(); } // try/catch is in the attempt function + catch (ex) { l = global.document.location.href.toString(); } + return l; + }, '')); + p('dsh', (global.screen ? global.screen.height : '')); + p('dsw', (global.screen ? global.screen.width : '')); + p('tz', (new Date()).getTimezoneOffset()); + p('dtype', ((/(ios|ipod|ipad|iphone|android)/i).test(global.navigator.userAgent) ? 1 : ((/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(global.navigator.userAgent) ? 3 : 2))); + p('flash', (flashInstalled() ? 1 : 0)); var heights = [], widths = [], floors = [], mediaTypes = [], - i=0; + i = 0; configuredPlacements = []; - p("hbv", global.$$PREBID_GLOBAL$$.version.replace(fat,"")+","+version.replace(fat,"")); - - for(; i 0 && typeof bids[i].sizes[0] === "number") - bids[i].sizes = [bids[i].sizes]; + if (bids[i].sizes.length > 0 && typeof bids[i].sizes[0] === 'number') + { bids[i].sizes = [bids[i].sizes]; } - for(var j = 0; j 0){ - data.ancestor_origins = ao[ao.length-1]; + if (ao && ao.length > 0) { + data.ancestor_origins = ao[ao.length - 1]; } - data.popped = window.opener!==null?1:0; - data.framed = window.top===window?0:1; + data.popped = window.opener !== null ? 1 : 0; + data.framed = window.top === window ? 0 : 1; - try{ + try { data.url = window.top.document.location.href.toString(); - }catch(ex){ + } catch (ex) { data.url = window.document.location.href.toString(); } var prebid_instance = global.$$PREBID_GLOBAL$$; - data.prebid_version = prebid_instance.version.replace(fat,""); + data.prebid_version = prebid_instance.version.replace(fat, ''); data.response_ms = (new Date()).getTime() - loadStart; - data.placement_codes = configuredPlacements.join(","); + data.placement_codes = configuredPlacements.join(','); data.bidder_version = version; data.prebid_timeout = prebid_instance.cbTimeout || prebid_instance.bidderTimeout; - for(var k in data){ - q.push(encodeURIComponent(k)+"="+encodeURIComponent((typeof data[k] === "object" ? JSON.stringify(data[k]) : data[k]))); + for (var k in data) { + q.push(encodeURIComponent(k) + '=' + encodeURIComponent((typeof data[k] === 'object' ? JSON.stringify(data[k]) : data[k]))); } q.sort(); - i.src = u+q.join("&"); + i.src = u + q.join('&'); } - this.callBids = function(params){ - + this.callBids = function(params) { var slotMap = {}, bidParams = getBidParameters(params.bids); debug = (bidParams !== null && bidParams.debug === true); - if(bidParams === null){ + if (bidParams === null) { noBids(params); return; } - for(var i = 0; i sizeMap[item] = key); function RubiconAdapter() { - function _callBids(bidderRequest) { var bids = bidderRequest.bids || []; @@ -100,7 +99,7 @@ function RubiconAdapter() { } ); } - } catch(err) { + } catch (err) { utils.logError('Error sending rubicon request for placement code ' + bid.placementCode, null, err); addErrorBid(); } @@ -141,17 +140,17 @@ function RubiconAdapter() { let params = bid.params; - if(!params || typeof params.video !== 'object') { + if (!params || typeof params.video !== 'object') { throw 'Invalid Video Bid'; } let size; - if(params.video.playerWidth && params.video.playerHeight) { + if (params.video.playerWidth && params.video.playerHeight) { size = [ params.video.playerWidth, params.video.playerHeight ]; - } else if( + } else if ( Array.isArray(bid.sizes) && bid.sizes.length > 0 && Array.isArray(bid.sizes[0]) && bid.sizes[0].length > 1 ) { @@ -160,9 +159,9 @@ function RubiconAdapter() { throw 'Invalid Video Bid - No size provided'; } - let postData = { + let postData = { page_url: !params.referrer ? utils.getTopWindowUrl() : params.referrer, - resolution: _getScreenResolution(), + resolution: _getScreenResolution(), account_id: params.accountId, integration: getIntegration(), timeout: bidderRequest.timeout - (Date.now() - bidderRequest.auctionStart + TIMEOUT_BUFFER), @@ -185,27 +184,27 @@ function RubiconAdapter() { }; // check and add inventory, keywords, visitor and size_id data - if(params.video.size_id) { + if (params.video.size_id) { slotData.size_id = params.video.size_id; } else { throw 'Invalid Video Bid - Invalid Ad Type!'; } - if(params.inventory && typeof params.inventory === 'object') { + if (params.inventory && typeof params.inventory === 'object') { slotData.inventory = params.inventory; } - if(params.keywords && Array.isArray(params.keywords)) { + if (params.keywords && Array.isArray(params.keywords)) { slotData.keywords = params.keywords; } - if(params.visitor && typeof params.visitor === 'object') { + if (params.visitor && typeof params.visitor === 'object') { slotData.visitor = params.visitor; } postData.slots.push(slotData); - return(JSON.stringify(postData)); + return (JSON.stringify(postData)); } function buildOptimizedCall(bid) { @@ -229,15 +228,15 @@ function RubiconAdapter() { position = position || 'btf'; // use rubicon sizes if provided, otherwise adUnit.sizes - var parsedSizes = RubiconAdapter.masSizeOrdering(Array.isArray(bid.params.sizes) ? - bid.params.sizes.map(size => (sizeMap[size] || '').split('x')) : bid.sizes + var parsedSizes = RubiconAdapter.masSizeOrdering(Array.isArray(bid.params.sizes) + ? bid.params.sizes.map(size => (sizeMap[size] || '').split('x')) : bid.sizes ); - if(parsedSizes.length < 1) { + if (parsedSizes.length < 1) { throw 'no valid sizes'; } - if(!/^\d+$/.test(accountId)) { + if (!/^\d+$/.test(accountId)) { throw 'invalid accountId provided'; } @@ -257,11 +256,11 @@ function RubiconAdapter() { 'tk_user_key', userId ]; - if(visitor !== null && typeof visitor === 'object') { + if (visitor !== null && typeof visitor === 'object') { utils._each(visitor, (item, key) => queryString.push(`tg_v.${key}`, item)); } - if(inventory !== null && typeof inventory === 'object') { + if (inventory !== null && typeof inventory === 'object') { utils._each(inventory, (item, key) => queryString.push(`tg_i.${key}`, item)); } @@ -272,8 +271,8 @@ function RubiconAdapter() { return queryString.reduce( (memo, curr, index) => - index % 2 === 0 && queryString[index + 1] !== undefined ? - memo + curr + '=' + encodeURIComponent(queryString[index + 1]) + '&' : memo, + index % 2 === 0 && queryString[index + 1] !== undefined + ? memo + curr + '=' + encodeURIComponent(queryString[index + 1]) + '&' : memo, FASTLANE_ENDPOINT + '?' ).slice(0, -1); // remove trailing & } @@ -290,11 +289,11 @@ function RubiconAdapter() { function handleRpCB(responseText, bidRequest) { var responseObj = JSON.parse(responseText), // can throw - ads = responseObj.ads, - adResponseKey = bidRequest.placementCode; + ads = responseObj.ads, + adResponseKey = bidRequest.placementCode; // check overall response - if(typeof responseObj !== 'object' || responseObj.status !== 'ok') { + if (typeof responseObj !== 'object' || responseObj.status !== 'ok') { throw 'bad response'; } @@ -304,7 +303,7 @@ function RubiconAdapter() { } // check the ad response - if(!Array.isArray(ads) || ads.length < 1) { + if (!Array.isArray(ads) || ads.length < 1) { throw 'invalid ad response'; } @@ -312,12 +311,12 @@ function RubiconAdapter() { ads = ads.sort(_adCpmSort); ads.forEach(ad => { - if(ad.status !== 'ok') { + if (ad.status !== 'ok') { throw 'bad ad status'; } - //store bid response - //bid status is good (indicating 1) + // store bid response + // bid status is good (indicating 1) var bid = bidfactory.createBid(STATUS.GOOD, bidRequest); bid.creative_id = ad.ad_id; bid.bidderCode = bidRequest.bidder; @@ -366,7 +365,7 @@ RubiconAdapter.masSizeOrdering = function(sizes) { // map sizes while excluding non-matches .reduce((result, size) => { let mappedSize = parseInt(sizeMap[size], 10); - if(mappedSize) { + if (mappedSize) { result.push(mappedSize); } return result; @@ -374,13 +373,13 @@ RubiconAdapter.masSizeOrdering = function(sizes) { .sort((first, second) => { // sort by MAS_SIZE_PRIORITY priority order let firstPriority = MAS_SIZE_PRIORITY.indexOf(first), - secondPriority = MAS_SIZE_PRIORITY.indexOf(second); + secondPriority = MAS_SIZE_PRIORITY.indexOf(second); - if(firstPriority > -1 || secondPriority > -1) { - if(firstPriority === -1) { + if (firstPriority > -1 || secondPriority > -1) { + if (firstPriority === -1) { return 1; } - if(secondPriority === -1) { + if (secondPriority === -1) { return -1; } return firstPriority - secondPriority; diff --git a/src/adapters/sekindoUM.js b/src/adapters/sekindoUM.js index f6c3d423742..62be5c2095d 100755 --- a/src/adapters/sekindoUM.js +++ b/src/adapters/sekindoUM.js @@ -7,23 +7,19 @@ var adloader = require('../adloader.js'); var sekindoUMAdapter; sekindoUMAdapter = function sekindoUMAdapter() { - function _callBids(params) { var bids = params.bids; var bidsCount = bids.length; var pubUrl = null; - if (parent !== window) - pubUrl = document.referrer; - else - pubUrl = window.location.href; + if (parent !== window) { pubUrl = document.referrer; } else { pubUrl = window.location.href; } for (var i = 0; i < bidsCount; i++) { var bidReqeust = bids[i]; var callbackId = bidReqeust.bidId; _requestBids(bidReqeust, callbackId, pubUrl); - //store a reference to the bidRequest from the callback id - //bidmanager.pbCallbackMap[callbackId] = bidReqeust; + // store a reference to the bidRequest from the callback id + // bidmanager.pbCallbackMap[callbackId] = bidReqeust; } } @@ -36,7 +32,6 @@ sekindoUMAdapter = function sekindoUMAdapter() { var placementCode = bidObj.placementCode; if (response.cpm !== undefined && response.cpm > 0) { - bid = bidfactory.createBid(CONSTANTS.STATUS.GOOD); bid.callback_uid = callbackId; bid.bidderCode = bidCode; @@ -47,35 +42,29 @@ sekindoUMAdapter = function sekindoUMAdapter() { bid.height = response.height; bidmanager.addBidResponse(placementCode, bid); - } - - else { + } else { bid = bidfactory.createBid(CONSTANTS.STATUS.NO_BID); bid.callback_uid = callbackId; bid.bidderCode = bidCode; bidmanager.addBidResponse(placementCode, bid); } } - } - - else { + } else { if (bidObj) { - utils.logMessage('No prebid response for placement '+bidObj.placementCode); - } - - else { + utils.logMessage('No prebid response for placement ' + bidObj.placementCode); + } else { utils.logMessage('sekindoUM callback general error'); } } }; function _requestBids(bid, callbackId, pubUrl) { - //determine tag params + // determine tag params var spaceId = utils.getBidIdParameter('spaceId', bid.params); var subId = utils.getBidIdParameter('subId', bid.params); var bidfloor = utils.getBidIdParameter('bidfloor', bid.params); - var protocol = ('https:' === document.location.protocol ? 's' : ''); - var scriptSrc = 'http'+protocol+'://hb.sekindo.com/live/liveView.php?'; + var protocol = (document.location.protocol === 'https:' ? 's' : ''); + var scriptSrc = 'http' + protocol + '://hb.sekindo.com/live/liveView.php?'; scriptSrc = utils.tryAppendQueryString(scriptSrc, 's', spaceId); scriptSrc = utils.tryAppendQueryString(scriptSrc, 'subId', subId); @@ -96,4 +85,3 @@ sekindoUMAdapter = function sekindoUMAdapter() { }; module.exports = sekindoUMAdapter; - diff --git a/src/adapters/serverbid.js b/src/adapters/serverbid.js index 74b731bbe3f..a7ba5f6a57e 100644 --- a/src/adapters/serverbid.js +++ b/src/adapters/serverbid.js @@ -5,48 +5,45 @@ import * as utils from 'src/utils'; import { ajax } from 'src/ajax'; const ServerBidAdapter = function ServerBidAdapter() { - const baseAdapter = Adapter.createNew('serverbid'); const BASE_URI = '//e.serverbid.com/api/v2'; const sizeMap = [null, - "120x90", - "120x90", - "468x60", - "728x90", - "300x250", - "160x600", - "120x600", - "300x100", - "180x150", - "336x280", - "240x400", - "234x60", - "88x31", - "120x60", - "120x240", - "125x125", - "220x250", - "250x250", - "250x90", - "0x0", - "200x90", - "300x50", - "320x50", - "320x480", - "185x185", - "620x45", - "300x125", - "800x250" + '120x90', + '120x90', + '468x60', + '728x90', + '300x250', + '160x600', + '120x600', + '300x100', + '180x150', + '336x280', + '240x400', + '234x60', + '88x31', + '120x60', + '120x240', + '125x125', + '220x250', + '250x250', + '250x90', + '0x0', + '200x90', + '300x50', + '320x50', + '320x480', + '185x185', + '620x45', + '300x125', + '800x250' ]; const bidIds = []; baseAdapter.callBids = function(params) { - if (params && params.bids && utils.isArray(params.bids) && params.bids.length) { - const data = { placements: [], time: Date.now(), @@ -77,19 +74,15 @@ const ServerBidAdapter = function ServerBidAdapter() { if (bid_data.networkId && bid_data.siteId) { data.placements.push(bid_data); } - } if (data.placements.length) { ajax(BASE_URI, _responseCallback, JSON.stringify(data), { method: 'POST', withCredentials: true, contentType: 'application/json' }); } - } - }; function _responseCallback(result) { - let bid; let bidId; let bidObj; @@ -103,7 +96,6 @@ const ServerBidAdapter = function ServerBidAdapter() { } for (let i = 0; i < bidIds.length; i++) { - bidId = bidIds[i]; bidObj = utils.getBidRequest(bidId); bidCode = bidObj.bidder; @@ -124,7 +116,6 @@ const ServerBidAdapter = function ServerBidAdapter() { bid = bidfactory.createBid(2, bidObj); bid.bidderCode = bidCode; } - } else { bid = bidfactory.createBid(2, bidObj); bid.bidderCode = bidCode; @@ -140,7 +131,7 @@ const ServerBidAdapter = function ServerBidAdapter() { function getSize(sizes) { const result = []; sizes.forEach(function(size) { - const index = sizeMap.indexOf(size[0] + "x" + size[1]); + const index = sizeMap.indexOf(size[0] + 'x' + size[1]); if (index >= 0) { result.push(index); } @@ -153,11 +144,10 @@ const ServerBidAdapter = function ServerBidAdapter() { return { callBids: baseAdapter.callBids }; - }; ServerBidAdapter.createNew = function() { return new ServerBidAdapter(); }; -module.exports = ServerBidAdapter; \ No newline at end of file +module.exports = ServerBidAdapter; diff --git a/src/adapters/sharethrough.js b/src/adapters/sharethrough.js index fd5c3072816..c8d4ca12e2d 100644 --- a/src/adapters/sharethrough.js +++ b/src/adapters/sharethrough.js @@ -3,14 +3,13 @@ var bidmanager = require('../bidmanager.js'); var bidfactory = require('../bidfactory.js'); var ajax = require('../ajax.js').ajax; -const STR_BIDDER_CODE = "sharethrough"; -const STR_VERSION = "1.2.0"; +const STR_BIDDER_CODE = 'sharethrough'; +const STR_VERSION = '1.2.0'; var SharethroughAdapter = function SharethroughAdapter() { - const str = {}; - str.STR_BTLR_HOST = document.location.protocol + "//btlr.sharethrough.com"; - str.STR_BEACON_HOST = document.location.protocol + "//b.sharethrough.com/butler?"; + str.STR_BTLR_HOST = document.location.protocol + '//btlr.sharethrough.com'; + str.STR_BEACON_HOST = document.location.protocol + '//b.sharethrough.com/butler?'; str.placementCodeSet = {}; str.ajax = ajax; @@ -37,7 +36,7 @@ var SharethroughAdapter = function SharethroughAdapter() { let host = str.STR_BTLR_HOST; - let url = host + "/header-bid/v1?"; + let url = host + '/header-bid/v1?'; url = utils.tryAppendQueryString(url, 'bidId', bid.bidId); url = utils.tryAppendQueryString(url, 'placement_key', pkey); url = appendEnvFields(url); @@ -100,7 +99,7 @@ var SharethroughAdapter = function SharethroughAdapter() { return { callBids: _callBids, - str : str, + str: str, }; }; diff --git a/src/adapters/smartadserver.js b/src/adapters/smartadserver.js index 5708e4047ab..ae5ec38844c 100644 --- a/src/adapters/smartadserver.js +++ b/src/adapters/smartadserver.js @@ -1,12 +1,12 @@ -var utils = require("../utils.js"); -var bidfactory = require("../bidfactory.js"); -var bidmanager = require("../bidmanager.js"); -var adloader = require("src/adloader.js"); -var url = require("url"); +var utils = require('../utils.js'); +var bidfactory = require('../bidfactory.js'); +var bidmanager = require('../bidmanager.js'); +var adloader = require('src/adloader.js'); +var url = require('url'); var SmartAdServer = function SmartAdServer() { var generateCallback = function(bid) { - var callbackId = "sas_" + utils.getUniqueIdentifierStr(); + var callbackId = 'sas_' + utils.getUniqueIdentifierStr(); $$PREBID_GLOBAL$$[callbackId] = function(adUnit) { var bidObject; if (adUnit) { @@ -35,18 +35,18 @@ var SmartAdServer = function SmartAdServer() { for (var i = 0; i < params.bids.length; i++) { var bid = params.bids[i]; var adCall = url.parse(bid.params.domain); - adCall.pathname = "/prebid"; + adCall.pathname = '/prebid'; adCall.search = { - "pbjscbk": "pbjs." + generateCallback(bid), - "siteid": bid.params.siteId, - "pgid": bid.params.pageId, - "fmtid": bid.params.formatId, - "ccy": bid.params.currency || "USD", - "bidfloor": bid.params.bidfloor || 0.0, - "tgt": encodeURIComponent(bid.params.target || ''), - "tag": bid.placementCode, - "sizes": bid.sizes.map(size => size[0] + "x" + size[1]).join(","), - "async": 1 + 'pbjscbk': 'pbjs.' + generateCallback(bid), + 'siteid': bid.params.siteId, + 'pgid': bid.params.pageId, + 'fmtid': bid.params.formatId, + 'ccy': bid.params.currency || 'USD', + 'bidfloor': bid.params.bidfloor || 0.0, + 'tgt': encodeURIComponent(bid.params.target || ''), + 'tag': bid.placementCode, + 'sizes': bid.sizes.map(size => size[0] + 'x' + size[1]).join(','), + 'async': 1 }; adloader.loadScript(url.format(adCall)); } diff --git a/src/adapters/smartyads.js b/src/adapters/smartyads.js index 2f2ce8c28ad..8416f90a701 100755 --- a/src/adapters/smartyads.js +++ b/src/adapters/smartyads.js @@ -44,9 +44,7 @@ var sizeMap = { utils._each(sizeMap, (item, key) => sizeMap[item] = key); function SmartyadsAdapter() { - function _callBids(bidderRequest) { - var bids = bidderRequest.bids || []; bids.forEach((bid) => { @@ -57,18 +55,17 @@ function SmartyadsAdapter() { } function bidCallback(responseText) { - try { utils.logMessage('XHR callback function called for ad ID: ' + bid.bidId); handleRpCB(responseText, bid); } catch (err) { - if (typeof err === "string") { + if (typeof err === 'string') { utils.logWarn(`${err} when processing smartyads response for placement code ${bid.placementCode}`); } else { utils.logError('Error processing smartyads response for placement code ' + bid.placementCode, null, err); } - //indicate that there is no bid for this placement + // indicate that there is no bid for this placement let badBid = bidfactory.createBid(STATUS.NO_BID, bid); badBid.bidderCode = bid.bidder; badBid.error = err; @@ -79,7 +76,6 @@ function SmartyadsAdapter() { } function buildOptimizedCall(bid) { - bid.startTime = new Date().getTime(); // use smartyads sizes if provided, otherwise adUnit.sizes @@ -88,7 +84,7 @@ function SmartyadsAdapter() { ); if (parsedSizes.length < 1) { - throw "no valid sizes"; + throw 'no valid sizes'; } var secure; @@ -109,27 +105,25 @@ function SmartyadsAdapter() { 'size_ad', parsedSizes[0], 'alt_size_ad', parsedSizes.slice(1).join(',') || undefined, 'host', host, - "page", page, - "language", language, - "deviceWidth", deviceWidth, - "deviceHeight", deviceHeight, - "secure", secure, - "bidId", bid.bidId, - "checkOn", 'rf' + 'page', page, + 'language', language, + 'deviceWidth', deviceWidth, + 'deviceHeight', deviceHeight, + 'secure', secure, + 'bidId', bid.bidId, + 'checkOn', 'rf' ]; return queryString.reduce( (memo, curr, index) => - index % 2 === 0 && queryString[index + 1] !== undefined ? - memo + curr + '=' + encodeURIComponent(queryString[index + 1]) + '&' + index % 2 === 0 && queryString[index + 1] !== undefined + ? memo + curr + '=' + encodeURIComponent(queryString[index + 1]) + '&' : memo, '//ssp-nj.webtradehub.com/?' ).slice(0, -1); - } function handleRpCB(responseText, bidRequest) { - let ad = JSON.parse(responseText); // can throw var bid = bidfactory.createBid(STATUS.GOOD, bidRequest); @@ -151,7 +145,6 @@ function SmartyadsAdapter() { } SmartyadsAdapter.masSizeOrdering = function (sizes) { - const MAS_SIZE_PRIORITY = [15, 2, 9]; return utils.parseSizesInput(sizes) @@ -186,4 +179,4 @@ SmartyadsAdapter.createNew = function () { return new SmartyadsAdapter(); }; -module.exports = SmartyadsAdapter; \ No newline at end of file +module.exports = SmartyadsAdapter; diff --git a/src/adapters/sonobi.js b/src/adapters/sonobi.js index cca84bb8829..cfec52257cf 100644 --- a/src/adapters/sonobi.js +++ b/src/adapters/sonobi.js @@ -3,11 +3,11 @@ var bidmanager = require('../bidmanager.js'); var adloader = require('../adloader.js'); var utils = require('../utils'); -var SonobiAdapter = function SonobiAdapter(){ +var SonobiAdapter = function SonobiAdapter() { var keymakerAssoc = {}; // Remember placement codes for callback mapping var bidReqAssoc = {}; // Remember bids for bid complete reporting - function _phone_in(request){ + function _phone_in(request) { var trinity = 'https://apex.go.sonobi.com/trinity.js?key_maker='; var adSlots = request.bids || []; var bidderRequestId = request.bidderRequestId; @@ -15,34 +15,34 @@ var SonobiAdapter = function SonobiAdapter(){ adloader.loadScript(trinity + JSON.stringify(_keymaker(adSlots)) + '&cv=' + _operator(bidderRequestId) + ref); } - function _keymaker(adSlots){ + function _keymaker(adSlots) { var keyring = {}; - utils._each(adSlots, function(bidRequest){ - if(bidRequest.params){ + utils._each(adSlots, function(bidRequest) { + if (bidRequest.params) { // Optional var floor = (bidRequest.params.floor) ? bidRequest.params.floor : null; // Mandatory var slotIdentifier = (bidRequest.params.ad_unit) ? bidRequest.params.ad_unit : (bidRequest.params.placement_id) ? bidRequest.params.placement_id : null; var sizes = (bidRequest.params.sizes) ? bidRequest.params.sizes : bidRequest.sizes || null; sizes = utils.parseSizesInput(sizes).toString(); - - if (utils.isEmpty(sizes)){ + + if (utils.isEmpty(sizes)) { utils.logError('Sonobi adapter expects sizes for ' + bidRequest.placementCode); } var bidId = bidRequest.bidId; var args = (sizes) ? ((floor) ? (sizes + '|f=' + floor) : (sizes)) : (floor) ? ('f=' + floor) : ''; - if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)){ + if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)) { slotIdentifier = slotIdentifier.charAt(0) === '/' ? slotIdentifier : '/' + slotIdentifier; keyring[slotIdentifier + '|' + bidId] = args; keymakerAssoc[slotIdentifier + '|' + bidId] = bidRequest.placementCode; bidReqAssoc[bidRequest.placementCode] = bidRequest; - } else if (/^[0-9a-fA-F]{20}$/.test(slotIdentifier) && slotIdentifier.length === 20){ + } else if (/^[0-9a-fA-F]{20}$/.test(slotIdentifier) && slotIdentifier.length === 20) { keyring[bidId] = slotIdentifier + '|' + args; keymakerAssoc[bidId] = bidRequest.placementCode; bidReqAssoc[bidRequest.placementCode] = bidRequest; - } else { + } else { keymakerAssoc[bidId] = bidRequest.placementCode; bidReqAssoc[bidRequest.placementCode] = bidRequest; _failure(bidRequest.placementCode); @@ -53,18 +53,18 @@ var SonobiAdapter = function SonobiAdapter(){ return keyring; } - function _operator(bidderRequestId){ - var cb_name = "sbi_" + bidderRequestId; + function _operator(bidderRequestId) { + var cb_name = 'sbi_' + bidderRequestId; window[cb_name] = _trinity; return cb_name; } - function _trinity(response){ + function _trinity(response) { var slots = response.slots || {}; var sbi_dc = response.sbi_dc || ''; - utils._each(slots, function(bid, slot_id){ + utils._each(slots, function(bid, slot_id) { var placementCode = keymakerAssoc[slot_id]; - if (bid.sbi_aid && bid.sbi_mouse && bid.sbi_size){ + if (bid.sbi_aid && bid.sbi_mouse && bid.sbi_size) { _success(placementCode, sbi_dc, bid); } else { _failure(placementCode); @@ -73,15 +73,15 @@ var SonobiAdapter = function SonobiAdapter(){ }); } - function _seraph(placementCode){ + function _seraph(placementCode) { var theOne = bidReqAssoc[placementCode]; delete bidReqAssoc[placementCode]; return theOne; } - function _success(placementCode, sbi_dc, bid){ + function _success(placementCode, sbi_dc, bid) { var goodBid = bidfactory.createBid(1, _seraph(placementCode)); - if(bid.sbi_dozer){ + if (bid.sbi_dozer) { goodBid.dealId = bid.sbi_dozer; } goodBid.bidderCode = 'sonobi'; @@ -92,24 +92,24 @@ var SonobiAdapter = function SonobiAdapter(){ bidmanager.addBidResponse(placementCode, goodBid); } - function _failure(placementCode){ + function _failure(placementCode) { var failBid = bidfactory.createBid(2, _seraph(placementCode)); failBid.bidderCode = 'sonobi'; bidmanager.addBidResponse(placementCode, failBid); } - function _creative(sbi_dc, sbi_aid){ + function _creative(sbi_dc, sbi_aid) { var src = 'https://' + sbi_dc + 'apex.go.sonobi.com/sbi.js?aid=' + sbi_aid + '&as=null'; return ''; } return { - callBids: _phone_in, - formRequest: _keymaker, - parseResponse: _trinity, - success: _success, - failure: _failure + callBids: _phone_in, + formRequest: _keymaker, + parseResponse: _trinity, + success: _success, + failure: _failure }; }; -module.exports = SonobiAdapter; \ No newline at end of file +module.exports = SonobiAdapter; diff --git a/src/adapters/sovrn.js b/src/adapters/sovrn.js index 284c458025a..968ce3985fa 100644 --- a/src/adapters/sovrn.js +++ b/src/adapters/sovrn.js @@ -23,15 +23,15 @@ var SovrnAdapter = function SovrnAdapter() { var sovrnImps = []; - //build impression array for sovrn + // build impression array for sovrn utils._each(bidReqs, function (bid) { var tagId = utils.getBidIdParameter('tagid', bid.params); var bidFloor = utils.getBidIdParameter('bidfloor', bid.params); var adW = 0; var adH = 0; - //sovrn supports only one size per tagid, so we just take the first size if there are more - //if we are a 2 item array of 2 numbers, we must be a SingleSize array + // sovrn supports only one size per tagid, so we just take the first size if there are more + // if we are a 2 item array of 2 numbers, we must be a SingleSize array var bidSizes = Array.isArray(bid.params.sizes) ? bid.params.sizes : bid.sizes; var sizeArrayLength = bidSizes.length; if (sizeArrayLength === 2 && typeof bidSizes[0] === 'number' && typeof bidSizes[1] === 'number') { @@ -43,15 +43,15 @@ var SovrnAdapter = function SovrnAdapter() { } var imp = - { - id: bid.bidId, - banner: { - w: adW, - h: adH - }, - tagid: tagId, - bidfloor: bidFloor - }; + { + id: bid.bidId, + banner: { + w: adW, + h: adH + }, + tagid: tagId, + bidfloor: bidFloor + }; sovrnImps.push(imp); }); @@ -88,7 +88,7 @@ var SovrnAdapter = function SovrnAdapter() { }); } - //expose the callback to the global object: + // expose the callback to the global object: $$PREBID_GLOBAL$$.sovrnResponse = function (sovrnResponseObj) { // valid object? if (sovrnResponseObj && sovrnResponseObj.id) { @@ -96,7 +96,6 @@ var SovrnAdapter = function SovrnAdapter() { if (sovrnResponseObj.seatbid && sovrnResponseObj.seatbid.length !== 0 && sovrnResponseObj.seatbid[0].bid && sovrnResponseObj.seatbid[0].bid.length !== 0) { var impidsWithBidBack = []; sovrnResponseObj.seatbid[0].bid.forEach(function (sovrnBid) { - var responseCPM; var placementCode = ''; var id = sovrnBid.impid; @@ -110,7 +109,7 @@ var SovrnAdapter = function SovrnAdapter() { placementCode = bidObj.placementCode; bidObj.status = CONSTANTS.STATUS.GOOD; - //place ad response on bidmanager._adResponsesByBidderId + // place ad response on bidmanager._adResponsesByBidderId responseCPM = parseFloat(sovrnBid.price); if (responseCPM !== 0) { @@ -121,14 +120,14 @@ var SovrnAdapter = function SovrnAdapter() { // build impression url from response var responseNurl = ''; - //store bid response - //bid status is good (indicating 1) + // store bid response + // bid status is good (indicating 1) bid = bidfactory.createBid(1, bidObj); bid.creative_id = sovrnBid.id; bid.bidderCode = 'sovrn'; bid.cpm = responseCPM; - //set ad content + impression url + // set ad content + impression url // sovrn returns "; - - return divHtml+script; + + var divHtml = '
'; + + var script = "'; + + return divHtml + script; }; - var formatIntextHTML = function(bid){ + var formatIntextHTML = function(bid) { var placementCode = bid.placementCode; var config = bid.params; - //default placement if no placement is set - if(!config.hasOwnProperty("domId") && !config.hasOwnProperty("auto") && !config.hasOwnProperty("p") && !config.hasOwnProperty("article")){ + // default placement if no placement is set + if (!config.hasOwnProperty('domId') && !config.hasOwnProperty('auto') && !config.hasOwnProperty('p') && !config.hasOwnProperty('article')) { config.domId = placementCode; } - var script = ""; + ''; return script; }; - var formatScreenRollHTML = function(bid){ + var formatScreenRollHTML = function(bid) { var placementCode = bid.placementCode; var config = bid.params; - var script = ""; + 'topWindow.com.stickyadstv.screenroll.start(config);' + + + ''; return script; }; - function formatAdHTML(bid, size){ - + function formatAdHTML(bid, size) { var integrationType = bid.params.format; - var html = ""; - if(integrationType === "intext-roll"){ + var html = ''; + if (integrationType === 'intext-roll') { html = formatIntextHTML(bid); - } - else if(integrationType === "screen-roll"){ + } else if (integrationType === 'screen-roll') { html = formatScreenRollHTML(bid); + } else { + html = formatInBannerHTML(bid, size); } - else { - html = formatInBannerHTML(bid,size); - } - + return html; } - - function extractPrice(vast){ + function extractPrice(vast) { var priceData = vast.getPricing(); - if(!priceData) { + if (!priceData) { console.warn("StickyAdsTV: Bid pricing Can't be retreived. You may need to enable pricing on you're zone. Please get in touch with your sticky contact."); } - + return priceData; } - function formatBidObject(bidRequest, valid, priceData, html, width, height){ + function formatBidObject(bidRequest, valid, priceData, html, width, height) { var bidObject; - if(valid && priceData) { + if (valid && priceData) { // valid bid response bidObject = bidfactory.createBid(1, bidRequest); bidObject.bidderCode = bidRequest.bidder; @@ -233,9 +217,7 @@ var StickyAdsTVAdapter = function StickyAdsTVAdapter() { bidObject.ad = html; bidObject.width = width; bidObject.height = height; - - } - else { + } else { // invalid bid response bidObject = bidfactory.createBid(2, bidRequest); bidObject.bidderCode = bidRequest.bidder; @@ -243,24 +225,21 @@ var StickyAdsTVAdapter = function StickyAdsTVAdapter() { return bidObject; } - /** * returns the top most accessible window */ - function getTopMostWindow(){ - var res=window; + function getTopMostWindow() { + var res = window; try { - while(top !== res){ - if(res.parent.location.href.length) - res=res.parent; + while (top !== res) { + if (res.parent.location.href.length) { res = res.parent; } } - } - catch(e){} + } catch (e) {} return res; } - + /* Create a function bound to a given object (assigning `this`, and arguments, * optionally). Binding with arguments is also known as `curry`. * Delegates to **ECMAScript 5**'s native `Function.bind` if available. @@ -268,25 +247,23 @@ var StickyAdsTVAdapter = function StickyAdsTVAdapter() { * * @param {function} func * @param {optional} context - * @param {...any} var_args + * @param {...any} var_args * @return {function} */ var bind = function(func, context) { - - return function() { - return func.apply(context,arguments); + return function() { + return func.apply(context, arguments); }; }; - return Object.assign(Adapter.createNew(STICKYADS_BIDDERCODE), { callBids: _callBids, formatBidObject: formatBidObject, formatAdHTML: formatAdHTML, - getBiggerSize:getBiggerSize, - getBid:getBid, - getTopMostWindow:getTopMostWindow, - createNew: StickyAdsTVAdapter.createNew //enable alias feature (to be used for freewheel-ssp alias) + getBiggerSize: getBiggerSize, + getBid: getBid, + getTopMostWindow: getTopMostWindow, + createNew: StickyAdsTVAdapter.createNew // enable alias feature (to be used for freewheel-ssp alias) }); }; @@ -294,4 +271,4 @@ StickyAdsTVAdapter.createNew = function() { return new StickyAdsTVAdapter(); }; -module.exports = StickyAdsTVAdapter; \ No newline at end of file +module.exports = StickyAdsTVAdapter; diff --git a/src/adapters/tapsense.js b/src/adapters/tapsense.js index f656c580546..9ac7cf2c0e2 100644 --- a/src/adapters/tapsense.js +++ b/src/adapters/tapsense.js @@ -1,4 +1,4 @@ -//v0.0.1 +// v0.0.1 const bidfactory = require('../bidfactory.js'); const bidmanager = require('../bidmanager.js'); @@ -6,22 +6,22 @@ const adloader = require('../adloader'); const utils = require('../utils.js'); const TapSenseAdapter = function TapSenseAdapter() { - const version = "0.0.1"; + const version = '0.0.1'; const creativeSizes = [ - "320x50" + '320x50' ]; const validParams = [ - "ufid", - "refer", - "ad_unit_id", //required - "device_id", - "lat", - "long", - "user", //required - "price_floor", - "test" + 'ufid', + 'refer', + 'ad_unit_id', // required + 'device_id', + 'lat', + 'long', + 'user', // required + 'price_floor', + 'test' ]; - const SCRIPT_URL = "https://ads04.tapsense.com/ads/headerad"; + const SCRIPT_URL = 'https://ads04.tapsense.com/ads/headerad'; let bids; $$PREBID_GLOBAL$$.tapsense = {}; function _callBids(params) { @@ -45,19 +45,19 @@ const TapSenseAdapter = function TapSenseAdapter() { let keys = Object.keys(bid.params); for (let j = 0; j < keys.length; j++) { if (validParams.indexOf(keys[j]) < 0) continue; - queryString += encodeURIComponent(keys[j]) + "=" + encodeURIComponent(bid.params[keys[j]]) + "&"; + queryString += encodeURIComponent(keys[j]) + '=' + encodeURIComponent(bid.params[keys[j]]) + '&'; } _requestBids(SCRIPT_URL + queryString); } } } - function generateCallback(bidId){ + function generateCallback(bidId) { return function tapsenseCallback(response, price) { let bidObj; if (response && price) { let bidReq = utils.getBidRequest(bidId); - if (response.status.value === "ok" && response.count_ad_units > 0) { + if (response.status.value === 'ok' && response.count_ad_units > 0) { bidObj = bidfactory.createBid(1, bidObj); bidObj.cpm = price; bidObj.width = response.width; @@ -68,7 +68,6 @@ const TapSenseAdapter = function TapSenseAdapter() { } bidObj.bidderCode = bidReq.bidder; bidmanager.addBidResponse(bidReq.placementCode, bidObj); - } else { utils.logMessage('No prebid response'); } diff --git a/src/adapters/thoughtleadr.js b/src/adapters/thoughtleadr.js index 2237adb89f5..13b5207a1b7 100644 --- a/src/adapters/thoughtleadr.js +++ b/src/adapters/thoughtleadr.js @@ -1,9 +1,9 @@ -"use strict"; -var bidfactory = require("../bidfactory"); -var bidmanager = require("../bidmanager"); +'use strict'; +var bidfactory = require('../bidfactory'); +var bidmanager = require('../bidmanager'); var utils = require('../utils'); -var adloader_1 = require("../adloader"); -var ROOT_URL = "//cdn.thoughtleadr.com/v4/"; +var adloader_1 = require('../adloader'); +var ROOT_URL = '//cdn.thoughtleadr.com/v4/'; var BID_AVAILABLE = 1; var ThoughtleadrAdapter = (function () { @@ -16,9 +16,8 @@ var ThoughtleadrAdapter = (function () { if (window.tldr && window.tldr.config && window.tldr.config.root_url) { rootUrl = window.tldr.config.root_url; } - adloader_1.loadScript(rootUrl + "page.js", this.handleBids.bind(this, params), true); - } - else { + adloader_1.loadScript(rootUrl + 'page.js', this.handleBids.bind(this, params), true); + } else { this.handleBids(params); } }; @@ -41,7 +40,7 @@ var ThoughtleadrAdapter = (function () { window.tldr.requestPrebid(bid.params.placementId, rid).then(function (params) { if (!params || !params.bid) { - utils.logError("invalid response from tldr.requestPrebid", undefined, undefined); + utils.logError('invalid response from tldr.requestPrebid', undefined, undefined); return; } @@ -52,7 +51,7 @@ var ThoughtleadrAdapter = (function () { } _this.stopListen(); }; - window.addEventListener("message", _this.receiver, false); + window.addEventListener('message', _this.receiver, false); setTimeout(function () { return _this.stopListen(); }, 5000); @@ -65,8 +64,7 @@ var ThoughtleadrAdapter = (function () { bidObject.ad = params.bid.ad; bidObject.width = size.width; bidObject.height = size.height; - } - else { + } else { bidObject = bidfactory.createBid(params.bid.code); bidObject.bidderCode = 'thoughtleadr'; } @@ -76,13 +74,13 @@ var ThoughtleadrAdapter = (function () { ThoughtleadrAdapter.prototype.stopListen = function () { if (this.receiver) { - window.removeEventListener("message", this.receiver); + window.removeEventListener('message', this.receiver); this.receiver = undefined; } }; ThoughtleadrAdapter.valid = function (bid) { - return !!(bid && bid.params && typeof bid.params.placementId === "string"); + return !!(bid && bid.params && typeof bid.params.placementId === 'string'); }; ThoughtleadrAdapter.getSizes = function (sizes) { diff --git a/src/adapters/trion.js b/src/adapters/trion.js index 6a0442d0b8f..e3c5c34c794 100644 --- a/src/adapters/trion.js +++ b/src/adapters/trion.js @@ -7,8 +7,8 @@ var bidmanager = require('../bidmanager.js'); var bidfactory = require('../bidfactory.js'); var Adapter = require('./adapter.js'); -const BID_REQUEST_BASE_URL = "https://in-appadvertising.com/api/bidRequest?"; -const USER_SYNC_URL = "https://in-appadvertising.com/api/userSync.js"; +const BID_REQUEST_BASE_URL = 'https://in-appadvertising.com/api/bidRequest?'; +const USER_SYNC_URL = 'https://in-appadvertising.com/api/userSync.js'; var TrionAdapter; TrionAdapter = function TrionAdapter() { @@ -18,7 +18,7 @@ TrionAdapter = function TrionAdapter() { baseAdapter.callBids = function (params) { var bids = params.bids || []; - if(!bids.length){ + if (!bids.length) { return; } @@ -27,10 +27,10 @@ TrionAdapter = function TrionAdapter() { userTag = window.TRION_INT || {}; userTag.pubId = utils.getBidIdParameter('pubId', bids[0].params); userTag.sectionId = utils.getBidIdParameter('sectionId', bids[0].params); - if(!userTag.to){ + if (!userTag.to) { getBids(bids); } - else{ + else { setTimeout(function () { getBids(bids); }, userTag.to); @@ -42,8 +42,8 @@ TrionAdapter = function TrionAdapter() { } }; - function getBids(bids){ - if(!userTag.int_t) { + function getBids(bids) { + if (!userTag.int_t) { userTag.int_t = window.TR_INT_T || -1; } @@ -74,11 +74,11 @@ TrionAdapter = function TrionAdapter() { if (sizes) { trionUrl += 'sizes=' + sizes + '&'; } - if(userTag) { + if (userTag) { trionUrl += 'tag=' + encodeURIComponent(JSON.stringify(userTag)) + '&'; } - //remove the trailing "&" + // remove the trailing "&" if (trionUrl.lastIndexOf('&') === trionUrl.length - 1) { trionUrl = trionUrl.substring(0, trionUrl.length - 1); } @@ -86,7 +86,7 @@ TrionAdapter = function TrionAdapter() { return trionUrl; } - //expose the callback to the global object: + // expose the callback to the global object: $$PREBID_GLOBAL$$.handleTrionCB = function (trionResponseObj) { var bid; var bidObj = {}; @@ -113,7 +113,7 @@ TrionAdapter = function TrionAdapter() { bid.height = result.height; } } - if(!bid) { + if (!bid) { bid = bidfactory.createBid(CONSTANTS.STATUS.NO_BID, bidObj); } bidmanager.addBidResponse(placementCode, bid); diff --git a/src/adapters/triplelift.js b/src/adapters/triplelift.js index b629e414dec..bc17682f8ea 100644 --- a/src/adapters/triplelift.js +++ b/src/adapters/triplelift.js @@ -7,9 +7,7 @@ var bidfactory = require('../bidfactory.js'); * Use to create a TripleLiftAdapter object */ - var TripleLiftAdapter = function TripleLiftAdapter() { - function _callBids(params) { var tlReq = params.bids; var bidsCount = tlReq.length; @@ -26,9 +24,8 @@ var TripleLiftAdapter = function TripleLiftAdapter() { } } - function buildTLCall(bid, callbackId) { - //determine tag params + // determine tag params var inventoryCode = utils.getBidIdParameter('inventoryCode', bid.params); var floor = utils.getBidIdParameter('floor', bid.params); @@ -99,7 +96,6 @@ var TripleLiftAdapter = function TripleLiftAdapter() { var bid = []; if (tlResponseObj && tlResponseObj.cpm && tlResponseObj.cpm !== 0) { - bid = bidfactory.createBid(1, bidObj); bid.bidderCode = 'triplelift'; bid.cpm = tlResponseObj.cpm; @@ -108,25 +104,21 @@ var TripleLiftAdapter = function TripleLiftAdapter() { bid.height = tlResponseObj.height; bid.dealId = tlResponseObj.deal_id; bidmanager.addBidResponse(placementCode, bid); - } else { // no response data // @if NODE_ENV='debug' - if (bidObj) {utils.logMessage('No prebid response from TripleLift for inventory code: ' + bidObj.params.inventoryCode);} + if (bidObj) { utils.logMessage('No prebid response from TripleLift for inventory code: ' + bidObj.params.inventoryCode); } // @endif bid = bidfactory.createBid(2, bidObj); bid.bidderCode = 'triplelift'; bidmanager.addBidResponse(placementCode, bid); } - } else { // no response data // @if NODE_ENV='debug' utils.logMessage('No prebid response for placement %%PLACEMENT%%'); // @endif - } - }; return { diff --git a/src/adapters/twenga.js b/src/adapters/twenga.js index a7c844d7dd7..5951e16bc2d 100644 --- a/src/adapters/twenga.js +++ b/src/adapters/twenga.js @@ -20,7 +20,6 @@ TwengaAdapter = function TwengaAdapter() { }; function buildBidCall(bid, callbackId) { - var bidUrl = '//rtb.t.c4tw.net/Bid?'; bidUrl = utils.tryAppendQueryString(bidUrl, 's', 'h'); bidUrl = utils.tryAppendQueryString(bidUrl, 'callback', '$$PREBID_GLOBAL$$.handleTwCB'); @@ -30,12 +29,12 @@ TwengaAdapter = function TwengaAdapter() { for (var key in bid.params) { var value = bid.params[key]; switch (key) { - case 'placementId': key = 'id'; break; - case 'siteId': key = 'sid'; break; - case 'publisherId': key = 'pid'; break; - case 'currency': key = 'cur'; break; - case 'bidFloor': key = 'min'; break; - case 'country': key = 'gz'; break; + case 'placementId': key = 'id'; break; + case 'siteId': key = 'sid'; break; + case 'publisherId': key = 'pid'; break; + case 'currency': key = 'cur'; break; + case 'bidFloor': key = 'min'; break; + case 'country': key = 'gz'; break; } bidUrl = utils.tryAppendQueryString(bidUrl, key, value); } @@ -53,25 +52,22 @@ TwengaAdapter = function TwengaAdapter() { // @endif - //append a timer here to track latency + // append a timer here to track latency bid.startTime = new Date().getTime(); return bidUrl; } - //expose the callback to the global object: + // expose the callback to the global object: $$PREBID_GLOBAL$$.handleTwCB = function (bidResponseObj) { - var bidCode; if (bidResponseObj && bidResponseObj.callback_uid) { - var responseCPM; var id = bidResponseObj.callback_uid; var placementCode = ''; var bidObj = getBidRequest(id); if (bidObj) { - bidCode = bidObj.bidder; placementCode = bidObj.placementCode; @@ -88,47 +84,41 @@ TwengaAdapter = function TwengaAdapter() { bidResponseObj.result.cpm && bidResponseObj.result.cpm !== 0 && bidResponseObj.result.ad) { - var result = bidResponseObj.result; responseCPM = parseInt(result.cpm, 10); - //CPM response from /Bid is dollar/cent multiplied by 10000 - //in order to avoid using floats - //switch CPM to "dollar/cent" + // CPM response from /Bid is dollar/cent multiplied by 10000 + // in order to avoid using floats + // switch CPM to "dollar/cent" responseCPM = responseCPM / 10000; var ad = result.ad.replace('%%WP%%', result.cpm); - //store bid response - //bid status is good (indicating 1) + // store bid response + // bid status is good (indicating 1) bid = bidfactory.createBid(1, bidObj); bid.creative_id = result.creative_id; bid.bidderCode = bidCode; bid.cpm = responseCPM; - if (ad && (ad.lastIndexOf('http', 0) === 0 || ad.lastIndexOf('//', 0) === 0)) - bid.adUrl = ad; - else - bid.ad = ad; + if (ad && (ad.lastIndexOf('http', 0) === 0 || ad.lastIndexOf('//', 0) === 0)) { bid.adUrl = ad; } else { bid.ad = ad; } bid.width = result.width; bid.height = result.height; bidmanager.addBidResponse(placementCode, bid); - } else { - //no response data + // no response data // @if NODE_ENV='debug' utils.logMessage('No prebid response from Twenga for placement code ' + placementCode); // @endif - //indicate that there is no bid for this placement + // indicate that there is no bid for this placement bid = bidfactory.createBid(2, bidObj); bid.bidderCode = bidCode; bidmanager.addBidResponse(placementCode, bid); } - } else { - //no response data + // no response data // @if NODE_ENV='debug' utils.logMessage('No prebid response for placement %%PLACEMENT%%'); diff --git a/src/adapters/underdogmedia.js b/src/adapters/underdogmedia.js index 365e2509555..b027fd46902 100644 --- a/src/adapters/underdogmedia.js +++ b/src/adapters/underdogmedia.js @@ -4,7 +4,6 @@ var adloader = require('../adloader.js'); var utils = require('../utils.js'); var UnderdogMediaAdapter = function UnderdogMediaAdapter() { - const UDM_ADAPTER_VERSION = '1.0.0'; var getJsStaticUrl = window.location.protocol + '//udmserve.net/udm/img.fetch?tid=1;dt=9;callback=$$PREBID_GLOBAL$$.handleUnderdogMediaCB;'; var bidParams = {}; @@ -18,17 +17,14 @@ var UnderdogMediaAdapter = function UnderdogMediaAdapter() { sizes = utils.flatten(sizes, utils.parseSizesInput(bidParam.sizes)); siteId = bidParam.params.siteId; }); - adloader.loadScript(getJsStaticUrl + "sid=" + siteId + ";sizes=" + sizes.join(","), null, false); + adloader.loadScript(getJsStaticUrl + 'sid=' + siteId + ';sizes=' + sizes.join(','), null, false); } function _callback(response) { - var mids = response.mids; bidParams.bids.forEach(bidParam => { - var filled = false; mids.forEach(mid => { - if (mid.useCount > 0) { return; } @@ -74,13 +70,12 @@ var UnderdogMediaAdapter = function UnderdogMediaAdapter() { $$PREBID_GLOBAL$$.handleUnderdogMediaCB = _callback; function _makeNotification(bid, mid, bidParam) { - var url = mid.notification_url; url += UDM_ADAPTER_VERSION; - url += ";cb=" + Math.random(); - url += ";qqq=" + (1 / bid.cpm); - url += ";hbt=" + $$PREBID_GLOBAL$$.bidderTimeout; + url += ';cb=' + Math.random(); + url += ';qqq=' + (1 / bid.cpm); + url += ';hbt=' + $$PREBID_GLOBAL$$.bidderTimeout; url += ';style=adapter'; url += ';vis=' + encodeURIComponent(document.visibilityState); @@ -88,7 +83,7 @@ var UnderdogMediaAdapter = function UnderdogMediaAdapter() { if (bidParam.params.subId) { url += ';subid=' + encodeURIComponent(bidParam.params.subId); } - return ""; + return ''; } function _getUrlVars() { @@ -109,7 +104,6 @@ var UnderdogMediaAdapter = function UnderdogMediaAdapter() { return { callBids: _callBids }; - }; module.exports = UnderdogMediaAdapter; diff --git a/src/adapters/vertamedia.js b/src/adapters/vertamedia.js index 13f036764d7..ecce8c1d84f 100644 --- a/src/adapters/vertamedia.js +++ b/src/adapters/vertamedia.js @@ -9,7 +9,7 @@ const ENDPOINT = '//rtb.vertamedia.com/hb/'; function VertamediaAdapter() { var baseAdapter = Adapter.createNew('vertamedia'), - bidRequest; + bidRequest; baseAdapter.callBids = function (bidRequests) { if (!bidRequests || !bidRequests.bids || bidRequests.bids.length === 0) { @@ -51,7 +51,7 @@ function VertamediaAdapter() { function getSize(requestSizes) { var parsed = {}, - size = utils.parseSizesInput(requestSizes)[0]; + size = utils.parseSizesInput(requestSizes)[0]; if (typeof size !== 'string') { return parsed; @@ -110,7 +110,6 @@ function VertamediaAdapter() { callBids: baseAdapter.callBids, setBidderCode: baseAdapter.setBidderCode }; - } VertamediaAdapter.createNew = function () { diff --git a/src/adapters/vertoz.js b/src/adapters/vertoz.js index a500f078a92..9f9767998d8 100755 --- a/src/adapters/vertoz.js +++ b/src/adapters/vertoz.js @@ -5,64 +5,61 @@ var bidmanager = require('../bidmanager.js'); var adloader = require('../adloader.js'); var VertozAdapter = function VertozAdapter() { - - const BASE_URI='//banner.vrtzads.com/vzhbidder/bid?'; - const BIDDER_NAME='vertoz'; - const QUERY_PARAM_KEY='q'; + const BASE_URI = '//banner.vrtzads.com/vzhbidder/bid?'; + const BIDDER_NAME = 'vertoz'; + const QUERY_PARAM_KEY = 'q'; function _callBids(params) { var bids = params.bids || []; for (var i = 0; i < bids.length; i++) { - var bid = bids[i]; - let slotBidId = utils.getValue(bid,'bidId'); + var bid = bids[i]; + let slotBidId = utils.getValue(bid, 'bidId'); let cb = Math.round(new Date().getTime() / 1000); let vzEndPoint = BASE_URI; let reqParams = bid.params || {}; - let placementId = utils.getValue(reqParams,'placementId'); - - if(utils.isEmptyStr(placementId)){ - utils.logError('missing params:',BIDDER_NAME,'Enter valid vzPlacementId'); + let placementId = utils.getValue(reqParams, 'placementId'); + + if (utils.isEmptyStr(placementId)) { + utils.logError('missing params:', BIDDER_NAME, 'Enter valid vzPlacementId'); return; } let reqSrc = utils.getTopWindowLocation().href; var vzReq = { - _vzPlacementId:placementId, - _rqsrc:reqSrc, - _cb:cb, - _slotBidId:slotBidId + _vzPlacementId: placementId, + _rqsrc: reqSrc, + _cb: cb, + _slotBidId: slotBidId }; - let queryParamValue=JSON.stringify(vzReq); + let queryParamValue = JSON.stringify(vzReq); vzEndPoint = utils.tryAppendQueryString(vzEndPoint, QUERY_PARAM_KEY, queryParamValue); adloader.loadScript(vzEndPoint); } - } $$PREBID_GLOBAL$$.vzResponse = function (vertozResponse) { var bidRespObj = vertozResponse; var bidObject; - var reqBidObj=utils.getBidRequest(bidRespObj.slotBidId); - + var reqBidObj = utils.getBidRequest(bidRespObj.slotBidId); + if (bidRespObj.cpm) { - bidObject = bidfactory.createBid(CONSTANTS.STATUS.GOOD,reqBidObj); + bidObject = bidfactory.createBid(CONSTANTS.STATUS.GOOD, reqBidObj); bidObject.cpm = Number(bidRespObj.cpm); bidObject.ad = bidRespObj.ad + utils.createTrackPixelHtml(decodeURIComponent(bidRespObj.nurl)); bidObject.width = bidRespObj.adWidth; bidObject.height = bidRespObj.adHeight; - }else { - let respStatusText=bidRespObj.statusText; - bidObject = bidfactory.createBid(CONSTANTS.STATUS.NO_BID,reqBidObj); + } else { + let respStatusText = bidRespObj.statusText; + bidObject = bidfactory.createBid(CONSTANTS.STATUS.NO_BID, reqBidObj); utils.logMessage(respStatusText); - } + } var adSpaceId = reqBidObj.placementCode; bidObject.bidderCode = BIDDER_NAME; bidmanager.addBidResponse(adSpaceId, bidObject); }; return { callBids: _callBids }; - }; module.exports = VertozAdapter; diff --git a/src/adapters/wideorbit.js b/src/adapters/wideorbit.js index b9e00ba7a82..857def5c790 100644 --- a/src/adapters/wideorbit.js +++ b/src/adapters/wideorbit.js @@ -1,16 +1,16 @@ var bidfactory = require('../bidfactory.js'), - bidmanager = require('../bidmanager.js'), - utils = require('../utils.js'), - adloader = require('../adloader'); + bidmanager = require('../bidmanager.js'), + utils = require('../utils.js'), + adloader = require('../adloader'); var WideOrbitAdapter = function WideOrbitAdapter() { var pageImpression = 'JSAdservingMP.ashx?pc={pc}&pbId={pbId}&clk=&exm=&jsv=1.0&tsv=1.0&cts={cts}&arp=0&fl=0&vitp=&vit=&jscb=window.$$PREBID_GLOBAL$$.handleWideOrbitCallback&url={referrer}&fp=&oid=&exr=&mraid=&apid=&apbndl=&mpp=0&uid=&cb={cb}&hb=1', - pageRepeatCommonParam = '&gid{o}={gid}&pp{o}=&clk{o}=&rpos{o}={rpos}&ecpm{o}={ecpm}&ntv{o}=&ntl{o}=&adsid{o}=', - pageRepeatParamId = '&pId{o}={pId}&rank{o}={rank}', - pageRepeatParamNamed = '&wsName{o}={wsName}&wName{o}={wName}&rank{o}={rank}&bfDim{o}={width}x{height}&subp{o}={subp}', - base = (window.location.protocol) + '//p{pbId}.atemda.com/', - bids, - adapterName = 'wideorbit'; + pageRepeatCommonParam = '&gid{o}={gid}&pp{o}=&clk{o}=&rpos{o}={rpos}&ecpm{o}={ecpm}&ntv{o}=&ntl{o}=&adsid{o}=', + pageRepeatParamId = '&pId{o}={pId}&rank{o}={rank}', + pageRepeatParamNamed = '&wsName{o}={wsName}&wName{o}={wName}&rank{o}={rank}&bfDim{o}={width}x{height}&subp{o}={subp}', + base = (window.location.protocol) + '//p{pbId}.atemda.com/', + bids, + adapterName = 'wideorbit'; function _fixParamNames(param) { if (!param) { @@ -18,7 +18,7 @@ var WideOrbitAdapter = function WideOrbitAdapter() { } var properties = ['site', 'page', 'width', 'height', 'rank', 'subPublisher', 'ecpm', 'atf', 'pId', 'pbId', 'referrer'], - prop; + prop; utils._each(properties, function (correctName) { for (prop in param) { @@ -130,7 +130,7 @@ var WideOrbitAdapter = function WideOrbitAdapter() { function _processUserMatchings(userMatchings) { var headElem = document.getElementsByTagName('head')[0], - createdElem; + createdElem; utils._each(userMatchings, function (userMatching) { createdElem = undefined; @@ -165,7 +165,7 @@ var WideOrbitAdapter = function WideOrbitAdapter() { } function _isUrl(scr) { - return scr.slice(0, 6) === "http:/" || scr.slice(0, 7) === "https:/" || scr.slice(0, 2) === "//"; + return scr.slice(0, 6) === 'http:/' || scr.slice(0, 7) === 'https:/' || scr.slice(0, 2) === '//'; } function _buildAdCode(placement) { diff --git a/src/adapters/widespace.js b/src/adapters/widespace.js index ac44d50fd18..cd8669f99be 100644 --- a/src/adapters/widespace.js +++ b/src/adapters/widespace.js @@ -8,20 +8,20 @@ const bidfactory = require('../bidfactory.js'); const WS_ADAPTER_VERSION = '1.0.2'; function WidespaceAdapter() { - let useSSL = 'https:' === document.location.protocol, - baseURL = (useSSL ? 'https:' : 'http:') + '//engine.widespace.com/map/engine/hb/dynamic?', - callbackName = '$$PREBID_GLOBAL$$.widespaceHandleCB'; + let useSSL = document.location.protocol === 'https:', + baseURL = (useSSL ? 'https:' : 'http:') + '//engine.widespace.com/map/engine/hb/dynamic?', + callbackName = '$$PREBID_GLOBAL$$.widespaceHandleCB'; function _callBids(params) { let bids = params && params.bids || []; for (var i = 0; i < bids.length; i++) { const bid = bids[i], - callbackUid = bid.bidId, - sid = bid.params.sid, - currency = bid.params.cur || bid.params.currency; + callbackUid = bid.bidId, + sid = bid.params.sid, + currency = bid.params.cur || bid.params.currency; - //Handle Sizes string + // Handle Sizes string let sizeQueryString = ''; let parsedSizes = utils.parseSizesInput(bid.sizes); @@ -58,17 +58,17 @@ function WidespaceAdapter() { } } - //Handle our callback + // Handle our callback var handleCallback = function handleCallback(bidsArray) { if (!bidsArray) { return; } var bidObject, - bidCode = 'widespace'; + bidCode = 'widespace'; for (var i = 0, l = bidsArray.length; i < l; i++) { var bid = bidsArray[i], - placementCode = '', - validSizes = []; + placementCode = '', + validSizes = []; bid.sizes = {height: bid.height, width: bid.width}; @@ -80,7 +80,7 @@ function WidespaceAdapter() { validSizes = inBid.sizes; } - if (bid && bid.callbackUid && bid.status !=='noad' && verifySize(bid.sizes, validSizes)) { + if (bid && bid.callbackUid && bid.status !== 'noad' && verifySize(bid.sizes, validSizes)) { bidObject = bidfactory.createBid(1); bidObject.bidderCode = bidCode; bidObject.cpm = bid.cpm; diff --git a/src/adapters/xhb.js b/src/adapters/xhb.js index 2b00844e2a1..811f7b971e2 100644 --- a/src/adapters/xhb.js +++ b/src/adapters/xhb.js @@ -7,7 +7,6 @@ const bidmanager = require('../bidmanager.js'); const bidfactory = require('../bidfactory.js'); const XhbAdapter = function XhbAdapter() { - const _defaultBidderSettings = { alwaysUseBid: true, adserverTargeting: [ @@ -28,13 +27,13 @@ const XhbAdapter = function XhbAdapter() { bidmanager.registerDefaultBidderSetting('xhb', _defaultBidderSettings); function buildJPTCall(bid, callbackId) { - //determine tag params + // determine tag params const placementId = utils.getBidIdParameter('placementId', bid.params); const inventoryCode = utils.getBidIdParameter('invCode', bid.params); let referrer = utils.getBidIdParameter('referrer', bid.params); const altReferrer = utils.getBidIdParameter('alt_referrer', bid.params); - //Always use https + // Always use https let jptCall = 'https://ib.adnxs.com/jpt?'; jptCall = utils.tryAppendQueryString(jptCall, 'callback', '$$PREBID_GLOBAL$$.handleXhbCB'); @@ -42,22 +41,22 @@ const XhbAdapter = function XhbAdapter() { jptCall = utils.tryAppendQueryString(jptCall, 'id', placementId); jptCall = utils.tryAppendQueryString(jptCall, 'code', inventoryCode); - //sizes takes a bit more logic + // sizes takes a bit more logic let sizeQueryString = ''; let parsedSizes = utils.parseSizesInput(bid.sizes); - //combine string into proper querystring for impbus + // combine string into proper querystring for impbus let parsedSizesLength = parsedSizes.length; if (parsedSizesLength > 0) { - //first value should be "size" + // first value should be "size" sizeQueryString = 'size=' + parsedSizes[0]; if (parsedSizesLength > 1) { - //any subsequent values should be "promo_sizes" + // any subsequent values should be "promo_sizes" sizeQueryString += '&promo_sizes='; for (let j = 1; j < parsedSizesLength; j++) { sizeQueryString += parsedSizes[j] += ','; } - //remove trailing comma + // remove trailing comma if (sizeQueryString && sizeQueryString.charAt(sizeQueryString.length - 1) === ',') { sizeQueryString = sizeQueryString.slice(0, sizeQueryString.length - 1); } @@ -68,25 +67,25 @@ const XhbAdapter = function XhbAdapter() { jptCall += sizeQueryString + '&'; } - //append custom attributes: + // append custom attributes: let paramsCopy = Object.assign({}, bid.params); - //delete attributes already used + // delete attributes already used delete paramsCopy.placementId; delete paramsCopy.invCode; delete paramsCopy.query; delete paramsCopy.referrer; delete paramsCopy.alt_referrer; - //get the reminder + // get the reminder let queryParams = utils.parseQueryStringParameters(paramsCopy); - //append + // append if (queryParams) { jptCall += queryParams; } - //append referrer + // append referrer if (referrer === '') { referrer = utils.getTopWindowUrl(); } @@ -94,7 +93,7 @@ const XhbAdapter = function XhbAdapter() { jptCall = utils.tryAppendQueryString(jptCall, 'referrer', referrer); jptCall = utils.tryAppendQueryString(jptCall, 'alt_referrer', altReferrer); - //remove the trailing "&" + // remove the trailing "&" if (jptCall.lastIndexOf('&') === jptCall.length - 1) { jptCall = jptCall.substring(0, jptCall.length - 1); } @@ -102,50 +101,48 @@ const XhbAdapter = function XhbAdapter() { return jptCall; } - //expose the callback to the global object: + // expose the callback to the global object: $$PREBID_GLOBAL$$.handleXhbCB = function (jptResponseObj) { - let bidCode; - - if (jptResponseObj && jptResponseObj.callback_uid) { - - let responseCPM; - let id = jptResponseObj.callback_uid; - let placementCode = ''; - let bidObj = getBidRequest(id); - if (bidObj) { - bidCode = bidObj.bidder; - placementCode = bidObj.placementCode; - //set the status - bidObj.status = CONSTANTS.STATUS.GOOD; - } + let bidCode; + + if (jptResponseObj && jptResponseObj.callback_uid) { + let responseCPM; + let id = jptResponseObj.callback_uid; + let placementCode = ''; + let bidObj = getBidRequest(id); + if (bidObj) { + bidCode = bidObj.bidder; + placementCode = bidObj.placementCode; + // set the status + bidObj.status = CONSTANTS.STATUS.GOOD; + } - let bid = []; - if (jptResponseObj.result && jptResponseObj.result.ad && jptResponseObj.result.ad !== '') { - responseCPM = 0.00; - - //store bid response - //bid status is good (indicating 1) - let adId = jptResponseObj.result.creative_id; - bid = bidfactory.createBid(CONSTANTS.STATUS.GOOD, bidObj); - bid.creative_id = adId; - bid.bidderCode = bidCode; - bid.cpm = responseCPM; - bid.adUrl = jptResponseObj.result.ad; - bid.width = jptResponseObj.result.width; - bid.height = jptResponseObj.result.height; - bid.dealId = '99999999'; - - bidmanager.addBidResponse(placementCode, bid); - - } else { - //no response data - //indicate that there is no bid for this placement - bid = bidfactory.createBid(2); - bid.bidderCode = bidCode; - bidmanager.addBidResponse(placementCode, bid); - } + let bid = []; + if (jptResponseObj.result && jptResponseObj.result.ad && jptResponseObj.result.ad !== '') { + responseCPM = 0.00; + + // store bid response + // bid status is good (indicating 1) + let adId = jptResponseObj.result.creative_id; + bid = bidfactory.createBid(CONSTANTS.STATUS.GOOD, bidObj); + bid.creative_id = adId; + bid.bidderCode = bidCode; + bid.cpm = responseCPM; + bid.adUrl = jptResponseObj.result.ad; + bid.width = jptResponseObj.result.width; + bid.height = jptResponseObj.result.height; + bid.dealId = '99999999'; + + bidmanager.addBidResponse(placementCode, bid); + } else { + // no response data + // indicate that there is no bid for this placement + bid = bidfactory.createBid(2); + bid.bidderCode = bidCode; + bidmanager.addBidResponse(placementCode, bid); } - }; + } + }; function _callBids(params) { let bids = params.bids || []; @@ -159,8 +156,8 @@ const XhbAdapter = function XhbAdapter() { // Export the callBids function, so that prebid.js can execute // this function when the page asks to send out bid requests. return { - callBids: _callBids - }; + callBids: _callBids + }; }; module.exports = XhbAdapter; diff --git a/src/adapters/yieldbot.js b/src/adapters/yieldbot.js index 65ce539c596..1dc77a30f73 100644 --- a/src/adapters/yieldbot.js +++ b/src/adapters/yieldbot.js @@ -14,7 +14,6 @@ var utils = require('../utils'); * @class */ var YieldbotAdapter = function YieldbotAdapter() { - window.ybotq = window.ybotq || []; var ybotlib = { @@ -47,7 +46,6 @@ var YieldbotAdapter = function YieldbotAdapter() { var bid = {}; if (slotCriteria && slotCriteria.ybot_ad && slotCriteria.ybot_ad !== 'n') { - bid = bidfactory.createBid(ybotlib.BID_STATUS.AVAILABLE); bid.cpm = parseInt(slotCriteria.ybot_cpm) / 100.0 || 0; // Yieldbot CPM bids are in cents @@ -65,7 +63,6 @@ var YieldbotAdapter = function YieldbotAdapter() { for (var k in slotCriteria) { bid[k] = slotCriteria[k]; } - } else { bid = bidfactory.createBid(ybotlib.BID_STATUS.EMPTY); } @@ -79,7 +76,6 @@ var YieldbotAdapter = function YieldbotAdapter() { * @private */ callBids: function (params) { - var bids = params.bids || []; var ybotq = window.ybotq || []; diff --git a/src/adloader.js b/src/adloader.js index e361d418576..a5c9b3edbe4 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -1,11 +1,11 @@ var utils = require('./utils'); let _requestCache = {}; -//add a script tag to the page, used to add /jpt call to page +// add a script tag to the page, used to add /jpt call to page exports.loadScript = function (tagSrc, callback, cacheRequest) { - //var noop = () => {}; + // var noop = () => {}; // - //callback = callback || noop; + // callback = callback || noop; if (!tagSrc) { utils.logError('Error attempting to request empty URL', 'adloader.js:loadScript'); return; @@ -15,10 +15,10 @@ exports.loadScript = function (tagSrc, callback, cacheRequest) { if (_requestCache[tagSrc]) { if (callback && typeof callback === 'function') { if (_requestCache[tagSrc].loaded) { - //invokeCallbacks immediately + // invokeCallbacks immediately callback(); } else { - //queue the callback + // queue the callback _requestCache[tagSrc].callbacks.push(callback); } } @@ -45,11 +45,10 @@ exports.loadScript = function (tagSrc, callback, cacheRequest) { } } - //trigger one time request + // trigger one time request else { requestResource(tagSrc, callback); } - }; function requestResource(tagSrc, callback) { @@ -75,7 +74,7 @@ function requestResource(tagSrc, callback) { jptScript.src = tagSrc; - //add the new script tag to the page + // add the new script tag to the page var elToAppend = document.getElementsByTagName('head'); elToAppend = elToAppend.length ? elToAppend : document.getElementsByTagName('body'); if (elToAppend.length) { diff --git a/src/adserver.js b/src/adserver.js index dbdcb0f916b..4346dbeb4a6 100644 --- a/src/adserver.js +++ b/src/adserver.js @@ -1,7 +1,7 @@ import {formatQS} from './url'; import {getWinningBids} from './targeting'; -//Adserver parent class +// Adserver parent class const AdServer = function(attr) { this.name = attr.adserver; this.code = attr.code; @@ -10,16 +10,16 @@ const AdServer = function(attr) { }; }; -//DFP ad server +// DFP ad server exports.dfpAdserver = function (options, urlComponents) { var adserver = new AdServer(options); adserver.urlComponents = urlComponents; var dfpReqParams = { - 'env' : 'vp', - 'gdfp_req' : '1', - 'impl' : 's', - 'unviewed_position_start' : '1' + 'env': 'vp', + 'gdfp_req': '1', + 'impl': 's', + 'unviewed_position_start': '1' }; var dfpParamsWithVariableValue = ['output', 'iu', 'sz', 'url', 'correlator', 'description_url', 'hl']; @@ -38,13 +38,13 @@ exports.dfpAdserver = function (options, urlComponents) { }; adserver.verifyAdserverTag = function() { - for(var key in dfpReqParams) { - if(!this.urlComponents.search.hasOwnProperty(key) || this.urlComponents.search[key] !== dfpReqParams[key]) { + for (var key in dfpReqParams) { + if (!this.urlComponents.search.hasOwnProperty(key) || this.urlComponents.search[key] !== dfpReqParams[key]) { return false; } } - for(var i in dfpParamsWithVariableValue) { - if(!this.urlComponents.search.hasOwnProperty(dfpParamsWithVariableValue[i])) { + for (var i in dfpParamsWithVariableValue) { + if (!this.urlComponents.search.hasOwnProperty(dfpParamsWithVariableValue[i])) { return false; } } diff --git a/src/ajax.js b/src/ajax.js index 59ebf977b86..f7ab1185225 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -20,7 +20,7 @@ export function ajax(url, callback, data, options = {}) { let useXDomainRequest = false; let method = options.method || (data ? 'POST' : 'GET'); - let callbacks = typeof callback === "object" ? callback : { + let callbacks = typeof callback === 'object' ? callback : { success: function() { utils.logMessage('xhr success'); }, @@ -29,13 +29,13 @@ export function ajax(url, callback, data, options = {}) { } }; - if(typeof callback === "function") { + if (typeof callback === 'function') { callbacks.success = callback; } if (!window.XMLHttpRequest) { useXDomainRequest = true; - } else{ + } else { x = new window.XMLHttpRequest(); if (x.responseType === undefined) { useXDomainRequest = true; @@ -50,10 +50,10 @@ export function ajax(url, callback, data, options = {}) { // http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9 x.onerror = function () { - callbacks.error("error", x); + callbacks.error('error', x); }; x.ontimeout = function () { - callbacks.error("timeout", x); + callbacks.error('timeout', x); }; x.onprogress = function() { utils.logMessage('xhr onprogress'); @@ -62,7 +62,7 @@ export function ajax(url, callback, data, options = {}) { x.onreadystatechange = function () { if (x.readyState === XHR_DONE) { let status = x.status; - if(status >= 200 && status < 300 || status === 304) { + if (status >= 200 && status < 300 || status === 304) { callbacks.success(x.responseText, x); } else { callbacks.error(x.statusText, x); diff --git a/src/bidfactory.js b/src/bidfactory.js index 0b43a9b7f4f..9b4da791311 100644 --- a/src/bidfactory.js +++ b/src/bidfactory.js @@ -41,11 +41,10 @@ function Bid(statusCode, bidRequest) { return _statusCode; }; - //returns the size of the bid creative. Concatenation of width and height by ‘x’. + // returns the size of the bid creative. Concatenation of width and height by ‘x’. this.getSize = function () { return this.width + 'x' + this.height; }; - } // Bid factory function. diff --git a/src/bidmanager.js b/src/bidmanager.js index 387524f189f..6b6200f0cee 100644 --- a/src/bidmanager.js +++ b/src/bidmanager.js @@ -48,9 +48,9 @@ function bidsBackAdUnit(adUnitCode) { .filter(bid => bid.placementCode === adUnitCode)) .reduce(flatten, []) .map(bid => { - return bid.bidder === 'indexExchange' ? - bid.sizes.length : - 1; + return bid.bidder === 'indexExchange' + ? bid.sizes.length + : 1; }).reduce(add, 0); const received = $$PREBID_GLOBAL$$._bidsReceived.filter(bid => bid.adUnitCode === adUnitCode).length; @@ -67,9 +67,9 @@ function bidsBackAll() { .reduce(flatten, []) .filter(adUnitsFilter.bind(this, $$PREBID_GLOBAL$$._adUnitCodes)) .map(bid => { - return bid.bidder === 'indexExchange' ? - bid.sizes.length : - 1; + return bid.bidder === 'indexExchange' + ? bid.sizes.length + : 1; }).reduce((a, b) => a + b, 0); const received = $$PREBID_GLOBAL$$._bidsReceived @@ -92,7 +92,6 @@ exports.addBidResponse = function (adUnitCode, bid) { } if (bid) { - const { requestId, start } = getBidderRequest(bid.bidderCode, adUnitCode); Object.assign(bid, { requestId: requestId, @@ -111,13 +110,13 @@ exports.addBidResponse = function (adUnitCode, bid) { exports.executeCallback(timedOut); } - //emit the bidAdjustment event before bidResponse, so bid response has the adjusted bid value + // emit the bidAdjustment event before bidResponse, so bid response has the adjusted bid value events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, bid); - //emit the bidResponse event + // emit the bidResponse event events.emit(CONSTANTS.EVENTS.BID_RESPONSE, bid); - //append price strings + // append price strings const priceStringsObj = getPriceBucketString(bid.cpm, _customPriceBucket); bid.pbLg = priceStringsObj.low; bid.pbMg = priceStringsObj.med; @@ -126,9 +125,9 @@ exports.addBidResponse = function (adUnitCode, bid) { bid.pbDg = priceStringsObj.dense; bid.pbCg = priceStringsObj.custom; - //if there is any key value pairs to map do here + // if there is any key value pairs to map do here var keyValues = {}; - if (bid.bidderCode && (bid.cpm > 0 || bid.dealId ) ) { + if (bid.bidderCode && (bid.cpm > 0 || bid.dealId)) { keyValues = getKeyValueTargetingPairs(bid.bidderCode, bid); } @@ -149,21 +148,21 @@ function getKeyValueTargetingPairs(bidderCode, custBidObj) { var keyValues = {}; var bidder_settings = $$PREBID_GLOBAL$$.bidderSettings; - //1) set the keys from "standard" setting or from prebid defaults + // 1) set the keys from "standard" setting or from prebid defaults if (custBidObj && bidder_settings) { - //initialize default if not set + // initialize default if not set const standardSettings = getStandardBidderSettings(); setKeys(keyValues, standardSettings, custBidObj); } - //2) set keys from specific bidder setting override if they exist + // 2) set keys from specific bidder setting override if they exist if (bidderCode && custBidObj && bidder_settings && bidder_settings[bidderCode] && bidder_settings[bidderCode][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]) { setKeys(keyValues, bidder_settings[bidderCode], custBidObj); custBidObj.alwaysUseBid = bidder_settings[bidderCode].alwaysUseBid; custBidObj.sendStandardTargeting = bidder_settings[bidderCode].sendStandardTargeting; } - //2) set keys from standard setting. NOTE: this API doesn't seem to be in use by any Adapter + // 2) set keys from standard setting. NOTE: this API doesn't seem to be in use by any Adapter else if (defaultBidderSettingsMap[bidderCode]) { setKeys(keyValues, defaultBidderSettingsMap[bidderCode], custBidObj); custBidObj.alwaysUseBid = defaultBidderSettingsMap[bidderCode].alwaysUseBid; @@ -198,8 +197,8 @@ function setKeys(keyValues, bidderSettings, custBidObj) { } if ( - (typeof bidderSettings.suppressEmptyKeys !== "undefined" && bidderSettings.suppressEmptyKeys === true || - key === "hb_deal") && // hb_deal is suppressed automatically if not set + (typeof bidderSettings.suppressEmptyKeys !== 'undefined' && bidderSettings.suppressEmptyKeys === true || + key === 'hb_deal') && // hb_deal is suppressed automatically if not set ( utils.isEmptyStr(value) || value === null || @@ -210,7 +209,6 @@ function setKeys(keyValues, bidderSettings, custBidObj) { } else { keyValues[key] = value; } - }); return keyValues; @@ -250,16 +248,14 @@ exports.executeCallback = function (timedOut) { } } - //execute one time callback + // execute one time callback if (externalCallbacks.oneTime) { events.emit(AUCTION_END); try { processCallbacks([externalCallbacks.oneTime]); - } - catch(e){ + } catch (e) { utils.logError('Error executing bidsBackHandler', null, e); - } - finally { + } finally { externalCallbacks.oneTime = null; externalCallbacks.timer = false; $$PREBID_GLOBAL$$.clearAuction(); @@ -272,7 +268,7 @@ exports.externalCallbackReset = function () { }; function triggerAdUnitCallbacks(adUnitCode) { - //todo : get bid responses and send in args + // todo : get bid responses and send in args var singleAdUnitCode = [adUnitCode]; processCallbacks(externalCallbacks.byAdUnit, singleAdUnitCode); } @@ -297,8 +293,7 @@ function processCallbacks(callbackQueue, singleAdUnitCode) { * @returns {*} as { [adUnitCode]: { bids: [Bid, Bid, Bid] } } */ function groupByPlacement(bidsByPlacement, bid) { - if (!bidsByPlacement[bid.adUnitCode]) - bidsByPlacement[bid.adUnitCode] = { bids: [] }; + if (!bidsByPlacement[bid.adUnitCode]) { bidsByPlacement[bid.adUnitCode] = { bids: [] }; } bidsByPlacement[bid.adUnitCode].bids.push(bid); @@ -324,7 +319,7 @@ exports.addCallback = function (id, callback, cbEvent) { } }; -//register event for bid adjustment +// register event for bid adjustment events.on(CONSTANTS.EVENTS.BID_ADJUSTMENT, function (bid) { adjustBids(bid); }); @@ -336,8 +331,7 @@ function adjustBids(bid) { if (typeof $$PREBID_GLOBAL$$.bidderSettings[code].bidCpmAdjustment === objectType_function) { try { bidPriceAdjusted = $$PREBID_GLOBAL$$.bidderSettings[code].bidCpmAdjustment.call(null, bid.cpm, Object.assign({}, bid)); - } - catch (e) { + } catch (e) { utils.logError('Error during bid adjustment', 'bidmanager.js', e); } } diff --git a/src/cookie.js b/src/cookie.js index 8e823b1acd9..912b0763a05 100644 --- a/src/cookie.js +++ b/src/cookie.js @@ -6,13 +6,13 @@ const queue = []; function fireSyncs() { queue.forEach(obj => { utils.logMessage(`Invoking cookie sync for bidder: ${obj.bidder}`); - if(obj.type === 'iframe') { + if (obj.type === 'iframe') { utils.insertCookieSyncIframe(obj.url, false); } else { utils.insertPixel(obj.url); } }); - //empty queue. + // empty queue. queue.length = 0; } @@ -30,7 +30,7 @@ cookie.queueSync = function ({bidder, url, type}) { * @param {number} timeout time in ms to delay in sending */ cookie.syncCookies = function(timeout) { - if(timeout) { + if (timeout) { setTimeout(fireSyncs, timeout); } else { @@ -39,7 +39,7 @@ cookie.syncCookies = function(timeout) { }; cookie.persist = function(url, msgHtml) { - if(!utils.isSafariBrowser()){ + if (!utils.isSafariBrowser()) { return; } linkOverride(url); @@ -47,11 +47,11 @@ cookie.persist = function(url, msgHtml) { }; function linkOverride(url) { - for (var i = 0; i < document.links.length; i++){ - var link = document.links[i]; - link.href = url + encodeURIComponent(link.href); - } - } + for (var i = 0; i < document.links.length; i++) { + var link = document.links[i]; + link.href = url + encodeURIComponent(link.href); + } +} function displayFooter(msgHtml) { // https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Example_3_Do_something_only_once diff --git a/src/cpmBucketManager.js b/src/cpmBucketManager.js index 5630204ac28..c135a644dc1 100644 --- a/src/cpmBucketManager.js +++ b/src/cpmBucketManager.js @@ -22,37 +22,37 @@ const _hgPriceConfig = { }; const _densePriceConfig = { 'buckets': [{ - 'min': 0, - 'max': 3, - 'increment': 0.01 - }, - { - 'min': 3, - 'max': 8, - 'increment': 0.05 - }, - { - 'min': 8, - 'max': 20, - 'increment': 0.5 - }] + 'min': 0, + 'max': 3, + 'increment': 0.01 + }, + { + 'min': 3, + 'max': 8, + 'increment': 0.05 + }, + { + 'min': 8, + 'max': 20, + 'increment': 0.5 + }] }; const _autoPriceConfig = { 'buckets': [{ - 'min': 0, - 'max': 5, - 'increment': 0.05 - }, - { - 'min': 5, - 'max': 10, - 'increment': 0.1 - }, - { - 'min': 10, - 'max': 20, - 'increment': 0.5 - }] + 'min': 0, + 'max': 5, + 'increment': 0.05 + }, + { + 'min': 5, + 'max': 10, + 'increment': 0.1 + }, + { + 'min': 10, + 'max': 20, + 'increment': 0.5 + }] }; function getPriceBucketString(cpm, customConfig) { @@ -68,7 +68,7 @@ function getPriceBucketString(cpm, customConfig) { high: (cpmFloat === '') ? '' : getCpmStringValue(cpm, _hgPriceConfig), auto: (cpmFloat === '') ? '' : getCpmStringValue(cpm, _autoPriceConfig), dense: (cpmFloat === '') ? '' : getCpmStringValue(cpm, _densePriceConfig), - custom: (cpmFloat === '') ? '' : getCpmStringValue(cpm, customConfig) + custom: (cpmFloat === '') ? '' : getCpmStringValue(cpm, customConfig) }; } @@ -77,7 +77,7 @@ function getCpmStringValue(cpm, config) { if (!isValidePriceConfig(config)) { return cpmStr; } - const cap = config.buckets.reduce((prev,curr) => { + const cap = config.buckets.reduce((prev, curr) => { if (prev.max > curr.max) { return prev; } @@ -105,7 +105,7 @@ function isValidePriceConfig(config) { } let isValid = true; config.buckets.forEach(bucket => { - if(typeof bucket.min === 'undefined' || !bucket.max || !bucket.increment) { + if (typeof bucket.min === 'undefined' || !bucket.max || !bucket.increment) { isValid = false; } }); diff --git a/src/events.js b/src/events.js index 2b52de1c38f..abef24d6ea3 100644 --- a/src/events.js +++ b/src/events.js @@ -6,19 +6,18 @@ var CONSTANTS = require('./constants'); var slice = Array.prototype.slice; var push = Array.prototype.push; -//define entire events -//var allEvents = ['bidRequested','bidResponse','bidWon','bidTimeout']; +// define entire events +// var allEvents = ['bidRequested','bidResponse','bidWon','bidTimeout']; var allEvents = utils._map(CONSTANTS.EVENTS, function (v) { return v; }); var idPaths = CONSTANTS.EVENT_ID_PATHS; -//keep a record of all events fired +// keep a record of all events fired var eventsFired = []; module.exports = (function () { - var _handlers = {}; var _public = {}; @@ -41,7 +40,7 @@ module.exports = (function () { var callbacks = []; - //record the event: + // record the event: eventsFired.push({ eventType: eventString, args: eventPayload, @@ -66,8 +65,7 @@ module.exports = (function () { if (!fn) return; try { fn.apply(null, args); - } - catch (e) { + } catch (e) { utils.logError('Error executing handler:', 'events.js', e); } }); @@ -78,8 +76,7 @@ module.exports = (function () { } _public.on = function (eventString, handler, id) { - - //check whether available event or not + // check whether available event or not if (_checkAvailableEvent(eventString)) { var event = _handlers[eventString] || { que: [] }; diff --git a/src/polyfill.js b/src/polyfill.js index 586e0d6e918..d1b316f41e3 100644 --- a/src/polyfill.js +++ b/src/polyfill.js @@ -1,7 +1,7 @@ /** @module polyfill Misc polyfills */ -/*jshint -W121 */ +/* jshint -W121 */ require('core-js/fn/array/find'); require('core-js/fn/array/includes'); require('core-js/fn/object/assign'); diff --git a/src/prebid.js b/src/prebid.js index 9466c3dcaea..9e2ed2f2b7e 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -48,7 +48,7 @@ $$PREBID_GLOBAL$$._sendAllBids = false; $$PREBID_GLOBAL$$.bidderSettings = $$PREBID_GLOBAL$$.bidderSettings || {}; -//default timeout for all bids +// default timeout for all bids $$PREBID_GLOBAL$$.bidderTimeout = $$PREBID_GLOBAL$$.bidderTimeout || 3000; // current timeout set in `requestBids` or to default `bidderTimeout` @@ -62,17 +62,17 @@ $$PREBID_GLOBAL$$.logging = $$PREBID_GLOBAL$$.logging || false; // domain where prebid is running for cross domain iframe communication $$PREBID_GLOBAL$$.publisherDomain = $$PREBID_GLOBAL$$.publisherDomain || window.location.origin; -//let the world know we are loaded +// let the world know we are loaded $$PREBID_GLOBAL$$.libLoaded = true; -//version auto generated from build +// version auto generated from build $$PREBID_GLOBAL$$.version = 'v$prebid.version$'; utils.logInfo('Prebid.js v$prebid.version$ loaded'); -//create adUnit array +// create adUnit array $$PREBID_GLOBAL$$.adUnits = $$PREBID_GLOBAL$$.adUnits || []; -//delay to request cookie sync to stay out of critical path +// delay to request cookie sync to stay out of critical path $$PREBID_GLOBAL$$.cookieSyncDelay = $$PREBID_GLOBAL$$.cookieSyncDelay || 100; @@ -139,11 +139,11 @@ function setRenderSize(doc, width, height) { } } -////////////////////////////////// +/// /////////////////////////////// // // // Start Public APIs // // // -////////////////////////////////// +/// /////////////////////////////// /** * This function returns the query string targeting parameters available at this moment for a given ad unit. Note that some bidder's response may not have been received if you call this function too quickly after the requests are sent. @@ -249,26 +249,26 @@ $$PREBID_GLOBAL$$.setTargetingForGPTAsync = function () { return; } - //first reset any old targeting + // first reset any old targeting targeting.resetPresetTargeting(); - //now set new targeting keys + // now set new targeting keys targeting.setTargeting(targeting.getAllTargeting()); - //emit event + // emit event events.emit(SET_TARGETING); }; $$PREBID_GLOBAL$$.setTargetingForAst = function() { utils.logInfo('Invoking $$PREBID_GLOBAL$$.setTargetingForAn', arguments); - if(!targeting.isApntagDefined()) { + if (!targeting.isApntagDefined()) { utils.logError('window.apntag is not defined on the page'); return; } targeting.setTargetingForAst(); - //emit event + // emit event events.emit(SET_TARGETING); }; @@ -294,16 +294,16 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) { utils.logMessage('Calling renderAd with adId :' + id); if (doc && id) { try { - //lookup ad by ad Id + // lookup ad by ad Id const bid = $$PREBID_GLOBAL$$._bidsReceived.find(bid => bid.adId === id); if (bid) { - //replace macros according to openRTB with price paid = bid.cpm + // replace macros according to openRTB with price paid = bid.cpm bid.ad = utils.replaceAuctionPrice(bid.ad, bid.cpm); bid.url = utils.replaceAuctionPrice(bid.url, bid.cpm); - //save winning bids + // save winning bids $$PREBID_GLOBAL$$._winningBids.push(bid); - //emit 'bid won' event here + // emit 'bid won' event here events.emit(BID_WON, bid); const { height, width, ad, mediaType, adUrl: url, renderer } = bid; @@ -323,18 +323,15 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) { } else { utils.logError('Error trying to write ad. No ad for bid response id: ' + id); } - } else { utils.logError('Error trying to write ad. Cannot find ad by given id : ' + id); } - } catch (e) { utils.logError('Error trying to write ad Id :' + id + ' to the page:' + e.message); } } else { utils.logError('Error trying to write ad Id :' + id + ' to the page. Missing document or adId'); } - }; /** @@ -389,7 +386,7 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a invalidVideoAdUnits.forEach(adUnit => { utils.logError(`adUnit ${adUnit.code} has 'mediaType' set to 'video' but contains a bidder that doesn't support video. No Prebid demand requests will be triggered for this adUnit.`); for (let i = 0; i < adUnits.length; i++) { - if (adUnits[i].code === adUnit.code) {adUnits.splice(i, 1);} + if (adUnits[i].code === adUnit.code) { adUnits.splice(i, 1); } } }); @@ -417,7 +414,7 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a return; } - //set timeout for all bids + // set timeout for all bids const timedOut = true; const timeoutCallback = bidmanager.executeCallback.bind(bidmanager, timedOut); const timer = setTimeout(timeoutCallback, cbTimeout); @@ -426,7 +423,7 @@ $$PREBID_GLOBAL$$.requestBids = function ({ bidsBackHandler, timeout, adUnits, a } adaptermanager.callBids({ adUnits, adUnitCodes, cbTimeout }); - if($$PREBID_GLOBAL$$._bidsRequested.length === 0) { + if ($$PREBID_GLOBAL$$._bidsRequested.length === 0) { bidmanager.executeCallback(); } }; @@ -522,7 +519,7 @@ $$PREBID_GLOBAL$$.addCallback = function (eventStr, func) { * @returns {String} id for callback */ $$PREBID_GLOBAL$$.removeCallback = function (/* cbId */) { - //todo + // todo return null; }; @@ -641,11 +638,11 @@ $$PREBID_GLOBAL$$.setPriceGranularity = function (granularity) { utils.logError('Prebid Error: no value passed to `setPriceGranularity()`'); return; } - if(typeof granularity === 'string') { + if (typeof granularity === 'string') { bidmanager.setPriceGranularity(granularity); } - else if(typeof granularity === 'object') { - if(!isValidePriceConfig(granularity)){ + else if (typeof granularity === 'object') { + if (!isValidePriceConfig(granularity)) { utils.logError('Invalid custom price value passed to `setPriceGranularity()`'); return; } @@ -672,15 +669,15 @@ $$PREBID_GLOBAL$$.buildMasterVideoTagFromAdserverTag = function (adserverTag, op utils.logInfo('Invoking $$PREBID_GLOBAL$$.buildMasterVideoTagFromAdserverTag', arguments); var urlComponents = parseURL(adserverTag); - //return original adserverTag if no bids received - if($$PREBID_GLOBAL$$._bidsReceived.length === 0) { + // return original adserverTag if no bids received + if ($$PREBID_GLOBAL$$._bidsReceived.length === 0) { return adserverTag; } var masterTag = ''; - if(options.adserver.toLowerCase() === 'dfp') { + if (options.adserver.toLowerCase() === 'dfp') { var dfpAdserverObj = adserver.dfpAdserver(options, urlComponents); - if(!dfpAdserverObj.verifyAdserverTag()) { + if (!dfpAdserverObj.verifyAdserverTag()) { utils.logError('Invalid adserverTag, required google params are missing in query string'); } dfpAdserverObj.appendQueryParams(); @@ -719,7 +716,6 @@ $$PREBID_GLOBAL$$.getHighestCpmBids = function (adUnitCode) { * @param {object} options - config object for s2s */ $$PREBID_GLOBAL$$.setS2SConfig = function(options) { - if (!utils.contains(Object.keys(options), 'accountId')) { utils.logError('accountId missing in Server to Server config'); return; @@ -731,11 +727,11 @@ $$PREBID_GLOBAL$$.setS2SConfig = function(options) { } const config = Object.assign({ - enabled : false, - endpoint : CONSTANTS.S2S.DEFAULT_ENDPOINT, - timeout : 1000, - maxBids : 1, - adapter : 'prebidServer' + enabled: false, + endpoint: CONSTANTS.S2S.DEFAULT_ENDPOINT, + timeout: 1000, + maxBids: 1, + adapter: 'prebidServer' }, options); adaptermanager.setS2SConfig(config); }; diff --git a/src/secure-creatives.js b/src/secure-creatives.js index 0c116c0a77b..893147cf053 100644 --- a/src/secure-creatives.js +++ b/src/secure-creatives.js @@ -8,7 +8,6 @@ import { EVENTS } from './constants'; const BID_WON = EVENTS.BID_WON; - export function listenMessagesFromCreative() { addEventListener('message', receiveMessage, false); } @@ -30,7 +29,7 @@ function receiveMessage(ev) { if (data.message === 'Prebid Request') { sendAdToCreative(adObject, data.adServerDomain, ev.source); - //save winning bids + // save winning bids $$PREBID_GLOBAL$$._winningBids.push(adObject); events.emit(BID_WON, adObject); diff --git a/src/sizeMapping.js b/src/sizeMapping.js index 90ce5b68851..53c2c63b542 100644 --- a/src/sizeMapping.js +++ b/src/sizeMapping.js @@ -5,37 +5,36 @@ import * as utils from './utils'; let _win; function mapSizes(adUnit) { - if(!isSizeMappingValid(adUnit.sizeMapping)){ + if (!isSizeMappingValid(adUnit.sizeMapping)) { return adUnit.sizes; } const width = getScreenWidth(); - if(!width) { - //size not detected - get largest value set for desktop + if (!width) { + // size not detected - get largest value set for desktop const mapping = adUnit.sizeMapping.reduce((prev, curr) => { return prev.minWidth < curr.minWidth ? curr : prev; }); - if(mapping.sizes && mapping.sizes.length) { + if (mapping.sizes && mapping.sizes.length) { return mapping.sizes; } return adUnit.sizes; } let sizes = ''; - const mapping = adUnit.sizeMapping.find(sizeMapping =>{ + const mapping = adUnit.sizeMapping.find(sizeMapping => { return width > sizeMapping.minWidth; }); - if(mapping && mapping.sizes && mapping.sizes.length){ + if (mapping && mapping.sizes && mapping.sizes.length) { sizes = mapping.sizes; utils.logMessage(`AdUnit : ${adUnit.code} resized based on device width to : ${sizes}`); } - else{ + else { utils.logMessage(`AdUnit : ${adUnit.code} not mapped to any sizes for device width. This request will be suppressed.`); } return sizes; - } function isSizeMappingValid(sizeMapping) { - if(utils.isArray(sizeMapping) && sizeMapping.length > 0){ + if (utils.isArray(sizeMapping) && sizeMapping.length > 0) { return true; } utils.logInfo('No size mapping defined'); diff --git a/src/targeting.js b/src/targeting.js index 63ac2937a77..c28c0063a9b 100644 --- a/src/targeting.js +++ b/src/targeting.js @@ -9,7 +9,7 @@ var pbTargetingKeys = []; targeting.resetPresetTargeting = function() { if (isGptPubadsDefined()) { window.googletag.pubads().getSlots().forEach(slot => { - pbTargetingKeys.forEach(function(key){ + pbTargetingKeys.forEach(function(key) { // reset only registered adunits $$PREBID_GLOBAL$$.adUnits.find(function(unit) { if (unit.code === slot.getAdUnitPath() || @@ -31,7 +31,7 @@ targeting.getAllTargeting = function(adUnitCode) { .concat(getAlwaysUseBidTargeting(adUnitCodes)) .concat($$PREBID_GLOBAL$$._sendAllBids ? getBidLandscapeTargeting(adUnitCodes) : []); - //store a reference of the targeting keys + // store a reference of the targeting keys targeting.map(adUnitCode => { Object.keys(adUnitCode).map(key => { adUnitCode[key].map(targetKey => { @@ -74,12 +74,12 @@ targeting.getWinningBids = function(adUnitCode) { .map(adUnitCode => $$PREBID_GLOBAL$$._bidsReceived .filter(bid => bid.adUnitCode === adUnitCode ? bid : null) .reduce(getHighestCpm, - { - adUnitCode: adUnitCode, - cpm: 0, - adserverTargeting: {}, - timeToRespond: 0 - })); + { + adUnitCode: adUnitCode, + cpm: 0, + adserverTargeting: {}, + timeToRespond: 0 + })); }; targeting.setTargetingForAst = function() { @@ -87,13 +87,13 @@ targeting.setTargetingForAst = function() { Object.keys(targeting).forEach(targetId => Object.keys(targeting[targetId]).forEach(key => { utils.logMessage(`Attempting to set targeting for targetId: ${targetId} key: ${key} value: ${targeting[targetId][key]}`); - //setKeywords supports string and array as value - if(utils.isStr(targeting[targetId][key]) || utils.isArray(targeting[targetId][key])) { + // setKeywords supports string and array as value + if (utils.isStr(targeting[targetId][key]) || utils.isArray(targeting[targetId][key])) { let keywordsObj = {}; let input = 'hb_adid'; let nKey = (key.substring(0, input.length) === input) ? key.toUpperCase() : key; keywordsObj[nKey] = targeting[targetId][key]; - window.apntag.setKeywords(targetId,keywordsObj); + window.apntag.setKeywords(targetId, keywordsObj); } }) ); @@ -107,7 +107,7 @@ function getWinningBidTargeting() { return { [winner.adUnitCode]: Object.keys(winner.adserverTargeting) .filter(key => - typeof winner.sendStandardTargeting === "undefined" || + typeof winner.sendStandardTargeting === 'undefined' || winner.sendStandardTargeting || standardKeys.indexOf(key) === -1) .map(key => ({ [key.substring(0, 20)]: [winner.adserverTargeting[key]] })) @@ -141,7 +141,6 @@ function getAlwaysUseBidTargeting(adUnitCodes) { } return { [key.substring(0, 20)]: [bid.adserverTargeting[key]] }; - }).filter(key => key) // remove empty elements }; } diff --git a/src/url.js b/src/url.js index 9bd555d6f4e..0682ece573a 100644 --- a/src/url.js +++ b/src/url.js @@ -18,9 +18,9 @@ export function parseQS(query) { export function formatQS(query) { return Object .keys(query) - .map(k => Array.isArray(query[k]) ? - query[k].map(v => `${k}[]=${v}`).join('&') : - `${k}=${query[k]}`) + .map(k => Array.isArray(query[k]) + ? query[k].map(v => `${k}[]=${v}`).join('&') + : `${k}=${query[k]}`) .join('&'); } @@ -31,7 +31,7 @@ export function parse(url) { protocol: (parsed.protocol || '').replace(/:$/, ''), hostname: parsed.hostname, port: +parsed.port, - pathname: parsed.pathname.replace(/^(?!\/)/,'/'), + pathname: parsed.pathname.replace(/^(?!\/)/, '/'), search: parseQS(parsed.search || ''), hash: (parsed.hash || '').replace(/^#/, ''), host: parsed.host diff --git a/src/utils.js b/src/utils.js index 2ff853920fd..9b60a1cccff 100644 --- a/src/utils.js +++ b/src/utils.js @@ -53,7 +53,7 @@ function _getUniqueIdentifierStr() { return getIncrementalInteger() + Math.random().toString(16).substr(2); } -//generate a random string (to be used as a dynamic JSONP callback) +// generate a random string (to be used as a dynamic JSONP callback) exports.getUniqueIdentifierStr = _getUniqueIdentifierStr; /** @@ -63,10 +63,9 @@ exports.getUniqueIdentifierStr = _getUniqueIdentifierStr; * https://gist.github.com/jed/982883 via node-uuid */ exports.generateUUID = function generateUUID(placeholder) { - return placeholder ? - (placeholder ^ Math.random() * 16 >> placeholder/4).toString(16) - : - ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, generateUUID); + return placeholder + ? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16) + : ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, generateUUID); }; exports.getBidIdParameter = function (key, paramsObj) { @@ -85,23 +84,22 @@ exports.tryAppendQueryString = function (existingUrl, key, value) { return existingUrl; }; -//parse a query string object passed in bid params -//bid params should be an object such as {key: "value", key1 : "value1"} +// parse a query string object passed in bid params +// bid params should be an object such as {key: "value", key1 : "value1"} exports.parseQueryStringParameters = function (queryObj) { var result = ''; for (var k in queryObj) { if (queryObj.hasOwnProperty(k)) - result += k + '=' + encodeURIComponent(queryObj[k]) + '&'; + { result += k + '=' + encodeURIComponent(queryObj[k]) + '&'; } } return result; }; -//transform an AdServer targeting bids into a query string to send to the adserver +// transform an AdServer targeting bids into a query string to send to the adserver exports.transformAdServerTargetingObj = function (targeting) { // we expect to receive targeting for a single slot at a time if (targeting && Object.getOwnPropertyNames(targeting).length > 0) { - return getKeys(targeting) .map(key => `${key}=${encodeURIComponent(getValue(targeting, key))}`).join('&'); } else { @@ -117,13 +115,13 @@ exports.transformAdServerTargetingObj = function (targeting) { exports.parseSizesInput = function (sizeObj) { var parsedSizes = []; - //if a string for now we can assume it is a single size, like "300x250" + // if a string for now we can assume it is a single size, like "300x250" if (typeof sizeObj === objectType_string) { - //multiple sizes will be comma-separated + // multiple sizes will be comma-separated var sizes = sizeObj.split(','); - //regular expression to match strigns like 300x250 - //start of line, at least 1 number, an "x" , then at least 1 number, and the then end of the line + // regular expression to match strigns like 300x250 + // start of line, at least 1 number, an "x" , then at least 1 number, and the then end of the line var sizeRegex = /^(\d)+x(\d)+$/i; if (sizes) { for (var curSizePos in sizes) { @@ -135,29 +133,27 @@ exports.parseSizesInput = function (sizeObj) { } else if (typeof sizeObj === objectType_object) { var sizeArrayLength = sizeObj.length; - //don't process empty array + // don't process empty array if (sizeArrayLength > 0) { - //if we are a 2 item array of 2 numbers, we must be a SingleSize array + // if we are a 2 item array of 2 numbers, we must be a SingleSize array if (sizeArrayLength === 2 && typeof sizeObj[0] === objectType_number && typeof sizeObj[1] === objectType_number) { parsedSizes.push(this.parseGPTSingleSizeArray(sizeObj)); } else { - //otherwise, we must be a MultiSize array + // otherwise, we must be a MultiSize array for (var i = 0; i < sizeArrayLength; i++) { parsedSizes.push(this.parseGPTSingleSizeArray(sizeObj[i])); } - } } } return parsedSizes; - }; -//parse a GPT style sigle size array, (i.e [300,250]) -//into an AppNexus style string, (i.e. 300x250) +// parse a GPT style sigle size array, (i.e [300,250]) +// into an AppNexus style string, (i.e. 300x250) exports.parseGPTSingleSizeArray = function (singleSize) { - //if we aren't exactly 2 items in this array, it is invalid + // if we aren't exactly 2 items in this array, it is invalid if (this.isArray(singleSize) && singleSize.length === 2 && (!isNaN(singleSize[0]) && !isNaN(singleSize[1]))) { return singleSize[0] + 'x' + singleSize[1]; } @@ -360,7 +356,7 @@ exports.isEmpty = function (object) { * @returns {boolean} if string is empty */ exports.isEmptyStr = function(str) { - return this.isStr(str) && (!str || 0 === str.length); + return this.isStr(str) && (!str || str.length === 0); }; /** @@ -410,7 +406,7 @@ exports.indexOf = (function () { } // ie8 no longer supported - //return polyfills.indexOf; + // return polyfills.indexOf; }()); /** @@ -441,7 +437,7 @@ var hasOwn = function (objectToCheck, propertyToCheckFor) { var insertElement = function(elm) { let elToAppend = document.getElementsByTagName('head'); - try{ + try { elToAppend = elToAppend.length ? elToAppend : document.getElementsByTagName('body'); if (elToAppend.length) { elToAppend = elToAppend[0]; @@ -460,7 +456,7 @@ exports.insertPixel = function (url) { img.onload = function() { try { this.parentNode.removeChild(this); - } catch(e) { + } catch (e) { } }; insertElement(img); @@ -475,7 +471,7 @@ exports.insertCookieSyncIframe = function(url, encodeUri) { let iframeHtml = this.createTrackPixelIframeHtml(url, encodeUri); let div = document.createElement('div'); div.innerHTML = iframeHtml; - let iframe = div.firstChild; + let iframe = div.firstChild; insertElement(iframe); }; @@ -505,7 +501,7 @@ exports.createTrackPixelIframeHtml = function (url, encodeUri = true) { if (!url) { return ''; } - if(encodeUri) { + if (encodeUri) { url = encodeURI(url); } @@ -543,7 +539,7 @@ exports.getValueString = function(param, val, defaultValue) { if (val === undefined || val === null) { return defaultValue; } - if (this.isStr(val) ) { + if (this.isStr(val)) { return val; } if (this.isNumber(val)) { @@ -627,7 +623,7 @@ export function adUnitsFilter(filter, bid) { * @param {HTMLDocument} doc document to check support of 'srcdoc' */ export function isSrcdocSupported(doc) { - //Firefox is excluded due to https://bugzilla.mozilla.org/show_bug.cgi?id=1265961 + // Firefox is excluded due to https://bugzilla.mozilla.org/show_bug.cgi?id=1265961 return doc.defaultView && doc.defaultView.frameElement && 'srcdoc' in doc.defaultView.frameElement && !/firefox/i.test(navigator.userAgent); } @@ -649,7 +645,7 @@ export function isSafariBrowser() { } export function replaceAuctionPrice(str, cpm) { - if(!str) return; + if (!str) return; return str.replace(/\$\{AUCTION_PRICE\}/g, cpm); } diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 00000000000..bdbda915293 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,50 @@ +{ + "env": { + "browser": true, + "mocha": true + }, + "extends": "standard", + "globals": { + "$$PREBID_GLOBAL$$": false + }, + "parserOptions": { + "sourceType": "module" + }, + "rules": { + "comma-dangle": "off", + "semi": "off", + "space-before-function-paren": "off", + + // Exceptions below this line are temporary, so that eslint can be added into the CI process. + // Violations of these styles should be fixed, and the exceptions removed over time. + // + // See Issue #1111. + "camelcase": "off", + "eqeqeq": "off", + "no-mixed-spaces-and-tabs": "off", + "no-tabs": "off", + "no-unused-expressions": "off", + "import/no-duplicates": "off", + "no-template-curly-in-string": "off", + "new-cap": "off", + "no-global-assign": "off", + "no-path-concat": "off", + "no-redeclare": "off", + "no-new-object": "off", + "no-array-constructor": "off", + "node/no-deprecated-api": "off", + "no-cond-assign": "off", + "no-sequences": "off", + "no-eval": "off", + "no-new": "off", + "no-return-assign": "off", + "no-undef": "off", + "no-unused-vars": "off", + "no-use-before-define": "off", + "no-useless-escape": "off", + "one-var": "off", + "standard/array-bracket-even-spacing": "off", + "standard/no-callback-literal": "off", + "standard/object-curly-even-spacing": "off" + } +} diff --git a/test/fixtures/fixtures.js b/test/fixtures/fixtures.js index 202d95b402b..e1cdbed8ab6 100644 --- a/test/fixtures/fixtures.js +++ b/test/fixtures/fixtures.js @@ -3,18 +3,18 @@ export function getBidRequests() { return [ { - "bidderCode": "appnexus", - "requestId": "1863e370099523", - "bidderRequestId": "2946b569352ef2", - "bids": [ + 'bidderCode': 'appnexus', + 'requestId': '1863e370099523', + 'bidderRequestId': '2946b569352ef2', + 'bids': [ { - "bidder": "appnexus", - "params": { - "placementId": "4799418", - "test": "me" + 'bidder': 'appnexus', + 'params': { + 'placementId': '4799418', + 'test': 'me' }, - "placementCode": "/19968336/header-bid-tag1", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag1', + 'sizes': [ [ 728, 90 @@ -24,20 +24,20 @@ export function getBidRequests() { 90 ] ], - "bidId": "392b5a6b05d648", - "bidderRequestId": "2946b569352ef2", - "requestId": "1863e370099523", - "startTime": 1462918897462, - "status": 1, - "transactionId": "fsafsa" + 'bidId': '392b5a6b05d648', + 'bidderRequestId': '2946b569352ef2', + 'requestId': '1863e370099523', + 'startTime': 1462918897462, + 'status': 1, + 'transactionId': 'fsafsa' }, { - "bidder": "appnexus", - "params": { - "placementId": "4799418" + 'bidder': 'appnexus', + 'params': { + 'placementId': '4799418' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -47,29 +47,29 @@ export function getBidRequests() { 600 ] ], - "bidId": "4dccdc37746135", - "bidderRequestId": "2946b569352ef2", - "requestId": "1863e370099523", - "startTime": 1462918897463, - "status": 1, - "transactionId": "fsafsa" + 'bidId': '4dccdc37746135', + 'bidderRequestId': '2946b569352ef2', + 'requestId': '1863e370099523', + 'startTime': 1462918897463, + 'status': 1, + 'transactionId': 'fsafsa' } ], - "start": 1462918897460 + 'start': 1462918897460 }, { - "bidderCode": "pubmatic", - "requestId": "1863e370099523", - "bidderRequestId": "5e1525bae3eb11", - "bids": [ + 'bidderCode': 'pubmatic', + 'requestId': '1863e370099523', + 'bidderRequestId': '5e1525bae3eb11', + 'bids': [ { - "bidder": "pubmatic", - "params": { - "publisherId": 39741, - "adSlot": "39620189@300x250" + 'bidder': 'pubmatic', + 'params': { + 'publisherId': 39741, + 'adSlot': '39620189@300x250' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -79,46 +79,46 @@ export function getBidRequests() { 600 ] ], - "bidId": "6d11aa2d5b3659", - "bidderRequestId": "5e1525bae3eb11", - "requestId": "1863e370099523", - "transactionId": "fsafsa" + 'bidId': '6d11aa2d5b3659', + 'bidderRequestId': '5e1525bae3eb11', + 'requestId': '1863e370099523', + 'transactionId': 'fsafsa' } ], - "start": 1462918897463 + 'start': 1462918897463 }, { - "bidderCode": "rubicon", - "requestId": "1863e370099523", - "bidderRequestId": "8778750ee15a77", - "bids": [ + 'bidderCode': 'rubicon', + 'requestId': '1863e370099523', + 'bidderRequestId': '8778750ee15a77', + 'bids': [ { - "bidder": "rubicon", - "params": { - "accountId": "14062", - "siteId": "70608", - "zoneId": "335918", - "userId": "12346", - "keywords": [ - "a", - "b", - "c" + 'bidder': 'rubicon', + 'params': { + 'accountId': '14062', + 'siteId': '70608', + 'zoneId': '335918', + 'userId': '12346', + 'keywords': [ + 'a', + 'b', + 'c' ], - "inventory": { - "rating": "5-star", - "prodtype": "tech" + 'inventory': { + 'rating': '5-star', + 'prodtype': 'tech' }, - "visitor": { - "ucat": "new", - "search": "iphone" + 'visitor': { + 'ucat': 'new', + 'search': 'iphone' }, - "sizes": [ + 'sizes': [ 15, 10 ], }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -128,26 +128,26 @@ export function getBidRequests() { 600 ] ], - "bidId": "96aff279720d39", - "bidderRequestId": "8778750ee15a77", - "requestId": "1863e370099523", - "transactionId": "fsafsa" + 'bidId': '96aff279720d39', + 'bidderRequestId': '8778750ee15a77', + 'requestId': '1863e370099523', + 'transactionId': 'fsafsa' } ], - "start": 1462918897474 + 'start': 1462918897474 }, { - "bidderCode": "triplelift", - "requestId": "1863e370099523", - "bidderRequestId": "107f5e6e98dcf09", - "bids": [ + 'bidderCode': 'triplelift', + 'requestId': '1863e370099523', + 'bidderRequestId': '107f5e6e98dcf09', + 'bids': [ { - "bidder": "triplelift", - "params": { - "inventoryCode": "sortable_all_right_sports" + 'bidder': 'triplelift', + 'params': { + 'inventoryCode': 'sortable_all_right_sports' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -157,27 +157,27 @@ export function getBidRequests() { 600 ] ], - "bidId": "1144e2f0de84363", - "bidderRequestId": "107f5e6e98dcf09", - "requestId": "1863e370099523", - "startTime": 1462918897477, - "transactionId": "fsafsa" + 'bidId': '1144e2f0de84363', + 'bidderRequestId': '107f5e6e98dcf09', + 'requestId': '1863e370099523', + 'startTime': 1462918897477, + 'transactionId': 'fsafsa' } ], - "start": 1462918897475 + 'start': 1462918897475 }, { - "bidderCode": "brightcom", - "requestId": "1863e370099523", - "bidderRequestId": "12eeded736650b4", - "bids": [ + 'bidderCode': 'brightcom', + 'requestId': '1863e370099523', + 'bidderRequestId': '12eeded736650b4', + 'bids': [ { - "bidder": "brightcom", - "params": { - "tagId": 16577 + 'bidder': 'brightcom', + 'params': { + 'tagId': 16577 }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -187,27 +187,27 @@ export function getBidRequests() { 600 ] ], - "bidId": "135e89c039705da", - "bidderRequestId": "12eeded736650b4", - "requestId": "1863e370099523", - "status": 1, - "transactionId": "fsafsa" + 'bidId': '135e89c039705da', + 'bidderRequestId': '12eeded736650b4', + 'requestId': '1863e370099523', + 'status': 1, + 'transactionId': 'fsafsa' } ], - "start": 1462918897477 + 'start': 1462918897477 }, { - "bidderCode": "brealtime", - "requestId": "1863e370099523", - "bidderRequestId": "167c4d79b615948", - "bids": [ + 'bidderCode': 'brealtime', + 'requestId': '1863e370099523', + 'bidderRequestId': '167c4d79b615948', + 'bids': [ { - "bidder": "brealtime", - "params": { - "placementId": "4799418" + 'bidder': 'brealtime', + 'params': { + 'placementId': '4799418' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -217,28 +217,28 @@ export function getBidRequests() { 600 ] ], - "bidId": "17dd1d869bed44e", - "bidderRequestId": "167c4d79b615948", - "requestId": "1863e370099523", - "startTime": 1462918897480, - "status": 1, - "transactionId": "fsafsa" + 'bidId': '17dd1d869bed44e', + 'bidderRequestId': '167c4d79b615948', + 'requestId': '1863e370099523', + 'startTime': 1462918897480, + 'status': 1, + 'transactionId': 'fsafsa' } ], - "start": 1462918897479 + 'start': 1462918897479 }, { - "bidderCode": "pagescience", - "requestId": "1863e370099523", - "bidderRequestId": "18bed198c172a69", - "bids": [ + 'bidderCode': 'pagescience', + 'requestId': '1863e370099523', + 'bidderRequestId': '18bed198c172a69', + 'bids': [ { - "bidder": "pagescience", - "params": { - "placementId": "4799418" + 'bidder': 'pagescience', + 'params': { + 'placementId': '4799418' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -248,28 +248,28 @@ export function getBidRequests() { 600 ] ], - "bidId": "192c8c1df0f5d1d", - "bidderRequestId": "18bed198c172a69", - "requestId": "1863e370099523", - "startTime": 1462918897481, - "status": 1, - "transactionId": "fsafsa" + 'bidId': '192c8c1df0f5d1d', + 'bidderRequestId': '18bed198c172a69', + 'requestId': '1863e370099523', + 'startTime': 1462918897481, + 'status': 1, + 'transactionId': 'fsafsa' } ], - "start": 1462918897480 + 'start': 1462918897480 }, { - "bidderCode": "amazon", - "requestId": "1863e370099523", - "bidderRequestId": "20d0d30333715a7", - "bids": [ + 'bidderCode': 'amazon', + 'requestId': '1863e370099523', + 'bidderRequestId': '20d0d30333715a7', + 'bids': [ { - "bidder": "amazon", - "params": { - "aId": 3080 + 'bidder': 'amazon', + 'params': { + 'aId': 3080 }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -279,13 +279,13 @@ export function getBidRequests() { 600 ] ], - "bidId": "21ae8131ec04f6e", - "bidderRequestId": "20d0d30333715a7", - "requestId": "1863e370099523", - "transactionId": "fsafsa" + 'bidId': '21ae8131ec04f6e', + 'bidderRequestId': '20d0d30333715a7', + 'requestId': '1863e370099523', + 'transactionId': 'fsafsa' } ], - "start": 1462918897482 + 'start': 1462918897482 } ]; } @@ -293,227 +293,227 @@ export function getBidRequests() { export function getBidResponses() { return [ { - "bidderCode": "triplelift", - "width": 0, - "height": 0, - "statusMessage": "Bid available", - "adId": "222bb26f9e8bd", - "cpm": 0.112256, - "ad": "", - "responseTimestamp": 1462919239337, - "requestTimestamp": 1462919238936, - "bidder": "triplelift", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 401, - "pbLg": "0.00", - "pbMg": "0.10", - "pbHg": "0.11", - "pbAg": "0.10", - "size": "0x0", - "requestId": 123456, - "adserverTargeting": { - "hb_bidder": "triplelift", - "hb_adid": "222bb26f9e8bd", - "hb_pb": "10.00", - "hb_size": "0x0", - "foobar": "0x0" + 'bidderCode': 'triplelift', + 'width': 0, + 'height': 0, + 'statusMessage': 'Bid available', + 'adId': '222bb26f9e8bd', + 'cpm': 0.112256, + 'ad': "", + 'responseTimestamp': 1462919239337, + 'requestTimestamp': 1462919238936, + 'bidder': 'triplelift', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 401, + 'pbLg': '0.00', + 'pbMg': '0.10', + 'pbHg': '0.11', + 'pbAg': '0.10', + 'size': '0x0', + 'requestId': 123456, + 'adserverTargeting': { + 'hb_bidder': 'triplelift', + 'hb_adid': '222bb26f9e8bd', + 'hb_pb': '10.00', + 'hb_size': '0x0', + 'foobar': '0x0' } }, { - "bidderCode": "appnexus", - "width": 300, - "height": 250, - "statusMessage": "Bid available", - "adId": "233bcbee889d46d", - "creative_id": 29681110, - "cpm": 10, - "adUrl": "http://lax1-ib.adnxs.com/ab?e=wqT_3QL8BKh8AgAAAwDWAAUBCMjAybkFEMLLiJWTu9PsVxjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4190DgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBskgLZASFmU21rZ0FpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCd0EzZ0RnQUVEaUFFRGtBRUJtQUVCb0FFQnFBRURzQUVBdVFFQUFBQUFBQURnUDhFQgkMTEFBNERfSkFRMkxMcEVUMU93XzJRFSggd1AtQUJBUFVCBSxASmdDaW9EVTJnV2dBZ0MxQWcBFgRDOQkIqERBQWdQSUFnUFFBZ1BZQWdQZ0FnRG9BZ0Q0QWdDQUF3RS6aAiUhV1FrbmI63AAcd2VBbklBUW8JXPCVVS7YAugH4ALH0wHqAh9odHRwOi8vcHJlYmlkLm9yZzo5OTk5L2dwdC5odG1sgAMAiAMBkAMAmAMFoAMBqgMAsAMAuAMAwAOsAsgDANgDAOADAOgDAPgDA4AEAJIEBC9qcHSYBACiBAoxMC4xLjEzLjM3qAQAsgQICAAQABgAIAC4BADABADIBADSBAoxMC4wLjg1Ljkx&s=1bf15e8cdc7c0c8c119614c6386ab1496560da39&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html", - "responseTimestamp": 1462919239340, - "requestTimestamp": 1462919238919, - "bidder": "appnexus", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 421, - "pbLg": "5.00", - "pbMg": "10.00", - "pbHg": "10.00", - "pbAg": "10.00", - "size": "300x250", - "alwaysUseBid": true, - "requestId": 123456, - "adserverTargeting": { - "hb_bidder": "appnexus", - "hb_adid": "233bcbee889d46d", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" + 'bidderCode': 'appnexus', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '233bcbee889d46d', + 'creative_id': 29681110, + 'cpm': 10, + 'adUrl': 'http://lax1-ib.adnxs.com/ab?e=wqT_3QL8BKh8AgAAAwDWAAUBCMjAybkFEMLLiJWTu9PsVxjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4190DgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBskgLZASFmU21rZ0FpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCd0EzZ0RnQUVEaUFFRGtBRUJtQUVCb0FFQnFBRURzQUVBdVFFQUFBQUFBQURnUDhFQgkMTEFBNERfSkFRMkxMcEVUMU93XzJRFSggd1AtQUJBUFVCBSxASmdDaW9EVTJnV2dBZ0MxQWcBFgRDOQkIqERBQWdQSUFnUFFBZ1BZQWdQZ0FnRG9BZ0Q0QWdDQUF3RS6aAiUhV1FrbmI63AAcd2VBbklBUW8JXPCVVS7YAugH4ALH0wHqAh9odHRwOi8vcHJlYmlkLm9yZzo5OTk5L2dwdC5odG1sgAMAiAMBkAMAmAMFoAMBqgMAsAMAuAMAwAOsAsgDANgDAOADAOgDAPgDA4AEAJIEBC9qcHSYBACiBAoxMC4xLjEzLjM3qAQAsgQICAAQABgAIAC4BADABADIBADSBAoxMC4wLjg1Ljkx&s=1bf15e8cdc7c0c8c119614c6386ab1496560da39&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html', + 'responseTimestamp': 1462919239340, + 'requestTimestamp': 1462919238919, + 'bidder': 'appnexus', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 421, + 'pbLg': '5.00', + 'pbMg': '10.00', + 'pbHg': '10.00', + 'pbAg': '10.00', + 'size': '300x250', + 'alwaysUseBid': true, + 'requestId': 123456, + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '233bcbee889d46d', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' } }, { - "bidderCode": "appnexus", - "width": 728, - "height": 90, - "statusMessage": "Bid available", - "adId": "24bd938435ec3fc", - "creative_id": 33989846, - "cpm": 10, - "adUrl": "http://lax1-ib.adnxs.com/ab?e=wqT_3QLyBKhyAgAAAwDWAAUBCMjAybkFEOOryfjI7rGNWhjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbJmhBYweAnYABokUB4mt0CgAEBigEDVVNEkgUG8ECYAdgFoAFaqAEBsAEAuAEBwAEDyAEA0AEA2AEA4AEA8AEAigI6dWYoJ2EnLCA0OTQ0NzIsIDE0NjI5MTkyNDApOwEcLHInLCAzMzk4OTg0NjYeAPBvkgLNASFwU2Y1YUFpNjBJY0VFTmJKbWhBWUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCd3lnNTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JJNTJDbGs5VjB6X1oVKCRQQV80QUVBOVFFBSw8bUFLS2dNQ0NENkFDQUxVQwUVBEwwCQh0T0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFfZ2lqYXdpMtAA8KZ3ZUFuSUFRb2lvREFnZzgu2ALoB-ACx9MB6gIfaHR0cDovL3ByZWJpZC5vcmc6OTk5OS9ncHQuaHRtbIADAIgDAZADAJgDBaADAaoDALADALgDAMADrALIAwDYAwDgAwDoAwD4AwOABACSBAQvanB0mAQAogQKMTAuMS4xMy4zN6gEi-wJsgQICAAQABgAIAC4BADABADIBADSBAsxMC4wLjgwLjI0MA..&s=1f584d32c2d7ae3ce3662cfac7ca24e710bc7fd0&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html", - "responseTimestamp": 1462919239342, - "requestTimestamp": 1462919238919, - "bidder": "appnexus", - "adUnitCode": "/19968336/header-bid-tag1", - "timeToRespond": 423, - "pbLg": "5.00", - "pbMg": "10.00", - "pbHg": "10.00", - "pbAg": "10.00", - "size": "728x90", - "alwaysUseBid": true, - "requestId": 123456, - "adserverTargeting": { - "hb_bidder": "appnexus", - "hb_adid": "24bd938435ec3fc", - "hb_pb": "10.00", - "hb_size": "728x90", - "foobar": "728x90" + 'bidderCode': 'appnexus', + 'width': 728, + 'height': 90, + 'statusMessage': 'Bid available', + 'adId': '24bd938435ec3fc', + 'creative_id': 33989846, + 'cpm': 10, + 'adUrl': 'http://lax1-ib.adnxs.com/ab?e=wqT_3QLyBKhyAgAAAwDWAAUBCMjAybkFEOOryfjI7rGNWhjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbJmhBYweAnYABokUB4mt0CgAEBigEDVVNEkgUG8ECYAdgFoAFaqAEBsAEAuAEBwAEDyAEA0AEA2AEA4AEA8AEAigI6dWYoJ2EnLCA0OTQ0NzIsIDE0NjI5MTkyNDApOwEcLHInLCAzMzk4OTg0NjYeAPBvkgLNASFwU2Y1YUFpNjBJY0VFTmJKbWhBWUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCd3lnNTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JJNTJDbGs5VjB6X1oVKCRQQV80QUVBOVFFBSw8bUFLS2dNQ0NENkFDQUxVQwUVBEwwCQh0T0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFfZ2lqYXdpMtAA8KZ3ZUFuSUFRb2lvREFnZzgu2ALoB-ACx9MB6gIfaHR0cDovL3ByZWJpZC5vcmc6OTk5OS9ncHQuaHRtbIADAIgDAZADAJgDBaADAaoDALADALgDAMADrALIAwDYAwDgAwDoAwD4AwOABACSBAQvanB0mAQAogQKMTAuMS4xMy4zN6gEi-wJsgQICAAQABgAIAC4BADABADIBADSBAsxMC4wLjgwLjI0MA..&s=1f584d32c2d7ae3ce3662cfac7ca24e710bc7fd0&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html', + 'responseTimestamp': 1462919239342, + 'requestTimestamp': 1462919238919, + 'bidder': 'appnexus', + 'adUnitCode': '/19968336/header-bid-tag1', + 'timeToRespond': 423, + 'pbLg': '5.00', + 'pbMg': '10.00', + 'pbHg': '10.00', + 'pbAg': '10.00', + 'size': '728x90', + 'alwaysUseBid': true, + 'requestId': 123456, + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '24bd938435ec3fc', + 'hb_pb': '10.00', + 'hb_size': '728x90', + 'foobar': '728x90' } }, { - "bidderCode": "pagescience", - "width": 300, - "height": 250, - "statusMessage": "Bid available", - "adId": "25bedd4813632d7", - "creative_id": 29681110, - "cpm": 0.5, - "adUrl": "http://lax1-ib.adnxs.com/ab?e=wqT_3QLzBKhzAgAAAwDWAAUBCMjAybkFEM7fioW41qjIQRjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4yIsEgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBvkgLNASFfeWVLYndpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCdzNBMTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JSR3RLaGp1UTFEX1oVKCRQQV80QUVBOVFFBSw8bUFLS2dQVFNES0FDQUxVQwUVBEwwCQhwT0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFlQWwtYkE20ADwpndlQW5JQVFvaW9EMDBndy7YAugH4ALH0wHqAh9odHRwOi8vcHJlYmlkLm9yZzo5OTk5L2dwdC5odG1sgAMAiAMBkAMAmAMFoAMBqgMAsAMAuAMAwAOsAsgDANgDAOADAOgDAPgDA4AEAJIEBC9qcHSYBACiBAoxMC4xLjEzLjM3qASL7AmyBAgIABAAGAAgALgEAMAEAMgEANIECzEwLjAuOTMuMjAy&s=1fd8d5650fa1fb8d918a2f403d6a1f97c10d7ec2&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html", - "responseTimestamp": 1462919239343, - "requestTimestamp": 1462919238943, - "bidder": "pagescience", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 400, - "pbLg": "0.50", - "pbMg": "0.50", - "pbHg": "0.50", - "pbAg": "0.50", - "size": "300x250", - "requestId": 123456, - "adserverTargeting": { - "hb_bidder": "pagescience", - "hb_adid": "25bedd4813632d7", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" + 'bidderCode': 'pagescience', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '25bedd4813632d7', + 'creative_id': 29681110, + 'cpm': 0.5, + 'adUrl': 'http://lax1-ib.adnxs.com/ab?e=wqT_3QLzBKhzAgAAAwDWAAUBCMjAybkFEM7fioW41qjIQRjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4yIsEgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBvkgLNASFfeWVLYndpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCdzNBMTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JSR3RLaGp1UTFEX1oVKCRQQV80QUVBOVFFBSw8bUFLS2dQVFNES0FDQUxVQwUVBEwwCQhwT0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFlQWwtYkE20ADwpndlQW5JQVFvaW9EMDBndy7YAugH4ALH0wHqAh9odHRwOi8vcHJlYmlkLm9yZzo5OTk5L2dwdC5odG1sgAMAiAMBkAMAmAMFoAMBqgMAsAMAuAMAwAOsAsgDANgDAOADAOgDAPgDA4AEAJIEBC9qcHSYBACiBAoxMC4xLjEzLjM3qASL7AmyBAgIABAAGAAgALgEAMAEAMgEANIECzEwLjAuOTMuMjAy&s=1fd8d5650fa1fb8d918a2f403d6a1f97c10d7ec2&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html', + 'responseTimestamp': 1462919239343, + 'requestTimestamp': 1462919238943, + 'bidder': 'pagescience', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 400, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'size': '300x250', + 'requestId': 123456, + 'adserverTargeting': { + 'hb_bidder': 'pagescience', + 'hb_adid': '25bedd4813632d7', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' } }, { - "bidderCode": "brightcom", - "width": 300, - "height": 250, - "statusMessage": "Bid available", - "adId": "26e0795ab963896", - "cpm": 0.17, - "ad": "", - "responseTimestamp": 1462919239420, - "requestTimestamp": 1462919238937, - "bidder": "brightcom", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 483, - "pbLg": "0.00", - "pbMg": "0.10", - "pbHg": "0.17", - "pbAg": "0.15", - "size": "300x250", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "brightcom", - "hb_adid": "26e0795ab963896", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" + 'bidderCode': 'brightcom', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '26e0795ab963896', + 'cpm': 0.17, + 'ad': "", + 'responseTimestamp': 1462919239420, + 'requestTimestamp': 1462919238937, + 'bidder': 'brightcom', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 483, + 'pbLg': '0.00', + 'pbMg': '0.10', + 'pbHg': '0.17', + 'pbAg': '0.15', + 'size': '300x250', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'brightcom', + 'hb_adid': '26e0795ab963896', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' } }, { - "bidderCode": "brealtime", - "width": 300, - "height": 250, - "statusMessage": "Bid available", - "adId": "275bd666f5a5a5d", - "creative_id": 29681110, - "cpm": 0.5, - "adUrl": "http://lax1-ib.adnxs.com/ab?e=wqT_3QLzBKhzAgAAAwDWAAUBCMjAybkFEIPr4YfMvKLoQBjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4mo8EgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBvkgLNASFsU2NQWlFpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCdzNBMTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JHZmNvazFBejFUX1oVKCRQQV80QUVBOVFFBSw8bUFLS2dOU0NEYUFDQUxVQwUVBEwwCQh0T0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFDUWxfYXdpMtAA8KZ3ZUFuSUFRb2lvRFVnZzAu2ALoB-ACx9MB6gIfaHR0cDovL3ByZWJpZC5vcmc6OTk5OS9ncHQuaHRtbIADAIgDAZADAJgDBaADAaoDALADALgDAMADrALIAwDYAwDgAwDoAwD4AwOABACSBAQvanB0mAQAogQKMTAuMS4xMy4zN6gEi-wJsgQICAAQABgAIAC4BADABADIBADSBAsxMC4wLjg1LjIwOA..&s=975cfe6518f064683541240f0d780d93a5f973da&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html", - "responseTimestamp": 1462919239486, - "requestTimestamp": 1462919238941, - "bidder": "brealtime", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 545, - "pbLg": "0.50", - "pbMg": "0.50", - "pbHg": "0.50", - "pbAg": "0.50", - "size": "300x250", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "brealtime", - "hb_adid": "275bd666f5a5a5d", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" + 'bidderCode': 'brealtime', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '275bd666f5a5a5d', + 'creative_id': 29681110, + 'cpm': 0.5, + 'adUrl': 'http://lax1-ib.adnxs.com/ab?e=wqT_3QLzBKhzAgAAAwDWAAUBCMjAybkFEIPr4YfMvKLoQBjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4mo8EgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBvkgLNASFsU2NQWlFpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCdzNBMTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JHZmNvazFBejFUX1oVKCRQQV80QUVBOVFFBSw8bUFLS2dOU0NEYUFDQUxVQwUVBEwwCQh0T0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFDUWxfYXdpMtAA8KZ3ZUFuSUFRb2lvRFVnZzAu2ALoB-ACx9MB6gIfaHR0cDovL3ByZWJpZC5vcmc6OTk5OS9ncHQuaHRtbIADAIgDAZADAJgDBaADAaoDALADALgDAMADrALIAwDYAwDgAwDoAwD4AwOABACSBAQvanB0mAQAogQKMTAuMS4xMy4zN6gEi-wJsgQICAAQABgAIAC4BADABADIBADSBAsxMC4wLjg1LjIwOA..&s=975cfe6518f064683541240f0d780d93a5f973da&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html', + 'responseTimestamp': 1462919239486, + 'requestTimestamp': 1462919238941, + 'bidder': 'brealtime', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 545, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'size': '300x250', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'brealtime', + 'hb_adid': '275bd666f5a5a5d', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' } }, { - "bidderCode": "pubmatic", - "width": "300", - "height": "250", - "statusMessage": "Bid available", - "adId": "28f4039c636b6a7", - "adSlot": "39620189@300x250", - "cpm": 5.9396, - "ad": "\r
", - "dealId": "", - "responseTimestamp": 1462919239544, - "requestTimestamp": 1462919238922, - "bidder": "pubmatic", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 622, - "pbLg": "5.00", - "pbMg": "5.90", - "pbHg": "5.93", - "pbAg": "5.90", - "size": "300x250", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "pubmatic", - "hb_adid": "28f4039c636b6a7", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" + 'bidderCode': 'pubmatic', + 'width': '300', + 'height': '250', + 'statusMessage': 'Bid available', + 'adId': '28f4039c636b6a7', + 'adSlot': '39620189@300x250', + 'cpm': 5.9396, + 'ad': "\r
", + 'dealId': '', + 'responseTimestamp': 1462919239544, + 'requestTimestamp': 1462919238922, + 'bidder': 'pubmatic', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 622, + 'pbLg': '5.00', + 'pbMg': '5.90', + 'pbHg': '5.93', + 'pbAg': '5.90', + 'size': '300x250', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'pubmatic', + 'hb_adid': '28f4039c636b6a7', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' } }, { - "bidderCode": "rubicon", - "width": 300, - "height": 600, - "statusMessage": "Bid available", - "adId": "29019e2ab586a5a", - "cpm": 2.74, - "ad": "", - "responseTimestamp": 1462919239860, - "requestTimestamp": 1462919238934, - "bidder": "rubicon", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 926, - "pbLg": "2.50", - "pbMg": "2.70", - "pbHg": "2.74", - "pbAg": "2.70", - "size": "300x600", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "rubicon", - "hb_adid": "29019e2ab586a5a", - "hb_pb": "10.00", - "hb_size": "300x600", - "foobar": "300x600" + 'bidderCode': 'rubicon', + 'width': 300, + 'height': 600, + 'statusMessage': 'Bid available', + 'adId': '29019e2ab586a5a', + 'cpm': 2.74, + 'ad': '', + 'responseTimestamp': 1462919239860, + 'requestTimestamp': 1462919238934, + 'bidder': 'rubicon', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 926, + 'pbLg': '2.50', + 'pbMg': '2.70', + 'pbHg': '2.74', + 'pbAg': '2.70', + 'size': '300x600', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'rubicon', + 'hb_adid': '29019e2ab586a5a', + 'hb_pb': '10.00', + 'hb_size': '300x600', + 'foobar': '300x600' } } ]; @@ -521,30 +521,30 @@ export function getBidResponses() { export function getSlotTargeting() { return { - "/19968336/header-bid-tag-0": [ + '/19968336/header-bid-tag-0': [ { - "hb_bidder": [ - "appnexus" + 'hb_bidder': [ + 'appnexus' ] }, { - "hb_adid": [ - "233bcbee889d46d" + 'hb_adid': [ + '233bcbee889d46d' ] }, { - "hb_pb": [ - "10.00" + 'hb_pb': [ + '10.00' ] }, { - "hb_size": [ - "300x250" + 'hb_size': [ + '300x250' ] }, { - "foobar": [ - "300x250" + 'foobar': [ + '300x250' ] } ] @@ -554,8 +554,8 @@ export function getSlotTargeting() { export function getAdUnits() { return [ { - "code": "/19968336/header-bid-tag1", - "sizes": [ + 'code': '/19968336/header-bid-tag1', + 'sizes': [ [ 728, 90 @@ -565,15 +565,15 @@ export function getAdUnits() { 90 ] ], - "bids": [ + 'bids': [ { - "bidder": "adequant", - "params": { - "publisher_id": "1234567", - "bidfloor": 0.01 + 'bidder': 'adequant', + 'params': { + 'publisher_id': '1234567', + 'bidfloor': 0.01 }, - "placementCode": "/19968336/header-bid-tag1", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag1', + 'sizes': [ [ 728, 90 @@ -583,18 +583,18 @@ export function getAdUnits() { 90 ] ], - "bidId": "3692954f816efc", - "bidderRequestId": "2b1a75d5e826c4", - "requestId": "1ff753bd4ae5cb" + 'bidId': '3692954f816efc', + 'bidderRequestId': '2b1a75d5e826c4', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "appnexus", - "params": { - "placementId": "543221", - "test": "me" + 'bidder': 'appnexus', + 'params': { + 'placementId': '543221', + 'test': 'me' }, - "placementCode": "/19968336/header-bid-tag1", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag1', + 'sizes': [ [ 728, 90 @@ -604,17 +604,17 @@ export function getAdUnits() { 90 ] ], - "bidId": "68136e1c47023d", - "bidderRequestId": "55e24a66bed717", - "requestId": "1ff753bd4ae5cb", - "startTime": 1463510220995, - "status": 1 + 'bidId': '68136e1c47023d', + 'bidderRequestId': '55e24a66bed717', + 'requestId': '1ff753bd4ae5cb', + 'startTime': 1463510220995, + 'status': 1 } ] }, { - "code": "/19968336/header-bid-tag-0", - "sizes": [ + 'code': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -624,14 +624,14 @@ export function getAdUnits() { 600 ] ], - "bids": [ + 'bids': [ { - "bidder": "appnexus", - "params": { - "placementId": "5324321" + 'bidder': 'appnexus', + 'params': { + 'placementId': '5324321' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -641,19 +641,19 @@ export function getAdUnits() { 600 ] ], - "bidId": "7e5d6af25ed188", - "bidderRequestId": "55e24a66bed717", - "requestId": "1ff753bd4ae5cb", - "startTime": 1463510220996 + 'bidId': '7e5d6af25ed188', + 'bidderRequestId': '55e24a66bed717', + 'requestId': '1ff753bd4ae5cb', + 'startTime': 1463510220996 }, { - "bidder": "adequant", - "params": { - "publisher_id": "12353433", - "bidfloor": 0.01 + 'bidder': 'adequant', + 'params': { + 'publisher_id': '12353433', + 'bidfloor': 0.01 }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -663,17 +663,17 @@ export function getAdUnits() { 600 ] ], - "bidId": "4448d80ac1374e", - "bidderRequestId": "2b1a75d5e826c4", - "requestId": "1ff753bd4ae5cb" + 'bidId': '4448d80ac1374e', + 'bidderRequestId': '2b1a75d5e826c4', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "triplelift", - "params": { - "inventoryCode": "inv_code_here" + 'bidder': 'triplelift', + 'params': { + 'inventoryCode': 'inv_code_here' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -683,20 +683,20 @@ export function getAdUnits() { 600 ] ], - "bidId": "9514d586c52abf", - "bidderRequestId": "8c4f03b838d7ee", - "requestId": "1ff753bd4ae5cb", - "startTime": 1463510220997 + 'bidId': '9514d586c52abf', + 'bidderRequestId': '8c4f03b838d7ee', + 'requestId': '1ff753bd4ae5cb', + 'startTime': 1463510220997 }, { - "bidder": "springserve", - "params": { - "impId": 1234, - "supplyPartnerId": 1, - "test": true + 'bidder': 'springserve', + 'params': { + 'impId': 1234, + 'supplyPartnerId': 1, + 'test': true }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -706,37 +706,37 @@ export function getAdUnits() { 600 ] ], - "bidId": "113079fed03f58c", - "bidderRequestId": "1048e0df882e965", - "requestId": "1ff753bd4ae5cb" + 'bidId': '113079fed03f58c', + 'bidderRequestId': '1048e0df882e965', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "rubicon", - "params": { - "accountId": "123456", - "siteId": "345678", - "zoneId": "234567", - "userId": "12346", - "keywords": [ - "a", - "b", - "c" + 'bidder': 'rubicon', + 'params': { + 'accountId': '123456', + 'siteId': '345678', + 'zoneId': '234567', + 'userId': '12346', + 'keywords': [ + 'a', + 'b', + 'c' ], - "inventory": { - "rating": "5-star", - "prodtype": "tech" + 'inventory': { + 'rating': '5-star', + 'prodtype': 'tech' }, - "visitor": { - "ucat": "new", - "search": "iphone" + 'visitor': { + 'ucat': 'new', + 'search': 'iphone' }, - "sizes": [ + 'sizes': [ 15, 10 ] }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -746,18 +746,18 @@ export function getAdUnits() { 600 ] ], - "bidId": "13c2c2a79d155ea", - "bidderRequestId": "129e383ac549e5d", - "requestId": "1ff753bd4ae5cb" + 'bidId': '13c2c2a79d155ea', + 'bidderRequestId': '129e383ac549e5d', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "openx", - "params": { - "jstag_url": "http://servedbyopenx.com/w/1.0/jstag?nc=account_key", - "unit": 2345677 + 'bidder': 'openx', + 'params': { + 'jstag_url': 'http://servedbyopenx.com/w/1.0/jstag?nc=account_key', + 'unit': 2345677 }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -767,18 +767,18 @@ export function getAdUnits() { 600 ] ], - "bidId": "154f9cbf82df565", - "bidderRequestId": "1448569c2453b84", - "requestId": "1ff753bd4ae5cb" + 'bidId': '154f9cbf82df565', + 'bidderRequestId': '1448569c2453b84', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "pubmatic", - "params": { - "publisherId": 1234567, - "adSlot": "1234567@300x250" + 'bidder': 'pubmatic', + 'params': { + 'publisherId': 1234567, + 'adSlot': '1234567@300x250' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -788,17 +788,17 @@ export function getAdUnits() { 600 ] ], - "bidId": "17f8c3a8fb13308", - "bidderRequestId": "16095445eeb05e4", - "requestId": "1ff753bd4ae5cb" + 'bidId': '17f8c3a8fb13308', + 'bidderRequestId': '16095445eeb05e4', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "pagescience", - "params": { - "placementId": "1234567" + 'bidder': 'pagescience', + 'params': { + 'placementId': '1234567' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -808,18 +808,18 @@ export function getAdUnits() { 600 ] ], - "bidId": "2074d5757675542", - "bidderRequestId": "19883380ef5453a", - "requestId": "1ff753bd4ae5cb", - "startTime": 1463510221014 + 'bidId': '2074d5757675542', + 'bidderRequestId': '19883380ef5453a', + 'requestId': '1ff753bd4ae5cb', + 'startTime': 1463510221014 }, { - "bidder": "brealtime", - "params": { - "placementId": "1234567" + 'bidder': 'brealtime', + 'params': { + 'placementId': '1234567' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -829,20 +829,20 @@ export function getAdUnits() { 600 ] ], - "bidId": "222b6ad5a9b835d", - "bidderRequestId": "2163409fdf6f333", - "requestId": "1ff753bd4ae5cb", - "startTime": 1463510221015 + 'bidId': '222b6ad5a9b835d', + 'bidderRequestId': '2163409fdf6f333', + 'requestId': '1ff753bd4ae5cb', + 'startTime': 1463510221015 }, { - "bidder": "indexExchange", - "params": { - "id": "1", - "siteID": 123456, - "timeout": 10000 + 'bidder': 'indexExchange', + 'params': { + 'id': '1', + 'siteID': 123456, + 'timeout': 10000 }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -852,19 +852,19 @@ export function getAdUnits() { 600 ] ], - "bidId": "2499961ab3f937a", - "bidderRequestId": "23b57a2de4ae50b", - "requestId": "1ff753bd4ae5cb" + 'bidId': '2499961ab3f937a', + 'bidderRequestId': '23b57a2de4ae50b', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "adform", - "params": { - "adxDomain": "adx.adform.net", - "mid": 123456, - "test": 1 + 'bidder': 'adform', + 'params': { + 'adxDomain': 'adx.adform.net', + 'mid': 123456, + 'test': 1 }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -874,17 +874,17 @@ export function getAdUnits() { 600 ] ], - "bidId": "26605265bf5e9c5", - "bidderRequestId": "25a0902299c17d3", - "requestId": "1ff753bd4ae5cb" + 'bidId': '26605265bf5e9c5', + 'bidderRequestId': '25a0902299c17d3', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "amazon", - "params": { - "aId": 3080 + 'bidder': 'amazon', + 'params': { + 'aId': 3080 }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -894,18 +894,18 @@ export function getAdUnits() { 600 ] ], - "bidId": "2935d8f6764fe45", - "bidderRequestId": "28afa21ca9246c1", - "requestId": "1ff753bd4ae5cb" + 'bidId': '2935d8f6764fe45', + 'bidderRequestId': '28afa21ca9246c1', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "aol", - "params": { - "network": "112345.45", - "placement": 12345 + 'bidder': 'aol', + 'params': { + 'network': '112345.45', + 'placement': 12345 }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -915,17 +915,17 @@ export function getAdUnits() { 600 ] ], - "bidId": "31d1489681dc539", - "bidderRequestId": "30bf32da9080fdd", - "requestId": "1ff753bd4ae5cb" + 'bidId': '31d1489681dc539', + 'bidderRequestId': '30bf32da9080fdd', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "sovrn", - "params": { - "tagid": "123556" + 'bidder': 'sovrn', + 'params': { + 'tagid': '123556' }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -935,19 +935,19 @@ export function getAdUnits() { 600 ] ], - "bidId": "33c1a8028d91563", - "bidderRequestId": "324bcb47cfcf034", - "requestId": "1ff753bd4ae5cb" + 'bidId': '33c1a8028d91563', + 'bidderRequestId': '324bcb47cfcf034', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "pulsepoint", - "params": { - "cf": "300X250", - "cp": 1233456, - "ct": 12357 + 'bidder': 'pulsepoint', + 'params': { + 'cf': '300X250', + 'cp': 1233456, + 'ct': 12357 }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -957,17 +957,17 @@ export function getAdUnits() { 600 ] ], - "bidId": "379219f0506a26f", - "bidderRequestId": "360ec66bbb0719c", - "requestId": "1ff753bd4ae5cb" + 'bidId': '379219f0506a26f', + 'bidderRequestId': '360ec66bbb0719c', + 'requestId': '1ff753bd4ae5cb' }, { - "bidder": "brightcom", - "params": { - "tagId": 75423 + 'bidder': 'brightcom', + 'params': { + 'tagId': 75423 }, - "placementCode": "/19968336/header-bid-tag-0", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 300, 250 @@ -977,9 +977,9 @@ export function getAdUnits() { 600 ] ], - "bidId": "395cfcf496e7d6d", - "bidderRequestId": "38a776c7f001ea", - "requestId": "1ff753bd4ae5cb" + 'bidId': '395cfcf496e7d6d', + 'bidderRequestId': '38a776c7f001ea', + 'requestId': '1ff753bd4ae5cb' } ] } @@ -988,117 +988,117 @@ export function getAdUnits() { export function getBidResponsesFromAPI() { return { - "/19968336/header-bid-tag-0": { - "bids": [ + '/19968336/header-bid-tag-0': { + 'bids': [ { - "bidderCode": "brightcom", - "width": 300, - "height": 250, - "statusMessage": "Bid available", - "adId": "26e0795ab963896", - "cpm": 0.17, - "ad": "", - "responseTimestamp": 1462919239420, - "requestTimestamp": 1462919238937, - "bidder": "brightcom", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 483, - "pbLg": "0.00", - "pbMg": "0.10", - "pbHg": "0.17", - "pbAg": "0.15", - "size": "300x250", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "brightcom", - "hb_adid": "26e0795ab963896", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" + 'bidderCode': 'brightcom', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '26e0795ab963896', + 'cpm': 0.17, + 'ad': "", + 'responseTimestamp': 1462919239420, + 'requestTimestamp': 1462919238937, + 'bidder': 'brightcom', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 483, + 'pbLg': '0.00', + 'pbMg': '0.10', + 'pbHg': '0.17', + 'pbAg': '0.15', + 'size': '300x250', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'brightcom', + 'hb_adid': '26e0795ab963896', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' } }, { - "bidderCode": "brealtime", - "width": 300, - "height": 250, - "statusMessage": "Bid available", - "adId": "275bd666f5a5a5d", - "creative_id": 29681110, - "cpm": 0.5, - "adUrl": "http://lax1-ib.adnxs.com/ab?e=wqT_3QLzBKhzAgAAAwDWAAUBCMjAybkFEIPr4YfMvKLoQBjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4mo8EgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBvkgLNASFsU2NQWlFpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCdzNBMTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JHZmNvazFBejFUX1oVKCRQQV80QUVBOVFFBSw8bUFLS2dOU0NEYUFDQUxVQwUVBEwwCQh0T0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFDUWxfYXdpMtAA8KZ3ZUFuSUFRb2lvRFVnZzAu2ALoB-ACx9MB6gIfaHR0cDovL3ByZWJpZC5vcmc6OTk5OS9ncHQuaHRtbIADAIgDAZADAJgDBaADAaoDALADALgDAMADrALIAwDYAwDgAwDoAwD4AwOABACSBAQvanB0mAQAogQKMTAuMS4xMy4zN6gEi-wJsgQICAAQABgAIAC4BADABADIBADSBAsxMC4wLjg1LjIwOA..&s=975cfe6518f064683541240f0d780d93a5f973da&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html", - "responseTimestamp": 1462919239486, - "requestTimestamp": 1462919238941, - "bidder": "brealtime", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 545, - "pbLg": "0.50", - "pbMg": "0.50", - "pbHg": "0.50", - "pbAg": "0.50", - "size": "300x250", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "brealtime", - "hb_adid": "275bd666f5a5a5d", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" + 'bidderCode': 'brealtime', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '275bd666f5a5a5d', + 'creative_id': 29681110, + 'cpm': 0.5, + 'adUrl': 'http://lax1-ib.adnxs.com/ab?e=wqT_3QLzBKhzAgAAAwDWAAUBCMjAybkFEIPr4YfMvKLoQBjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4mo8EgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBvkgLNASFsU2NQWlFpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCdzNBMTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JHZmNvazFBejFUX1oVKCRQQV80QUVBOVFFBSw8bUFLS2dOU0NEYUFDQUxVQwUVBEwwCQh0T0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFDUWxfYXdpMtAA8KZ3ZUFuSUFRb2lvRFVnZzAu2ALoB-ACx9MB6gIfaHR0cDovL3ByZWJpZC5vcmc6OTk5OS9ncHQuaHRtbIADAIgDAZADAJgDBaADAaoDALADALgDAMADrALIAwDYAwDgAwDoAwD4AwOABACSBAQvanB0mAQAogQKMTAuMS4xMy4zN6gEi-wJsgQICAAQABgAIAC4BADABADIBADSBAsxMC4wLjg1LjIwOA..&s=975cfe6518f064683541240f0d780d93a5f973da&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html', + 'responseTimestamp': 1462919239486, + 'requestTimestamp': 1462919238941, + 'bidder': 'brealtime', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 545, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'size': '300x250', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'brealtime', + 'hb_adid': '275bd666f5a5a5d', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' } }, { - "bidderCode": "pubmatic", - "width": "300", - "height": "250", - "statusMessage": "Bid available", - "adId": "28f4039c636b6a7", - "adSlot": "39620189@300x250", - "cpm": 5.9396, - "ad": "\r
", - "dealId": "", - "responseTimestamp": 1462919239544, - "requestTimestamp": 1462919238922, - "bidder": "pubmatic", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 622, - "pbLg": "5.00", - "pbMg": "5.90", - "pbHg": "5.93", - "pbAg": "5.90", - "size": "300x250", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "pubmatic", - "hb_adid": "28f4039c636b6a7", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" + 'bidderCode': 'pubmatic', + 'width': '300', + 'height': '250', + 'statusMessage': 'Bid available', + 'adId': '28f4039c636b6a7', + 'adSlot': '39620189@300x250', + 'cpm': 5.9396, + 'ad': "\r
", + 'dealId': '', + 'responseTimestamp': 1462919239544, + 'requestTimestamp': 1462919238922, + 'bidder': 'pubmatic', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 622, + 'pbLg': '5.00', + 'pbMg': '5.90', + 'pbHg': '5.93', + 'pbAg': '5.90', + 'size': '300x250', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'pubmatic', + 'hb_adid': '28f4039c636b6a7', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' } }, { - "bidderCode": "rubicon", - "width": 300, - "height": 600, - "statusMessage": "Bid available", - "adId": "29019e2ab586a5a", - "cpm": 2.74, - "ad": "", - "responseTimestamp": 1462919239860, - "requestTimestamp": 1462919238934, - "bidder": "rubicon", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 926, - "pbLg": "2.50", - "pbMg": "2.70", - "pbHg": "2.74", - "pbAg": "2.70", - "size": "300x600", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "rubicon", - "hb_adid": "29019e2ab586a5a", - "hb_pb": "10.00", - "hb_size": "300x600", - "foobar": "300x600" + 'bidderCode': 'rubicon', + 'width': 300, + 'height': 600, + 'statusMessage': 'Bid available', + 'adId': '29019e2ab586a5a', + 'cpm': 2.74, + 'ad': '', + 'responseTimestamp': 1462919239860, + 'requestTimestamp': 1462919238934, + 'bidder': 'rubicon', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 926, + 'pbLg': '2.50', + 'pbMg': '2.70', + 'pbHg': '2.74', + 'pbAg': '2.70', + 'size': '300x600', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'rubicon', + 'hb_adid': '29019e2ab586a5a', + 'hb_pb': '10.00', + 'hb_size': '300x600', + 'foobar': '300x600' } } ] @@ -1109,51 +1109,51 @@ export function getBidResponsesFromAPI() { // Ad server targeting when `$$PREBID_GLOBAL$$.enableSendAllBids()` is called. export function getAdServerTargeting() { return { - "/19968336/header-bid-tag-0": { - "foobar": "300x250", - "hb_size": "300x250", - "hb_pb": "10.00", - "hb_adid": "233bcbee889d46d", - "hb_bidder": "appnexus", - "hb_size_triplelift": "0x0", - "hb_pb_triplelift": "10.00", - "hb_adid_triplelift": "222bb26f9e8bd", - "hb_bidder_triplelift": "triplelift", - "hb_size_appnexus": "300x250", - "hb_pb_appnexus": "10.00", - "hb_adid_appnexus": "233bcbee889d46d", - "hb_bidder_appnexus": "appnexus", - "hb_size_pagescience": "300x250", - "hb_pb_pagescience": "10.00", - "hb_adid_pagescience": "25bedd4813632d7", - "hb_bidder_pagescienc": "pagescience", - "hb_size_brightcom": "300x250", - "hb_pb_brightcom": "10.00", - "hb_adid_brightcom": "26e0795ab963896", - "hb_bidder_brightcom": "brightcom", - "hb_size_brealtime": "300x250", - "hb_pb_brealtime": "10.00", - "hb_adid_brealtime": "275bd666f5a5a5d", - "hb_bidder_brealtime": "brealtime", - "hb_size_pubmatic": "300x250", - "hb_pb_pubmatic": "10.00", - "hb_adid_pubmatic": "28f4039c636b6a7", - "hb_bidder_pubmatic": "pubmatic", - "hb_size_rubicon": "300x600", - "hb_pb_rubicon": "10.00", - "hb_adid_rubicon": "29019e2ab586a5a", - "hb_bidder_rubicon": "rubicon" + '/19968336/header-bid-tag-0': { + 'foobar': '300x250', + 'hb_size': '300x250', + 'hb_pb': '10.00', + 'hb_adid': '233bcbee889d46d', + 'hb_bidder': 'appnexus', + 'hb_size_triplelift': '0x0', + 'hb_pb_triplelift': '10.00', + 'hb_adid_triplelift': '222bb26f9e8bd', + 'hb_bidder_triplelift': 'triplelift', + 'hb_size_appnexus': '300x250', + 'hb_pb_appnexus': '10.00', + 'hb_adid_appnexus': '233bcbee889d46d', + 'hb_bidder_appnexus': 'appnexus', + 'hb_size_pagescience': '300x250', + 'hb_pb_pagescience': '10.00', + 'hb_adid_pagescience': '25bedd4813632d7', + 'hb_bidder_pagescienc': 'pagescience', + 'hb_size_brightcom': '300x250', + 'hb_pb_brightcom': '10.00', + 'hb_adid_brightcom': '26e0795ab963896', + 'hb_bidder_brightcom': 'brightcom', + 'hb_size_brealtime': '300x250', + 'hb_pb_brealtime': '10.00', + 'hb_adid_brealtime': '275bd666f5a5a5d', + 'hb_bidder_brealtime': 'brealtime', + 'hb_size_pubmatic': '300x250', + 'hb_pb_pubmatic': '10.00', + 'hb_adid_pubmatic': '28f4039c636b6a7', + 'hb_bidder_pubmatic': 'pubmatic', + 'hb_size_rubicon': '300x600', + 'hb_pb_rubicon': '10.00', + 'hb_adid_rubicon': '29019e2ab586a5a', + 'hb_bidder_rubicon': 'rubicon' }, - "/19968336/header-bid-tag1": { - "foobar": "728x90", - "hb_size": "728x90", - "hb_pb": "10.00", - "hb_adid": "24bd938435ec3fc", - "hb_bidder": "appnexus", - "hb_size_appnexus": "728x90", - "hb_pb_appnexus": "10.00", - "hb_adid_appnexus": "24bd938435ec3fc", - "hb_bidder_appnexus": "appnexus" + '/19968336/header-bid-tag1': { + 'foobar': '728x90', + 'hb_size': '728x90', + 'hb_pb': '10.00', + 'hb_adid': '24bd938435ec3fc', + 'hb_bidder': 'appnexus', + 'hb_size_appnexus': '728x90', + 'hb_pb_appnexus': '10.00', + 'hb_adid_appnexus': '24bd938435ec3fc', + 'hb_bidder_appnexus': 'appnexus' } }; } @@ -1162,28 +1162,28 @@ export function getAdServerTargeting() { export function getTargetingKeys() { return [ [ - "hb_bidder", - "appnexus" + 'hb_bidder', + 'appnexus' ], [ - "hb_adid", - "233bcbee889d46d" + 'hb_adid', + '233bcbee889d46d' ], [ - "hb_pb", - "10.00" + 'hb_pb', + '10.00' ], [ - "hb_size", - "300x250" + 'hb_size', + '300x250' ], [ - "foobar", - "300x250" + 'foobar', + '300x250' ], [ - "foobar", - "300x250" + 'foobar', + '300x250' ] ]; } @@ -1193,158 +1193,158 @@ export function getTargetingKeys() { export function getTargetingKeysBidLandscape() { return [ [ - "hb_bidder", - "appnexus" + 'hb_bidder', + 'appnexus' ], [ - "hb_adid", - "233bcbee889d46d" + 'hb_adid', + '233bcbee889d46d' ], [ - "hb_pb", - "10.00" + 'hb_pb', + '10.00' ], [ - "hb_size", - "300x250" + 'hb_size', + '300x250' ], [ - "foobar", - "300x250" + 'foobar', + '300x250' ], [ - "foobar", - "300x250" + 'foobar', + '300x250' ], [ - "hb_bidder_triplelift", - "triplelift" + 'hb_bidder_triplelift', + 'triplelift' ], [ - "hb_adid_triplelift", - "222bb26f9e8bd" + 'hb_adid_triplelift', + '222bb26f9e8bd' ], [ - "hb_pb_triplelift", - "10.00" + 'hb_pb_triplelift', + '10.00' ], [ - "hb_size_triplelift", - "0x0" + 'hb_size_triplelift', + '0x0' ], [ - "hb_bidder_appnexus", - "appnexus" + 'hb_bidder_appnexus', + 'appnexus' ], [ - "hb_adid_appnexus", - "233bcbee889d46d" + 'hb_adid_appnexus', + '233bcbee889d46d' ], [ - "hb_pb_appnexus", - "10.00" + 'hb_pb_appnexus', + '10.00' ], [ - "hb_size_appnexus", - "300x250" + 'hb_size_appnexus', + '300x250' ], [ - "hb_bidder_pagescienc", - "pagescience" + 'hb_bidder_pagescienc', + 'pagescience' ], [ - "hb_adid_pagescience", - "25bedd4813632d7" + 'hb_adid_pagescience', + '25bedd4813632d7' ], [ - "hb_pb_pagescience", - "10.00" + 'hb_pb_pagescience', + '10.00' ], [ - "hb_size_pagescience", - "300x250" + 'hb_size_pagescience', + '300x250' ], [ - "hb_bidder_brightcom", - "brightcom" + 'hb_bidder_brightcom', + 'brightcom' ], [ - "hb_adid_brightcom", - "26e0795ab963896" + 'hb_adid_brightcom', + '26e0795ab963896' ], [ - "hb_pb_brightcom", - "10.00" + 'hb_pb_brightcom', + '10.00' ], [ - "hb_size_brightcom", - "300x250" + 'hb_size_brightcom', + '300x250' ], [ - "hb_bidder_brealtime", - "brealtime" + 'hb_bidder_brealtime', + 'brealtime' ], [ - "hb_adid_brealtime", - "275bd666f5a5a5d" + 'hb_adid_brealtime', + '275bd666f5a5a5d' ], [ - "hb_pb_brealtime", - "10.00" + 'hb_pb_brealtime', + '10.00' ], [ - "hb_size_brealtime", - "300x250" + 'hb_size_brealtime', + '300x250' ], [ - "hb_bidder_pubmatic", - "pubmatic" + 'hb_bidder_pubmatic', + 'pubmatic' ], [ - "hb_adid_pubmatic", - "28f4039c636b6a7" + 'hb_adid_pubmatic', + '28f4039c636b6a7' ], [ - "hb_pb_pubmatic", - "10.00" + 'hb_pb_pubmatic', + '10.00' ], [ - "hb_size_pubmatic", - "300x250" + 'hb_size_pubmatic', + '300x250' ], [ - "hb_bidder_rubicon", - "rubicon" + 'hb_bidder_rubicon', + 'rubicon' ], [ - "hb_adid_rubicon", - "29019e2ab586a5a" + 'hb_adid_rubicon', + '29019e2ab586a5a' ], [ - "hb_pb_rubicon", - "10.00" + 'hb_pb_rubicon', + '10.00' ], [ - "hb_size_rubicon", - "300x600" + 'hb_size_rubicon', + '300x600' ] ]; } export function getBidRequestedPayload() { return { - "bidderCode": "adequant", - "requestId": "150f361b202aa8", - "bidderRequestId": "2b193b7a6ff421", - "bids": [ + 'bidderCode': 'adequant', + 'requestId': '150f361b202aa8', + 'bidderRequestId': '2b193b7a6ff421', + 'bids': [ { - "bidder": "adequant", - "params": { - "publisher_id": "5000563", - "bidfloor": 0.01 + 'bidder': 'adequant', + 'params': { + 'publisher_id': '5000563', + 'bidfloor': 0.01 }, - "placementCode": "/19968336/header-bid-tag-1", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag-1', + 'sizes': [ [ 300, 250 @@ -1362,11 +1362,11 @@ export function getBidRequestedPayload() { 100 ] ], - "bidId": "39032dc5c7e834", - "bidderRequestId": "2b193b7a6ff421", - "requestId": "150f361b202aa8" + 'bidId': '39032dc5c7e834', + 'bidderRequestId': '2b193b7a6ff421', + 'requestId': '150f361b202aa8' } ], - "start": 1465426155412 + 'start': 1465426155412 }; } diff --git a/test/helpers/index_adapter_utils.js b/test/helpers/index_adapter_utils.js index ab96743e960..9c1063bf026 100644 --- a/test/helpers/index_adapter_utils.js +++ b/test/helpers/index_adapter_utils.js @@ -1,328 +1,324 @@ var AllowedAdUnits = [[728, 90], [120, 600], [300, 250], [160, 600], [336, 280], [234, 60], [300, 600], [300, 50], [320, 50], [970, 250], [300, 1050], [970, 90], [180, 150]]; var UnsupportedAdUnits = [[700, 100], [100, 600], [300, 200], [100, 600], [300, 200], [200, 60], [900, 200], [300, 1000], [900, 90], [100, 100]]; -exports.supportedSizes = AllowedAdUnits; +exports.supportedSizes = AllowedAdUnits; exports.unsupportedSizes = UnsupportedAdUnits; -var DefaultSiteID = 234567; -var DefaultPlacementCodePrefix = "placementCode-"; -var DefaultCurrency = 'USD'; -var DefaultDspID = 124; -var DefaultTradingDeskID = 3456; -var DefaultCreativeID = 123234; -var DefaultBrandID = 123356; -var DefaultBrand = "LA Tourism & Convention Board"; -var DefaultAdDoman = 2342342; -var DefaultPriceLevel = 1000; //only this is important? -var DefaultDeal = '515'; -var DefaultDealName = 'name: testdeal'; -var DefaultDealID = 'ixdl'; - -var ADAPTER_CODE = 'indexExchange'; - -exports.DefaultSiteID = DefaultSiteID; -exports.DefaultPlacementCodePrefix = DefaultPlacementCodePrefix; -exports.DefaultCurrency = DefaultCurrency; -exports.DefaultDspID = DefaultDspID; -exports.DefaultTradingDeskID = DefaultTradingDeskID; -exports.DefaultCreativeID = DefaultCreativeID; -exports.DefaultBrandID = DefaultBrandID; -exports.DefaultBrand = DefaultBrand; -exports.DefaultAdDoman = DefaultAdDoman; -exports.DefaultPriceLevel = DefaultPriceLevel; -exports.DefaultDeal = DefaultDeal; -exports.DefaultDealName = DefaultDealName; -exports.DefaultDealID = DefaultDealID; - -exports.ADAPTER_CODE = ADAPTER_CODE; +var DefaultSiteID = 234567; +var DefaultPlacementCodePrefix = 'placementCode-'; +var DefaultCurrency = 'USD'; +var DefaultDspID = 124; +var DefaultTradingDeskID = 3456; +var DefaultCreativeID = 123234; +var DefaultBrandID = 123356; +var DefaultBrand = 'LA Tourism & Convention Board'; +var DefaultAdDoman = 2342342; +var DefaultPriceLevel = 1000; // only this is important? +var DefaultDeal = '515'; +var DefaultDealName = 'name: testdeal'; +var DefaultDealID = 'ixdl'; + +var ADAPTER_CODE = 'indexExchange'; + +exports.DefaultSiteID = DefaultSiteID; +exports.DefaultPlacementCodePrefix = DefaultPlacementCodePrefix; +exports.DefaultCurrency = DefaultCurrency; +exports.DefaultDspID = DefaultDspID; +exports.DefaultTradingDeskID = DefaultTradingDeskID; +exports.DefaultCreativeID = DefaultCreativeID; +exports.DefaultBrandID = DefaultBrandID; +exports.DefaultBrand = DefaultBrand; +exports.DefaultAdDoman = DefaultAdDoman; +exports.DefaultPriceLevel = DefaultPriceLevel; +exports.DefaultDeal = DefaultDeal; +exports.DefaultDealName = DefaultDealName; +exports.DefaultDealID = DefaultDealID; + +exports.ADAPTER_CODE = ADAPTER_CODE; function _createBidSlot(placementCode, indexSlotID, sizes, config) { - config = config || {}; - var bid = {}; - bid.bidder = ('bidder' in config) ? config.bidder : ADAPTER_CODE; - bid.placementCode = placementCode; - bid.params = {}; - bid.params.id = indexSlotID; - bid.params.siteID = ('siteID' in config) ? config.siteID : DefaultSiteID; - bid.sizes = sizes; - - //optional parameter - if ( typeof config.timeout !== 'undefined' ){ - bid.params.timeout = config.timeout; - } - if ( typeof config.tier2SiteID !== 'undefined' ){ - bid.params.tier2SiteID = config.tier2SiteID; - } - if ( typeof config.tier3SiteID !== 'undefined' ){ - bid.params.tier3SiteID = config.tier3SiteID; - } - if ( typeof config.slotSize !== 'undefined' ){ - bid.params.size = config.slotSize; - } - - //special parameter - if ( typeof(config.missingSlotID) !== 'undefined' ){ - delete bid.params.id; - } - if ( typeof(config.missingSiteID) !== 'undefined' ){ - delete bid.params.siteID; - } - - return bid; + config = config || {}; + var bid = {}; + bid.bidder = ('bidder' in config) ? config.bidder : ADAPTER_CODE; + bid.placementCode = placementCode; + bid.params = {}; + bid.params.id = indexSlotID; + bid.params.siteID = ('siteID' in config) ? config.siteID : DefaultSiteID; + bid.sizes = sizes; + + // optional parameter + if (typeof config.timeout !== 'undefined') { + bid.params.timeout = config.timeout; + } + if (typeof config.tier2SiteID !== 'undefined') { + bid.params.tier2SiteID = config.tier2SiteID; + } + if (typeof config.tier3SiteID !== 'undefined') { + bid.params.tier3SiteID = config.tier3SiteID; + } + if (typeof config.slotSize !== 'undefined') { + bid.params.size = config.slotSize; + } + + // special parameter + if (typeof (config.missingSlotID) !== 'undefined') { + delete bid.params.id; + } + if (typeof (config.missingSiteID) !== 'undefined') { + delete bid.params.siteID; + } + + return bid; } exports.createBidSlot = _createBidSlot; -exports.createBidSlots = function( numSlot, numSize ) { - if( typeof numSlot === 'undefined' ) numSlot = 1; - if( typeof numSize === 'undefined' ) numSize = 1; +exports.createBidSlots = function(numSlot, numSize) { + if (typeof numSlot === 'undefined') numSlot = 1; + if (typeof numSize === 'undefined') numSize = 1; - var bids = new Array( numSlot ); + var bids = new Array(numSlot); - var mkPlacementCode = function(i, j) { return DefaultPlacementCodePrefix + i + "_" + j; }; - for( var i=0; i [bid.ext.sid, bid])); - - var compared = compareOnKeys(lstore, rstore); - var matched = compared.intersection.map(function(pair) { return { configured: pair.left, sent: pair.right, name: pair.name } }); - - return { unmatched: { configured: compared.lhsOnly, sent: compared.rhsOnly } , matched: matched}; + var lonly = []; + var ronly = []; + + var configured = []; + for (var i = 0; i < lhs.length; i++) { + var group = lhs[i]; + for (var j = 0; j < group.length; j++) { + var bid = group[j]; + configured.push([bid.params.id + '_' + (j + 1), bid]); + + if (typeof bid.params.tier2SiteID !== 'undefined') { + configured.push(['T1_' + bid.params.id + '_' + (j + 1), bid]); + } + if (typeof bid.params.tier3SiteID !== 'undefined') { + configured.push(['T2_' + bid.params.id + '_' + (j + 1), bid]); + } + } + } + + var lstore = createObjectFromArray(configured); + var rstore = createObjectFromArray(rhs.map(bid => [bid.ext.sid, bid])); + + var compared = compareOnKeys(lstore, rstore); + var matched = compared.intersection.map(function(pair) { return { configured: pair.left, sent: pair.right, name: pair.name } }); + + return { unmatched: { configured: compared.lhsOnly, sent: compared.rhsOnly }, matched: matched}; } exports.matchBidsOnSize = function(lhs, rhs) { - var lonly = []; - var ronly = []; + var lonly = []; + var ronly = []; - var configured = []; - for (var i = 0; i < lhs.length; i++) { - var group = lhs[i]; - for (var j = 0; j < group.length; j++) { - var bid = group[j]; - configured.push([bid.size[0] + 'x' + bid.size[1], bid]); - } - } + var configured = []; + for (var i = 0; i < lhs.length; i++) { + var group = lhs[i]; + for (var j = 0; j < group.length; j++) { + var bid = group[j]; + configured.push([bid.size[0] + 'x' + bid.size[1], bid]); + } + } - var lstore = createObjectFromArray(configured); - var rstore = createObjectFromArray(rhs.map(bid => [ bid.banner.w + 'x' + bid.banner.h, bid])); + var lstore = createObjectFromArray(configured); + var rstore = createObjectFromArray(rhs.map(bid => [ bid.banner.w + 'x' + bid.banner.h, bid])); - var compared = compareOnKeys(lstore, rstore); - var matched = compared.intersection.map(function(pair) { return { configured: pair.left, sent: pair.right, name: pair.name } }); + var compared = compareOnKeys(lstore, rstore); + var matched = compared.intersection.map(function(pair) { return { configured: pair.left, sent: pair.right, name: pair.name } }); - return { unmatched: { configured: compared.lhsOnly, sent: compared.rhsOnly } , matched: matched}; + return { unmatched: { configured: compared.lhsOnly, sent: compared.rhsOnly }, matched: matched}; } -exports.getBidResponse = function( configuredBids, urlJSON, optionalPriceLevel, optionalResponseIdentifier, optionalPassOnBid, optionalResponseParam ) { - if( typeof configuredBids === 'undefined' || typeof urlJSON === 'undefined' ) return {}; - var response = {}; - - response.cur = DefaultCurrency; - response.id = urlJSON.r.id; - response.seatbid = []; - - optionalPassOnBid = optionalPassOnBid || []; - - var priceLevel = DefaultPriceLevel; - var adCount = 1; - - for( var i=0; i< configuredBids.length; i++ ) { - - var bidObj = {}; - bidObj.seat = (DefaultTradingDeskID+i).toString(); - bidObj.bid = []; - - var sizes = configuredBids[i].sizes; - var impressionID = 1; - for( var j=0; j", - "cpm": 0.39440, - "ex": "", - "height": "90", - "id": "BirH", - "nurl": "", - "width": "728", - "cid": "bidId1" - }, - { - "adm": "
", - "cpm": 0.03485, - "ex": "", - "height": "600", - "id": "661h", - "nurl": "", - "width": "300", - "cid": "bidId2" + { + bidId: 'bidId2', + bidder: 'aardvark', + placementCode: 'bar', + sizes: [[300, 600]], + rtkid: 1, + params: { + ai: 'AH5S', + sc: '661h', + host: 'custom.server.com' } - ]; + } + ] + }, + // respond + bidderResponse = [ + { + 'adm': '
', + 'cpm': 0.39440, + 'ex': '', + 'height': '90', + 'id': 'BirH', + 'nurl': '', + 'width': '728', + 'cid': 'bidId1' + }, + { + 'adm': '
', + 'cpm': 0.03485, + 'ex': '', + 'height': '600', + 'id': '661h', + 'nurl': '', + 'width': '300', + 'cid': 'bidId2' + } + ]; beforeEach(() => { aardvark = new adapter(); @@ -101,14 +98,12 @@ describe('aardvark adapter tests', function () { $$PREBID_GLOBAL$$._bidsRequested = []; }); - afterEach(() => { sandbox.restore(); $$PREBID_GLOBAL$$._bidsRequested = bidsRequestedOriginal; }); - describe('callBids', () => { beforeEach(() => { sandbox.stub(adloader, 'loadScript'); @@ -121,7 +116,6 @@ describe('aardvark adapter tests', function () { }); }); - describe('callBids with custom host', () => { beforeEach(() => { sandbox.stub(adloader, 'loadScript'); @@ -134,15 +128,12 @@ describe('aardvark adapter tests', function () { }); }); - describe('aardvarkResponse', () => { it('should exist and be a function', () => { expect($$PREBID_GLOBAL$$.aardvarkResponse).to.exist.and.to.be.a('function'); }); }); - - describe('add empty bids if no bid returned', () => { let firstBid; let secondBid; @@ -185,10 +176,8 @@ describe('aardvark adapter tests', function () { expect(firstBid).to.have.property('bidderCode', 'aardvark'); expect(secondBid).to.have.property('bidderCode', 'aardvark'); }); - }); - describe('add bids to the manager', () => { let firstBid; let secondBid; @@ -248,9 +237,4 @@ describe('aardvark adapter tests', function () { expect(secondBid).to.have.property('height', 600); }); }); - - - - }); - diff --git a/test/spec/adapters/adblade_spec.js b/test/spec/adapters/adblade_spec.js index 729917c626d..db5155a7d79 100644 --- a/test/spec/adapters/adblade_spec.js +++ b/test/spec/adapters/adblade_spec.js @@ -84,7 +84,6 @@ describe('adblade adapter', () => { }); describe('callBids', () => { - beforeEach(() => { sandbox.stub(adLoader, 'loadScript'); adapter.callBids(bidderRequest); @@ -96,18 +95,15 @@ describe('adblade adapter', () => { expect(adLoader.loadScript.firstCall.args[0]).to.include('adblade.com'); expect(adLoader.loadScript.firstCall.args[0]).to.include('prebidjs'); }); - }); describe('adbladeResponse', () => { - it('should exist and be a function', () => { expect(pbjs.adbladeResponse).to.exist.and.to.be.a('function'); }); }); describe('add bids to the manager', () => { - let firstBid; beforeEach(() => { @@ -117,25 +113,25 @@ describe('adblade adapter', () => { // respond let bidderReponse = { - "cur": "USD", - "id": "03a9404f-7b39-4d04-b50b-6459b9aa3ffa", - "seatbid": [ + 'cur': 'USD', + 'id': '03a9404f-7b39-4d04-b50b-6459b9aa3ffa', + 'seatbid': [ { - "seat": "1", - "bid": [ + 'seat': '1', + 'bid': [ { - "nurl": "http://example.com", - "crid": "20063", - "adomain": [ - "www.adblade.com" + 'nurl': 'http://example.com', + 'crid': '20063', + 'adomain': [ + 'www.adblade.com' ], - "price": 3, - "w": 728, - "h": 90, - "id": "1", - "adm": "
", - "impid": "bidId1", - "cid": "99" + 'price': 3, + 'w': 728, + 'h': 90, + 'id': '1', + 'adm': '
', + 'impid': 'bidId1', + 'cid': '99' } ] } @@ -175,7 +171,6 @@ describe('adblade adapter', () => { }); describe('add empty bids if no bid returned', () => { - let firstBid; beforeEach(() => { @@ -207,6 +202,5 @@ describe('adblade adapter', () => { it('should add the bidder code to the bid object', () => { expect(firstBid).to.have.property('bidderCode', 'adblade'); }); - }); }); diff --git a/test/spec/adapters/adbund_spec.js b/test/spec/adapters/adbund_spec.js index 0714d041c83..868b9a9258d 100644 --- a/test/spec/adapters/adbund_spec.js +++ b/test/spec/adapters/adbund_spec.js @@ -4,93 +4,91 @@ import bidManager from 'src/bidmanager'; import CONSTANTS from 'src/constants.json'; describe('adbund adapter tests', function () { - - let sandbox; - let adapter; - let server; - - const request = { - bidderCode: 'adbund', - bids: [{ - bidder: 'adbund', - params: { - sid: '110238', - bidfloor: 0.036 - }, - placementCode: 'adbund', - sizes: [[300, 250]], - bidId: 'adbund_bidId', - bidderRequestId: 'adbund_bidderRequestId', - requestId: 'adbund_requestId' - }] - }; - - const response = { - bidderCode: 'adbund', - cpm: 1.06, - height: 250, - width: 300 - }; - + let sandbox; + let adapter; + let server; + + const request = { + bidderCode: 'adbund', + bids: [{ + bidder: 'adbund', + params: { + sid: '110238', + bidfloor: 0.036 + }, + placementCode: 'adbund', + sizes: [[300, 250]], + bidId: 'adbund_bidId', + bidderRequestId: 'adbund_bidderRequestId', + requestId: 'adbund_requestId' + }] + }; + + const response = { + bidderCode: 'adbund', + cpm: 1.06, + height: 250, + width: 300 + }; + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + + afterEach(() => { + sandbox.restore(); + }); + + describe('adbund callBids validation', () => { beforeEach(() => { - sandbox = sinon.sandbox.create(); + adapter = new Adapter(); }); afterEach(() => { - sandbox.restore(); }); - describe('adbund callBids validation', () => { - - beforeEach(() => { - adapter = new Adapter(); - }); + it('Valid bid-request', () => { + let bidderRequest; - afterEach(() => { - }); + sandbox.stub(adapter, 'callBids'); + adapter.callBids(request); - it('Valid bid-request', () => { - let bidderRequest; + bidderRequest = adapter.callBids.getCall(0).args[0]; - sandbox.stub(adapter, 'callBids'); - adapter.callBids(request); - - bidderRequest = adapter.callBids.getCall(0).args[0]; - - expect(bidderRequest).to.have.property('bids') + expect(bidderRequest).to.have.property('bids') .that.is.an('array') .with.lengthOf(1); - expect(bidderRequest).to.have.deep.property('bids[0]') + expect(bidderRequest).to.have.deep.property('bids[0]') .to.have.property('bidder', 'adbund'); - expect(bidderRequest).to.have.deep.property('bids[0]') + expect(bidderRequest).to.have.deep.property('bids[0]') .with.property('sizes') .that.is.an('array') .with.lengthOf(1) .that.deep.equals(request.bids[0].sizes); - expect(bidderRequest).to.have.deep.property('bids[0]') + expect(bidderRequest).to.have.deep.property('bids[0]') .with.property('params') .to.have.property('bidfloor', 0.036); - }); + }); - it('Valid bid-response', () => { - var bidderResponse; + it('Valid bid-response', () => { + var bidderResponse; - sandbox.stub(bidManager, 'addBidResponse'); - adapter.callBids(request); - bidderResponse = bidManager.addBidResponse.getCall(0) || + sandbox.stub(bidManager, 'addBidResponse'); + adapter.callBids(request); + bidderResponse = bidManager.addBidResponse.getCall(0) || bidManager.addBidResponse.getCall(1); - if (bidderResponse && bidderResponse.args && bidderResponse.args[1]) { - bidderResponse = bidderResponse.args[1]; - expect(bidderResponse.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); - expect(bidderResponse.bidderCode).to.equal(response.bidderCode); - expect(bidderResponse.width).to.equal(response.width); - expect(bidderResponse.height).to.equal(response.height); - expect(bidderResponse.cpm).to.equal(response.cpm); - } - }); + if (bidderResponse && bidderResponse.args && bidderResponse.args[1]) { + bidderResponse = bidderResponse.args[1]; + expect(bidderResponse.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); + expect(bidderResponse.bidderCode).to.equal(response.bidderCode); + expect(bidderResponse.width).to.equal(response.width); + expect(bidderResponse.height).to.equal(response.height); + expect(bidderResponse.cpm).to.equal(response.cpm); + } }); -}); \ No newline at end of file + }); +}); diff --git a/test/spec/adapters/adbutler_spec.js b/test/spec/adapters/adbutler_spec.js index 172c2205210..ed08fb1888a 100644 --- a/test/spec/adapters/adbutler_spec.js +++ b/test/spec/adapters/adbutler_spec.js @@ -1,543 +1,521 @@ describe('adbutler adapter tests', function () { + var expect = require('chai').expect; + var adapter = require('src/adapters/adbutler'); + var adLoader = require('src/adloader'); + var bidmanager = require('src/bidmanager'); - var expect = require('chai').expect; - var adapter = require('src/adapters/adbutler'); - var adLoader = require('src/adloader'); - var bidmanager = require('src/bidmanager'); + window.pbjs = window.pbjs || {}; + if (typeof (pbjs) === 'undefined') { + var pbjs = window.pbjs; + } - window.pbjs = window.pbjs || {}; - if (typeof(pbjs)==="undefined"){ - var pbjs = window.pbjs; + describe('creation of bid url', function () { + var stubLoadScript; + + beforeEach(function () { + stubLoadScript = sinon.stub(adLoader, 'loadScript'); + }); + + afterEach(function () { + stubLoadScript.restore(); + }); + + if (typeof (pbjs._bidsReceived) === 'undefined') { + pbjs._bidsReceived = []; + } + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = []; } - - describe('creation of bid url', function () { - - var stubLoadScript; - - beforeEach(function () { - stubLoadScript = sinon.stub(adLoader, 'loadScript'); - }); - - afterEach(function () { - stubLoadScript.restore(); - }); - - if (typeof(pbjs._bidsReceived) === "undefined") { - pbjs._bidsReceived = []; - } - if (typeof(pbjs._bidsRequested) === "undefined") { - pbjs._bidsRequested = []; - } - if (typeof(pbjs._adsReceived) === "undefined") { - pbjs._adsReceived = []; - } - - it('should be called', function () { - - var params = { - bidderCode: 'adbutler', - bids: [ - { - bidId: '3c9408cdbf2f68', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210093' - }, - requestId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - - ] - }; - - adapter().callBids(params); - - sinon.assert.called(stubLoadScript); - - }); - - it('should populate the keyword',function(){ - var params = { - bidderCode: 'adbutler', - bids: [ - { - bidId: '3c9408cdbf2f68', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210093', - keyword: 'fish' - }, - requestId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - - ] - }; - - adapter().callBids(params); - - var requestURI = stubLoadScript.getCall(0).args[0]; - - expect(requestURI).to.have.string(';kw=fish;'); - }); - - it('should use custom domain string',function(){ - var params = { - bidderCode: 'adbutler', - bids: [ - { - bidId: '3c9408cdbf2f68', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '107878', - zoneID: '86133', - domain: 'servedbyadbutler.com.dan.test' - }, - requestId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - ] - }; - - adapter().callBids(params); - - var requestURI = stubLoadScript.getCall(0).args[0]; - - expect(requestURI).to.have.string('.dan.test'); - }); + if (typeof (pbjs._adsReceived) === 'undefined') { + pbjs._adsReceived = []; + } + + it('should be called', function () { + var params = { + bidderCode: 'adbutler', + bids: [ + { + bidId: '3c9408cdbf2f68', + sizes: [[300, 250]], + bidder: 'adbutler', + params: { + accountID: '167283', + zoneID: '210093' + }, + requestId: '10b327aa396609', + placementCode: '/123456/header-bid-tag-1' + } + + ] + }; + + adapter().callBids(params); + + sinon.assert.called(stubLoadScript); }); - describe('bid responses',function(){ - - it('should return complete bid response',function(){ - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - - var params = { - bidderCode: 'adbutler', - bidder: 'adbutler', - bids: [ - { - bidId: '3c94018cdbf2f68-1', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210093', - }, - requestId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - - ] - }; - - var response = { - status: "SUCCESS", - account_id: 167283, - zone_id: 210093, - cpm: 1.5, - width: 300, - height: 250, - place: 0 - }; - - adapter().callBids(params); - - var adUnits = new Array(); - var unit = new Object(); - unit.bids = params.bids; - unit.code = '/123456/header-bid-tag-1'; - unit.sizes=[[300,250]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } - else{ - pbjs._bidsRequested.push(params); - } - - pbjs.adUnits = adUnits; - - - pbjs.adbutlerCB(response); - - var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - - expect(bidPlacementCode1).to.equal('/123456/header-bid-tag-1'); - expect(bidObject1.getStatusCode()).to.equal(1); - expect(bidObject1.bidderCode).to.equal('adbutler'); - expect(bidObject1.cpm).to.equal(1.5); - expect(bidObject1.width).to.equal(300); - expect(bidObject1.height).to.equal(250); - - stubAddBidResponse.restore(); - }); - - it('should return empty bid response', function(){ - - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - var params = { - bidderCode: 'adbutler', - bids: [ - { - bidId: '3c9408cdbf2f68-2', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210085', - }, - requestId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - - ] - }; - - var response = { - status: "NO_ELIGIBLE_ADS", - zone_id: 210085, - width: 728, - height: 90, - place: 0 - }; - - adapter().callBids(params); - - var adUnits = new Array(); - var unit = new Object(); - unit.bids = params.bids; - unit.code = '/123456/header-bid-tag-1'; - unit.sizes=[[300,250]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } - else{ - pbjs._bidsRequested.push(params); - } - - pbjs.adUnits = adUnits; - - pbjs.adbutlerCB(response); - - var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - - expect(bidPlacementCode1).to.equal('/123456/header-bid-tag-1'); - expect(bidObject1.getStatusCode()).to.equal(2); - expect(bidObject1.bidderCode).to.equal('adbutler'); - - stubAddBidResponse.restore(); - }); - - it('should return empty bid response on incorrect size',function(){ - - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - var params = { - bidderCode: 'adbutler', - bids: [ - { - bidId: '3c9408cdbf2f68-3', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210085', - }, - requestId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - - ] - }; - - var response = { - status: "SUCCESS", - account_id: 167283, - zone_id: 210085, - cpm: 1.5, - width: 728, - height: 90, - place: 0 - }; - - adapter().callBids(params); - - var adUnits = new Array(); - var unit = new Object(); - unit.bids = params.bids; - unit.code = '/123456/header-bid-tag-1'; - unit.sizes=[[300,250]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } - else{ - pbjs._bidsRequested.push(params); - } - - pbjs.adUnits = adUnits; - - pbjs.adbutlerCB(response); - - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - expect(bidObject1.getStatusCode()).to.equal(2); - - stubAddBidResponse.restore(); - }); - - it('should return empty bid response with CPM too low',function(){ - - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - var params = { - bidderCode: 'adbutler', - bids: [ - { - bidId: '3c9408cdbf2f68-4', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210093', - minCPM: '5.00' - }, - requestId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - - ] - }; - - var response = { - status: "SUCCESS", - account_id: 167283, - zone_id: 210093, - cpm: 1.5, - width: 300, - height: 250, - place: 0 - }; - - adapter().callBids(params); - - var adUnits = new Array(); - var unit = new Object(); - unit.bids = params.bids; - unit.code = '/123456/header-bid-tag-1'; - unit.sizes=[[300,250]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } - else{ - pbjs._bidsRequested.push(params); - } - - pbjs.adUnits = adUnits; - - pbjs.adbutlerCB(response); - - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - expect(bidObject1.getStatusCode()).to.equal(2); - - stubAddBidResponse.restore(); - }); - - it('should return empty bid response with CPM too high',function(){ - - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - - var params = { - bidderCode: 'adbutler', - bids: [ - { - bidId: '3c9408cdbf2f68-5', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210093', - maxCPM: '1.00' - }, - requestId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - - ] - }; - - var response = { - status: "SUCCESS", - account_id: 167283, - zone_id: 210093, - cpm: 1.5, - width: 300, - height: 250, - place: 0 - }; - - adapter().callBids(params); - - var adUnits = new Array(); - var unit = new Object(); - unit.bids = params.bids; - unit.code = '/123456/header-bid-tag-1'; - unit.sizes=[[300,250]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } - else{ - pbjs._bidsRequested.push(params); - } - - pbjs.adUnits = adUnits; - - pbjs.adbutlerCB(response); - - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - expect(bidObject1.getStatusCode()).to.equal(2); - - stubAddBidResponse.restore(); - }); + it('should populate the keyword', function() { + var params = { + bidderCode: 'adbutler', + bids: [ + { + bidId: '3c9408cdbf2f68', + sizes: [[300, 250]], + bidder: 'adbutler', + params: { + accountID: '167283', + zoneID: '210093', + keyword: 'fish' + }, + requestId: '10b327aa396609', + placementCode: '/123456/header-bid-tag-1' + } + + ] + }; + + adapter().callBids(params); + + var requestURI = stubLoadScript.getCall(0).args[0]; + + expect(requestURI).to.have.string(';kw=fish;'); + }); + + it('should use custom domain string', function() { + var params = { + bidderCode: 'adbutler', + bids: [ + { + bidId: '3c9408cdbf2f68', + sizes: [[300, 250]], + bidder: 'adbutler', + params: { + accountID: '107878', + zoneID: '86133', + domain: 'servedbyadbutler.com.dan.test' + }, + requestId: '10b327aa396609', + placementCode: '/123456/header-bid-tag-1' + } + ] + }; + + adapter().callBids(params); + + var requestURI = stubLoadScript.getCall(0).args[0]; + + expect(requestURI).to.have.string('.dan.test'); + }); + }); + describe('bid responses', function() { + it('should return complete bid response', function() { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + + var params = { + bidderCode: 'adbutler', + bidder: 'adbutler', + bids: [ + { + bidId: '3c94018cdbf2f68-1', + sizes: [[300, 250]], + bidder: 'adbutler', + params: { + accountID: '167283', + zoneID: '210093', + }, + requestId: '10b327aa396609', + placementCode: '/123456/header-bid-tag-1' + } + + ] + }; + + var response = { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210093, + cpm: 1.5, + width: 300, + height: 250, + place: 0 + }; + + adapter().callBids(params); + + var adUnits = new Array(); + var unit = new Object(); + unit.bids = params.bids; + unit.code = '/123456/header-bid-tag-1'; + unit.sizes = [[300, 250]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + + pbjs.adUnits = adUnits; + + pbjs.adbutlerCB(response); + + var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + + expect(bidPlacementCode1).to.equal('/123456/header-bid-tag-1'); + expect(bidObject1.getStatusCode()).to.equal(1); + expect(bidObject1.bidderCode).to.equal('adbutler'); + expect(bidObject1.cpm).to.equal(1.5); + expect(bidObject1.width).to.equal(300); + expect(bidObject1.height).to.equal(250); + + stubAddBidResponse.restore(); }); - - describe('ad code',function(){ - - it('should be populated',function(){ - - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - - var params = { - bidderCode: 'adbutler', - bids: [ - { - bidId: '3c9408cdbf2f68-6', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210093' - }, - requestId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - - ] - }; - - var response = { - status: "SUCCESS", - account_id: 167283, - zone_id: 210093, - cpm: 1.5, - width: 300, - height: 250, - place: 0, - ad_code: '' - }; - - adapter().callBids(params); - - var adUnits = new Array(); - var unit = new Object(); - unit.bids = params.bids; - unit.code = '/123456/header-bid-tag-1'; - unit.sizes=[[300,250]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } - else{ - pbjs._bidsRequested.push(params); - } - - pbjs.adUnits = adUnits; - - pbjs.adbutlerCB(response); - - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - expect(bidObject1.getStatusCode()).to.equal(1); - expect(bidObject1.ad).to.have.length.above(1); - - stubAddBidResponse.restore(); - }); - - it('should contain tracking pixels',function(){ - - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - - var params = { - bidderCode: 'adbutler', - bids: [ - { - bidId: '3c9408cdbf2f68-7', - sizes: [[300, 250]], - bidder: 'adbutler', - params: { - accountID: '167283', - zoneID: '210093' - }, - requestId: '10b327aa396609', - placementCode: '/123456/header-bid-tag-1' - } - - ] - }; - - var response = { - status: "SUCCESS", - account_id: 167283, - zone_id: 210093, - cpm: 1.5, - width: 300, - height: 250, - place: 0, - ad_code: '', - tracking_pixels: [ - "http://tracking.pixel.com/params=info" - ] - }; - - adapter().callBids(params); - - var adUnits = new Array(); - var unit = new Object(); - unit.bids = params.bids; - unit.code = '/123456/header-bid-tag-1'; - unit.sizes=[[300,250]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } - else{ - pbjs._bidsRequested.push(params); - } - - pbjs.adUnits = adUnits; - - pbjs.adbutlerCB(response); - - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - expect(bidObject1.getStatusCode()).to.equal(1); - expect(bidObject1.ad).to.have.string('http://tracking.pixel.com/params=info'); - - stubAddBidResponse.restore(); - }); - + + it('should return empty bid response', function() { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + var params = { + bidderCode: 'adbutler', + bids: [ + { + bidId: '3c9408cdbf2f68-2', + sizes: [[300, 250]], + bidder: 'adbutler', + params: { + accountID: '167283', + zoneID: '210085', + }, + requestId: '10b327aa396609', + placementCode: '/123456/header-bid-tag-1' + } + + ] + }; + + var response = { + status: 'NO_ELIGIBLE_ADS', + zone_id: 210085, + width: 728, + height: 90, + place: 0 + }; + + adapter().callBids(params); + + var adUnits = new Array(); + var unit = new Object(); + unit.bids = params.bids; + unit.code = '/123456/header-bid-tag-1'; + unit.sizes = [[300, 250]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + + pbjs.adUnits = adUnits; + + pbjs.adbutlerCB(response); + + var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + + expect(bidPlacementCode1).to.equal('/123456/header-bid-tag-1'); + expect(bidObject1.getStatusCode()).to.equal(2); + expect(bidObject1.bidderCode).to.equal('adbutler'); + + stubAddBidResponse.restore(); + }); + + it('should return empty bid response on incorrect size', function() { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + var params = { + bidderCode: 'adbutler', + bids: [ + { + bidId: '3c9408cdbf2f68-3', + sizes: [[300, 250]], + bidder: 'adbutler', + params: { + accountID: '167283', + zoneID: '210085', + }, + requestId: '10b327aa396609', + placementCode: '/123456/header-bid-tag-1' + } + + ] + }; + + var response = { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210085, + cpm: 1.5, + width: 728, + height: 90, + place: 0 + }; + + adapter().callBids(params); + + var adUnits = new Array(); + var unit = new Object(); + unit.bids = params.bids; + unit.code = '/123456/header-bid-tag-1'; + unit.sizes = [[300, 250]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + + pbjs.adUnits = adUnits; + + pbjs.adbutlerCB(response); + + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + expect(bidObject1.getStatusCode()).to.equal(2); + + stubAddBidResponse.restore(); + }); + + it('should return empty bid response with CPM too low', function() { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + var params = { + bidderCode: 'adbutler', + bids: [ + { + bidId: '3c9408cdbf2f68-4', + sizes: [[300, 250]], + bidder: 'adbutler', + params: { + accountID: '167283', + zoneID: '210093', + minCPM: '5.00' + }, + requestId: '10b327aa396609', + placementCode: '/123456/header-bid-tag-1' + } + + ] + }; + + var response = { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210093, + cpm: 1.5, + width: 300, + height: 250, + place: 0 + }; + + adapter().callBids(params); + + var adUnits = new Array(); + var unit = new Object(); + unit.bids = params.bids; + unit.code = '/123456/header-bid-tag-1'; + unit.sizes = [[300, 250]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + + pbjs.adUnits = adUnits; + + pbjs.adbutlerCB(response); + + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + expect(bidObject1.getStatusCode()).to.equal(2); + + stubAddBidResponse.restore(); + }); + + it('should return empty bid response with CPM too high', function() { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + + var params = { + bidderCode: 'adbutler', + bids: [ + { + bidId: '3c9408cdbf2f68-5', + sizes: [[300, 250]], + bidder: 'adbutler', + params: { + accountID: '167283', + zoneID: '210093', + maxCPM: '1.00' + }, + requestId: '10b327aa396609', + placementCode: '/123456/header-bid-tag-1' + } + + ] + }; + + var response = { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210093, + cpm: 1.5, + width: 300, + height: 250, + place: 0 + }; + + adapter().callBids(params); + + var adUnits = new Array(); + var unit = new Object(); + unit.bids = params.bids; + unit.code = '/123456/header-bid-tag-1'; + unit.sizes = [[300, 250]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + + pbjs.adUnits = adUnits; + + pbjs.adbutlerCB(response); + + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + expect(bidObject1.getStatusCode()).to.equal(2); + + stubAddBidResponse.restore(); + }); + }); + + describe('ad code', function() { + it('should be populated', function() { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + + var params = { + bidderCode: 'adbutler', + bids: [ + { + bidId: '3c9408cdbf2f68-6', + sizes: [[300, 250]], + bidder: 'adbutler', + params: { + accountID: '167283', + zoneID: '210093' + }, + requestId: '10b327aa396609', + placementCode: '/123456/header-bid-tag-1' + } + + ] + }; + + var response = { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210093, + cpm: 1.5, + width: 300, + height: 250, + place: 0, + ad_code: '' + }; + + adapter().callBids(params); + + var adUnits = new Array(); + var unit = new Object(); + unit.bids = params.bids; + unit.code = '/123456/header-bid-tag-1'; + unit.sizes = [[300, 250]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + + pbjs.adUnits = adUnits; + + pbjs.adbutlerCB(response); + + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + expect(bidObject1.getStatusCode()).to.equal(1); + expect(bidObject1.ad).to.have.length.above(1); + + stubAddBidResponse.restore(); + }); + + it('should contain tracking pixels', function() { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + + var params = { + bidderCode: 'adbutler', + bids: [ + { + bidId: '3c9408cdbf2f68-7', + sizes: [[300, 250]], + bidder: 'adbutler', + params: { + accountID: '167283', + zoneID: '210093' + }, + requestId: '10b327aa396609', + placementCode: '/123456/header-bid-tag-1' + } + + ] + }; + + var response = { + status: 'SUCCESS', + account_id: 167283, + zone_id: 210093, + cpm: 1.5, + width: 300, + height: 250, + place: 0, + ad_code: '', + tracking_pixels: [ + 'http://tracking.pixel.com/params=info' + ] + }; + + adapter().callBids(params); + + var adUnits = new Array(); + var unit = new Object(); + unit.bids = params.bids; + unit.code = '/123456/header-bid-tag-1'; + unit.sizes = [[300, 250]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + + pbjs.adUnits = adUnits; + + pbjs.adbutlerCB(response); + + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + expect(bidObject1.getStatusCode()).to.equal(1); + expect(bidObject1.ad).to.have.string('http://tracking.pixel.com/params=info'); + + stubAddBidResponse.restore(); }); -}); \ No newline at end of file + }); +}); diff --git a/test/spec/adapters/adform_spec.js b/test/spec/adapters/adform_spec.js index 70ad3807259..80511be92ac 100644 --- a/test/spec/adapters/adform_spec.js +++ b/test/spec/adapters/adform_spec.js @@ -7,7 +7,7 @@ import bidManager from '../../../src/bidmanager'; import adapter from '../../../src/adapters/adform'; describe('Adform adapter', () => { - let _adapter, sandbox; + let _adapter, sandbox; describe('request', () => { it('should create callback method on PREBID_GLOBAL', () => { @@ -33,7 +33,6 @@ describe('Adform adapter', () => { assert.equal(_query.url, encodeURIComponent('some// there')); }); - it('should correctly form bid items', () => { const _items = parseUrl(adLoader.loadScript.args[0][0]).items; @@ -148,7 +147,7 @@ describe('Adform adapter', () => { pdom: 'home' } } - ]}); + ]}); }); afterEach(() => { @@ -162,7 +161,7 @@ function parseUrl(url) { return { path: parts.join('/'), items: query - .filter((i) => ! ~i.indexOf('=')) + .filter((i) => !~i.indexOf('=')) .map((i) => fromBase64(i) .split('&') .reduce(toObject, {})), @@ -189,4 +188,4 @@ function toObject(cache, string) { const keyValue = string.split('='); cache[keyValue[0]] = keyValue[1]; return cache; -} \ No newline at end of file +} diff --git a/test/spec/adapters/adkernel_spec.js b/test/spec/adapters/adkernel_spec.js index f505a4188f2..095a51249fb 100644 --- a/test/spec/adapters/adkernel_spec.js +++ b/test/spec/adapters/adkernel_spec.js @@ -6,63 +6,62 @@ import bidmanager from 'src/bidmanager'; import CONSTANTS from 'src/constants.json'; describe('Adkernel adapter', () => { - const bid1_zone1 = { - bidder: 'adkernel', - bidId: 'Bid_01', - params: {zoneId: 1, host: 'rtb.adkernel.com'}, - placementCode: 'ad-unit-1', - sizes: [[300, 250]] - }, bid2_zone2 = { - bidder: 'adkernel', - bidId: 'Bid_02', - params: {zoneId: 2, host: 'rtb.adkernel.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid3_host2 = { - bidder: 'adkernel', - bidId: 'Bid_02', - params: {zoneId: 1, host: 'rtb-private.adkernel.com'}, - placementCode: 'ad-unit-2', - sizes: [[728, 90]] - }, bid_without_zone = { - bidder: 'adkernel', - bidId: 'Bid_W', - params: {host: 'rtb-private.adkernel.com'}, - placementCode: 'ad-unit-1', - sizes: [[728, 90]] - }, bid_without_host = { - bidder: 'adkernel', - bidId: 'Bid_W', - params: {zoneId: 1}, - placementCode: 'ad-unit-1', - sizes: [[728, 90]] - }; + bidder: 'adkernel', + bidId: 'Bid_01', + params: {zoneId: 1, host: 'rtb.adkernel.com'}, + placementCode: 'ad-unit-1', + sizes: [[300, 250]] + }, bid2_zone2 = { + bidder: 'adkernel', + bidId: 'Bid_02', + params: {zoneId: 2, host: 'rtb.adkernel.com'}, + placementCode: 'ad-unit-2', + sizes: [[728, 90]] + }, bid3_host2 = { + bidder: 'adkernel', + bidId: 'Bid_02', + params: {zoneId: 1, host: 'rtb-private.adkernel.com'}, + placementCode: 'ad-unit-2', + sizes: [[728, 90]] + }, bid_without_zone = { + bidder: 'adkernel', + bidId: 'Bid_W', + params: {host: 'rtb-private.adkernel.com'}, + placementCode: 'ad-unit-1', + sizes: [[728, 90]] + }, bid_without_host = { + bidder: 'adkernel', + bidId: 'Bid_W', + params: {zoneId: 1}, + placementCode: 'ad-unit-1', + sizes: [[728, 90]] + }; const bidResponse1 = { - 'id': 'bid1', - 'seatbid': [{ - 'bid': [{ - 'id': '1', - 'impid': 'Bid_01', - 'price': 3.01, - 'nurl': 'https://rtb.com/win?i=ZjKoPYSFI3Y_0', - 'adm': '' - }] - }], - 'cur': 'USD' - }, bidResponse2 = { - 'id': 'bid2', - 'seatbid': [{ - 'bid': [{ - 'id': '2', - 'impid': 'Bid_02', - 'price': 1.31, - 'adm': '' - }] - }], - 'cur': 'USD' - }; + 'id': 'bid1', + 'seatbid': [{ + 'bid': [{ + 'id': '1', + 'impid': 'Bid_01', + 'price': 3.01, + 'nurl': 'https://rtb.com/win?i=ZjKoPYSFI3Y_0', + 'adm': '' + }] + }], + 'cur': 'USD' + }, bidResponse2 = { + 'id': 'bid2', + 'seatbid': [{ + 'bid': [{ + 'id': '2', + 'impid': 'Bid_02', + 'price': 1.31, + 'adm': '' + }] + }], + 'cur': 'USD' + }; let adapter, sandbox, @@ -85,7 +84,7 @@ describe('Adkernel adapter', () => { }); } - describe('input parameters validation', ()=> { + describe('input parameters validation', () => { let spy; beforeEach(() => { @@ -124,7 +123,7 @@ describe('Adkernel adapter', () => { hostname: 'example.com', host: 'example.com', pathname: '/index.html', - href : 'http://example.com/index.html' + href: 'http://example.com/index.html' }; }); @@ -160,16 +159,14 @@ describe('Adkernel adapter', () => { expect(bidRequest.site).to.have.property('page', 'http://example.com/index.html'); }); - it('should fill device with caller macro', ()=> { + it('should fill device with caller macro', () => { expect(bidRequest).to.have.property('device'); expect(bidRequest.device).to.have.property('ip', 'caller'); expect(bidRequest.device).to.have.property('ua', 'caller'); }) - }); describe('requests routing', () => { - it('should issue a request for each network', () => { ajaxStub.onFirstCall().callsArgWith(1, '') .onSecondCall().callsArgWith(1, ''); @@ -196,7 +193,6 @@ describe('Adkernel adapter', () => { }); describe('responses processing', () => { - beforeEach(() => { sandbox.stub(bidmanager, 'addBidResponse'); }); @@ -256,10 +252,9 @@ describe('Adkernel adapter', () => { sandbox.spy(utils, 'createInvisibleIframe'); doRequest([bid1_zone1, bid2_zone2, bid2_zone2, bid3_host2]); expect(utils.createInvisibleIframe.calledThrice); - let userSyncUrls = utils.createInvisibleIframe.returnValues.map( val => val.src); + let userSyncUrls = utils.createInvisibleIframe.returnValues.map(val => val.src); expect(userSyncUrls).to.be.eql(expectedSyncUrls); }); - }); describe('adapter aliasing', () => { diff --git a/test/spec/adapters/admixer_spec.js b/test/spec/adapters/admixer_spec.js index a49a2b4b230..79174390b62 100644 --- a/test/spec/adapters/admixer_spec.js +++ b/test/spec/adapters/admixer_spec.js @@ -84,7 +84,7 @@ describe('Admixer adapter', function () { it('ajax params should be matched', function () { Adapter.callBids(validData_1); sinon.assert.calledWith(stubAjax, sinon.match(invUrl, function () { - }, validJsonParams, {method: "GET"})); + }, validJsonParams, {method: 'GET'})); }); }); describe('bid request with invalid data', function () { @@ -135,4 +135,4 @@ describe('Admixer adapter', function () { expect(arg.bidderCode).to.equal('admixer'); }) }); -}); \ No newline at end of file +}); diff --git a/test/spec/adapters/adsupply_spec.js b/test/spec/adapters/adsupply_spec.js index 0798f9821d7..59f7dc42d41 100644 --- a/test/spec/adapters/adsupply_spec.js +++ b/test/spec/adapters/adsupply_spec.js @@ -1,359 +1,358 @@ describe('adsupply adapter tests', function () { - - const expect = require('chai').expect; - - const AdSupplyAdapter = require('../../../src/adapters/adsupply'); - const adloader = require('../../../src/adloader'); - const bidmanager = require('../../../src/bidmanager'); - const CONSTANTS = require('../../../src/constants.json'); - let adsupplyAdapter = new AdSupplyAdapter(); - - //before(() => sinon.stub(document.body, 'appendChild')); - //after(() => document.body.appendChild.restore()); - - it('adsupply response handler should exist and be a function', function () { - expect(pbjs.adSupplyResponseHandler).to.exist.and.to.be.a('function'); - }); - - it('two requests are sent to adsupply engine', function () { - let stubLoadScript = sinon.stub(adloader, 'loadScript'); - - let request = { - bids: [{ - placementCode: "pc1", - bidder: "adsupply", - bidId: 'bidId1', - params: { - zoneId: 111, - clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: 'engine.4dsply.com' - } - }, - { - placementCode: "pc2", - bidder: "adsupply", - bidId: 'bidId2', - params: { - clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', - zoneId: 222, - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: 'engine.4dsply.com' - } - }] - }; - - adsupplyAdapter.callBids(request); - - sinon.assert.calledTwice(stubLoadScript); - - adloader.loadScript.restore(); - }); - - it('zoneId is not a number and not specified', function () { - let stubLoadScript = sinon.stub(adloader, 'loadScript'); - - let request = { - bids: [{ - placementCode: "pc1", - bidder: "adsupply", - bidId: 'bidId1', - params: { - clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', - zoneId: '111', - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: 'engine.4dsply.com' - } - }, - { - placementCode: "pc2", - bidder: "adsupply", - bidId: 'bidId2', - params: { - clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: 'engine.4dsply.com' - } - }] - }; - - adsupplyAdapter.callBids(request); - - sinon.assert.notCalled(stubLoadScript); - - adloader.loadScript.restore(); - }); - - it('siteId is empty and not specified', function () { - let stubLoadScript = sinon.stub(adloader, 'loadScript'); - - let request = { - bids: [{ - placementCode: "pc1", - bidder: "adsupply", - bidId: 'bidId1', - params: { - zoneId: 111, - siteId: '', - clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', - endpointUrl: 'engine.4dsply.com' - } - }, - { - placementCode: "pc2", - bidder: "adsupply", - bidId: 'bidId2', - params: { - zoneId: 222, - clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', - endpointUrl: 'engine.4dsply.com' - } - }] - }; - - adsupplyAdapter.callBids(request); - - sinon.assert.notCalled(stubLoadScript); - - adloader.loadScript.restore(); - }); - - it('endpointUrl is empty and not specified', function () { - let stubLoadScript = sinon.stub(adloader, 'loadScript'); - - let request = { - bids: [{ - placementCode: "pc1", - bidder: "adsupply", - bidId: 'bidId1', - params: { - clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', - zoneId: 111, - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: '' - } - }, - { - placementCode: "pc2", - bidder: "adsupply", - bidId: 'bidId2', - params: { - clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', - zoneId: 222, - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - } - }] - }; - - adsupplyAdapter.callBids(request); - - sinon.assert.notCalled(stubLoadScript); - - adloader.loadScript.restore(); - }); - - it('clientId is empty and not specified', function () { - let stubLoadScript = sinon.stub(adloader, 'loadScript'); - - let request = { - bids: [{ - placementCode: "pc1", - bidder: "adsupply", - bidId: 'bidId1', - params: { - clientId: '', - zoneId: 111, - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: 'engine.4dsply.com' - } - }, - { - placementCode: "pc2", - bidder: "adsupply", - bidId: 'bidId2', - params: { - zoneId: 222, - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: 'engine.4dsply.com' - } - }] - }; - - adsupplyAdapter.callBids(request); - - sinon.assert.notCalled(stubLoadScript); - - adloader.loadScript.restore(); - }); - - it('parameters are missed', function () { - let stubLoadScript = sinon.stub(adloader, 'loadScript'); - - let request = { - bids: [{ - placementCode: "pc1", - bidder: "adsupply", - bidId: 'bidId1' - }] - }; - - adsupplyAdapter.callBids(request); - - sinon.assert.notCalled(stubLoadScript); - - adloader.loadScript.restore(); - }); - - it('Parameters added to the request url', function () { - let stubLoadScript = sinon.stub(adloader, 'loadScript'); - - let request = { - bids: [{ - placementCode: "pc1", - bidder: "adsupply", - bidId: 'bidId1', - params: { - zoneId: 111, - clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: 'engine.4dsply.com' - } - }] - }; - - adsupplyAdapter.callBids(request); - - var requestUrl = stubLoadScript.getCall(0).args[0]; - expect(requestUrl).to.contain('111'); - expect(requestUrl).to.contain('0ab16161-a1de-4683-8837-c420bd4387c0'); - expect(requestUrl).to.contain('engine.4dsply.com'); - expect(requestUrl).to.contain('&hbt=1'); - expect(requestUrl).to.contain('g32db6906-55f4-42b1-a7d2-7dfaddce96fd'); - - adloader.loadScript.restore(); - }); - - it('Response handler invalid data', function () { - let stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + const expect = require('chai').expect; + + const AdSupplyAdapter = require('../../../src/adapters/adsupply'); + const adloader = require('../../../src/adloader'); + const bidmanager = require('../../../src/bidmanager'); + const CONSTANTS = require('../../../src/constants.json'); + let adsupplyAdapter = new AdSupplyAdapter(); + + // before(() => sinon.stub(document.body, 'appendChild')); + // after(() => document.body.appendChild.restore()); + + it('adsupply response handler should exist and be a function', function () { + expect(pbjs.adSupplyResponseHandler).to.exist.and.to.be.a('function'); + }); + + it('two requests are sent to adsupply engine', function () { + let stubLoadScript = sinon.stub(adloader, 'loadScript'); + + let request = { + bids: [{ + placementCode: 'pc1', + bidder: 'adsupply', + bidId: 'bidId1', + params: { + zoneId: 111, + clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: 'engine.4dsply.com' + } + }, + { + placementCode: 'pc2', + bidder: 'adsupply', + bidId: 'bidId2', + params: { + clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', + zoneId: 222, + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: 'engine.4dsply.com' + } + }] + }; + + adsupplyAdapter.callBids(request); + + sinon.assert.calledTwice(stubLoadScript); + + adloader.loadScript.restore(); + }); + + it('zoneId is not a number and not specified', function () { + let stubLoadScript = sinon.stub(adloader, 'loadScript'); + + let request = { + bids: [{ + placementCode: 'pc1', + bidder: 'adsupply', + bidId: 'bidId1', + params: { + clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', + zoneId: '111', + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: 'engine.4dsply.com' + } + }, + { + placementCode: 'pc2', + bidder: 'adsupply', + bidId: 'bidId2', + params: { + clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: 'engine.4dsply.com' + } + }] + }; + + adsupplyAdapter.callBids(request); + + sinon.assert.notCalled(stubLoadScript); + + adloader.loadScript.restore(); + }); + + it('siteId is empty and not specified', function () { + let stubLoadScript = sinon.stub(adloader, 'loadScript'); + + let request = { + bids: [{ + placementCode: 'pc1', + bidder: 'adsupply', + bidId: 'bidId1', + params: { + zoneId: 111, + siteId: '', + clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', + endpointUrl: 'engine.4dsply.com' + } + }, + { + placementCode: 'pc2', + bidder: 'adsupply', + bidId: 'bidId2', + params: { + zoneId: 222, + clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', + endpointUrl: 'engine.4dsply.com' + } + }] + }; + + adsupplyAdapter.callBids(request); + + sinon.assert.notCalled(stubLoadScript); + + adloader.loadScript.restore(); + }); + + it('endpointUrl is empty and not specified', function () { + let stubLoadScript = sinon.stub(adloader, 'loadScript'); + + let request = { + bids: [{ + placementCode: 'pc1', + bidder: 'adsupply', + bidId: 'bidId1', + params: { + clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', + zoneId: 111, + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: '' + } + }, + { + placementCode: 'pc2', + bidder: 'adsupply', + bidId: 'bidId2', + params: { + clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', + zoneId: 222, + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + } + }] + }; + + adsupplyAdapter.callBids(request); + + sinon.assert.notCalled(stubLoadScript); + + adloader.loadScript.restore(); + }); + + it('clientId is empty and not specified', function () { + let stubLoadScript = sinon.stub(adloader, 'loadScript'); + + let request = { + bids: [{ + placementCode: 'pc1', + bidder: 'adsupply', + bidId: 'bidId1', + params: { + clientId: '', + zoneId: 111, + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: 'engine.4dsply.com' + } + }, + { + placementCode: 'pc2', + bidder: 'adsupply', + bidId: 'bidId2', + params: { + zoneId: 222, + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: 'engine.4dsply.com' + } + }] + }; + + adsupplyAdapter.callBids(request); + + sinon.assert.notCalled(stubLoadScript); + + adloader.loadScript.restore(); + }); + + it('parameters are missed', function () { + let stubLoadScript = sinon.stub(adloader, 'loadScript'); + + let request = { + bids: [{ + placementCode: 'pc1', + bidder: 'adsupply', + bidId: 'bidId1' + }] + }; + + adsupplyAdapter.callBids(request); + + sinon.assert.notCalled(stubLoadScript); + + adloader.loadScript.restore(); + }); + + it('Parameters added to the request url', function () { + let stubLoadScript = sinon.stub(adloader, 'loadScript'); + + let request = { + bids: [{ + placementCode: 'pc1', + bidder: 'adsupply', + bidId: 'bidId1', + params: { + zoneId: 111, + clientId: 'g32db6906-55f4-42b1-a7d2-7dfaddce96fd', + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: 'engine.4dsply.com' + } + }] + }; + + adsupplyAdapter.callBids(request); + + var requestUrl = stubLoadScript.getCall(0).args[0]; + expect(requestUrl).to.contain('111'); + expect(requestUrl).to.contain('0ab16161-a1de-4683-8837-c420bd4387c0'); + expect(requestUrl).to.contain('engine.4dsply.com'); + expect(requestUrl).to.contain('&hbt=1'); + expect(requestUrl).to.contain('g32db6906-55f4-42b1-a7d2-7dfaddce96fd'); + + adloader.loadScript.restore(); + }); + + it('Response handler invalid data', function () { + let stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); // adapter needs to be called, in order for the stub to register. - new AdSupplyAdapter(); + new AdSupplyAdapter(); // bidId is not valid - pbjs.adSupplyResponseHandler(null); + pbjs.adSupplyResponseHandler(null); // bidRequest object is not found - pbjs.adSupplyResponseHandler('bidId1'); - - let clientId = 'g5d384afa-c050-4bac-b202-dab8fb06e381'; - //Zone property is not found - let bidderRequest = { - bidderCode: 'adsupply', - bids: [{ - placementCode: "pc1", - bidder: "adsupply", - bidId: 'bidId1', - params: { - clientId: clientId, - zoneId: 111, - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: 'engine.4dsply.com' - } - }] - }; - pbjs._bidsRequested.push(bidderRequest); - pbjs.adSupplyResponseHandler('bidId1'); - - //Media is not found - window[clientId] = window[clientId] || {}; - window[clientId]['b111'] = window[clientId]['b111'] || {}; - pbjs.adSupplyResponseHandler('bidId1'); - - sinon.assert.notCalled(stubAddBidResponse); - - pbjs._bidsRequested.pop(); - bidmanager.addBidResponse.restore(); - }); - - it('No Fill response', function () { - let stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + pbjs.adSupplyResponseHandler('bidId1'); + + let clientId = 'g5d384afa-c050-4bac-b202-dab8fb06e381'; + // Zone property is not found + let bidderRequest = { + bidderCode: 'adsupply', + bids: [{ + placementCode: 'pc1', + bidder: 'adsupply', + bidId: 'bidId1', + params: { + clientId: clientId, + zoneId: 111, + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: 'engine.4dsply.com' + } + }] + }; + pbjs._bidsRequested.push(bidderRequest); + pbjs.adSupplyResponseHandler('bidId1'); + + // Media is not found + window[clientId] = window[clientId] || {}; + window[clientId]['b111'] = window[clientId]['b111'] || {}; + pbjs.adSupplyResponseHandler('bidId1'); + + sinon.assert.notCalled(stubAddBidResponse); + + pbjs._bidsRequested.pop(); + bidmanager.addBidResponse.restore(); + }); + + it('No Fill response', function () { + let stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); // adapter needs to be called, in order for the stub to register. - new AdSupplyAdapter(); - - let clientId = 'g5d384afa-c050-4bac-b202-dab8fb06e381'; - //Zone property is not found - let bidderRequest = { - bidderCode: 'adsupply', - bids: [{ - placementCode: "pc1", - bidder: "adsupply", - bidId: 'bidId1', - params: { - clientId: clientId, - zoneId: 111, - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: 'engine.4dsply.com' - } - }] - }; - - pbjs._bidsRequested.push(bidderRequest); - - window[clientId] = window[clientId] || {}; - window[clientId]['b111'] = window[clientId]['b111'] || {}; - window[clientId]['b111'].Media = { width: 300 }; - pbjs.adSupplyResponseHandler('bidId1'); - - sinon.assert.calledOnce(stubAddBidResponse); - - let bidPlacementCode = stubAddBidResponse.getCall(0).args[0]; - let bidResponse = stubAddBidResponse.getCall(0).args[1]; - expect(bidPlacementCode).to.equal('pc1'); - expect(bidResponse.getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); - expect(bidResponse.bidderCode).to.equal('adsupply'); - - pbjs._bidsRequested.pop(); - bidmanager.addBidResponse.restore(); - }); - - it('Fill response', function () { - let stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + new AdSupplyAdapter(); + + let clientId = 'g5d384afa-c050-4bac-b202-dab8fb06e381'; + // Zone property is not found + let bidderRequest = { + bidderCode: 'adsupply', + bids: [{ + placementCode: 'pc1', + bidder: 'adsupply', + bidId: 'bidId1', + params: { + clientId: clientId, + zoneId: 111, + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: 'engine.4dsply.com' + } + }] + }; + + pbjs._bidsRequested.push(bidderRequest); + + window[clientId] = window[clientId] || {}; + window[clientId]['b111'] = window[clientId]['b111'] || {}; + window[clientId]['b111'].Media = { width: 300 }; + pbjs.adSupplyResponseHandler('bidId1'); + + sinon.assert.calledOnce(stubAddBidResponse); + + let bidPlacementCode = stubAddBidResponse.getCall(0).args[0]; + let bidResponse = stubAddBidResponse.getCall(0).args[1]; + expect(bidPlacementCode).to.equal('pc1'); + expect(bidResponse.getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); + expect(bidResponse.bidderCode).to.equal('adsupply'); + + pbjs._bidsRequested.pop(); + bidmanager.addBidResponse.restore(); + }); + + it('Fill response', function () { + let stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); // adapter needs to be called, in order for the stub to register. - new AdSupplyAdapter(); - - let clientId = 'g5d384afa-c050-4bac-b202-dab8fb06e381'; - //Zone property is not found - let bidderRequest = { - bidderCode: 'adsupply', - bids: [{ - placementCode: "pc1", - bidder: "adsupply", - bidId: 'bidId1', - params: { - clientId: clientId, - zoneId: 111, - siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', - endpointUrl: 'engine.4dsply.com' - } - }] - }; - - pbjs._bidsRequested.push(bidderRequest); - - window[clientId] = window[clientId] || {}; - window[clientId]['b111'] = window[clientId]['b111'] || {}; - window[clientId]['b111'].Media = { Width: 300, Height: 250, Url: '/Redirect.engine', Ecpm: 0.0012 }; - pbjs.adSupplyResponseHandler('bidId1'); - - sinon.assert.calledOnce(stubAddBidResponse); - - let bidPlacementCode = stubAddBidResponse.getCall(0).args[0]; - let bidResponse = stubAddBidResponse.getCall(0).args[1]; - expect(bidPlacementCode).to.equal('pc1'); - expect(bidResponse.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); - expect(bidResponse.bidderCode).to.equal('adsupply'); - - pbjs._bidsRequested.pop(); - bidmanager.addBidResponse.restore(); - }); + new AdSupplyAdapter(); + + let clientId = 'g5d384afa-c050-4bac-b202-dab8fb06e381'; + // Zone property is not found + let bidderRequest = { + bidderCode: 'adsupply', + bids: [{ + placementCode: 'pc1', + bidder: 'adsupply', + bidId: 'bidId1', + params: { + clientId: clientId, + zoneId: 111, + siteId: '0ab16161-a1de-4683-8837-c420bd4387c0', + endpointUrl: 'engine.4dsply.com' + } + }] + }; + + pbjs._bidsRequested.push(bidderRequest); + + window[clientId] = window[clientId] || {}; + window[clientId]['b111'] = window[clientId]['b111'] || {}; + window[clientId]['b111'].Media = { Width: 300, Height: 250, Url: '/Redirect.engine', Ecpm: 0.0012 }; + pbjs.adSupplyResponseHandler('bidId1'); + + sinon.assert.calledOnce(stubAddBidResponse); + + let bidPlacementCode = stubAddBidResponse.getCall(0).args[0]; + let bidResponse = stubAddBidResponse.getCall(0).args[1]; + expect(bidPlacementCode).to.equal('pc1'); + expect(bidResponse.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); + expect(bidResponse.bidderCode).to.equal('adsupply'); + + pbjs._bidsRequested.pop(); + bidmanager.addBidResponse.restore(); + }); }); diff --git a/test/spec/adapters/analytics/pubwiseanalytics_spec.js b/test/spec/adapters/analytics/pubwiseanalytics_spec.js index b7350891593..62c6e463ca9 100644 --- a/test/spec/adapters/analytics/pubwiseanalytics_spec.js +++ b/test/spec/adapters/analytics/pubwiseanalytics_spec.js @@ -4,9 +4,7 @@ let adaptermanager = require('../../../../src/adaptermanager'); let constants = require('../../../../src/constants.json'); describe('PubWise Prebid Analytics', function () { - describe('enableAnalytics', function () { - it('should catch all events', function () { sinon.spy(pubwiseAnalytics, 'track'); diff --git a/test/spec/adapters/analytics/roxot_analytic_spec.js b/test/spec/adapters/analytics/roxot_analytic_spec.js index fd19ca464a8..78da9489ca8 100644 --- a/test/spec/adapters/analytics/roxot_analytic_spec.js +++ b/test/spec/adapters/analytics/roxot_analytic_spec.js @@ -4,10 +4,7 @@ let adaptermanager = require('../../../../src/adaptermanager'); let constants = require('../../../../src/constants.json'); describe('Roxot Prebid Analytic', function () { - describe('enableAnalytics', function () { - - it('should catch all events', function () { sinon.spy(roxotAnalytic, 'track'); diff --git a/test/spec/adapters/aol_spec.js b/test/spec/adapters/aol_spec.js index df2d3d6b550..0359dfc7d70 100644 --- a/test/spec/adapters/aol_spec.js +++ b/test/spec/adapters/aol_spec.js @@ -24,24 +24,23 @@ const DEFAULT_BIDDER_REQUEST = { }] }; const DEFAULT_PUBAPI_RESPONSE = { - "id": "245730051428950632", - "cur": "USD", - "seatbid": [{ - "bid": [{ - "id": 1, - "impid": "245730051428950632", - "price": 0.09, - "adm": "", - "crid": "0", - "h": 90, - "w": 728, - "ext": {"sizeid": 225} + 'id': '245730051428950632', + 'cur': 'USD', + 'seatbid': [{ + 'bid': [{ + 'id': 1, + 'impid': '245730051428950632', + 'price': 0.09, + 'adm': "", + 'crid': '0', + 'h': 90, + 'w': 728, + 'ext': {'sizeid': 225} }] }] }; describe('AolAdapter', () => { - let adapter; beforeEach(() => adapter = new AolAdapter()); @@ -63,9 +62,7 @@ describe('AolAdapter', () => { }); describe('bid request', () => { - describe('Marketplace api', () => { - let xhr; let requests; @@ -218,11 +215,9 @@ describe('AolAdapter', () => { })); expect(requests[0].url).to.contain('bidfloor=0.8'); }); - }); describe('Nexage api', () => { - let xhr; let requests; @@ -337,11 +332,9 @@ describe('AolAdapter', () => { }) ; }); - }); describe('bid response', () => { - let server; beforeEach(() => { @@ -428,9 +421,9 @@ describe('AolAdapter', () => { it('should be added to bidmanager as invalid in case of no bid data', () => { server.respondWith(JSON.stringify({ - "id": "245730051428950632", - "cur": "USD", - "seatbid": [] + 'id': '245730051428950632', + 'cur': 'USD', + 'seatbid': [] })); adapter.callBids(DEFAULT_BIDDER_REQUEST); server.respond(); @@ -440,9 +433,9 @@ describe('AolAdapter', () => { it('should have adId matching the bidId from bid request in case of no bid data', () => { server.respondWith(JSON.stringify({ - "id": "245730051428950632", - "cur": "USD", - "seatbid": [] + 'id': '245730051428950632', + 'cur': 'USD', + 'seatbid': [] })); adapter.callBids(DEFAULT_BIDDER_REQUEST); server.respond(); @@ -453,17 +446,17 @@ describe('AolAdapter', () => { it('should be added to bidmanager as invalid in case of empty price', () => { server.respondWith(JSON.stringify({ - "id": "245730051428950632", - "cur": "USD", - "seatbid": [{ - "bid": [{ - "id": 1, - "impid": "245730051428950632", - "adm": "", - "crid": "0", - "h": 90, - "w": 728, - "ext": {"sizeid": 225} + 'id': '245730051428950632', + 'cur': 'USD', + 'seatbid': [{ + 'bid': [{ + 'id': 1, + 'impid': '245730051428950632', + 'adm': "", + 'crid': '0', + 'h': 90, + 'w': 728, + 'ext': {'sizeid': 225} }] }] })); @@ -475,18 +468,18 @@ describe('AolAdapter', () => { it('should be added to bidmanager with attributes from pubapi response', () => { server.respondWith(JSON.stringify({ - "id": "245730051428950632", - "cur": "USD", - "seatbid": [{ - "bid": [{ - "id": 1, - "impid": "245730051428950632", - "price": 0.09, - "adm": "", - "crid": "12345", - "h": 90, - "w": 728, - "ext": {"sizeid": 225} + 'id': '245730051428950632', + 'cur': 'USD', + 'seatbid': [{ + 'bid': [{ + 'id': 1, + 'impid': '245730051428950632', + 'price': 0.09, + 'adm': "", + 'crid': '12345', + 'h': 90, + 'w': 728, + 'ext': {'sizeid': 225} }] }] })); @@ -504,22 +497,22 @@ describe('AolAdapter', () => { it('should be added to bidmanager including pixels from pubapi response', () => { server.respondWith(JSON.stringify({ - "id": "245730051428950632", - "cur": "USD", - "seatbid": [{ - "bid": [{ - "id": 1, - "impid": "245730051428950632", - "price": 0.09, - "adm": "", - "crid": "12345", - "h": 90, - "w": 728, - "ext": {"sizeid": 225} + 'id': '245730051428950632', + 'cur': 'USD', + 'seatbid': [{ + 'bid': [{ + 'id': 1, + 'impid': '245730051428950632', + 'price': 0.09, + 'adm': "", + 'crid': '12345', + 'h': 90, + 'w': 728, + 'ext': {'sizeid': 225} }] }], - "ext": { - "pixels": "" + 'ext': { + 'pixels': "" } })); adapter.callBids(DEFAULT_BIDDER_REQUEST); @@ -534,20 +527,20 @@ describe('AolAdapter', () => { it('should be added to bidmanager including dealid from pubapi response', () => { server.respondWith(JSON.stringify({ - "id": "245730051428950632", - "cur": "USD", - "seatbid": [{ - "bid": [{ - "id": 1, - "impid": "245730051428950632", - "dealid": "12345", - "price": 0.09, - "adm": "", - "crid": "12345", - "h": 90, - "w": 728, - "ext": { - "sizeid": 225 + 'id': '245730051428950632', + 'cur': 'USD', + 'seatbid': [{ + 'bid': [{ + 'id': 1, + 'impid': '245730051428950632', + 'dealid': '12345', + 'price': 0.09, + 'adm': "", + 'crid': '12345', + 'h': 90, + 'w': 728, + 'ext': { + 'sizeid': 225 } }] }] @@ -561,21 +554,21 @@ describe('AolAdapter', () => { it('should be added to bidmanager including encrypted price from pubapi response', () => { server.respondWith(JSON.stringify({ - "id": "245730051428950632", - "cur": "USD", - "seatbid": [{ - "bid": [{ - "id": 1, - "impid": "245730051428950632", - "dealid": "12345", - "price": 0.09, - "adm": "", - "crid": "12345", - "h": 90, - "w": 728, - "ext": { - "sizeid": 225, - "encp": "a9334987" + 'id': '245730051428950632', + 'cur': 'USD', + 'seatbid': [{ + 'bid': [{ + 'id': 1, + 'impid': '245730051428950632', + 'dealid': '12345', + 'price': 0.09, + 'adm': "", + 'crid': '12345', + 'h': 90, + 'w': 728, + 'ext': { + 'sizeid': 225, + 'encp': 'a9334987' } }] }] @@ -589,22 +582,22 @@ describe('AolAdapter', () => { it('should not render pixels on pubapi response when no parameter is set', () => { server.respondWith(JSON.stringify({ - "id": "245730051428950632", - "cur": "USD", - "seatbid": [{ - "bid": [{ - "id": 1, - "impid": "245730051428950632", - "price": 0.09, - "adm": "", - "crid": "12345", - "h": 90, - "w": 728, - "ext": {"sizeid": 225} + 'id': '245730051428950632', + 'cur': 'USD', + 'seatbid': [{ + 'bid': [{ + 'id': 1, + 'impid': '245730051428950632', + 'price': 0.09, + 'adm': "", + 'crid': '12345', + 'h': 90, + 'w': 728, + 'ext': {'sizeid': 225} }] }], - "ext": { - "pixels": "" + 'ext': { + 'pixels': "" } })); adapter.callBids(DEFAULT_BIDDER_REQUEST); @@ -615,22 +608,22 @@ describe('AolAdapter', () => { it('should render pixels from pubapi response when param userSyncOn is set with \'bidResponse\'', () => { server.respondWith(JSON.stringify({ - "id": "245730051428950632", - "cur": "USD", - "seatbid": [{ - "bid": [{ - "id": 1, - "impid": "245730051428950632", - "price": 0.09, - "adm": "", - "crid": "12345", - "h": 90, - "w": 728, - "ext": {"sizeid": 225} + 'id': '245730051428950632', + 'cur': 'USD', + 'seatbid': [{ + 'bid': [{ + 'id': 1, + 'impid': '245730051428950632', + 'price': 0.09, + 'adm': "", + 'crid': '12345', + 'h': 90, + 'w': 728, + 'ext': {'sizeid': 225} }] }], - "ext": { - "pixels": "" } })); @@ -667,7 +660,6 @@ describe('AolAdapter', () => { assertPixelsItem('iframe[src="pixels.org"]'); assertPixelsItem('iframe[src="pixels1.org"]'); }); - }); describe('when bidCpmAdjustment is set', () => { diff --git a/test/spec/adapters/appnexusAst_spec.js b/test/spec/adapters/appnexusAst_spec.js index 273beac7629..2fcfe2b76c5 100644 --- a/test/spec/adapters/appnexusAst_spec.js +++ b/test/spec/adapters/appnexusAst_spec.js @@ -5,55 +5,55 @@ import bidmanager from 'src/bidmanager'; const ENDPOINT = '//ib.adnxs.com/ut/v2/prebid'; const REQUEST = { - "bidderCode": "appnexusAst", - "requestId": "d3e07445-ab06-44c8-a9dd-5ef9af06d2a6", - "bidderRequestId": "7101db09af0db2", - "bids": [ + 'bidderCode': 'appnexusAst', + 'requestId': 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', + 'bidderRequestId': '7101db09af0db2', + 'bids': [ { - "bidder": "appnexusAst", - "params": { - "placementId": "4799418", + 'bidder': 'appnexusAst', + 'params': { + 'placementId': '4799418', }, - "placementCode": "/19968336/header-bid-tag1", - "sizes": [ + 'placementCode': '/19968336/header-bid-tag1', + 'sizes': [ [728, 90], [970, 90] ], - "bidId": "84ab500420319d", - "bidderRequestId": "7101db09af0db2", - "requestId": "d3e07445-ab06-44c8-a9dd-5ef9af06d2a6" + 'bidId': '84ab500420319d', + 'bidderRequestId': '7101db09af0db2', + 'requestId': 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6' } ], - "start": 1469479810130 + 'start': 1469479810130 }; const RESPONSE = { - "version": "0.0.1", - "tags": [{ - "uuid": "84ab500420319d", - "tag_id": 4799418, - "auction_id": "2256922143947979797", - "no_ad_url": "http://lax1-ib.adnxs.com/no-ad", - "timeout_ms": 2500, - "ads": [{ - "content_source": "rtb", - "ad_type": "banner", - "buyer_member_id": 958, - "creative_id": 33989846, - "media_type_id": 1, - "media_subtype_id": 1, - "cpm": 0.500000, - "cpm_publisher_currency": 0.500000, - "publisher_currency_code": "$", - "client_initiated_ad_counting": true, - "rtb": { - "banner": { - "width": 728, - "height": 90, - "content": "" + 'version': '0.0.1', + 'tags': [{ + 'uuid': '84ab500420319d', + 'tag_id': 4799418, + 'auction_id': '2256922143947979797', + 'no_ad_url': 'http://lax1-ib.adnxs.com/no-ad', + 'timeout_ms': 2500, + 'ads': [{ + 'content_source': 'rtb', + 'ad_type': 'banner', + 'buyer_member_id': 958, + 'creative_id': 33989846, + 'media_type_id': 1, + 'media_subtype_id': 1, + 'cpm': 0.500000, + 'cpm_publisher_currency': 0.500000, + 'publisher_currency_code': '$', + 'client_initiated_ad_counting': true, + 'rtb': { + 'banner': { + 'width': 728, + 'height': 90, + 'content': '' }, - "trackers": [{ - "impression_urls": ["http://lax1-ib.adnxs.com/impression"] + 'trackers': [{ + 'impression_urls': ['http://lax1-ib.adnxs.com/impression'] }] } }] @@ -61,13 +61,11 @@ const RESPONSE = { }; describe('AppNexusAdapter', () => { - let adapter; beforeEach(() => adapter = Adapter.createNew()); describe('request function', () => { - let xhr; let requests; @@ -90,7 +88,7 @@ describe('AppNexusAdapter', () => { it('requires member && invCode', () => { let backup = REQUEST.bids[0].params; - REQUEST.bids[0].params = {member : 1234}; + REQUEST.bids[0].params = {member: 1234}; adapter.callBids(REQUEST); expect(requests).to.be.empty; REQUEST.bids[0].params = backup; @@ -143,7 +141,7 @@ describe('AppNexusAdapter', () => { singleArr: ['val'], singleArrNum: [5], multiValMixed: ['value1', 2, 'value3'], - singleValNum: 123, + singleValNum: 123, badValue: {'foo': 'bar'} // should be dropped }; @@ -151,29 +149,27 @@ describe('AppNexusAdapter', () => { const request = JSON.parse(requests[0].requestBody).tags[0]; expect(request.keywords).to.deep.equal([{ - "key": "single", - "value": ["val"] - }, { - "key": "singleArr", - "value": ["val"] - }, { - "key": "singleArrNum", - "value": ["5"] - }, { - "key": "multiValMixed", - "value": ["value1", "2", "value3"] - }, { - "key": "singleValNum", - "value": ["123"] - }]); + 'key': 'single', + 'value': ['val'] + }, { + 'key': 'singleArr', + 'value': ['val'] + }, { + 'key': 'singleArrNum', + 'value': ['5'] + }, { + 'key': 'multiValMixed', + 'value': ['value1', '2', 'value3'] + }, { + 'key': 'singleValNum', + 'value': ['123'] + }]); delete REQUEST.bids[0].params.keywords; }); - }); describe('response handler', () => { - let server; beforeEach(() => { @@ -200,12 +196,12 @@ describe('AppNexusAdapter', () => { it('handles nobid responses', () => { server.respondWith(JSON.stringify({ - "version": "0.0.1", - "tags": [{ - "uuid": "84ab500420319d", - "tag_id": 5976557, - "auction_id": "297492697822162468", - "nobid": true + 'version': '0.0.1', + 'tags': [{ + 'uuid': '84ab500420319d', + 'tag_id': 5976557, + 'auction_id': '297492697822162468', + 'nobid': true }] })); @@ -222,14 +218,14 @@ describe('AppNexusAdapter', () => { it('handles non-banner media responses', () => { server.respondWith(JSON.stringify({ - "tags": [{ - "uuid": "84ab500420319d", - "ads": [{ - "ad_type": "video", - "cpm": 0.500000, - "rtb": { - "video": { - "content": "" + 'tags': [{ + 'uuid': '84ab500420319d', + 'ads': [{ + 'ad_type': 'video', + 'cpm': 0.500000, + 'rtb': { + 'video': { + 'content': '' } } }] @@ -257,7 +253,5 @@ describe('AppNexusAdapter', () => { 'Bid returned empty or error response' ); }); - }); - }); diff --git a/test/spec/adapters/appnexus_spec.js b/test/spec/adapters/appnexus_spec.js index c29bd3dfdbe..7479f7960ff 100644 --- a/test/spec/adapters/appnexus_spec.js +++ b/test/spec/adapters/appnexus_spec.js @@ -4,7 +4,6 @@ import bidManager from '../../../src/bidmanager'; import adLoader from '../../../src/adloader'; describe('AppNexus Adapter', () => { - let adapter; const REQUEST = { @@ -16,7 +15,7 @@ describe('AppNexus Adapter', () => { 'bidder': 'appnexus', 'params': { 'placementId': '4799418', - 'trafficSourceCode' : 'source' + 'trafficSourceCode': 'source' }, 'placementCode': '/19968336/header-bid-tag1', 'sizes': [ @@ -39,5 +38,4 @@ describe('AppNexus Adapter', () => { adapter.callBids(REQUEST); expect(adLoaderStub.getCall(0).args[0]).to.contain('traffic_source_code=source'); }); - }); diff --git a/test/spec/adapters/atomx_spec.js b/test/spec/adapters/atomx_spec.js index fb4bdc83f1b..db865057d68 100644 --- a/test/spec/adapters/atomx_spec.js +++ b/test/spec/adapters/atomx_spec.js @@ -14,7 +14,7 @@ describe('Atomx adapter', function () { bidId: 'bid_id', params: {id: 1234}, placementCode: 'ad-unit-1', - sizes: [[300, 250],[800, 600]] + sizes: [[300, 250], [800, 600]] } ] }; @@ -54,7 +54,7 @@ describe('Atomx adapter', function () { 'url': 'http://p.ato.mx/placement?id=1234', 'width': 300, 'height': 250, - 'code': 'ad-unit-1' + 'code': 'ad-unit-1' }); var responseEmpty = ''; @@ -65,7 +65,7 @@ describe('Atomx adapter', function () { }; describe('loads the tag code', function() { - var stubLoadScript = sinon.stub(adLoader, "loadScript"); + var stubLoadScript = sinon.stub(adLoader, 'loadScript'); Adapter.callBids(validData_1); sinon.assert.calledOnce(stubLoadScript); let url = stubLoadScript.firstCall.args[0]; @@ -95,7 +95,7 @@ describe('Atomx adapter', function () { it('ajax params should be matched', function () { Adapter.callBids(validData_1); sinon.assert.calledWith(stubAjax, sinon.match('/placement', function () { - }, validJsonParams, {method: "GET"})); + }, validJsonParams, {method: 'GET'})); }); }); describe('bid request with invalid data', function () { diff --git a/test/spec/adapters/audienceNetwork_spec.js b/test/spec/adapters/audienceNetwork_spec.js index f1c528521b8..33b44e31171 100644 --- a/test/spec/adapters/audienceNetwork_spec.js +++ b/test/spec/adapters/audienceNetwork_spec.js @@ -24,9 +24,7 @@ const expectToContain = (haystack, needle, n = 1) => expect(haystack.split(needle)).to.have.lengthOf(n + 1, `expected ${n} occurrence(s) of '${needle}' in '${haystack}'`); - describe('AudienceNetwork adapter', () => { - describe('Public API', () => { const adapter = AudienceNetwork(); it('getBidderCode', () => { @@ -42,7 +40,6 @@ describe('AudienceNetwork adapter', () => { }); describe('callBids parameter parsing', () => { - let xhr; let requests; let addBidResponse; @@ -123,22 +120,20 @@ describe('AudienceNetwork adapter', () => { // Verify no attempt to log error expect(logError.called).to.equal(false); }); - }); describe('callBids response handling', () => { - let server; let addBidResponse; let logError; - beforeEach( () => { + beforeEach(() => { server = sinon.fakeServer.create(); addBidResponse = sinon.stub(bidmanager, 'addBidResponse'); logError = sinon.stub(utils, 'logError'); }); - afterEach( () => { + afterEach(() => { server.restore(); bidmanager.addBidResponse.restore(); utils.logError.restore(); @@ -372,7 +367,5 @@ describe('AudienceNetwork adapter', () => { // Verify no attempt to log error expect(logError.called).to.equal(false, 'logError called'); }); - }); - }); diff --git a/test/spec/adapters/beachfront_spec.js b/test/spec/adapters/beachfront_spec.js index 6401b6f5357..3d5396b7b76 100644 --- a/test/spec/adapters/beachfront_spec.js +++ b/test/spec/adapters/beachfront_spec.js @@ -5,129 +5,127 @@ import bidmanager from 'src/bidmanager'; const ENDPOINT = '//reachms.bfmio.com/bid.json?exchange_id=11bc5dd5-7421-4dd8-c926-40fa653bec76'; const REQUEST = { - "width": 640, - "height": 480, - "bidId": "2a1444be20bb2c", - "bidder": "beachfront", - "bidderRequestId": "7101db09af0db2", - "params": { - "appId": "whatever", - "video": {}, - "placementCode": "video", - "sizes": [ - 640, 480 - ] - }, - "bids": [ - { - "bidFloor": 0.01, - "bidder": "beachfront", - "params": { - "appId": "11bc5dd5-7421-4dd8-c926-40fa653bec76", - "bidfloor": 0.01, - "dev": true - }, - "placementCode": "video", - "sizes": [640, 480], - "bidId": "2a1444be20bb2c", - "bidderRequestId": "7101db09af0db2", - "requestId": "979b659e-ecff-46b8-ae03-7251bae4b725" - } - ], - "requestId": "979b659e-ecff-46b8-ae03-7251bae4b725", + 'width': 640, + 'height': 480, + 'bidId': '2a1444be20bb2c', + 'bidder': 'beachfront', + 'bidderRequestId': '7101db09af0db2', + 'params': { + 'appId': 'whatever', + 'video': {}, + 'placementCode': 'video', + 'sizes': [ + 640, 480 + ] + }, + 'bids': [ + { + 'bidFloor': 0.01, + 'bidder': 'beachfront', + 'params': { + 'appId': '11bc5dd5-7421-4dd8-c926-40fa653bec76', + 'bidfloor': 0.01, + 'dev': true + }, + 'placementCode': 'video', + 'sizes': [640, 480], + 'bidId': '2a1444be20bb2c', + 'bidderRequestId': '7101db09af0db2', + 'requestId': '979b659e-ecff-46b8-ae03-7251bae4b725' + } + ], + 'requestId': '979b659e-ecff-46b8-ae03-7251bae4b725', }; var RESPONSE = { - "bidPrice": 5.00, - "url": "http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da:0a47f4ce-d91f-48d0-bd1c-64fa2c196f13:2.90&dsp=58bf26882aba5e6ad608beda,0.612&i_type=pre" + 'bidPrice': 5.00, + 'url': 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da:0a47f4ce-d91f-48d0-bd1c-64fa2c196f13:2.90&dsp=58bf26882aba5e6ad608beda,0.612&i_type=pre' }; describe('BeachfrontAdapter', () => { + let adapter; - let adapter; + beforeEach(() => adapter = BeachfrontAdapter.createNew()); - beforeEach(() => adapter = BeachfrontAdapter.createNew()); - - describe('request function', () => { - let xhr; - let requests; - beforeEach(() => { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - }); - - afterEach(() => xhr.restore()); + describe('request function', () => { + let xhr; + let requests; + beforeEach(() => { + xhr = sinon.useFakeXMLHttpRequest(); + requests = []; + xhr.onCreate = request => requests.push(request); + }); - it('exists and is a function', () => { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); + afterEach(() => xhr.restore()); - it('requires parameters to make request', () => { - adapter.callBids({}); - expect(requests).to.be.empty; - }); + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); - it('sends bid request to ENDPOINT via POST', () => { - adapter.callBids(REQUEST); - expect(requests[0].url).to.equal(ENDPOINT); - expect(requests[0].method).to.equal('POST'); - }); + it('requires parameters to make request', () => { + adapter.callBids({}); + expect(requests).to.be.empty; }); - describe('response handler', () => { + it('sends bid request to ENDPOINT via POST', () => { + adapter.callBids(REQUEST); + expect(requests[0].url).to.equal(ENDPOINT); + expect(requests[0].method).to.equal('POST'); + }); + }); - let server; + describe('response handler', () => { + let server; - beforeEach(() => { - server = sinon.fakeServer.create(); - sinon.stub(bidmanager, 'addBidResponse'); - }); + beforeEach(() => { + server = sinon.fakeServer.create(); + sinon.stub(bidmanager, 'addBidResponse'); + }); - afterEach(() => { - server.restore(); - bidmanager.addBidResponse.restore(); - }); + afterEach(() => { + server.restore(); + bidmanager.addBidResponse.restore(); + }); - it('registers bids', () => { - server.respondWith(JSON.stringify(RESPONSE)); + it('registers bids', () => { + server.respondWith(JSON.stringify(RESPONSE)); - adapter.callBids(REQUEST); - server.respond(); - sinon.assert.calledOnce(bidmanager.addBidResponse); + adapter.callBids(REQUEST); + server.respond(); + sinon.assert.calledOnce(bidmanager.addBidResponse); - const response = bidmanager.addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('cpm', 5.00); - }); + const response = bidmanager.addBidResponse.firstCall.args[1]; + expect(response).to.have.property('statusMessage', 'Bid available'); + expect(response).to.have.property('cpm', 5.00); + }); - it('handles nobid responses', () => { - server.respondWith(JSON.stringify({ - "bidPrice": 5.00 - })); + it('handles nobid responses', () => { + server.respondWith(JSON.stringify({ + 'bidPrice': 5.00 + })); - adapter.callBids(REQUEST); - server.respond(); - sinon.assert.calledOnce(bidmanager.addBidResponse); + adapter.callBids(REQUEST); + server.respond(); + sinon.assert.calledOnce(bidmanager.addBidResponse); - const response = bidmanager.addBidResponse.firstCall.args[1]; - expect(response).to.have.property( + const response = bidmanager.addBidResponse.firstCall.args[1]; + expect(response).to.have.property( 'statusMessage', 'Bid returned empty or error response' ); - }); + }); - it('handles JSON.parse errors', () => { - server.respondWith(''); + it('handles JSON.parse errors', () => { + server.respondWith(''); - adapter.callBids(REQUEST); - server.respond(); - sinon.assert.calledOnce(bidmanager.addBidResponse); + adapter.callBids(REQUEST); + server.respond(); + sinon.assert.calledOnce(bidmanager.addBidResponse); - const response = bidmanager.addBidResponse.firstCall.args[1]; - expect(response).to.have.property( + const response = bidmanager.addBidResponse.firstCall.args[1]; + expect(response).to.have.property( 'statusMessage', 'Bid returned empty or error response' ); - }); }); + }); }); diff --git a/test/spec/adapters/bidfluence_spec.js b/test/spec/adapters/bidfluence_spec.js index d6851f4fac2..1e5510c4532 100644 --- a/test/spec/adapters/bidfluence_spec.js +++ b/test/spec/adapters/bidfluence_spec.js @@ -1,74 +1,71 @@ describe('Bidfluence Adapter', () => { - const expect = require('chai').expect; - const adapter = require('src/adapters/bidfluence'); - const bidmanager = require('src/bidmanager'); + const expect = require('chai').expect; + const adapter = require('src/adapters/bidfluence'); + const bidmanager = require('src/bidmanager'); - var REQUEST = { - bidderCode: "bidfluence", - sizes: [[300, 250]], - placementCode: "div-1", - bids: [{ - bidder: 'bidfluence', - params: { - pubId: "test", - adunitId: "test" - } - }] - }; + var REQUEST = { + bidderCode: 'bidfluence', + sizes: [[300, 250]], + placementCode: 'div-1', + bids: [{ + bidder: 'bidfluence', + params: { + pubId: 'test', + adunitId: 'test' + } + }] + }; - var RESPONSE = { - ad: "ad-code", - cpm: 0.9, - width: 300, - height: 250, - placementCode: "div-1" - }; + var RESPONSE = { + ad: 'ad-code', + cpm: 0.9, + width: 300, + height: 250, + placementCode: 'div-1' + }; - var NO_RESPONSE = { - ad: "ad-code", - cpm: 0, - width: 300, - height: 250, - placementCode: "div-1" - }; + var NO_RESPONSE = { + ad: 'ad-code', + cpm: 0, + width: 300, + height: 250, + placementCode: 'div-1' + }; - it('Should exist and be a function', function () { - expect($$PREBID_GLOBAL$$.bfPbjsCB).to.exist.and.to.be.a('function'); - }); - - it('Shoud push a valid bid', () => { + it('Should exist and be a function', function () { + expect($$PREBID_GLOBAL$$.bfPbjsCB).to.exist.and.to.be.a('function'); + }); - var stubAddBidResponse = sinon.stub(bidmanager, "addBidResponse"); - pbjs._bidsRequested.push(REQUEST); - adapter(); - $$PREBID_GLOBAL$$.bfPbjsCB(RESPONSE); + it('Shoud push a valid bid', () => { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + pbjs._bidsRequested.push(REQUEST); + adapter(); + $$PREBID_GLOBAL$$.bfPbjsCB(RESPONSE); - var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - expect(bidPlacementCode1).to.equal("div-1"); - expect(bidObject1.getStatusCode()).to.equal(1); - expect(bidObject1.bidderCode).to.equal('bidfluence'); + expect(bidPlacementCode1).to.equal('div-1'); + expect(bidObject1.getStatusCode()).to.equal(1); + expect(bidObject1.bidderCode).to.equal('bidfluence'); - stubAddBidResponse.restore(); - }); + stubAddBidResponse.restore(); + }); - it('Shoud push an empty bid', () => { + it('Shoud push an empty bid', () => { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + pbjs._bidsRequested.push(REQUEST); + adapter(); - var stubAddBidResponse = sinon.stub(bidmanager, "addBidResponse"); - pbjs._bidsRequested.push(REQUEST); - adapter(); + $$PREBID_GLOBAL$$.bfPbjsCB(NO_RESPONSE); - $$PREBID_GLOBAL$$.bfPbjsCB(NO_RESPONSE); + var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + expect(bidPlacementCode1).to.equal('div-1'); + expect(bidObject1.getStatusCode()).to.equal(2); + expect(bidObject1.bidderCode).to.equal('bidfluence'); - expect(bidPlacementCode1).to.equal("div-1"); - expect(bidObject1.getStatusCode()).to.equal(2); - expect(bidObject1.bidderCode).to.equal('bidfluence'); - - stubAddBidResponse.restore(); - - }); + stubAddBidResponse.restore(); + }); }); diff --git a/test/spec/adapters/centro_spec.js b/test/spec/adapters/centro_spec.js index a3f186fad65..73dcf287ff0 100644 --- a/test/spec/adapters/centro_spec.js +++ b/test/spec/adapters/centro_spec.js @@ -1,230 +1,224 @@ describe('centro adapter tests', function () { - var expect = require('chai').expect; - var assert = require('chai').assert; - var urlParse = require('url-parse'); - var querystringify = require('querystringify'); - - var adapter = require('src/adapters/centro'); - var bidmanager = require('src/bidmanager'); - var adLoader = require('src/adloader'); - var utils = require('src/utils'); - - window.pbjs = window.pbjs || {}; - if (typeof(pbjs)==="undefined"){ - var pbjs = window.pbjs; + var expect = require('chai').expect; + var assert = require('chai').assert; + var urlParse = require('url-parse'); + var querystringify = require('querystringify'); + + var adapter = require('src/adapters/centro'); + var bidmanager = require('src/bidmanager'); + var adLoader = require('src/adloader'); + var utils = require('src/utils'); + + window.pbjs = window.pbjs || {}; + if (typeof (pbjs) === 'undefined') { + var pbjs = window.pbjs; + } + + let stubLoadScript; + beforeEach(function () { + stubLoadScript = sinon.stub(adLoader, 'loadScript'); + }); + + afterEach(function () { + stubLoadScript.restore(); + }); + + var logErrorSpy; + beforeEach(function () { + logErrorSpy = sinon.spy(utils, 'logError'); + }); + + afterEach(function () { + logErrorSpy.restore(); + }); + + describe('creation of bid url', function () { + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = []; } - let stubLoadScript; - beforeEach(function () { - stubLoadScript = sinon.stub(adLoader, 'loadScript'); + it('should fix parameter name', function () { + var params = { + bidderCode: 'centro', + bids: [ + { + bidder: 'centro', + sizes: [[300, 250]], + params: { + unit: 28136, + page_url: 'http://test_url.ru' + }, + placementCode: 'div-gpt-ad-12345-1' + }, + { + bidder: 'centro', + sizes: [[728, 90]], + params: { + unit: 28137 + }, + placementCode: 'div-gpt-ad-12345-2' + }, + { + bidder: 'centro', + sizes: [[728, 90]], + params: {}, + placementCode: 'div-gpt-ad-12345-3' + } + ] + }; + + adapter().callBids(params); + var bidUrl1 = stubLoadScript.getCall(0).args[0]; + var bidUrl2 = stubLoadScript.getCall(1).args[0]; + + sinon.assert.calledWith(logErrorSpy, 'Bid has no unit', 'centro'); + sinon.assert.calledWith(stubLoadScript, bidUrl1); + + var parsedBidUrl = urlParse(bidUrl1); + var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); + var generatedCallback = 'window["adCentroHandler_28136300x250div-gpt-ad-12345-1"]'; + + expect(parsedBidUrl.hostname).to.equal('staging.brand-server.com'); + expect(parsedBidUrl.pathname).to.equal('/hb'); + + expect(parsedBidUrlQueryString).to.have.property('s').and.to.equal('28136'); + expect(parsedBidUrlQueryString).to.have.property('url').and.to.equal('http://test_url.ru'); + expect(parsedBidUrlQueryString).to.have.property('sz').and.to.equal('300x250'); + expect(parsedBidUrlQueryString).to.have.property('callback').and.to.equal(generatedCallback); + + sinon.assert.calledWith(stubLoadScript, bidUrl2); + + parsedBidUrl = urlParse(bidUrl2); + parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); + generatedCallback = 'window["adCentroHandler_28137728x90div-gpt-ad-12345-2"]'; + + expect(parsedBidUrl.hostname).to.equal('t.brand-server.com'); + expect(parsedBidUrl.pathname).to.equal('/hb'); + + expect(parsedBidUrlQueryString).to.have.property('s').and.to.equal('28137'); + expect(parsedBidUrlQueryString).to.have.property('url').and.to.equal(location.href); + expect(parsedBidUrlQueryString).to.have.property('sz').and.to.equal('728x90'); + expect(parsedBidUrlQueryString).to.have.property('callback').and.to.equal(generatedCallback); }); + }); - afterEach(function () { - stubLoadScript.restore(); - }); - - var logErrorSpy; - beforeEach(function () { - logErrorSpy = sinon.spy(utils, 'logError'); - }); - - afterEach(function () { - logErrorSpy.restore(); - }); - - describe('creation of bid url', function () { + describe('handling of the callback response', function () { + if (typeof (pbjs._bidsReceived) === 'undefined') { + pbjs._bidsReceived = []; + } + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = []; + } + if (typeof (pbjs._adsReceived) === 'undefined') { + pbjs._adsReceived = []; + } - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = []; + var params = { + bidderCode: 'centro', + bids: [ + { + bidder: 'centro', + sizes: [[300, 250]], + params: { + unit: 28136 + }, + placementCode: '/19968336/header-bid-tag-0' + }, + { + bidder: 'centro', + sizes: [[728, 90]], + params: { + unit: 111111 + }, + placementCode: '/19968336/header-bid-tag-1' + }, + { + bidder: 'centro', + sizes: [[728, 90]], + params: { + unit: 222222 + }, + placementCode: '/19968336/header-bid-tag-2' + }, + { + bidder: 'centro', + sizes: [[728, 90]], + params: { + unit: 333333 + }, + placementCode: '/19968336/header-bid-tag-3' } + ] + }; - it('should fix parameter name', function () { - - var params = { - bidderCode: 'centro', - bids: [ - { - bidder: 'centro', - sizes: [[300, 250]], - params: { - unit: 28136, - page_url: 'http://test_url.ru' - }, - placementCode: 'div-gpt-ad-12345-1' - }, - { - bidder: 'centro', - sizes: [[728, 90]], - params: { - unit: 28137 - }, - placementCode: 'div-gpt-ad-12345-2' - }, - { - bidder: 'centro', - sizes: [[728, 90]], - params: {}, - placementCode: 'div-gpt-ad-12345-3' - } - ] - }; - - adapter().callBids(params); - var bidUrl1 = stubLoadScript.getCall(0).args[0]; - var bidUrl2 = stubLoadScript.getCall(1).args[0]; - - sinon.assert.calledWith(logErrorSpy, 'Bid has no unit', 'centro'); - sinon.assert.calledWith(stubLoadScript, bidUrl1); - - var parsedBidUrl = urlParse(bidUrl1); - var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - var generatedCallback = 'window["adCentroHandler_28136300x250div-gpt-ad-12345-1"]'; - - expect(parsedBidUrl.hostname).to.equal('staging.brand-server.com'); - expect(parsedBidUrl.pathname).to.equal('/hb'); - - expect(parsedBidUrlQueryString).to.have.property('s').and.to.equal('28136'); - expect(parsedBidUrlQueryString).to.have.property('url').and.to.equal('http://test_url.ru'); - expect(parsedBidUrlQueryString).to.have.property('sz').and.to.equal('300x250'); - expect(parsedBidUrlQueryString).to.have.property('callback').and.to.equal(generatedCallback); - - sinon.assert.calledWith(stubLoadScript, bidUrl2); - - parsedBidUrl = urlParse(bidUrl2); - parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - generatedCallback = 'window["adCentroHandler_28137728x90div-gpt-ad-12345-2"]'; - - expect(parsedBidUrl.hostname).to.equal('t.brand-server.com'); - expect(parsedBidUrl.pathname).to.equal('/hb'); - - expect(parsedBidUrlQueryString).to.have.property('s').and.to.equal('28137'); - expect(parsedBidUrlQueryString).to.have.property('url').and.to.equal(location.href); - expect(parsedBidUrlQueryString).to.have.property('sz').and.to.equal('728x90'); - expect(parsedBidUrlQueryString).to.have.property('callback').and.to.equal(generatedCallback); - }); + it('callback function should exist', function () { + adapter().callBids(params); - }); - - describe('handling of the callback response', function () { - if (typeof(pbjs._bidsReceived)==="undefined"){ - pbjs._bidsReceived = []; - } - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = []; - } - if (typeof(pbjs._adsReceived)==="undefined"){ - pbjs._adsReceived = []; - } - - var params = { - bidderCode: 'centro', - bids: [ - { - bidder: 'centro', - sizes: [[300, 250]], - params: { - unit: 28136 - }, - placementCode: '/19968336/header-bid-tag-0' - }, - { - bidder: 'centro', - sizes: [[728, 90]], - params: { - unit: 111111 - }, - placementCode: '/19968336/header-bid-tag-1' - }, - { - bidder: 'centro', - sizes: [[728, 90]], - params: { - unit: 222222 - }, - placementCode: '/19968336/header-bid-tag-2' - }, - { - bidder: 'centro', - sizes: [[728, 90]], - params: { - unit: 333333 - }, - placementCode: '/19968336/header-bid-tag-3' - } - ] - }; - - it('callback function should exist', function () { - - adapter().callBids(params); - - expect(window['adCentroHandler_28136300x250%2F19968336%2Fheader-bid-tag-0']) + expect(window['adCentroHandler_28136300x250%2F19968336%2Fheader-bid-tag-0']) .to.exist.and.to.be.a('function'); - expect(window['adCentroHandler_111111728x90%2F19968336%2Fheader-bid-tag-1']) + expect(window['adCentroHandler_111111728x90%2F19968336%2Fheader-bid-tag-1']) .to.exist.and.to.be.a('function'); - }); - - it('bidmanager.addBidResponse should be called with correct arguments', function () { - - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - - adapter().callBids(params); - - var adUnits = new Array(); - var unit = new Object(); - unit.bids = params.bids; - unit.code = '/19968336/header-bid-tag'; - unit.sizes=[[300,250],[728,90]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } - else{ - pbjs._bidsRequested.push(params); - } - - pbjs.adUnits = adUnits; - - var response = {"adTag":"
test content
","statusMessage":"Bid available","height":250,"_comment":"","value":0.2,"width":300,"sectionID":28136}; - var response2 = {"adTag":"","statusMessage":"No bid.","height":0,"value":0,"width":0,"sectionID":111111}; - var response3 = {"adTag":"","height":0,"value":0,"width":0,"sectionID":222222}; - var response4 = ''; - - window['adCentroHandler_28136300x250%2F19968336%2Fheader-bid-tag-0'](response); - window['adCentroHandler_111111728x90%2F19968336%2Fheader-bid-tag-1'](response2); - window['adCentroHandler_222222728x90%2F19968336%2Fheader-bid-tag-2'](response3); - window['adCentroHandler_333333728x90%2F19968336%2Fheader-bid-tag-3'](response4); - - var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - var bidPlacementCode2 = stubAddBidResponse.getCall(1).args[0]; - var bidObject2 = stubAddBidResponse.getCall(1).args[1]; - var bidPlacementCode3 = stubAddBidResponse.getCall(2).args[0]; - var bidObject3 = stubAddBidResponse.getCall(2).args[1]; - var bidPlacementCode4 = stubAddBidResponse.getCall(3).args[0]; - var bidObject4 = stubAddBidResponse.getCall(3).args[1]; - - expect(logErrorSpy.getCall(0).args[0]).to.equal('Requested unit is 111111. No bid.'); - expect(logErrorSpy.getCall(1).args[0]).to.equal('Requested unit is 222222. Bid has missmatch format.'); - expect(logErrorSpy.getCall(2).args[0]).to.equal('Requested unit is 333333. Response has no bid.'); - - expect(bidPlacementCode1).to.equal('/19968336/header-bid-tag-0'); - expect(bidObject1.cpm).to.equal(0.2); - expect(bidObject1.ad).to.equal('
test content
'); - expect(bidObject1.width).to.equal(300); - expect(bidObject1.height).to.equal(250); - expect(bidObject1.getStatusCode()).to.equal(1); - expect(bidObject1.bidderCode).to.equal('centro'); - - expect(bidPlacementCode2).to.equal('/19968336/header-bid-tag-1'); - expect(bidObject2.getStatusCode()).to.equal(2); - expect(bidPlacementCode3).to.equal('/19968336/header-bid-tag-2'); - expect(bidObject3.getStatusCode()).to.equal(2); - expect(bidPlacementCode4).to.equal('/19968336/header-bid-tag-3'); - expect(bidObject4.getStatusCode()).to.equal(2); - - stubAddBidResponse.restore(); - }); }); + + it('bidmanager.addBidResponse should be called with correct arguments', function () { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + + adapter().callBids(params); + + var adUnits = new Array(); + var unit = new Object(); + unit.bids = params.bids; + unit.code = '/19968336/header-bid-tag'; + unit.sizes = [[300, 250], [728, 90]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + + pbjs.adUnits = adUnits; + + var response = {'adTag': '
test content
', 'statusMessage': 'Bid available', 'height': 250, '_comment': '', 'value': 0.2, 'width': 300, 'sectionID': 28136}; + var response2 = {'adTag': '', 'statusMessage': 'No bid.', 'height': 0, 'value': 0, 'width': 0, 'sectionID': 111111}; + var response3 = {'adTag': '', 'height': 0, 'value': 0, 'width': 0, 'sectionID': 222222}; + var response4 = ''; + + window['adCentroHandler_28136300x250%2F19968336%2Fheader-bid-tag-0'](response); + window['adCentroHandler_111111728x90%2F19968336%2Fheader-bid-tag-1'](response2); + window['adCentroHandler_222222728x90%2F19968336%2Fheader-bid-tag-2'](response3); + window['adCentroHandler_333333728x90%2F19968336%2Fheader-bid-tag-3'](response4); + + var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + var bidPlacementCode2 = stubAddBidResponse.getCall(1).args[0]; + var bidObject2 = stubAddBidResponse.getCall(1).args[1]; + var bidPlacementCode3 = stubAddBidResponse.getCall(2).args[0]; + var bidObject3 = stubAddBidResponse.getCall(2).args[1]; + var bidPlacementCode4 = stubAddBidResponse.getCall(3).args[0]; + var bidObject4 = stubAddBidResponse.getCall(3).args[1]; + + expect(logErrorSpy.getCall(0).args[0]).to.equal('Requested unit is 111111. No bid.'); + expect(logErrorSpy.getCall(1).args[0]).to.equal('Requested unit is 222222. Bid has missmatch format.'); + expect(logErrorSpy.getCall(2).args[0]).to.equal('Requested unit is 333333. Response has no bid.'); + + expect(bidPlacementCode1).to.equal('/19968336/header-bid-tag-0'); + expect(bidObject1.cpm).to.equal(0.2); + expect(bidObject1.ad).to.equal('
test content
'); + expect(bidObject1.width).to.equal(300); + expect(bidObject1.height).to.equal(250); + expect(bidObject1.getStatusCode()).to.equal(1); + expect(bidObject1.bidderCode).to.equal('centro'); + + expect(bidPlacementCode2).to.equal('/19968336/header-bid-tag-1'); + expect(bidObject2.getStatusCode()).to.equal(2); + expect(bidPlacementCode3).to.equal('/19968336/header-bid-tag-2'); + expect(bidObject3.getStatusCode()).to.equal(2); + expect(bidPlacementCode4).to.equal('/19968336/header-bid-tag-3'); + expect(bidObject4.getStatusCode()).to.equal(2); + + stubAddBidResponse.restore(); + }); + }); }); diff --git a/test/spec/adapters/conversant_spec.js b/test/spec/adapters/conversant_spec.js index dead09688ba..3c9d636a700 100644 --- a/test/spec/adapters/conversant_spec.js +++ b/test/spec/adapters/conversant_spec.js @@ -3,7 +3,6 @@ var Adapter = require('src/adapters/conversant'); var bidManager = require('src/bidmanager'); describe('Conversant adapter tests', function () { - var addBidResponseSpy; var adapter; @@ -43,7 +42,6 @@ describe('Conversant adapter tests', function () { ] }; - it('The Conversant response should exist and be a function', function () { expect($$PREBID_GLOBAL$$.conversantResponse).to.exist.and.to.be.a('function'); }); @@ -67,14 +65,14 @@ describe('Conversant adapter tests', function () { id: 1111111, impid: 'bidId1', price: 0 - },{ + }, { id: 2345, impid: 'bidId2', price: 0.22, nurl: '', adm: 'adm2', - h:300, - w:600 + h: 300, + w: 600 }] }] }; @@ -139,29 +137,29 @@ describe('Conversant adapter tests', function () { id: 1111111, impid: 'bidId1', price: 0.11, - nurl : '', + nurl: '', adm: 'adm', h: 250, w: 300, - ext : {} - },{ + ext: {} + }, { id: 2345, impid: 'bidId2', price: 0.22, nurl: '', adm: 'adm2', - h:300, - w:600 + h: 300, + w: 600 }, - { - id: 33333, - impid: 'bidId3', - price: 0.33, - nurl: '', - adm: 'adm3', - h: 160, - w: 600 - }] + { + id: 33333, + impid: 'bidId3', + price: 0.33, + nurl: '', + adm: 'adm3', + h: 160, + w: 600 + }] }] }; @@ -177,7 +175,7 @@ describe('Conversant adapter tests', function () { expect(firstBid.getStatusCode()).to.equal(1); expect(firstBid.bidderCode).to.equal('conversant'); expect(firstBid.cpm).to.equal(0.11); - expect(firstBid.ad).to.equal('adm'+ ''); + expect(firstBid.ad).to.equal('adm' + ''); expect(placementCode1).to.equal('div1'); expect(secondBid.getStatusCode()).to.equal(1); @@ -196,10 +194,9 @@ describe('Conversant adapter tests', function () { }); }); - describe('Should submit the correct headers in the xhr', function () { var server, - adapter; + adapter; var bidResponse = { id: 123, @@ -208,29 +205,29 @@ describe('Conversant adapter tests', function () { id: 1111, impid: 'bidId1', price: 0.11, - nurl : '', + nurl: '', adm: 'adm', h: 250, w: 300, - ext : {} - },{ + ext: {} + }, { id: 2222, impid: 'bidId2', price: 0.22, nurl: '', adm: 'adm2', - h:300, - w:600 + h: 300, + w: 600 }, - { - id: 3333, - impid: 'bidId3', - price: 0.33, - nurl: '', - adm: 'adm3', - h: 160, - w: 600 - }] + { + id: 3333, + impid: 'bidId3', + price: 0.33, + nurl: '', + adm: 'adm3', + h: 160, + w: 600 + }] }] }; diff --git a/test/spec/adapters/criteo_spec.js b/test/spec/adapters/criteo_spec.js index 5b2159e1594..e6f2033c738 100644 --- a/test/spec/adapters/criteo_spec.js +++ b/test/spec/adapters/criteo_spec.js @@ -7,51 +7,50 @@ import {expect} from 'chai'; var CONSTANTS = require('../../../src/constants'); describe('criteo adapter test', () => { - let adapter; let stubAddBidResponse; let validBid = { - bidderCode: 'criteo', - bids: [ - { - bidder: 'criteo', - placementCode: 'foo', - sizes: [[250, 350]], - params: { - zoneId: 32934, - audit: 'true' - } - } - ] - }; - - let validResponse = {slots: [{impid: "foo", cpm: 1.12, creative: ""}]}; - let invalidResponse = { slots: [{ "impid": "unknownSlot" }] } + bidderCode: 'criteo', + bids: [ + { + bidder: 'criteo', + placementCode: 'foo', + sizes: [[250, 350]], + params: { + zoneId: 32934, + audit: 'true' + } + } + ] + }; + + let validResponse = {slots: [{impid: 'foo', cpm: 1.12, creative: ""}]}; + let invalidResponse = { slots: [{ 'impid': 'unknownSlot' }] } let validMultiBid = { - bidderCode: 'criteo', - bids: [ - { - bidder: 'criteo', - placementCode: 'foo', - sizes: [[250, 350]], - params: { - zoneId: 32934, - audit: 'true' - } - }, - { - bidder: 'criteo', - placementCode: 'bar', - sizes: [[250, 350]], - params: { - zoneId: 32935, - audit: 'true' - } - } - ] - }; + bidderCode: 'criteo', + bids: [ + { + bidder: 'criteo', + placementCode: 'foo', + sizes: [[250, 350]], + params: { + zoneId: 32934, + audit: 'true' + } + }, + { + bidder: 'criteo', + placementCode: 'bar', + sizes: [[250, 350]], + params: { + zoneId: 32935, + audit: 'true' + } + } + ] + }; beforeEach(() => { adapter = new Adapter(); @@ -61,7 +60,7 @@ describe('criteo adapter test', () => { stubAddBidResponse.restore(); }); -describe('adding bids to the manager', () => { + describe('adding bids to the manager', () => { let server; beforeEach(() => { @@ -71,8 +70,8 @@ describe('adding bids to the manager', () => { it('adds bid for valid request', (done) => { stubAddBidResponse = sinon.stub(bidManager, 'addBidResponse', function (adUnitCode, bid) { - expect(bid).to.satisfy(bid => { return bid.getStatusCode() == CONSTANTS.STATUS.GOOD }); - done(); + expect(bid).to.satisfy(bid => { return bid.getStatusCode() == CONSTANTS.STATUS.GOOD }); + done(); }); adapter.callBids(validBid); @@ -81,10 +80,9 @@ describe('adding bids to the manager', () => { it('adds bid for multibid valid request', (done) => { let callCount = 0; stubAddBidResponse = sinon.stub(bidManager, 'addBidResponse', function (adUnitCode, bid) { - callCount++; + callCount++; - if (callCount == 2) - done(); + if (callCount == 2) { done(); } }); adapter.callBids(validMultiBid); @@ -92,8 +90,8 @@ describe('adding bids to the manager', () => { it('adds bidderCode to the response of a valid request', (done) => { stubAddBidResponse = sinon.stub(bidManager, 'addBidResponse', function (adUnitCode, bid) { - expect(bid).to.have.property('bidderCode', 'criteo'); - done(); + expect(bid).to.have.property('bidderCode', 'criteo'); + done(); }); adapter.callBids(validBid); @@ -114,9 +112,9 @@ describe('adding bids to the manager', () => { }); adapter.callBids(validBid); }); -}); + }); -describe('dealing with unexpected situations', () => { + describe('dealing with unexpected situations', () => { let server; beforeEach(() => { @@ -124,33 +122,33 @@ describe('dealing with unexpected situations', () => { }); it('no bid if cdb handler responds with no bid empty string response', (done) => { - server.respondWith(""); + server.respondWith(''); stubAddBidResponse = sinon.stub(bidManager, 'addBidResponse', function (adUnitCode, bid) { - expect(bid).to.satisfy(bid => { return bid.getStatusCode() == CONSTANTS.STATUS.NO_BID }); - done(); + expect(bid).to.satisfy(bid => { return bid.getStatusCode() == CONSTANTS.STATUS.NO_BID }); + done(); }); adapter.callBids(validBid); }); it('no bid if cdb handler responds with no bid empty object response', (done) => { - server.respondWith("{ }"); + server.respondWith('{ }'); stubAddBidResponse = sinon.stub(bidManager, 'addBidResponse', function (adUnitCode, bid) { - expect(bid).to.satisfy(bid => { return bid.getStatusCode() == CONSTANTS.STATUS.NO_BID }); - done(); + expect(bid).to.satisfy(bid => { return bid.getStatusCode() == CONSTANTS.STATUS.NO_BID }); + done(); }); adapter.callBids(validBid); }); it('no bid if cdb handler responds with HTTP error', (done) => { - server.respondWith([500, {}, "Internal Server Error"]); + server.respondWith([500, {}, 'Internal Server Error']); stubAddBidResponse = sinon.stub(bidManager, 'addBidResponse', function (adUnitCode, bid) { - expect(bid).to.satisfy(bid => { return bid.getStatusCode() == CONSTANTS.STATUS.NO_BID }); - done(); + expect(bid).to.satisfy(bid => { return bid.getStatusCode() == CONSTANTS.STATUS.NO_BID }); + done(); }); adapter.callBids(validBid); @@ -160,12 +158,11 @@ describe('dealing with unexpected situations', () => { server.respondWith(JSON.stringify(invalidResponse)); stubAddBidResponse = sinon.stub(bidManager, 'addBidResponse', function (adUnitCode, bid) { - expect(bid).to.satisfy(bid => { return bid.getStatusCode() == CONSTANTS.STATUS.NO_BID }); - done(); + expect(bid).to.satisfy(bid => { return bid.getStatusCode() == CONSTANTS.STATUS.NO_BID }); + done(); }); adapter.callBids(validBid); }); }); - }); diff --git a/test/spec/adapters/districtm_spec.js b/test/spec/adapters/districtm_spec.js index 4b457fe8d3a..6c703bff191 100644 --- a/test/spec/adapters/districtm_spec.js +++ b/test/spec/adapters/districtm_spec.js @@ -2,292 +2,244 @@ * Created by stevealliance on 2016-11-15. */ - - -import {expect} from "chai"; -import {should} from "chai"; +import {expect} from 'chai'; +import {should} from 'chai'; import Adaptor from '../../../src/adapters/districtmDMX'; import adLoader from '../../../src/adloader'; - - -var _each = function(obj, fn){ - for(var o in obj){ - fn(o, obj[o]); - } +var _each = function(obj, fn) { + for (var o in obj) { + fn(o, obj[o]); + } } let districtm; -const PREBID_RESPONSE = function(){ - return { - result: { - cpm: '3.45', - callbackId: '1490bd6bdc59ce', - width: 300, - height: 250, - banner: 'html' - }, - callback_uid: '1490bd6bdc59ce' - }; +const PREBID_RESPONSE = function() { + return { + result: { + cpm: '3.45', + callbackId: '1490bd6bdc59ce', + width: 300, + height: 250, + banner: 'html' + }, + callback_uid: '1490bd6bdc59ce' + }; } const PREBID_PARAMS = { - bidderCode: 'districtmDMX', - requestId: '5ccedbd5-86c1-436f-8649-964262461eac', + bidderCode: 'districtmDMX', + requestId: '5ccedbd5-86c1-436f-8649-964262461eac', + bidderRequestId: '1490bd6bdc59ce', + start: new Date().getTime(), + bids: [{ + bidder: 'districtmDMX', + bidId: '84ab500420319d', bidderRequestId: '1490bd6bdc59ce', - start: new Date().getTime(), - bids: [{ - bidder: 'districtmDMX', - bidId: '84ab500420319d', - bidderRequestId: '1490bd6bdc59ce', - requestId: '5ccedbd5-86c1-436f-8649-964262461eac', - placementCode: 'golden', - params: { - placement: 109801, - floor: '1.00' - }, - sizes: [[300, 250], [300, 600]] - }] + requestId: '5ccedbd5-86c1-436f-8649-964262461eac', + placementCode: 'golden', + params: { + placement: 109801, + floor: '1.00' + }, + sizes: [[300, 250], [300, 600]] + }] }; function resetDm() { - window.hb_dmx_res = undefined; + window.hb_dmx_res = undefined; } function activated() { - window.hb_dmx_res = { - ssp: {}, - bh(){ - - }, - auction: { - fixSize(s){ - let size; - if (!Array.isArray(s[0])) { - size = [s[0] + 'x' + s[1]]; - } else { - size = s.map(ss => { - return ss[0] + 'x' + ss[1]; - }) - } - - return size; + window.hb_dmx_res = { + ssp: {}, + bh() { + + }, + auction: { + fixSize(s) { + let size; + if (!Array.isArray(s[0])) { + size = [s[0] + 'x' + s[1]]; + } else { + size = s.map(ss => { + return ss[0] + 'x' + ss[1]; + }) + } - }, + return size; + }, - run(a, b, c){ + run(a, b, c) { - } - } + } } + } } - -function definitions(){ - districtm.callBids({ - bidderCode: 'districtmDMX', - bids: [ - { - bidder: 'districtmDMX', - adUnitCode: 'golden', - sizes: [[728, 90]], - params: { - siteId: '101000' - } - }, - { - bidder: 'districtmDMX', - adUnitCode: 'stevealliance', - sizes: [[300, 250]], - params: { - siteId: '101000' - } - } - ] - }); +function definitions() { + districtm.callBids({ + bidderCode: 'districtmDMX', + bids: [ + { + bidder: 'districtmDMX', + adUnitCode: 'golden', + sizes: [[728, 90]], + params: { + siteId: '101000' + } + }, + { + bidder: 'districtmDMX', + adUnitCode: 'stevealliance', + sizes: [[300, 250]], + params: { + siteId: '101000' + } + } + ] + }); } describe('DistrictM adapter test', () => { - - - describe('File loading', ()=>{ - let districtm; - afterEach(()=>{ - - districtm = new Adaptor(); - adLoader.loadScript(districtm.districtUrl, function(){}); - - }) - - it('For loading file ', ()=>{ - expect(!window.hb_dmx_res).to.equal(true); - }) - - + describe('File loading', () => { + let districtm; + afterEach(() => { + districtm = new Adaptor(); + adLoader.loadScript(districtm.districtUrl, function() {}); }) - - describe('check for library do exists', ()=>{ - it('library was not loaded', ()=>{ - - expect(!window.hb_dmx_res).to.equal(true); - }) - - it('library is now available', ()=>{ - activated(); - - expect(!!window.hb_dmx_res).to.equal(true); - - }) + it('For loading file ', () => { + expect(!window.hb_dmx_res).to.equal(true); }) + }) - - describe('Check if size get clean', ()=>{ - beforeEach(()=>{ - activated(); - }) - it('size clean up using fixe size', ()=>{ - activated(); - - expect(window.hb_dmx_res.auction.fixSize([728, 90])[0]).to.equal(['728x90'][0]); - expect(window.hb_dmx_res.auction.fixSize([[300, 250], [300,600]]).toString()).to.equal(['300x250', '300x600'].toString()); - - }) + describe('check for library do exists', () => { + it('library was not loaded', () => { + expect(!window.hb_dmx_res).to.equal(true); }) - describe('Check call bids return no errors', ()=>{ - let districtm; - beforeEach(()=>{ - districtm = new Adaptor(); - }); - it('check value push using cal bids', ()=>{ - let obj = districtm.callBids(PREBID_PARAMS); - obj.should.have.property('bidderCode'); - obj.should.have.property('requestId'); - obj.should.have.property('bidderRequestId'); - obj.should.have.property('start'); - obj.should.have.property('bids'); + it('library is now available', () => { + activated(); - }) - it('check if value got pass correctly for DM params', ()=>{ - let dm = districtm.callBids(PREBID_PARAMS).bids.map( bid => bid); - dm.forEach( a =>{ - a.should.have.property('bidder'); - a.should.have.property('requestId'); - a.should.have.property('bidderRequestId'); - a.should.have.property('placementCode'); - a.should.have.property('params'); - a.should.have.property('sizes'); - expect(a.bidder).to.equal('districtmDMX'); - expect(a.placementCode).to.equal('golden'); - expect(a.params.placement).to.equal(109801); - }) - - - }) + expect(!!window.hb_dmx_res).to.equal(true); }) + }) - describe('Run prebid definitions !', ()=>{ - let districtm; - beforeEach(()=>{ - districtm = new Adaptor(); - }) - - it('Run and return send bids', ()=>{ - let sendBids = districtm.sendBids(PREBID_PARAMS); - sendBids.forEach(sb =>{ - - expect(sb.sizes.toString()).to.equal([[300, 250], [300, 600]].toString()); - }) - - }) - - + describe('Check if size get clean', () => { + beforeEach(() => { + activated(); }) + it('size clean up using fixe size', () => { + activated(); - describe('HandlerRes function test', ()=>{ - let districtm; - - beforeEach(()=>{ - districtm = new Adaptor(); - }) - - it('it\'s now time to play with the response ...', ()=>{ - let result = districtm.handlerRes(PREBID_RESPONSE(), PREBID_PARAMS); - _each(result, function(k, v){ - - }) - - - expect(result.cpm).to.equal('3.45'); - expect(result.width).to.equal(300); - expect(result.height).to.equal(250); - expect(result.ad).to.equal('html'); - - - - } ) - it('it\'s now time to play with the response failure...', ()=>{ - let result = districtm.handlerRes({result:{cpm:0}}, PREBID_PARAMS); - - result.should.have.property('bidderCode'); - + expect(window.hb_dmx_res.auction.fixSize([728, 90])[0]).to.equal(['728x90'][0]); + expect(window.hb_dmx_res.auction.fixSize([[300, 250], [300, 600]]).toString()).to.equal(['300x250', '300x600'].toString()); + }) + }) - } ) + describe('Check call bids return no errors', () => { + let districtm; + beforeEach(() => { + districtm = new Adaptor(); + }); + it('check value push using cal bids', () => { + let obj = districtm.callBids(PREBID_PARAMS); + obj.should.have.property('bidderCode'); + obj.should.have.property('requestId'); + obj.should.have.property('bidderRequestId'); + obj.should.have.property('start'); + obj.should.have.property('bids'); + }) + it('check if value got pass correctly for DM params', () => { + let dm = districtm.callBids(PREBID_PARAMS).bids.map(bid => bid); + dm.forEach(a => { + a.should.have.property('bidder'); + a.should.have.property('requestId'); + a.should.have.property('bidderRequestId'); + a.should.have.property('placementCode'); + a.should.have.property('params'); + a.should.have.property('sizes'); + expect(a.bidder).to.equal('districtmDMX'); + expect(a.placementCode).to.equal('golden'); + expect(a.params.placement).to.equal(109801); + }) + }) + }) + describe('Run prebid definitions !', () => { + let districtm; + beforeEach(() => { + districtm = new Adaptor(); }) - describe('look at the adloader', ()=>{ - let districtm; - beforeEach(()=>{ - districtm = new Adaptor(); - sinon.stub(adLoader, "loadScript"); - }) + it('Run and return send bids', () => { + let sendBids = districtm.sendBids(PREBID_PARAMS); + sendBids.forEach(sb => { + expect(sb.sizes.toString()).to.equal([[300, 250], [300, 600]].toString()); + }) + }) + }) - it('Verify districtm library is downloaded if nessesary', () => { - resetDm(); - districtm.callBids(PREBID_PARAMS); - let libraryLoadCall = adLoader.loadScript.firstCall.args[0]; - let callback = adLoader.loadScript.firstCall.args[1]; - expect(libraryLoadCall).to.equal('http://prebid.districtm.ca/lib.js'); - expect(callback).to.be.a('function'); + describe('HandlerRes function test', () => { + let districtm; + beforeEach(() => { + districtm = new Adaptor(); + }) - }); + it('it\'s now time to play with the response ...', () => { + let result = districtm.handlerRes(PREBID_RESPONSE(), PREBID_PARAMS); + _each(result, function(k, v) { - afterEach(()=>{ - adLoader.loadScript.restore(); - }) + }) + expect(result.cpm).to.equal('3.45'); + expect(result.width).to.equal(300); + expect(result.height).to.equal(250); + expect(result.ad).to.equal('html'); + }) + it('it\'s now time to play with the response failure...', () => { + let result = districtm.handlerRes({result: {cpm: 0}}, PREBID_PARAMS); + result.should.have.property('bidderCode'); + }) + }) + describe('look at the adloader', () => { + let districtm; + beforeEach(() => { + districtm = new Adaptor(); + sinon.stub(adLoader, 'loadScript'); + }) + it('Verify districtm library is downloaded if nessesary', () => { + resetDm(); + districtm.callBids(PREBID_PARAMS); + let libraryLoadCall = adLoader.loadScript.firstCall.args[0]; + let callback = adLoader.loadScript.firstCall.args[1]; + expect(libraryLoadCall).to.equal('http://prebid.districtm.ca/lib.js'); + expect(callback).to.be.a('function'); }); - describe('run send bid from within !!!', ()=> { - beforeEach(()=> { - districtm = new Adaptor(); - sinon.stub(districtm, 'sendBids'); - }) - it('last test on send bids', ()=>{ - resetDm(); - districtm.sendBids(PREBID_PARAMS); - expect(districtm.sendBids.calledOnce).to.be.true; - expect(districtm.sendBids.firstCall.args[0]).to.be.a('object'); - - - }); - - afterEach(()=> { - districtm.sendBids.restore(); - }) + afterEach(() => { + adLoader.loadScript.restore(); + }) + }); + describe('run send bid from within !!!', () => { + beforeEach(() => { + districtm = new Adaptor(); + sinon.stub(districtm, 'sendBids'); + }) + it('last test on send bids', () => { + resetDm(); + districtm.sendBids(PREBID_PARAMS); + expect(districtm.sendBids.calledOnce).to.be.true; + expect(districtm.sendBids.firstCall.args[0]).to.be.a('object'); }); - - - - - - + afterEach(() => { + districtm.sendBids.restore(); + }) + }); }); - diff --git a/test/spec/adapters/fidelity_spec.js b/test/spec/adapters/fidelity_spec.js index 31ae9378574..3b852713bff 100644 --- a/test/spec/adapters/fidelity_spec.js +++ b/test/spec/adapters/fidelity_spec.js @@ -1,18 +1,17 @@ describe('fidelity adapter tests', function() { const expect = require('chai').expect; const adapter = require('src/adapters/fidelity'); - const adLoader = require('src/adloader'); + const adLoader = require('src/adloader'); const bidmanager = require('src/bidmanager'); const STATUS = require('src/constants').STATUS; var urlParse = require('url-parse'); var querystringify = require('querystringify'); describe('creation of bid url', function () { - it('should be called', function () { var stubLoadScript; stubLoadScript = sinon.stub(adLoader, 'loadScript'); - + var bidderRequest = { bidderCode: 'fidelity', bids: [ @@ -36,7 +35,7 @@ describe('fidelity adapter tests', function() { it('should populate required parameters', function () { var stubLoadScript; stubLoadScript = sinon.stub(adLoader, 'loadScript'); - + var bidderRequest = { bidderCode: 'fidelity', bids: [ @@ -59,7 +58,7 @@ describe('fidelity adapter tests', function() { it('should populate required and optional parameters', function () { var stubLoadScript; stubLoadScript = sinon.stub(adLoader, 'loadScript'); - + var bidderRequest = { bidderCode: 'fidelity', bids: [ @@ -88,7 +87,7 @@ describe('fidelity adapter tests', function() { expect(parsedBidUrlQueryString).to.have.property('zoneid').and.to.equal('37'); expect(parsedBidUrlQueryString).to.have.property('impid').and.to.equal('bidId-123456-1'); - expect(parsedBidUrlQueryString).to.have.property('callback').and.to.equal('window.$$PREBID_GLOBAL$$.fidelityResponse'); + expect(parsedBidUrlQueryString).to.have.property('callback').and.to.equal('window.$$PREBID_GLOBAL$$.fidelityResponse'); expect(parsedBidUrlQueryString).to.have.property('loc').and.to.equal('http://locurl'); expect(parsedBidUrlQueryString).to.have.property('ct0').and.to.equal('http://clickurl'); expect(parsedBidUrlQueryString).to.have.property('subid').and.to.equal('000'); @@ -96,9 +95,8 @@ describe('fidelity adapter tests', function() { stubLoadScript.restore(); }); }); - - describe('fidelityResponse', function () { + describe('fidelityResponse', function () { it('should exist and be a function', function () { expect(pbjs.fidelityResponse).to.exist.and.to.be.a('function'); }); @@ -122,8 +120,8 @@ describe('fidelity adapter tests', function() { // no bids returned in the response. var response = { - "id": "543210", - "seatbid": [] + 'id': '543210', + 'seatbid': [] }; pbjs._bidsRequested.push(bidderRequest); @@ -161,15 +159,15 @@ describe('fidelity adapter tests', function() { // Returning a single bid in the response. var response = { - "id": "543210", - "seatbid": [ { - "bid" : [ { - "id" : "1111111", - "impid" : "bidId-123456-1", - "price" : 0.09, - "adm" : "<>", - "height" : 90, - "width" : 728 + 'id': '543210', + 'seatbid': [ { + 'bid': [ { + 'id': '1111111', + 'impid': 'bidId-123456-1', + 'price': 0.09, + 'adm': '<>', + 'height': 90, + 'width': 728 } ] } ] }; @@ -194,4 +192,4 @@ describe('fidelity adapter tests', function() { stubAddBidResponse.restore(); }); }); -}); \ No newline at end of file +}); diff --git a/test/spec/adapters/getintent_spec.js b/test/spec/adapters/getintent_spec.js index 64b33ba72ec..3537564f029 100644 --- a/test/spec/adapters/getintent_spec.js +++ b/test/spec/adapters/getintent_spec.js @@ -5,7 +5,6 @@ import {expect} from 'chai'; var assert = require('chai').assert; describe('getintent media adapter test', () => { - let adapter; window.gi_hb = { @@ -13,69 +12,69 @@ describe('getintent media adapter test', () => { var pid = bidRequest.pid; var tid = bidRequest.tid; - if (pid == "p1" || pid == "p2") { - callback({ - ad : `Ad Markup ${pid} ${tid}`, - cpm : 2.71, - size : `${bidRequest.size}` - }, bidRequest); - } else if (pid == "p3") { + if (pid == 'p1' || pid == 'p2') { + callback({ + ad: `Ad Markup ${pid} ${tid}`, + cpm: 2.71, + size: `${bidRequest.size}` + }, bidRequest); + } else if (pid == 'p3') { callback({ no_bid: 1 }, bidRequest); - } else if (pid == "p4") { + } else if (pid == 'p4') { callback({ - vast_url : `http://test.com?pid=${pid}&tid=${tid}`, - cpm : 2.88, - size : `${bidRequest.size}` - }, bidRequest); + vast_url: `http://test.com?pid=${pid}&tid=${tid}`, + cpm: 2.88, + size: `${bidRequest.size}` + }, bidRequest); } } }; function callOut() { adapter.callBids({ - bidderCode: "getintent", + bidderCode: 'getintent', bids: [ { - bidder: "getintent", - adUnitCode: "test1", - sizes: [[320,240]], + bidder: 'getintent', + adUnitCode: 'test1', + sizes: [[320, 240]], params: { - pid: "p1", - tid: "t1", - cur: "USD" + pid: 'p1', + tid: 't1', + cur: 'USD' } }, { - bidder: "getintent", - adUnitCode: "test2", - sizes: [[720,90]], + bidder: 'getintent', + adUnitCode: 'test2', + sizes: [[720, 90]], params: { - pid: "p2", - tid: "t1", - cur: "USD" + pid: 'p2', + tid: 't1', + cur: 'USD' } }, { - bidder: "getintent", - adUnitCode: "test3", - sizes: [[400,500]], + bidder: 'getintent', + adUnitCode: 'test3', + sizes: [[400, 500]], params: { - pid: "p3", - tid: "t2", - cur: "USD" + pid: 'p3', + tid: 't2', + cur: 'USD' } }, { - bidder: "getintent", - adUnitCode: "test4", + bidder: 'getintent', + adUnitCode: 'test4', mediaType: 'video', - sizes: [[480,352]], + sizes: [[480, 352]], params: { - pid: "p4", - tid: "t3", - cur: "USD" + pid: 'p4', + tid: 't3', + cur: 'USD' } } ] @@ -90,7 +89,6 @@ describe('getintent media adapter test', () => { }); describe('adding bids to the manager', () => { - let firstBid; let secondBid; let thirdBid; @@ -137,7 +135,7 @@ describe('getintent media adapter test', () => { expect(secondBid).to.have.property('bidderCode', 'getintent'); expect(thirdBid).to.have.property('bidderCode', 'getintent'); }); - + it('will respond to the video bid', () => { expect(videoBid).to.have.property('vastUrl', 'http://test.com?pid=p4&tid=t3'); expect(videoBid).to.have.property('cpm', 2.88); @@ -145,5 +143,4 @@ describe('getintent media adapter test', () => { expect(videoBid).to.have.property('height', '352'); }); }); - }); diff --git a/test/spec/adapters/gumgum_spec.js b/test/spec/adapters/gumgum_spec.js index 9eb1a36ae08..96e756d1052 100644 --- a/test/spec/adapters/gumgum_spec.js +++ b/test/spec/adapters/gumgum_spec.js @@ -59,20 +59,20 @@ describe('gumgum adapter', () => { }] }; const pageParams = { - "pvid": "PVID" + 'pvid': 'PVID' }; const bidderResponse = { - "ad": { - "id": 1, - "width": 728, - "height": 90, - "markup": "
some fancy ad
", - "ii": true, - "du": "http://example.com/", - "price": TEST.CPM, - "impurl": "http://example.com/" + 'ad': { + 'id': 1, + 'width': 728, + 'height': 90, + 'markup': '
some fancy ad
', + 'ii': true, + 'du': 'http://example.com/', + 'price': TEST.CPM, + 'impurl': 'http://example.com/' }, - "pag": pageParams + 'pag': pageParams }; function mockBidResponse(response) { @@ -93,7 +93,6 @@ describe('gumgum adapter', () => { }); describe('callBids', () => { - beforeEach(() => { sandbox.stub(adLoader, 'loadScript'); adapter.callBids(bidderRequest); @@ -136,7 +135,6 @@ describe('gumgum adapter', () => { it('last call should be slot', () => { expect(adLoader.loadScript.lastCall.args[0]).to.include('pi=3'); }); - }); describe('handleGumGumCB[...]', () => { @@ -146,7 +144,6 @@ describe('gumgum adapter', () => { }); describe('respond with a successful bid', () => { - let successfulBid; beforeEach(() => { @@ -179,11 +176,9 @@ describe('gumgum adapter', () => { expect(successfulBid).to.have.property('width', 728); expect(successfulBid).to.have.property('height', 90); }); - }); describe('respond with an empty bid', () => { - let noBid; beforeEach(() => { @@ -206,11 +201,9 @@ describe('gumgum adapter', () => { it('adds the bidder code to the bid object', () => { expect(noBid).to.have.property('bidderCode', TEST.BIDDER_CODE); }); - }); describe('refresh throttle', () => { - beforeEach(() => { mockBidResponse(bidderResponse); }); @@ -230,7 +223,5 @@ describe('gumgum adapter', () => { warning.to.include(TEST.PLACEMENT); warning.to.include('inScreen'); }); - }); - }); diff --git a/test/spec/adapters/hiromedia_spec.js b/test/spec/adapters/hiromedia_spec.js index b91bcca38ac..4fe7a0ec1cd 100644 --- a/test/spec/adapters/hiromedia_spec.js +++ b/test/spec/adapters/hiromedia_spec.js @@ -1,5 +1,5 @@ -/*jslint white: true, es6: true, single: true*/ -/*jshint esversion:6*/ +/* jslint white: true, es6: true, single: true */ +/* jshint esversion:6 */ import { expect } from 'chai'; import querystringify from 'querystringify'; @@ -11,8 +11,7 @@ import bidmanager from 'src/bidmanager'; import { STATUS } from 'src/constants'; import * as utils from 'src/utils'; -describe('hiromedia adapter', function () { - +describe('hiromedia adapter', function () { const BIDDER_CODE = 'hiromedia'; const DEFAULT_CALLBACK_NAME = 'hiromedia_callback'; const DEFAULT_ENDPOINT = 'https://hb-rtb.ktdpublishers.com/bid/get'; @@ -26,8 +25,7 @@ describe('hiromedia adapter', function () { window.$$PREBID_GLOBAL$$ = window.$$PREBID_GLOBAL$$ || {}; - beforeEach(() => { - + beforeEach(() => { adapter = new Adapter(); sandbox = sinon.sandbox.create(); @@ -40,8 +38,7 @@ describe('hiromedia adapter', function () { // Used to spy on bid validation hasValidBidRequestSpy = sandbox.spy(utils, 'hasValidBidRequest'); - placementId = 0; - + placementId = 0; }); afterEach(() => { @@ -50,16 +47,13 @@ describe('hiromedia adapter', function () { // Helper function that asserts that no bidding activity (requests nor responses) // was made during a test. - const assertNoBids = () => { - + const assertNoBids = () => { sinon.assert.notCalled(loadScriptStub); - sinon.assert.notCalled(addBidResponseStub); - + sinon.assert.notCalled(addBidResponseStub); }; // Helper function to generate a 'mock' bid object - const makePlacement = (size) => { - + const makePlacement = (size) => { placementId += 1; return { @@ -69,8 +63,7 @@ describe('hiromedia adapter', function () { accountId: '1337' }, placementCode: 'div-gpt-ad-12345-' + placementId - }; - + }; }; // 300x250 are in the allowed size by default @@ -79,8 +72,7 @@ describe('hiromedia adapter', function () { // anything else should have no bid by default const leaderPlacement = () => makePlacement([728, 90]); - describe('callbids', () => { - + describe('callbids', () => { it('exists and is a function', () => { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); @@ -100,14 +92,13 @@ describe('hiromedia adapter', function () { assertNoBids(); }); - it('invokes a bid request per placement', () => { - + it('invokes a bid request per placement', () => { const expectedRequests = [{ - batchKey: [DEFAULT_ENDPOINT,'1337','300x250',''].join('-'), + batchKey: [DEFAULT_ENDPOINT, '1337', '300x250', ''].join('-'), placementCode: 'div-gpt-ad-12345-1', selectedSize: '300x250' }, { - batchKey: [DEFAULT_ENDPOINT,'1337','728x90',''].join('-'), + batchKey: [DEFAULT_ENDPOINT, '1337', '728x90', ''].join('-'), placementCode: 'div-gpt-ad-12345-2', selectedSize: '728x90' }]; @@ -121,8 +112,7 @@ describe('hiromedia adapter', function () { sinon.assert.notCalled(addBidResponseStub); sinon.assert.calledTwice(hasValidBidRequestSpy); - expectedRequests.forEach(function(request, index) { - + expectedRequests.forEach(function(request, index) { expect(hasValidBidRequestSpy.returnValues[index]).to.be.equal(true); // validate request @@ -141,15 +131,12 @@ describe('hiromedia adapter', function () { expect(query).to.have.property('accountId').and.to.equal('1337'); expect(query).to.have.property('selectedSize').and.to.equal(request.selectedSize); expect(query).to.not.have.property('additionalSizes'); - expect(query).to.have.property('domain').and.to.equal(window.top.location.hostname); - - }); - + expect(query).to.have.property('domain').and.to.equal(window.top.location.hostname); + }); }); // Test additionalSizes parameter - it('attaches multiple sizes to additionalSizes', () => { - + it('attaches multiple sizes to additionalSizes', () => { const placement = tilePlacement(); // Append additional @@ -168,13 +155,11 @@ describe('hiromedia adapter', function () { const query = querystringify.parse(bidUrl.query); expect(query).to.have.property('selectedSize').and.to.equal('300x250'); - expect(query).to.have.property('additionalSizes').and.to.equal('300x600,300x900'); - + expect(query).to.have.property('additionalSizes').and.to.equal('300x600,300x900'); }); // Test `params.accountId` validation - it('invalidates bids with no id', () => { - + it('invalidates bids with no id', () => { const placement = tilePlacement(); delete placement.params; @@ -185,13 +170,11 @@ describe('hiromedia adapter', function () { adapter.callBids(params); sinon.assert.notCalled(loadScriptStub); sinon.assert.calledOnce(hasValidBidRequestSpy); - expect(hasValidBidRequestSpy.returnValues[0]).to.be.equal(false); - + expect(hasValidBidRequestSpy.returnValues[0]).to.be.equal(false); }); // Test `params.bidUrl` - it('accepts a custom bid endpoint url', () => { - + it('accepts a custom bid endpoint url', () => { const placement = tilePlacement(); placement.params.bidUrl = DEFAULT_ENDPOINT + '?someparam=value'; @@ -210,25 +193,20 @@ describe('hiromedia adapter', function () { expect(bidUrl.hostname).to.equal(defaultBidUrl.hostname); expect(bidUrl.pathname).to.equal(defaultBidUrl.pathname); - expect(query).to.have.property('someparam').and.to.equal('value'); - + expect(query).to.have.property('someparam').and.to.equal('value'); }); - it('batches similar bid requests for similar sized placements', () => { - + it('batches similar bid requests for similar sized placements', () => { const params = { bids: [tilePlacement(), tilePlacement()] }; adapter.callBids(params); - sinon.assert.calledOnce(loadScriptStub); // and only once! - - }); - + sinon.assert.calledOnce(loadScriptStub); // and only once! + }); }); - describe('global response handler', () => { - + describe('global response handler', () => { const getPbjs = () => window.$$PREBID_GLOBAL$$; const getResponseHandler = () => window.$$PREBID_GLOBAL$$[DEFAULT_CALLBACK_NAME]; @@ -250,23 +228,21 @@ describe('hiromedia adapter', function () { // batch key. // To do this, we have to have the internal state of // the adapter set up correctly. - it('adds a bid reponse for each pending bid', () => { - + it('adds a bid reponse for each pending bid', () => { const expectedResponses = [{ - batchKey: [DEFAULT_ENDPOINT,'1337','300x250',''].join('-'), + batchKey: [DEFAULT_ENDPOINT, '1337', '300x250', ''].join('-'), width: '300', height: '250', cpm: 0.4, ad: '' }, { - batchKey: [DEFAULT_ENDPOINT,'1337','728x90',''].join('-'), + batchKey: [DEFAULT_ENDPOINT, '1337', '728x90', ''].join('-'), width: '728', height: '90', cpm: 0.4, ad: '' }]; - // Instead of the dead stub defined in the top scope, we'll use // one that mocks a response. loadScriptStub.restore(); @@ -286,8 +262,7 @@ describe('hiromedia adapter', function () { sinon.assert.calledTwice(activeLoadScriptStub); sinon.assert.calledTwice(addBidResponseStub); - expectedResponses.forEach((expectedResponse, i) => { - + expectedResponses.forEach((expectedResponse, i) => { const placementCode = addBidResponseStub.getCall(i).args[0]; const bidObject = addBidResponseStub.getCall(i).args[1]; @@ -297,20 +272,17 @@ describe('hiromedia adapter', function () { expect(bidObject).to.have.property('cpm').and.to.equal(expectedResponse.cpm); expect(bidObject).to.have.property('ad').and.to.equal(expectedResponse.ad); expect(bidObject).to.have.property('width').and.to.equal(expectedResponse.width); - expect(bidObject).to.have.property('height').and.to.equal(expectedResponse.height); - - }); - + expect(bidObject).to.have.property('height').and.to.equal(expectedResponse.height); + }); }); // We want to check that responses are added according to a sampling value, // this is possible by stubbing `Math.random`, to ensure the effect is // limited to the area we check, we create a self destructing stub which // restores itself once called. - it('adds responses according to the sampling defined in the response', () => { - + it('adds responses according to the sampling defined in the response', () => { const response = { - batchKey: [DEFAULT_ENDPOINT,'1337','300x250',''].join('-'), + batchKey: [DEFAULT_ENDPOINT, '1337', '300x250', ''].join('-'), cpm: 0.4, chance: 0.25, ad: '' @@ -325,21 +297,18 @@ describe('hiromedia adapter', function () { const activeLoadScriptStub = sandbox.stub(adloader, 'loadScript', (url) => { const handler = getResponseHandler(); - const mathRandomStub = sandbox.stub(Math, 'random', function () { - + const mathRandomStub = sandbox.stub(Math, 'random', function () { const randomValue = randomValues[randomIndex]; randomIndex += 1; mathRandomStub.restore(); // self destruct on call - return randomValue; - + return randomValue; }); handler(response); - mathRandomStub.restore(); - + mathRandomStub.restore(); }); const params = { @@ -355,10 +324,7 @@ describe('hiromedia adapter', function () { const secondBidObject = addBidResponseStub.getCall(1).args[1]; expect(firstBidObject.getStatusCode()).to.be.equal(STATUS.GOOD); - expect(secondBidObject.getStatusCode()).to.be.equal(STATUS.NO_BID); - - }); - - }); - + expect(secondBidObject.getStatusCode()).to.be.equal(STATUS.NO_BID); + }); + }); }); diff --git a/test/spec/adapters/huddledmasses_spec.js b/test/spec/adapters/huddledmasses_spec.js index 434ae58cd58..e045d96f997 100644 --- a/test/spec/adapters/huddledmasses_spec.js +++ b/test/spec/adapters/huddledmasses_spec.js @@ -5,126 +5,123 @@ import bidManager from 'src/bidmanager'; import CONSTANTS from 'src/constants.json'; describe('HuddledMasses adapter tests', function () { - - let sandbox; - const adUnit = { - code: 'huddledmasses', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'huddledmasses', - params: { - placement_id: 0 - } - }] - }; - - const response = { - ad_id: 15, - adm: "
Bid Response
", - cpm: 0.712, - deal: "5e1f0a8f2aa1", - width: 300, - height: 250 - }; + let sandbox; + const adUnit = { + code: 'huddledmasses', + sizes: [[300, 250], [300, 600]], + bids: [{ + bidder: 'huddledmasses', + params: { + placement_id: 0 + } + }] + }; + + const response = { + ad_id: 15, + adm: '
Bid Response
', + cpm: 0.712, + deal: '5e1f0a8f2aa1', + width: 300, + height: 250 + }; + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + + afterEach(() => { + sandbox.restore(); + }); + + describe('HuddledMasses callBids validation', () => { + let bids, + server; beforeEach(() => { - sandbox = sinon.sandbox.create(); + bids = []; + server = sinon.fakeServer.create(); + sandbox.stub(bidManager, 'addBidResponse', (elemId, bid) => { + bids.push(bid); + }); }); afterEach(() => { - sandbox.restore(); + server.restore(); }); - describe('HuddledMasses callBids validation', () => { - - let bids, - server; - - beforeEach(() => { - bids = []; - server = sinon.fakeServer.create(); - sandbox.stub(bidManager, 'addBidResponse', (elemId, bid) => { - bids.push(bid); - }); - }); - - afterEach(() => { - server.restore(); - }); - - let adapter = adapterManager.bidderRegistry['huddledmasses']; + let adapter = adapterManager.bidderRegistry['huddledmasses']; - it('Valid bid-request', () => { - sandbox.stub(adapter, 'callBids'); - adapterManager.callBids({ - adUnits: [clone(adUnit)] - }); + it('Valid bid-request', () => { + sandbox.stub(adapter, 'callBids'); + adapterManager.callBids({ + adUnits: [clone(adUnit)] + }); - let bidderRequest = adapter.callBids.getCall(0).args[0]; + let bidderRequest = adapter.callBids.getCall(0).args[0]; - expect(bidderRequest).to.have.property('bids') + expect(bidderRequest).to.have.property('bids') .that.is.an('array') .with.lengthOf(1); - expect(bidderRequest).to.have.deep.property('bids[0]') + expect(bidderRequest).to.have.deep.property('bids[0]') .to.have.property('bidder', 'huddledmasses'); - expect(bidderRequest).to.have.deep.property('bids[0]') + expect(bidderRequest).to.have.deep.property('bids[0]') .with.property('sizes') .that.is.an('array') .with.lengthOf(2) .that.deep.equals(adUnit.sizes); - expect(bidderRequest).to.have.deep.property('bids[0]') + expect(bidderRequest).to.have.deep.property('bids[0]') .with.property('params') .to.have.property('placement_id', 0); - }); + }); - it('Valid bid-response', ()=>{ - server.respondWith(JSON.stringify( + it('Valid bid-response', () => { + server.respondWith(JSON.stringify( response )); - adapterManager.callBids({ - adUnits: [clone(adUnit)] - }); - server.respond(); - - expect(bids).to.be.lengthOf(1); - expect(bids[0].getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); - expect(bids[0].bidderCode).to.equal("huddledmasses"); - expect(bids[0].width).to.equal(300); - expect(bids[0].height).to.equal(250); - expect(bids[0].cpm).to.equal(0.712); - expect(bids[0].dealId).to.equal("5e1f0a8f2aa1"); - }); + adapterManager.callBids({ + adUnits: [clone(adUnit)] + }); + server.respond(); + + expect(bids).to.be.lengthOf(1); + expect(bids[0].getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); + expect(bids[0].bidderCode).to.equal('huddledmasses'); + expect(bids[0].width).to.equal(300); + expect(bids[0].height).to.equal(250); + expect(bids[0].cpm).to.equal(0.712); + expect(bids[0].dealId).to.equal('5e1f0a8f2aa1'); }); + }); - describe('MAS mapping / ordering', () => { - - let masSizeOrdering = Adapter.masSizeOrdering; + describe('MAS mapping / ordering', () => { + let masSizeOrdering = Adapter.masSizeOrdering; - it('should not include values without a proper mapping', () => { - let ordering = masSizeOrdering([[320, 50], [42, 42], [300, 250], [640, 480], [0, 0]]); - expect(ordering).to.deep.equal([15, 43, 65]); - }); + it('should not include values without a proper mapping', () => { + let ordering = masSizeOrdering([[320, 50], [42, 42], [300, 250], [640, 480], [0, 0]]); + expect(ordering).to.deep.equal([15, 43, 65]); + }); - it('should sort values without any MAS priority sizes in regular ascending order', () => { - let ordering = masSizeOrdering([[320, 50], [640, 480], [200, 600]]); - expect(ordering).to.deep.equal([43, 65, 119]); - }); + it('should sort values without any MAS priority sizes in regular ascending order', () => { + let ordering = masSizeOrdering([[320, 50], [640, 480], [200, 600]]); + expect(ordering).to.deep.equal([43, 65, 119]); + }); - it('should sort MAS priority sizes in the proper order w/ rest ascending', () => { - let ordering = masSizeOrdering([[320, 50], [640, 480], [300, 250], [200, 600]]); - expect(ordering).to.deep.equal([15, 43, 65, 119]); + it('should sort MAS priority sizes in the proper order w/ rest ascending', () => { + let ordering = masSizeOrdering([[320, 50], [640, 480], [300, 250], [200, 600]]); + expect(ordering).to.deep.equal([15, 43, 65, 119]); - ordering = masSizeOrdering([[320, 50], [300, 250], [640, 480], [200, 600], [728, 90]]); - expect(ordering).to.deep.equal([15, 2, 43, 65, 119]); + ordering = masSizeOrdering([[320, 50], [300, 250], [640, 480], [200, 600], [728, 90]]); + expect(ordering).to.deep.equal([15, 2, 43, 65, 119]); - ordering = masSizeOrdering([ [320, 50], [640, 480], [200, 600], [728, 90]]); - expect(ordering).to.deep.equal([2, 43, 65, 119]); - }) - }); + ordering = masSizeOrdering([ [320, 50], [640, 480], [200, 600], [728, 90]]); + expect(ordering).to.deep.equal([2, 43, 65, 119]); + }) + }); }); function clone(obj) { - return JSON.parse(JSON.stringify(obj)); -} \ No newline at end of file + return JSON.parse(JSON.stringify(obj)); +} diff --git a/test/spec/adapters/indexExchange_request_spec.js b/test/spec/adapters/indexExchange_request_spec.js index 5b41bc5cfd9..df143b6476c 100644 --- a/test/spec/adapters/indexExchange_request_spec.js +++ b/test/spec/adapters/indexExchange_request_spec.js @@ -2,465 +2,459 @@ import Adapter from '../../../src/adapters/indexExchange'; import bidManager from '../../../src/bidmanager'; import adLoader from '../../../src/adloader'; -var assert = require('chai').assert; -var IndexUtils = require('../../helpers/index_adapter_utils.js'); +var assert = require('chai').assert; +var IndexUtils = require('../../helpers/index_adapter_utils.js'); var HeaderTagRequest = '/cygnus'; -var SlotThreshold = 20; -var ADAPTER_CODE = 'indexExchange'; +var SlotThreshold = 20; +var ADAPTER_CODE = 'indexExchange'; window.pbjs = window.pbjs || {}; describe('indexExchange adapter - Request', function () { - let adapter; - let sandbox; + let adapter; + let sandbox; - beforeEach( function() { - window._IndexRequestData = {}; - _IndexRequestData.impIDToSlotID = {}; - _IndexRequestData.reqOptions = {}; - _IndexRequestData.targetIDToResp = {}; - window.cygnus_index_args = {}; + beforeEach(function() { + window._IndexRequestData = {}; + _IndexRequestData.impIDToSlotID = {}; + _IndexRequestData.reqOptions = {}; + _IndexRequestData.targetIDToResp = {}; + window.cygnus_index_args = {}; - adapter = new Adapter(); - sandbox = sinon.sandbox.create(); - sandbox.stub(adLoader, 'loadScript'); - }); + adapter = new Adapter(); + sandbox = sinon.sandbox.create(); + sandbox.stub(adLoader, 'loadScript'); + }); - afterEach( function() { - sandbox.restore(); - }); + afterEach(function() { + sandbox.restore(); + }); - it('test_prebid_indexAdapter_parameter_x3: prebid sends AS request -> x3 parameter does not exist in the request', function () { - var configuredBids = IndexUtils.createBidSlots(); - adapter.callBids({ bids: configuredBids }); + it('test_prebid_indexAdapter_parameter_x3: prebid sends AS request -> x3 parameter does not exist in the request', function () { + var configuredBids = IndexUtils.createBidSlots(); + adapter.callBids({ bids: configuredBids }); - assert.notInclude(adLoader.loadScript.firstCall.args[0], 'x3=', 'x3 parameter is not in AS request'); - }); + assert.notInclude(adLoader.loadScript.firstCall.args[0], 'x3=', 'x3 parameter is not in AS request'); + }); - it('test_prebid_indexAdapter_request_1_1: single slot with single size -> single request object for the slot', function () { - var configuredBids = IndexUtils.createBidSlots(); - adapter.callBids({ bids: configuredBids }); + it('test_prebid_indexAdapter_request_1_1: single slot with single size -> single request object for the slot', function () { + var configuredBids = IndexUtils.createBidSlots(); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.isString( requestJSON.r.id, "ID is string"); - }); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.isString(requestJSON.r.id, 'ID is string'); + }); - it('test_prebid_indexAdapter_request_1_1: single slot with single size -> single request object for the slot', function () { - var configuredBids = IndexUtils.createBidSlots(); - adapter.callBids({ bids: configuredBids }); + it('test_prebid_indexAdapter_request_1_1: single slot with single size -> single request object for the slot', function () { + var configuredBids = IndexUtils.createBidSlots(); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); + it('test_prebid_indexAdapter_request_1_2: single slot with unsupported single size -> indexExchange does not participate in auction', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.unsupportedSizes[0] ]) + ]; + adapter.callBids({ bids: configuredBids }); - }); + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'no request made to AS'); + }); - it('test_prebid_indexAdapter_request_1_2: single slot with unsupported single size -> indexExchange does not participate in auction', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.unsupportedSizes[0] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + it('test_prebid_indexAdapter_request_2_1: single slot with all supported multiple sizes -> multiple request objects for the slot', function () { + var configuredBids = IndexUtils.createBidSlots(1, 5); + adapter.callBids({ bids: configuredBids }); - assert.isUndefined( adLoader.loadScript.firstCall.args[0], "no request made to AS"); - }); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - it('test_prebid_indexAdapter_request_2_1: single slot with all supported multiple sizes -> multiple request objects for the slot', function () { - var configuredBids = IndexUtils.createBidSlots(1, 5); - adapter.callBids({ bids: configuredBids }); + var impressionObj = requestJSON.r.imp; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var impressionObj = requestJSON.r.imp; + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + it('test_prebid_indexAdapter_request_2_2: single slot with all unsupported multiple sizes -> no request objects for the slot', function () { + var isSetExpectedBidsCountCalled = false; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.unsupportedSizes[0], IndexUtils.unsupportedSizes[1], IndexUtils.unsupportedSizes[2] ]) + ]; + adapter.callBids({ bids: configuredBids }); - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - }); + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'no request made to AS'); + }); - it('test_prebid_indexAdapter_request_2_2: single slot with all unsupported multiple sizes -> no request objects for the slot', function () { - var isSetExpectedBidsCountCalled = false; + it('test_prebid_indexAdapter_request_2_3: single slot with supported, unsupportrd, supported sizes -> only the supported size request objects for the slot', function () { + var unsupportedSize = IndexUtils.unsupportedSizes[0]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], unsupportedSize, IndexUtils.supportedSizes[1] ]) + ]; + adapter.callBids({ bids: configuredBids }); - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.unsupportedSizes[0], IndexUtils.unsupportedSizes[1], IndexUtils.unsupportedSizes[2] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - assert.isUndefined( adLoader.loadScript.firstCall.args[0], "no request made to AS"); - }); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - it('test_prebid_indexAdapter_request_2_3: single slot with supported, unsupportrd, supported sizes -> only the supported size request objects for the slot', function () { - var unsupportedSize = IndexUtils.unsupportedSizes[0]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], unsupportedSize, IndexUtils.supportedSizes[1] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + var impressionObj = requestJSON.r.imp; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); - var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, unsupportedSize, 'configured bid not in impression obj size width is' + JSON.stringify(unsupportedSize)); + }); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + it('test_prebid_indexAdapter_request_2_4: single slot with unsupported, supportrd, unsupported sizes -> only the supported size request objects for the slot', function () { + var unsupportedSize1 = IndexUtils.unsupportedSizes[0]; + var unsupportedSize2 = IndexUtils.unsupportedSizes[1]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ unsupportedSize1, IndexUtils.supportedSizes[1], unsupportedSize2 ]) + ]; + adapter.callBids({ bids: configuredBids }); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, unsupportedSize, "configured bid not in impression obj size width is" + JSON.stringify(unsupportedSize) ); - }); + var impressionObj = requestJSON.r.imp; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - it('test_prebid_indexAdapter_request_2_4: single slot with unsupported, supportrd, unsupported sizes -> only the supported size request objects for the slot', function () { - var unsupportedSize1 = IndexUtils.unsupportedSizes[0]; - var unsupportedSize2 = IndexUtils.unsupportedSizes[1]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ unsupportedSize1, IndexUtils.supportedSizes[1], unsupportedSize2 ] ) - ]; - adapter.callBids({ bids: configuredBids }); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); - var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + assert.equal(sidMatched.unmatched.configured.length, 2, '2 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, unsupportedSize1, 'configured bid not in impression obj size width is' + JSON.stringify(unsupportedSize1)); + assert.equal(sidMatched.unmatched.configured[1].size, unsupportedSize2, 'configured bid not in impression obj size width is' + JSON.stringify(unsupportedSize2)); + }); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + it('test_prebid_indexAdapter_request_3: multiple slots with single size below allowed slot threshold -> request for all the slots', function () { + var configuredBids = IndexUtils.createBidSlots(10); + adapter.callBids({ bids: configuredBids }); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); + var impressionObj = requestJSON.r.imp; - assert.equal( sidMatched.unmatched.configured.length, 2, "2 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, unsupportedSize1, "configured bid not in impression obj size width is" + JSON.stringify(unsupportedSize1) ); - assert.equal( sidMatched.unmatched.configured[1].size, unsupportedSize2, "configured bid not in impression obj size width is" + JSON.stringify(unsupportedSize2) ); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - it('test_prebid_indexAdapter_request_3: multiple slots with single size below allowed slot threshold -> request for all the slots', function () { - var configuredBids = IndexUtils.createBidSlots(10); - adapter.callBids({ bids: configuredBids }); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + it('test_prebid_indexAdapter_request_4: multiple slots with single size at exact allowed slot threshold -> request for all the slots', function () { + var configuredBids = IndexUtils.createBidSlots(SlotThreshold); + adapter.callBids({ bids: configuredBids }); - var impressionObj = requestJSON.r.imp; + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var impressionObj = requestJSON.r.imp; - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - it('test_prebid_indexAdapter_request_4: multiple slots with single size at exact allowed slot threshold -> request for all the slots', function () { - var configuredBids = IndexUtils.createBidSlots(SlotThreshold); - adapter.callBids({ bids: configuredBids }); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + it('test_prebid_indexAdapter_request_5: multiple slots with single size exceed allowed slot threshold -> request for all the slots', function () { + var requestSlotNumber = SlotThreshold + 1; + var configuredBids = IndexUtils.createBidSlots(requestSlotNumber); + adapter.callBids({ bids: configuredBids }); - var impressionObj = requestJSON.r.imp; + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var impressionObj = requestJSON.r.imp; - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - it('test_prebid_indexAdapter_request_5: multiple slots with single size exceed allowed slot threshold -> request for all the slots', function () { - var requestSlotNumber = SlotThreshold+1; - var configuredBids = IndexUtils.createBidSlots(requestSlotNumber); - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); - var impressionObj = requestJSON.r.imp; - - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } - - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - }); - - - it('test_prebid_indexAdapter_request_6: threshold valid + non valid which exceeds threshold -> 1 Ad Server request with supported sizes only', function () { - var unsupportedSizeCount = 1; - var requestSlotNumber = SlotThreshold; - var configuredBids = IndexUtils.createBidSlots(requestSlotNumber); + it('test_prebid_indexAdapter_request_6: threshold valid + non valid which exceeds threshold -> 1 Ad Server request with supported sizes only', function () { + var unsupportedSizeCount = 1; + var requestSlotNumber = SlotThreshold; + var configuredBids = IndexUtils.createBidSlots(requestSlotNumber); // add additional unsupported sized slot - var invalidSlotPlacement = IndexUtils.DefaultPlacementCodePrefix + 'invalid'; - var invalidSlotID = 'slot-invalid'; - configuredBids.push( IndexUtils.createBidSlot( invalidSlotPlacement, invalidSlotID, [ IndexUtils.unsupportedSizes[0] ] ) ); + var invalidSlotPlacement = IndexUtils.DefaultPlacementCodePrefix + 'invalid'; + var invalidSlotID = 'slot-invalid'; + configuredBids.push(IndexUtils.createBidSlot(invalidSlotPlacement, invalidSlotID, [ IndexUtils.unsupportedSizes[0] ])); - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.equal( sidMatched.unmatched.configured.length, unsupportedSizeCount, unsupportedSizeCount + " of configured bids is missing in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].placementCode, invalidSlotPlacement, "missing slot's placement code is " + invalidSlotPlacement); - assert.equal( sidMatched.unmatched.configured[0].params.id, invalidSlotID, "missing slot's slotID is " + invalidSlotID); + assert.equal(sidMatched.unmatched.configured.length, unsupportedSizeCount, unsupportedSizeCount + ' of configured bids is missing in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].placementCode, invalidSlotPlacement, "missing slot's placement code is " + invalidSlotPlacement); + assert.equal(sidMatched.unmatched.configured[0].params.id, invalidSlotID, "missing slot's slotID is " + invalidSlotID); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - }); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); - it('test_prebid_indexAdapter_request_7: multiple sizes with slots that exceeds max threshold requests -> 1 Ad Server request with supported sizes only', function () { - var requestSlotNumber = SlotThreshold; - var requestSizeNumber = 2; - var configuredBids = IndexUtils.createBidSlots(requestSlotNumber, requestSizeNumber ); - adapter.callBids({ bids: configuredBids }); + it('test_prebid_indexAdapter_request_7: multiple sizes with slots that exceeds max threshold requests -> 1 Ad Server request with supported sizes only', function () { + var requestSlotNumber = SlotThreshold; + var requestSizeNumber = 2; + var configuredBids = IndexUtils.createBidSlots(requestSlotNumber, requestSizeNumber); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - assert.equal( sidMatched.matched.length, requestSlotNumber * requestSizeNumber, 'All slots each with multiple sizes are in AS request'); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.equal(sidMatched.matched.length, requestSlotNumber * requestSizeNumber, 'All slots each with multiple sizes are in AS request'); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - }); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); - it('test_prebid_indexAdapter_request_sizeID_1: 1 prebid size slot, 1 index slot with size -> one slot in AS request 1 no size ID', function () { - var slotID = 52; - var slotSizes = IndexUtils.supportedSizes[0]; + it('test_prebid_indexAdapter_request_sizeID_1: 1 prebid size slot, 1 index slot with size -> one slot in AS request 1 no size ID', function () { + var slotID = 52; + var slotSizes = IndexUtils.supportedSizes[0]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotID, [ slotSizes ], { slotSize : slotSizes } ) - ]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotID, [ slotSizes ], { slotSize: slotSizes }) + ]; - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - assert.equal(impressionObj.length, 1, "1 slot is made in the request" ); - assert.equal(impressionObj[0].banner.w, slotSizes[0], "the width made in the request matches with request: " + slotSizes[0] ); - assert.equal(impressionObj[0].banner.h, slotSizes[1], "the height made in the request matches with request: " + slotSizes[1] ); - assert.equal(impressionObj[0].ext.sid, slotID, "slotID in the request matches with configuration: " + slotID ); - assert.equal(impressionObj[0].ext.siteID, IndexUtils.DefaultSiteID, "siteID in the request matches with request: " + IndexUtils.DefaultSiteID ); - }); + assert.equal(impressionObj.length, 1, '1 slot is made in the request'); + assert.equal(impressionObj[0].banner.w, slotSizes[0], 'the width made in the request matches with request: ' + slotSizes[0]); + assert.equal(impressionObj[0].banner.h, slotSizes[1], 'the height made in the request matches with request: ' + slotSizes[1]); + assert.equal(impressionObj[0].ext.sid, slotID, 'slotID in the request matches with configuration: ' + slotID); + assert.equal(impressionObj[0].ext.siteID, IndexUtils.DefaultSiteID, 'siteID in the request matches with request: ' + IndexUtils.DefaultSiteID); + }); - it('test_prebid_indexAdapter_request_sizeID_2: multiple prebid size slot, 1 index slot with size -> one slot in AS request 1 no size ID', function () { - var slotID = 52; - var slotSizes = IndexUtils.supportedSizes[0]; + it('test_prebid_indexAdapter_request_sizeID_2: multiple prebid size slot, 1 index slot with size -> one slot in AS request 1 no size ID', function () { + var slotID = 52; + var slotSizes = IndexUtils.supportedSizes[0]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotID, [ slotSizes, IndexUtils.supportedSizes[1] ], { slotSize : slotSizes } ) - ]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotID, [ slotSizes, IndexUtils.supportedSizes[1] ], { slotSize: slotSizes }) + ]; - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - assert.equal(impressionObj.length, 1, "1 slot is made in the request" ); - assert.equal(impressionObj[0].banner.w, slotSizes[0], "the width made in the request matches with request: " + slotSizes[0] ); - assert.equal(impressionObj[0].banner.h, slotSizes[1], "the height made in the request matches with request: " + slotSizes[1] ); - assert.equal(impressionObj[0].ext.sid, slotID, "slotID in the request matches with configuration: " + slotID ); - assert.equal(impressionObj[0].ext.siteID, IndexUtils.DefaultSiteID, "siteID in the request matches with request: " + IndexUtils.DefaultSiteID ); - }); + assert.equal(impressionObj.length, 1, '1 slot is made in the request'); + assert.equal(impressionObj[0].banner.w, slotSizes[0], 'the width made in the request matches with request: ' + slotSizes[0]); + assert.equal(impressionObj[0].banner.h, slotSizes[1], 'the height made in the request matches with request: ' + slotSizes[1]); + assert.equal(impressionObj[0].ext.sid, slotID, 'slotID in the request matches with configuration: ' + slotID); + assert.equal(impressionObj[0].ext.siteID, IndexUtils.DefaultSiteID, 'siteID in the request matches with request: ' + IndexUtils.DefaultSiteID); + }); - it('test_prebid_indexAdapter_request_sizeID_3: multiple prebid size slot, index slots with size for all prebid slots -> all size in AS request, no size ID', function () { - var slotID_1 = 52; - var slotID_2 = 53; - var slotSizes_1 = IndexUtils.supportedSizes[0]; - var slotSizes_2 = IndexUtils.supportedSizes[1]; + it('test_prebid_indexAdapter_request_sizeID_3: multiple prebid size slot, index slots with size for all prebid slots -> all size in AS request, no size ID', function () { + var slotID_1 = 52; + var slotID_2 = 53; + var slotSizes_1 = IndexUtils.supportedSizes[0]; + var slotSizes_2 = IndexUtils.supportedSizes[1]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotID_1, [ slotSizes_1, slotSizes_2 ], { slotSize : slotSizes_1 } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotID_2, [ slotSizes_1, slotSizes_2 ], { slotSize : slotSizes_2 } ) - ]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotID_1, [ slotSizes_1, slotSizes_2 ], { slotSize: slotSizes_1 }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotID_2, [ slotSizes_1, slotSizes_2 ], { slotSize: slotSizes_2 }) + ]; - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; - assert.equal(impressionObj.length, 2, "2 slot is made in the request" ); - assert.equal(impressionObj[0].banner.w, slotSizes_1[0], "the width made in the request matches with request: " + slotSizes_1[0] ); - assert.equal(impressionObj[0].banner.h, slotSizes_1[1], "the height made in the request matches with request: " + slotSizes_1[1] ); - assert.equal(impressionObj[0].ext.sid, slotID_1, "slotID in the request matches with configuration: " + slotID_1 ); - assert.equal(impressionObj[0].ext.siteID, IndexUtils.DefaultSiteID, "siteID in the request matches with request: " + IndexUtils.DefaultSiteID ); + var impressionObj = requestJSON.r.imp; + assert.equal(impressionObj.length, 2, '2 slot is made in the request'); + assert.equal(impressionObj[0].banner.w, slotSizes_1[0], 'the width made in the request matches with request: ' + slotSizes_1[0]); + assert.equal(impressionObj[0].banner.h, slotSizes_1[1], 'the height made in the request matches with request: ' + slotSizes_1[1]); + assert.equal(impressionObj[0].ext.sid, slotID_1, 'slotID in the request matches with configuration: ' + slotID_1); + assert.equal(impressionObj[0].ext.siteID, IndexUtils.DefaultSiteID, 'siteID in the request matches with request: ' + IndexUtils.DefaultSiteID); - assert.equal(impressionObj[1].banner.w, slotSizes_2[0], "the width made in the request matches with request: " + slotSizes_2[0] ); - assert.equal(impressionObj[1].banner.h, slotSizes_2[1], "the height made in the request matches with request: " + slotSizes_2[1] ); - assert.equal(impressionObj[1].ext.sid, slotID_2, "slotID in the request matches with configuration: " + slotID_2 ); - assert.equal(impressionObj[1].ext.siteID, IndexUtils.DefaultSiteID, "siteID in the request matches with request: " + IndexUtils.DefaultSiteID ); - }); + assert.equal(impressionObj[1].banner.w, slotSizes_2[0], 'the width made in the request matches with request: ' + slotSizes_2[0]); + assert.equal(impressionObj[1].banner.h, slotSizes_2[1], 'the height made in the request matches with request: ' + slotSizes_2[1]); + assert.equal(impressionObj[1].ext.sid, slotID_2, 'slotID in the request matches with configuration: ' + slotID_2); + assert.equal(impressionObj[1].ext.siteID, IndexUtils.DefaultSiteID, 'siteID in the request matches with request: ' + IndexUtils.DefaultSiteID); + }); - it('test_prebid_indexAdapter_request_sizeID_4: multiple prebid size slot, 1 index slot but size not in prebid defined size git -> no AS requset', function () { - var slotID = 52; - var slotSizes = IndexUtils.unsupportedSizes[0]; + it('test_prebid_indexAdapter_request_sizeID_4: multiple prebid size slot, 1 index slot but size not in prebid defined size git -> no AS requset', function () { + var slotID = 52; + var slotSizes = IndexUtils.unsupportedSizes[0]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotID, [ IndexUtils.supportedSizes[0] ], { slotSize : slotSizes } ) - ]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotID, [ IndexUtils.supportedSizes[0] ], { slotSize: slotSizes }) + ]; - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isUndefined( adLoader.loadScript.firstCall.args[0], "no request made to AS"); - }); + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'no request made to AS'); + }); - it('test_prebid_indexAdapter_request_sizeID_5: multiple prebid size slot, 1 index slot but size not defined in slot -> no AS requset', function () { - var slotID = 52; - var slotSizes = IndexUtils.supportedSizes[1]; + it('test_prebid_indexAdapter_request_sizeID_5: multiple prebid size slot, 1 index slot but size not defined in slot -> no AS requset', function () { + var slotID = 52; + var slotSizes = IndexUtils.supportedSizes[1]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotID, [ IndexUtils.supportedSizes[0] ], { slotSize : slotSizes } ) - ]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotID, [ IndexUtils.supportedSizes[0] ], { slotSize: slotSizes }) + ]; - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isUndefined( adLoader.loadScript.firstCall.args[0], "no request made to AS"); - }); + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'no request made to AS'); + }); }); diff --git a/test/spec/adapters/indexExchange_response_spec.js b/test/spec/adapters/indexExchange_response_spec.js index e258620727c..2e563b13398 100644 --- a/test/spec/adapters/indexExchange_response_spec.js +++ b/test/spec/adapters/indexExchange_response_spec.js @@ -2,1180 +2,1169 @@ import Adapter from '../../../src/adapters/indexExchange'; import bidManager from '../../../src/bidmanager'; import adLoader from '../../../src/adloader'; -var assert = require('chai').assert; -var IndexUtils = require('../../helpers/index_adapter_utils.js'); +var assert = require('chai').assert; +var IndexUtils = require('../../helpers/index_adapter_utils.js'); var HeaderTagRequest = '/cygnus'; -var SlotThreshold = 20; -var ADAPTER_CODE = 'indexExchange'; -var DefaultValue = { - dealID : 'IXDeal' +var SlotThreshold = 20; +var ADAPTER_CODE = 'indexExchange'; +var DefaultValue = { + dealID: 'IXDeal' }; window.pbjs = window.pbjs || {}; var ResponseStatus = { - noBid: "Bid returned empty or error response" + noBid: 'Bid returned empty or error response' }; describe('indexExchange adapter - Response', function () { - let adapter; - let sandbox; + let adapter; + let sandbox; - beforeEach( function() { - window._IndexRequestData = {}; - _IndexRequestData.impIDToSlotID = {}; - _IndexRequestData.reqOptions = {}; - _IndexRequestData.targetIDToResp = {}; - window.cygnus_index_args = {}; + beforeEach(function() { + window._IndexRequestData = {}; + _IndexRequestData.impIDToSlotID = {}; + _IndexRequestData.reqOptions = {}; + _IndexRequestData.targetIDToResp = {}; + window.cygnus_index_args = {}; + + adapter = new Adapter(); + sandbox = sinon.sandbox.create(); + sandbox.stub(bidManager, 'addBidResponse'); + sandbox.stub(adLoader, 'loadScript'); + }); + + afterEach(function() { + sandbox.restore(); + }); + + it('test_prebid_indexAdapter_response_1_1: response for single slot with single size -> bid fetched into prebid', function () { + var configuredBids = IndexUtils.createBidSlots(1, 1); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON); + cygnus_index_parse_res(asResponse); + + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + assert.equal(pair.prebid.length, 1, 'Only one bid is ferched into prebid'); + assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[0].siteID); + assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[0].bidderCode); + assert.equal(pair.prebid[0].width, pair.expected[0].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[0].width); + assert.equal(pair.prebid[0].height, pair.expected[0].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[0].height); + assert.equal(pair.prebid[0].ad, pair.expected[0].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[0].ad); + assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[0].cpm); + } + + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_1_2: pass on bid for single slot with single size -> bid fetched into prebid', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot1', [ IndexUtils.supportedSizes[0] ]), + ]; + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, [ [ true ] ]); + cygnus_index_parse_res(asResponse); + + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + + assert.equal(prebidResponsePair.matched.length, 0, 'No bids are added to prebid'); + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 1, 'no Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_2_1: response for single slot with multiple sizes -> all bids fetched into prebid', function () { + var configuredBids = IndexUtils.createBidSlots(1, 3); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON); + cygnus_index_parse_res(asResponse); + + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse, [ [1000, 3000, 2000] ]); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - adapter = new Adapter(); - sandbox = sinon.sandbox.create(); - sandbox.stub(bidManager, 'addBidResponse'); - sandbox.stub(adLoader, 'loadScript'); - }); + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + + assert.equal(pair.prebid.length, 3, 'all bids are fetched into prebid'); + for (var j = 0; j < pair.prebid.length; j++) { + assert.equal(pair.prebid[j].siteID, pair.expected[j].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[j].siteID); + assert.equal(pair.prebid[j].bidderCode, pair.expected[j].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[j].bidderCode); + assert.equal(pair.prebid[j].width, pair.expected[j].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[j].width); + assert.equal(pair.prebid[j].height, pair.expected[j].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[j].height); + assert.equal(pair.prebid[j].ad, pair.expected[j].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[j].ad); + assert.equal(pair.prebid[j].cpm, pair.expected[j].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[j].cpm); + } + } - afterEach( function() { - sandbox.restore(); - }); - - it('test_prebid_indexAdapter_response_1_1: response for single slot with single size -> bid fetched into prebid', function () { - var configuredBids = IndexUtils.createBidSlots(1, 1); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON ); - cygnus_index_parse_res( asResponse ); - - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - assert.equal( pair.prebid.length, 1, "Only one bid is ferched into prebid"); - assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[0].siteID); - assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[0].bidderCode); - assert.equal(pair.prebid[0].width, pair.expected[0].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[0].width); - assert.equal(pair.prebid[0].height, pair.expected[0].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[0].height); - assert.equal(pair.prebid[0].ad, pair.expected[0].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[0].ad); - assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[0].cpm); - } - - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - it('test_prebid_indexAdapter_response_1_2: pass on bid for single slot with single size -> bid fetched into prebid', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, 'slot1', [ IndexUtils.supportedSizes[0] ] ), - ]; - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, [ [ true ] ] ); - cygnus_index_parse_res( asResponse ); - - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - - assert.equal( prebidResponsePair.matched.length, 0, 'No bids are added to prebid' ); - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 1, "no Adapter response for prebid is from AS bid"); - }); - - - it('test_prebid_indexAdapter_response_2_1: response for single slot with multiple sizes -> all bids fetched into prebid', function () { - var configuredBids = IndexUtils.createBidSlots(1, 3); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON ); - cygnus_index_parse_res( asResponse ); - - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse, [ [1000, 3000, 2000] ]); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - - assert.equal(pair.prebid.length, 3, "all bids are fetched into prebid"); - for ( var j = 0; j < pair.prebid.length; j++) { - assert.equal(pair.prebid[j].siteID, pair.expected[j].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[j].siteID); - assert.equal(pair.prebid[j].bidderCode, pair.expected[j].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[j].bidderCode); - assert.equal(pair.prebid[j].width, pair.expected[j].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[j].width); - assert.equal(pair.prebid[j].height, pair.expected[j].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[j].height); - assert.equal(pair.prebid[j].ad, pair.expected[j].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[j].ad); - assert.equal(pair.prebid[j].cpm, pair.expected[j].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[j].cpm); - } - } - - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - it('test_prebid_indexAdapter_response_2_2: pass on bid on some sizes for single slot with multiple sizes -> highest bid fetched into prebid', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, 'slot1', [ IndexUtils.supportedSizes[0], IndexUtils.supportedSizes[1] ] ), - ]; - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_2_2: pass on bid on some sizes for single slot with multiple sizes -> highest bid fetched into prebid', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot1', [ IndexUtils.supportedSizes[0], IndexUtils.supportedSizes[1] ]), + ]; + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); // pass on bid on second size - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, [ [ false, true ] ] ); - cygnus_index_parse_res( asResponse ); + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, [ [ false, true ] ]); + cygnus_index_parse_res(asResponse); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); - var adapterResponse = {}; + var adapterResponse = {}; - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - assert.equal( prebidResponsePair.matched.length, 1, 'one slot is added to prebid' ); - var pair = prebidResponsePair.matched[0]; - assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[0].siteID); - assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[0].bidderCode); - assert.equal(pair.prebid[0].width, pair.expected[0].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[0].width); - assert.equal(pair.prebid[0].height, pair.expected[0].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[0].height); - assert.equal(pair.prebid[0].ad, pair.expected[0].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[0].ad); - assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[0].cpm); + assert.equal(prebidResponsePair.matched.length, 1, 'one slot is added to prebid'); + var pair = prebidResponsePair.matched[0]; + assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[0].siteID); + assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[0].bidderCode); + assert.equal(pair.prebid[0].width, pair.expected[0].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[0].width); + assert.equal(pair.prebid[0].height, pair.expected[0].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[0].height); + assert.equal(pair.prebid[0].ad, pair.expected[0].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[0].ad); + assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[0].cpm); - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); - it('test_prebid_indexAdapter_response_2_3: pass on bid on all sizes for a single slot -> no bids fetched into prebid', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, 'slot1', [ IndexUtils.supportedSizes[0], IndexUtils.supportedSizes[1] ] ), - ]; - adapter.callBids({ bids: configuredBids }); + it('test_prebid_indexAdapter_response_2_3: pass on bid on all sizes for a single slot -> no bids fetched into prebid', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot1', [ IndexUtils.supportedSizes[0], IndexUtils.supportedSizes[1] ]), + ]; + adapter.callBids({ bids: configuredBids }); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); // pass on bid on all bids - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, [ [ true, true ] ] ); - cygnus_index_parse_res( asResponse ); + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, [ [ true, true ] ]); + cygnus_index_parse_res(asResponse); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); - var adapterResponse = {}; + var adapterResponse = {}; - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - assert.equal( prebidResponsePair.matched.length, 0, 'no bids fetched into prebid' ); - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid[0][0].statusMessage, ResponseStatus.noBid, "Bid response status is set to " + ResponseStatus.noBid ); - }); + assert.equal(prebidResponsePair.matched.length, 0, 'no bids fetched into prebid'); + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid[0][0].statusMessage, ResponseStatus.noBid, 'Bid response status is set to ' + ResponseStatus.noBid); + }); - it('test_prebid_indexAdapter_response_3_1: response for multiple slots request with single size for each slots -> all response for all adunit fetched into prebid', function () { - var configuredBids = IndexUtils.createBidSlots(20); - adapter.callBids({ bids: configuredBids }); + it('test_prebid_indexAdapter_response_3_1: response for multiple slots request with single size for each slots -> all response for all adunit fetched into prebid', function () { + var configuredBids = IndexUtils.createBidSlots(20); + adapter.callBids({ bids: configuredBids }); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON ); - cygnus_index_parse_res( asResponse ); + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON); + cygnus_index_parse_res(asResponse); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse, [ [1000, 3000, 2000] ]); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse, [ [1000, 3000, 2000] ]); - var adapterResponse = {}; + var adapterResponse = {}; - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; - assert.equal(pair.prebid.length, 1, "all bids are fetched into prebid"); - assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[0].siteID); - assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[0].bidderCode); - assert.equal(pair.prebid[0].width, pair.expected[0].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[0].width); - assert.equal(pair.prebid[0].height, pair.expected[0].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[0].height); - assert.equal(pair.prebid[0].ad, pair.expected[0].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[0].ad); - assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[0].cpm); - } + assert.equal(pair.prebid.length, 1, 'all bids are fetched into prebid'); + assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[0].siteID); + assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[0].bidderCode); + assert.equal(pair.prebid[0].width, pair.expected[0].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[0].width); + assert.equal(pair.prebid[0].height, pair.expected[0].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[0].height); + assert.equal(pair.prebid[0].ad, pair.expected[0].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[0].ad); + assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[0].cpm); + } - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); - it('test_prebid_indexAdapter_response_3_2: some slots response returned -> returned bids fetched into prebid ', function () { - var configuredBids = IndexUtils.createBidSlots(2); - adapter.callBids({ bids: configuredBids }); + it('test_prebid_indexAdapter_response_3_2: some slots response returned -> returned bids fetched into prebid ', function () { + var configuredBids = IndexUtils.createBidSlots(2); + adapter.callBids({ bids: configuredBids }); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var passOnBid = [ + var passOnBid = [ [ false ], // bids back on first slot - [ true ], // pass on bid on second slot - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, passOnBid ); - cygnus_index_parse_res( asResponse ); + [ true ], // pass on bid on second slot + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, passOnBid); + cygnus_index_parse_res(asResponse); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse, [ [1000, 3000, 2000] ]); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse, [ [1000, 3000, 2000] ]); - var adapterResponse = {}; + var adapterResponse = {}; - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - assert.equal( prebidResponsePair.matched.length, 1, "1 bid from ad server is fetched into prebid"); - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; + assert.equal(prebidResponsePair.matched.length, 1, '1 bid from ad server is fetched into prebid'); + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; - assert.equal(pair.prebid.length, 1, "all bids are fetched into prebid"); - assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[0].siteID); - assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[0].bidderCode); - assert.equal(pair.prebid[0].width, pair.expected[0].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[0].width); - assert.equal(pair.prebid[0].height, pair.expected[0].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[0].height); - assert.equal(pair.prebid[0].ad, pair.expected[0].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[0].ad); - assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[0].cpm); - } + assert.equal(pair.prebid.length, 1, 'all bids are fetched into prebid'); + assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[0].siteID); + assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[0].bidderCode); + assert.equal(pair.prebid[0].width, pair.expected[0].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[0].width); + assert.equal(pair.prebid[0].height, pair.expected[0].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[0].height); + assert.equal(pair.prebid[0].ad, pair.expected[0].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[0].ad); + assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[0].cpm); + } - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 1, "One slot passed on bid from Ad Server"); - }); + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 1, 'One slot passed on bid from Ad Server'); + }); - it('test_prebid_indexAdapter_response_3_3: response for multiple slots with no response returned -> no bid fetched into prebid', function () { - var configuredBids = IndexUtils.createBidSlots(2); - adapter.callBids({ bids: configuredBids }); + it('test_prebid_indexAdapter_response_3_3: response for multiple slots with no response returned -> no bid fetched into prebid', function () { + var configuredBids = IndexUtils.createBidSlots(2); + adapter.callBids({ bids: configuredBids }); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var passOnBid = [ - [ true ], // pass on bid on the first slot - [ true ], // pass on bid on the second slot - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, passOnBid ); - cygnus_index_parse_res( asResponse ); + var passOnBid = [ + [ true ], // pass on bid on the first slot + [ true ], // pass on bid on the second slot + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, passOnBid); + cygnus_index_parse_res(asResponse); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse, [ [1000, 3000, 2000] ]); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse, [ [1000, 3000, 2000] ]); - var adapterResponse = {}; + var adapterResponse = {}; - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - assert.equal( prebidResponsePair.matched.length, 0, "no bids from ad server is fetched into prebid"); + assert.equal(prebidResponsePair.matched.length, 0, 'no bids from ad server is fetched into prebid'); - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 2, "two slots passed on bid from Ad Server"); - }); + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 2, 'two slots passed on bid from Ad Server'); + }); - it("test_prebid_indexAdapter_refreshSlot_1: slot refreshes multiple times with different bids on refresh with same price -> response to prebid use correct AS response's creative", function () { - var configuredBids = IndexUtils.createBidSlots(1, 1); + it("test_prebid_indexAdapter_refreshSlot_1: slot refreshes multiple times with different bids on refresh with same price -> response to prebid use correct AS response's creative", function () { + var configuredBids = IndexUtils.createBidSlots(1, 1); - var refreshSetup = [ {price:1000, request:"request-1"}, {price:1000, request:"request-2"} ]; - for( var i=0; i response to prebid use correct AS response's creative", function () { - var configuredBids = IndexUtils.createBidSlots(1, 1); + it("test_prebid_indexAdapter_refreshSlot_2: slot refreshes multiple times with different bids on refresh with different price, but first bid is higher -> response to prebid use correct AS response's creative", function () { + var configuredBids = IndexUtils.createBidSlots(1, 1); - var refreshSetup = [ {price:8000, request:"request-1"}, {price:1000, request:"request-2"} ]; - for( var i=0; i response to prebid use correct AS response's creative", function () { - var configuredBids = IndexUtils.createBidSlots(1, 1); + it("test_prebid_indexAdapter_refreshSlot_3: slot refreshes multiple times with different bids on refresh with different price, but first bid is lower -> response to prebid use correct AS response's creative", function () { + var configuredBids = IndexUtils.createBidSlots(1, 1); - var refreshSetup = [ {price:1000, request:"request-1"}, {price:8000, request:"request-2"} ]; - for( var i=0; i no bids fetched into prebid", function () { - var configuredBids = IndexUtils.createBidSlots(1, 1); + it('test_prebid_indexAdapter_refreshSlot_4: got no response the second time -> no bids fetched into prebid', function () { + var configuredBids = IndexUtils.createBidSlots(1, 1); - var refreshSetup = [ { price:1000, request:"request-1", passOnBid: false}, { price:1000, request:"request-2", passOnBid: true} ]; - for( var i=0; i no ad server request, no bids fetched into prebid", function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.unsupportedSizes[0] ] ) - ]; - - var refreshSetup = [ { request:"request-1" }, { request:"request-2" } ]; - for( var i=0; i bid fetched into prebid', function () { - var configuredBids = IndexUtils.createBidSlots(1, 1); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var optionalResponseParam = [ - [ + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, [ [requestParams.price] ], requestParams.request, [ [ requestParams.passOnBid ] ]); + cygnus_index_parse_res(asResponse); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + + for (var j = 0; j < prebidResponsePair.matched.length; j++) { + var pair = prebidResponsePair.matched[j]; + + assert.equal(pair.prebid.length, 1, 'all bids are fetched into prebid'); + for (var k = 0; k < pair.prebid.length; k++) { + assert.equal(pair.prebid[k].siteID, pair.expected[k].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[k].siteID); + assert.equal(pair.prebid[k].bidderCode, pair.expected[k].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[k].bidderCode); + assert.equal(pair.prebid[k].width, pair.expected[k].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[k].width); + assert.equal(pair.prebid[k].height, pair.expected[k].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[k].height); + assert.equal(pair.prebid[k].ad, pair.expected[k].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[k].ad); + assert.equal(pair.prebid[k].cpm, pair.expected[k].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[k].cpm); + } + } + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + if (requestParams.passOnBid) { + assert.equal(prebidResponsePair.unmatched.prebid.length, 1, '1 Adapter response is missing'); + } else { + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + } + + bidManager.addBidResponse.reset(); + adapterResponse = {}; // initialize adapterReaponse for refresh test + } + }); + + it('test_prebid_indexAdapter_refreshSlot_5: unsupported slots refresh -> no ad server request, no bids fetched into prebid', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.unsupportedSizes[0] ]) + ]; + + var refreshSetup = [ { request: 'request-1' }, { request: 'request-2' } ]; + for (var i = 0; i < refreshSetup.length; i++) { + var requestParams = refreshSetup[i]; + + adapter.callBids({ bids: configuredBids }); + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'no ad server request for ' + requestParams.request) + } + }); + + it('test_prebid_indexAdapter_response_deal_1_1: response for single slot with single size contains alpha deal -> bid fetched into prebid', function () { + var configuredBids = IndexUtils.createBidSlots(1, 1); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var optionalResponseParam = [ + [ { ext: { dealid: 'ixDeal' } } // first slot first size - ] - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam ); - cygnus_index_parse_res( asResponse ); - - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - - assert.equal(pair.prebid[i].siteID, pair.expected[i].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[i].siteID); - assert.equal(pair.prebid[i].bidderCode, pair.expected[i].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[i].bidderCode); - assert.equal(pair.prebid[i].width, pair.expected[i].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[i].width); - assert.equal(pair.prebid[i].height, pair.expected[i].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[i].height); - assert.equal(pair.prebid[i].ad, pair.expected[i].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[i].ad); - assert.equal(pair.prebid[i].cpm, pair.expected[i].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[i].cpm); - assert.equal(pair.prebid[i].dealId, pair.expected[i].dealId, "adapter response for " + pair.placementCode + " deaiid is set to "+pair.expected[i].dealId); - } - - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - it('test_prebid_indexAdapter_response_deal_1_2: response for single slot with single size contains numeric deal -> bid fetched into prebid', function () { - var configuredBids = IndexUtils.createBidSlots(1, 1); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var optionalResponseParam = [ - [ + ] + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam); + cygnus_index_parse_res(asResponse); + + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + + assert.equal(pair.prebid[i].siteID, pair.expected[i].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[i].siteID); + assert.equal(pair.prebid[i].bidderCode, pair.expected[i].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[i].bidderCode); + assert.equal(pair.prebid[i].width, pair.expected[i].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[i].width); + assert.equal(pair.prebid[i].height, pair.expected[i].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[i].height); + assert.equal(pair.prebid[i].ad, pair.expected[i].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[i].ad); + assert.equal(pair.prebid[i].cpm, pair.expected[i].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[i].cpm); + assert.equal(pair.prebid[i].dealId, pair.expected[i].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is set to ' + pair.expected[i].dealId); + } + + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_deal_1_2: response for single slot with single size contains numeric deal -> bid fetched into prebid', function () { + var configuredBids = IndexUtils.createBidSlots(1, 1); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var optionalResponseParam = [ + [ { ext: { dealid: '239' } } // first slot first size - ] - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam ); - cygnus_index_parse_res( asResponse ); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - - assert.equal(pair.prebid[i].siteID, pair.expected[i].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[i].siteID); - assert.equal(pair.prebid[i].bidderCode, pair.expected[i].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[i].bidderCode); - assert.equal(pair.prebid[i].width, pair.expected[i].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[i].width); - assert.equal(pair.prebid[i].height, pair.expected[i].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[i].height); - assert.equal(pair.prebid[i].ad, pair.expected[i].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[i].ad); - assert.equal(pair.prebid[i].cpm, pair.expected[i].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[i].cpm); - assert.equal(pair.prebid[i].dealId, pair.expected[i].dealId, "adapter response for " + pair.placementCode + " deaiid is set to "+pair.expected[i].dealId); - } - - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - - it('test_prebid_indexAdapter_response_deal_1_3: response for single slot with single size contains alpha-numeric deal starting with numeric -> bid fetched into prebid', function () { - var configuredBids = IndexUtils.createBidSlots(1, 1); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var optionalResponseParam = [ - [ + ] + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam); + cygnus_index_parse_res(asResponse); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + + assert.equal(pair.prebid[i].siteID, pair.expected[i].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[i].siteID); + assert.equal(pair.prebid[i].bidderCode, pair.expected[i].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[i].bidderCode); + assert.equal(pair.prebid[i].width, pair.expected[i].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[i].width); + assert.equal(pair.prebid[i].height, pair.expected[i].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[i].height); + assert.equal(pair.prebid[i].ad, pair.expected[i].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[i].ad); + assert.equal(pair.prebid[i].cpm, pair.expected[i].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[i].cpm); + assert.equal(pair.prebid[i].dealId, pair.expected[i].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is set to ' + pair.expected[i].dealId); + } + + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_deal_1_3: response for single slot with single size contains alpha-numeric deal starting with numeric -> bid fetched into prebid', function () { + var configuredBids = IndexUtils.createBidSlots(1, 1); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var optionalResponseParam = [ + [ { ext: { dealid: '1234Deal' } } // first slot first size - ] - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam ); - cygnus_index_parse_res( asResponse ); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - - assert.equal(pair.prebid[i].siteID, pair.expected[i].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[i].siteID); - assert.equal(pair.prebid[i].bidderCode, pair.expected[i].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[i].bidderCode); - assert.equal(pair.prebid[i].width, pair.expected[i].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[i].width); - assert.equal(pair.prebid[i].height, pair.expected[i].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[i].height); - assert.equal(pair.prebid[i].ad, pair.expected[i].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[i].ad); - assert.equal(pair.prebid[i].cpm, pair.expected[i].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[i].cpm); - assert.equal(pair.prebid[i].dealId, pair.expected[i].dealId, "adapter response for " + pair.placementCode + " deaiid is set to "+pair.expected[i].dealId); - } - - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - it('test_prebid_indexAdapter_response_deal_1_4: response for single slot with single size contains alpha-numeric deal starting with non-numeric -> bid fetched into prebid ', function () { - var configuredBids = IndexUtils.createBidSlots(1, 1); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var optionalResponseParam = [ - [ + ] + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam); + cygnus_index_parse_res(asResponse); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + + assert.equal(pair.prebid[i].siteID, pair.expected[i].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[i].siteID); + assert.equal(pair.prebid[i].bidderCode, pair.expected[i].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[i].bidderCode); + assert.equal(pair.prebid[i].width, pair.expected[i].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[i].width); + assert.equal(pair.prebid[i].height, pair.expected[i].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[i].height); + assert.equal(pair.prebid[i].ad, pair.expected[i].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[i].ad); + assert.equal(pair.prebid[i].cpm, pair.expected[i].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[i].cpm); + assert.equal(pair.prebid[i].dealId, pair.expected[i].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is set to ' + pair.expected[i].dealId); + } + + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_deal_1_4: response for single slot with single size contains alpha-numeric deal starting with non-numeric -> bid fetched into prebid ', function () { + var configuredBids = IndexUtils.createBidSlots(1, 1); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var optionalResponseParam = [ + [ { ext: { dealid: 'deal1234' } } // first slot first size - ] - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam ); // Alpha numeric starting with non-numeric - cygnus_index_parse_res( asResponse ); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - - assert.equal(pair.prebid[i].siteID, pair.expected[i].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[i].siteID); - assert.equal(pair.prebid[i].bidderCode, pair.expected[i].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[i].bidderCode); - assert.equal(pair.prebid[i].width, pair.expected[i].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[i].width); - assert.equal(pair.prebid[i].height, pair.expected[i].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[i].height); - assert.equal(pair.prebid[i].ad, pair.expected[i].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[i].ad); - assert.equal(pair.prebid[i].cpm, pair.expected[i].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[i].cpm); - assert.equal(pair.prebid[i].dealId, pair.expected[i].dealId, "adapter response for " + pair.placementCode + " deaiid is set to "+pair.expected[i].dealId); - } - - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - - - it('test_prebid_indexAdapter_response_deal_2_1: response for single slot with multi size, all deal bids returned -> all bid fetched into prebid as deal bid', function () { - var sizeCount = 2; - var configuredBids = IndexUtils.createBidSlots(1, sizeCount); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var optionalResponseParam = [ - [ + ] + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam); // Alpha numeric starting with non-numeric + cygnus_index_parse_res(asResponse); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + + assert.equal(pair.prebid[i].siteID, pair.expected[i].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[i].siteID); + assert.equal(pair.prebid[i].bidderCode, pair.expected[i].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[i].bidderCode); + assert.equal(pair.prebid[i].width, pair.expected[i].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[i].width); + assert.equal(pair.prebid[i].height, pair.expected[i].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[i].height); + assert.equal(pair.prebid[i].ad, pair.expected[i].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[i].ad); + assert.equal(pair.prebid[i].cpm, pair.expected[i].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[i].cpm); + assert.equal(pair.prebid[i].dealId, pair.expected[i].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is set to ' + pair.expected[i].dealId); + } + + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_deal_2_1: response for single slot with multi size, all deal bids returned -> all bid fetched into prebid as deal bid', function () { + var sizeCount = 2; + var configuredBids = IndexUtils.createBidSlots(1, sizeCount); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var optionalResponseParam = [ + [ { ext: { deal: 'deal1', dealid: 'ixDealID1', dealname: 'deal name 1' } }, // first slot first size { ext: { deal: 'deal2', dealid: 'ixDealID2', dealname: 'deal name 2' } }, // first slot second size - ] - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam ); - cygnus_index_parse_res( asResponse ); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - - for ( var j = 0; j < pair.expected.length; j++ ) { - assert.equal(pair.prebid[j].siteID, pair.expected[j].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[i].siteID); - assert.equal(pair.prebid[j].bidderCode, pair.expected[j].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[i].bidderCode); - assert.equal(pair.prebid[j].width, pair.expected[j].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[i].width); - assert.equal(pair.prebid[j].height, pair.expected[j].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[i].height); - assert.equal(pair.prebid[j].ad, pair.expected[j].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[i].ad); - assert.equal(pair.prebid[j].cpm, pair.expected[j].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[i].cpm); - assert.equal(pair.prebid[j].dealId, pair.expected[j].dealId, "adapter response for " + pair.placementCode + " deaiid is set to "+pair.expected[i].dealId); - } - } - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - - it('test_prebid_indexAdapter_response_deal_2_2: response for single slot with multi size, some deal resposne returned and the rest non deal response -> all bid fetched, only deal response has dealID', function () { - var sizeCount = 2; - var configuredBids = IndexUtils.createBidSlots(1, sizeCount); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var optionalResponseParam = [ - [ + ] + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam); + cygnus_index_parse_res(asResponse); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + + for (var j = 0; j < pair.expected.length; j++) { + assert.equal(pair.prebid[j].siteID, pair.expected[j].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[i].siteID); + assert.equal(pair.prebid[j].bidderCode, pair.expected[j].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[i].bidderCode); + assert.equal(pair.prebid[j].width, pair.expected[j].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[i].width); + assert.equal(pair.prebid[j].height, pair.expected[j].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[i].height); + assert.equal(pair.prebid[j].ad, pair.expected[j].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[i].ad); + assert.equal(pair.prebid[j].cpm, pair.expected[j].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[i].cpm); + assert.equal(pair.prebid[j].dealId, pair.expected[j].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is set to ' + pair.expected[i].dealId); + } + } + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_deal_2_2: response for single slot with multi size, some deal resposne returned and the rest non deal response -> all bid fetched, only deal response has dealID', function () { + var sizeCount = 2; + var configuredBids = IndexUtils.createBidSlots(1, sizeCount); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var optionalResponseParam = [ + [ { ext: { deal: 'deal1', dealid: 'ixDealID1', dealname: 'deal name 1' } } // first slot first size // No deal on first slot second size - ] - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam ); - cygnus_index_parse_res( asResponse ); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - - for ( var j = 0; j < pair.expected.length; j++ ) { - assert.equal(pair.prebid[j].siteID, pair.expected[j].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[i].siteID); - assert.equal(pair.prebid[j].bidderCode, pair.expected[j].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[i].bidderCode); - assert.equal(pair.prebid[j].width, pair.expected[j].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[i].width); - assert.equal(pair.prebid[j].height, pair.expected[j].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[i].height); - assert.equal(pair.prebid[j].ad, pair.expected[j].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[i].ad); - assert.equal(pair.prebid[j].cpm, pair.expected[j].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[i].cpm); - if ( i === 0) { - assert.equal(pair.prebid[j].dealId, pair.expected[j].dealId, "adapter response for " + pair.placementCode + " deaiid is set to "+pair.expected[i].dealId); - } else { - assert.isUndefined( pair.prebid[j].dealId, "adapter response for " + pair.placementCode + " deaiid is not set"); - } - } - } - - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - - it('test_prebid_indexAdapter_response_deal_2_3: response for single slot with multi size, all returned as non-deal response -> all bid fetched, no response has dealID', function () { - var sizeCount = 2; - var configuredBids = IndexUtils.createBidSlots(1, sizeCount); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var optionalResponseParam = [ - [ + ] + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam); + cygnus_index_parse_res(asResponse); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + + for (var j = 0; j < pair.expected.length; j++) { + assert.equal(pair.prebid[j].siteID, pair.expected[j].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[i].siteID); + assert.equal(pair.prebid[j].bidderCode, pair.expected[j].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[i].bidderCode); + assert.equal(pair.prebid[j].width, pair.expected[j].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[i].width); + assert.equal(pair.prebid[j].height, pair.expected[j].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[i].height); + assert.equal(pair.prebid[j].ad, pair.expected[j].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[i].ad); + assert.equal(pair.prebid[j].cpm, pair.expected[j].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[i].cpm); + if (i === 0) { + assert.equal(pair.prebid[j].dealId, pair.expected[j].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is set to ' + pair.expected[i].dealId); + } else { + assert.isUndefined(pair.prebid[j].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is not set'); + } + } + } + + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_deal_2_3: response for single slot with multi size, all returned as non-deal response -> all bid fetched, no response has dealID', function () { + var sizeCount = 2; + var configuredBids = IndexUtils.createBidSlots(1, sizeCount); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var optionalResponseParam = [ + [ {}, {} // No deal on first slot first size // No deal on first slot second size - ] - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam ); - - cygnus_index_parse_res( asResponse ); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - for ( var j = 0; j < pair.expected.length; j++ ) { - assert.equal(pair.prebid[i].siteID, pair.expected[i].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[i].siteID); - assert.equal(pair.prebid[i].bidderCode, pair.expected[i].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[i].bidderCode); - assert.equal(pair.prebid[i].width, pair.expected[i].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[i].width); - assert.equal(pair.prebid[i].height, pair.expected[i].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[i].height); - assert.equal(pair.prebid[i].ad, pair.expected[i].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[i].ad); - assert.equal(pair.prebid[i].cpm, pair.expected[i].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[i].cpm); - assert.isUndefined( pair.prebid[i].dealId, "adapter response for " + pair.placementCode + " deaiid is not set"); - } - } - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - - it('test_prebid_indexAdapter_response_deal_3_1: multi slots, all responses contain deal -> all bid fetched into prebid as deal bid', function () { - var slotCount = 2; - var configuredBids = IndexUtils.createBidSlots(slotCount, 1); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var optionalResponseParam = [ - [ + ] + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam); + + cygnus_index_parse_res(asResponse); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + for (var j = 0; j < pair.expected.length; j++) { + assert.equal(pair.prebid[i].siteID, pair.expected[i].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[i].siteID); + assert.equal(pair.prebid[i].bidderCode, pair.expected[i].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[i].bidderCode); + assert.equal(pair.prebid[i].width, pair.expected[i].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[i].width); + assert.equal(pair.prebid[i].height, pair.expected[i].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[i].height); + assert.equal(pair.prebid[i].ad, pair.expected[i].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[i].ad); + assert.equal(pair.prebid[i].cpm, pair.expected[i].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[i].cpm); + assert.isUndefined(pair.prebid[i].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is not set'); + } + } + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_deal_3_1: multi slots, all responses contain deal -> all bid fetched into prebid as deal bid', function () { + var slotCount = 2; + var configuredBids = IndexUtils.createBidSlots(slotCount, 1); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var optionalResponseParam = [ + [ { ext: { dealid: 'ixDeal1' } } // first slot first size - ], - [ + ], + [ { ext: { dealid: 'ixDeal2' } } // second slot first size - ] - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam ); - cygnus_index_parse_res( asResponse ); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[0].siteID); - assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[0].bidderCode); - assert.equal(pair.prebid[0].width, pair.expected[0].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[0].width); - assert.equal(pair.prebid[0].height, pair.expected[0].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[0].height); - assert.equal(pair.prebid[0].ad, pair.expected[0].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[0].ad); - assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[0].cpm); - assert.equal(pair.prebid[0].dealId, pair.expected[0].dealId, "adapter response for " + pair.placementCode + " deaiid is set to "+pair.expected[0].dealId); - } - - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - - it('test_prebid_indexAdapter_response_deal_3_2: multi slots, some responses contain deal -> all bid fetched, only deal response has dealID', function () { - var slotCount = 2; - var configuredBids = IndexUtils.createBidSlots(slotCount, 1); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var optionalResponseParam = [ - [ + ] + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam); + cygnus_index_parse_res(asResponse); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[0].siteID); + assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[0].bidderCode); + assert.equal(pair.prebid[0].width, pair.expected[0].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[0].width); + assert.equal(pair.prebid[0].height, pair.expected[0].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[0].height); + assert.equal(pair.prebid[0].ad, pair.expected[0].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[0].ad); + assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[0].cpm); + assert.equal(pair.prebid[0].dealId, pair.expected[0].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is set to ' + pair.expected[0].dealId); + } + + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_deal_3_2: multi slots, some responses contain deal -> all bid fetched, only deal response has dealID', function () { + var slotCount = 2; + var configuredBids = IndexUtils.createBidSlots(slotCount, 1); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var optionalResponseParam = [ + [ { ext: { dealid: 'ixDeal1' } } // first slot first size - ], - [ + ], + [ {} // no deal on second slot first size - ] - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam ); - cygnus_index_parse_res( asResponse ); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - var count = 0; - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[0].siteID); - assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[0].bidderCode); - assert.equal(pair.prebid[0].width, pair.expected[0].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[0].width); - assert.equal(pair.prebid[0].height, pair.expected[0].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[0].height); - assert.equal(pair.prebid[0].ad, pair.expected[0].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[0].ad); - assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[0].cpm); - if ( count === 0 ) { // if first slot, check deal parameter - assert.equal(pair.prebid[0].dealId, pair.expected[0].dealId, "adapter response for " + pair.placementCode + " deaiid is set to "+pair.expected[0].dealId); - } else { - assert.isUndefined( pair.prebid[0].dealId, "adapter response for " + pair.placementCode + " deaiid is not defined"); - } - count ++; - } - - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - - it('test_prebid_indexAdapter_response_deal_3_3: multi slots, no responses contain deal -> all bid fetched, no response has dealID ', function () { - var slotCount = 2; - var configuredBids = IndexUtils.createBidSlots(slotCount, 1); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var optionalResponseParam = [ - [ + ] + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam); + cygnus_index_parse_res(asResponse); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + var count = 0; + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[0].siteID); + assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[0].bidderCode); + assert.equal(pair.prebid[0].width, pair.expected[0].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[0].width); + assert.equal(pair.prebid[0].height, pair.expected[0].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[0].height); + assert.equal(pair.prebid[0].ad, pair.expected[0].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[0].ad); + assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[0].cpm); + if (count === 0) { // if first slot, check deal parameter + assert.equal(pair.prebid[0].dealId, pair.expected[0].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is set to ' + pair.expected[0].dealId); + } else { + assert.isUndefined(pair.prebid[0].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is not defined'); + } + count++; + } + + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_response_deal_3_3: multi slots, no responses contain deal -> all bid fetched, no response has dealID ', function () { + var slotCount = 2; + var configuredBids = IndexUtils.createBidSlots(slotCount, 1); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var optionalResponseParam = [ + [ {} // no deal on first slot first size - ], - [ + ], + [ {} // no deal on second slot first size - ] - ]; - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam ); - cygnus_index_parse_res( asResponse ); - var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse( configuredBids, asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - - var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); - - for ( var i = 0; i < prebidResponsePair.matched.length; i++) { - var pair = prebidResponsePair.matched[i]; - assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, "adapter response for " + pair.placementCode + " siteID is set to "+pair.expected[0].siteID); - assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, "adapter response for " + pair.placementCode + " bidderCode is set to "+pair.expected[0].bidderCode); - assert.equal(pair.prebid[0].width, pair.expected[0].width, "adapter response for " + pair.placementCode + " width is set to "+pair.expected[0].width); - assert.equal(pair.prebid[0].height, pair.expected[0].height, "adapter response for " + pair.placementCode + " height is set to "+pair.expected[0].height); - assert.equal(pair.prebid[0].ad, pair.expected[0].ad, "adapter response for " + pair.placementCode + " ad is set to "+pair.expected[0].ad); - assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, "adapter response for " + pair.placementCode + " cpm is set to "+pair.expected[0].cpm); - assert.isUndefined( pair.prebid[0].dealId, "adapter response for " + pair.placementCode + " deaiid is not defined"); - } - - assert.equal( prebidResponsePair.unmatched.expected.length, 0, "All AS bid response translated to Adapter response for prebid"); - assert.equal( prebidResponsePair.unmatched.prebid.length, 0, "All Adapter response for prebid is from AS bid"); - }); - - - it( 'test_prebid_indexAdapter_tier: one slot with multiple tier -> all tier bids are fetched into prebid', function(){ - var slotConfig = { - tier2SiteID: IndexUtils.DefaultSiteID + 1, - tier3SiteID: IndexUtils.DefaultSiteID + 2, - }; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], slotConfig ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - - assert.equal( sidMatched.matched.length, 3, 'Three slots are configured and sent to AS'); + ] + ]; + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, undefined, optionalResponseParam); + cygnus_index_parse_res(asResponse); + var expectedAdapterResponse = IndexUtils.getExpectedAdaptorResponse(configuredBids, asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + + var prebidResponsePair = IndexUtils.matchOnPlacementCode(expectedAdapterResponse, adapterResponse); + + for (var i = 0; i < prebidResponsePair.matched.length; i++) { + var pair = prebidResponsePair.matched[i]; + assert.equal(pair.prebid[0].siteID, pair.expected[0].siteID, 'adapter response for ' + pair.placementCode + ' siteID is set to ' + pair.expected[0].siteID); + assert.equal(pair.prebid[0].bidderCode, pair.expected[0].bidderCode, 'adapter response for ' + pair.placementCode + ' bidderCode is set to ' + pair.expected[0].bidderCode); + assert.equal(pair.prebid[0].width, pair.expected[0].width, 'adapter response for ' + pair.placementCode + ' width is set to ' + pair.expected[0].width); + assert.equal(pair.prebid[0].height, pair.expected[0].height, 'adapter response for ' + pair.placementCode + ' height is set to ' + pair.expected[0].height); + assert.equal(pair.prebid[0].ad, pair.expected[0].ad, 'adapter response for ' + pair.placementCode + ' ad is set to ' + pair.expected[0].ad); + assert.equal(pair.prebid[0].cpm, pair.expected[0].cpm, 'adapter response for ' + pair.placementCode + ' cpm is set to ' + pair.expected[0].cpm); + assert.isUndefined(pair.prebid[0].dealId, 'adapter response for ' + pair.placementCode + ' deaiid is not defined'); + } + + assert.equal(prebidResponsePair.unmatched.expected.length, 0, 'All AS bid response translated to Adapter response for prebid'); + assert.equal(prebidResponsePair.unmatched.prebid.length, 0, 'All Adapter response for prebid is from AS bid'); + }); + + it('test_prebid_indexAdapter_tier: one slot with multiple tier -> all tier bids are fetched into prebid', function() { + var slotConfig = { + tier2SiteID: IndexUtils.DefaultSiteID + 1, + tier3SiteID: IndexUtils.DefaultSiteID + 2, + }; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], slotConfig), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + + assert.equal(sidMatched.matched.length, 3, 'Three slots are configured and sent to AS'); // check normal site id - var normalSitePair = sidMatched.matched[0]; + var normalSitePair = sidMatched.matched[0]; - var expectedSlotID = normalSitePair.configured.params.id + '_1'; - assert.equal( normalSitePair.sent.ext.sid, expectedSlotID, "request " + normalSitePair.name + " site ID is set to " + expectedSlotID); - assert.isString( normalSitePair.sent.ext.sid, "type of slot ID is string"); + var expectedSlotID = normalSitePair.configured.params.id + '_1'; + assert.equal(normalSitePair.sent.ext.sid, expectedSlotID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedSlotID); + assert.isString(normalSitePair.sent.ext.sid, 'type of slot ID is string'); - var expectedSiteID = normalSitePair.configured.params.siteID; - assert.equal(normalSitePair.sent.ext.siteID, expectedSiteID, "request " + normalSitePair.name + " site ID is set to " + expectedSiteID); - assert.isNumber(normalSitePair.sent.ext.siteID, "site ID is integer"); + var expectedSiteID = normalSitePair.configured.params.siteID; + assert.equal(normalSitePair.sent.ext.siteID, expectedSiteID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedSiteID); + assert.isNumber(normalSitePair.sent.ext.siteID, 'site ID is integer'); // check tier 1 site id - var tier2SitePair = sidMatched.matched[1]; - var expectedTierSlotID = 'T1_' + tier2SitePair.configured.params.id + '_1'; - assert.equal( tier2SitePair.sent.ext.sid, expectedTierSlotID, "request " + tier2SitePair.name + " site ID is set to " + expectedTierSlotID); - assert.isString( tier2SitePair.sent.ext.sid, "type of slot ID is string"); + var tier2SitePair = sidMatched.matched[1]; + var expectedTierSlotID = 'T1_' + tier2SitePair.configured.params.id + '_1'; + assert.equal(tier2SitePair.sent.ext.sid, expectedTierSlotID, 'request ' + tier2SitePair.name + ' site ID is set to ' + expectedTierSlotID); + assert.isString(tier2SitePair.sent.ext.sid, 'type of slot ID is string'); - var expectedTierSiteID = tier2SitePair.configured.params.tier2SiteID; - assert.equal(tier2SitePair.sent.ext.siteID, expectedTierSiteID, "request " + normalSitePair.name + " site ID is set to " + expectedTierSiteID); - assert.isNumber(tier2SitePair.sent.ext.siteID, "site ID is integer"); + var expectedTierSiteID = tier2SitePair.configured.params.tier2SiteID; + assert.equal(tier2SitePair.sent.ext.siteID, expectedTierSiteID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedTierSiteID); + assert.isNumber(tier2SitePair.sent.ext.siteID, 'site ID is integer'); // check tier 2 site id - var tier3SitePair = sidMatched.matched[2]; - var expectedTierSlotID = 'T2_' + tier3SitePair.configured.params.id + '_1'; - assert.equal( tier3SitePair.sent.ext.sid, expectedTierSlotID, "request " + tier3SitePair.name + " site ID is set to " + expectedTierSlotID); - assert.isString( tier3SitePair.sent.ext.sid, "type of slot ID is string"); + var tier3SitePair = sidMatched.matched[2]; + var expectedTierSlotID = 'T2_' + tier3SitePair.configured.params.id + '_1'; + assert.equal(tier3SitePair.sent.ext.sid, expectedTierSlotID, 'request ' + tier3SitePair.name + ' site ID is set to ' + expectedTierSlotID); + assert.isString(tier3SitePair.sent.ext.sid, 'type of slot ID is string'); - var expectedTier3SiteID = tier3SitePair.configured.params.tier3SiteID; - assert.equal(tier3SitePair.sent.ext.siteID, expectedTier3SiteID, "request " + normalSitePair.name + " site ID is set to " + expectedTier3SiteID); - assert.isNumber(tier3SitePair.sent.ext.siteID, "site ID is integer"); + var expectedTier3SiteID = tier3SitePair.configured.params.tier3SiteID; + assert.equal(tier3SitePair.sent.ext.siteID, expectedTier3SiteID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedTier3SiteID); + assert.isNumber(tier3SitePair.sent.ext.siteID, 'site ID is integer'); // check unsent bids - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - }); - - it('test_prebid_indexAdapter_callback_bids: callback function defined with bids -> calls callback function with bids', function () { - var callbackCalled = false; - var callback_requestID; - var callback_slots; - window.cygnus_index_args['callback'] = function( requestID, slots ) { - callbackCalled = true; - callback_requestID = requestID; - callback_slots = slots; - } - - var configuredBids = IndexUtils.createBidSlots(1, 1); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON ); - cygnus_index_parse_res( asResponse ); - - assert.equal(callbackCalled, true, 'callback function is called'); - assert.equal( callback_requestID, requestJSON.r.id, 'callback requestID matches with actual request ID: ' + requestJSON.r.id ); - assert.equal( callback_slots.length, 1, 'callback slots include one slot'); - }); - - - it('test_prebid_indexAdapter_callback_nobids: callback function defined with no bids -> calls callback function without bids', function () { - var callbackCalled = false; - var callback_requestID; - var callback_slots; - window.cygnus_index_args['callback'] = function( requestID, slots ) { - callbackCalled = true; - callback_requestID = requestID; - callback_slots = slots; - } - - var configuredBids = IndexUtils.createBidSlots(1, 1); - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, [[true]] ); // pass on bid - cygnus_index_parse_res( asResponse ); - - assert.equal(callbackCalled, true, 'callback function is called'); - assert.equal( callback_requestID, requestJSON.r.id, 'callback requestID matches with actual request ID: ' + requestJSON.r.id ); - assert.isUndefined( callback_slots, 'callback slot is undefined because all bids passed on bid'); - }); - - it('test_prebid_indexAdapter_response_sizeID_1: multiple prebid size slot, index slots with size for all prebid slots -> all size in AS request, no size ID', function () { - var slotID_1 = "52"; - var slotID_2 = "53"; - var slotSizes_1 = IndexUtils.supportedSizes[0]; - var slotSizes_2 = IndexUtils.supportedSizes[1]; - - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix + slotID_1, slotID_1, [ slotSizes_1, slotSizes_2 ], { slotSize : slotSizes_1 } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix + slotID_2, slotID_2, [ slotSizes_1, slotSizes_2 ], { siteID : IndexUtils.DefaultSiteID + 1 } ) - ]; - - adapter.callBids({ bids: configuredBids }); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - var asResponse = IndexUtils.getBidResponse( configuredBids, requestJSON, undefined, undefined, [[true]] ); // pass on bid - cygnus_index_parse_res( asResponse ); - - var adapterResponse = {}; - - for ( var i = 0; i < bidManager.addBidResponse.callCount; i++ ) { - var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; - var bid = bidManager.addBidResponse.getCall(i).args[1]; - - if ( typeof adapterResponse[adUnitCode] === 'undefined'){ - adapterResponse[adUnitCode] = []; - }; - adapterResponse[adUnitCode].push(bid); - } - }); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); + + it('test_prebid_indexAdapter_callback_bids: callback function defined with bids -> calls callback function with bids', function () { + var callbackCalled = false; + var callback_requestID; + var callback_slots; + window.cygnus_index_args['callback'] = function(requestID, slots) { + callbackCalled = true; + callback_requestID = requestID; + callback_slots = slots; + } + + var configuredBids = IndexUtils.createBidSlots(1, 1); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON); + cygnus_index_parse_res(asResponse); + + assert.equal(callbackCalled, true, 'callback function is called'); + assert.equal(callback_requestID, requestJSON.r.id, 'callback requestID matches with actual request ID: ' + requestJSON.r.id); + assert.equal(callback_slots.length, 1, 'callback slots include one slot'); + }); + + it('test_prebid_indexAdapter_callback_nobids: callback function defined with no bids -> calls callback function without bids', function () { + var callbackCalled = false; + var callback_requestID; + var callback_slots; + window.cygnus_index_args['callback'] = function(requestID, slots) { + callbackCalled = true; + callback_requestID = requestID; + callback_slots = slots; + } + + var configuredBids = IndexUtils.createBidSlots(1, 1); + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, [[true]]); // pass on bid + cygnus_index_parse_res(asResponse); + + assert.equal(callbackCalled, true, 'callback function is called'); + assert.equal(callback_requestID, requestJSON.r.id, 'callback requestID matches with actual request ID: ' + requestJSON.r.id); + assert.isUndefined(callback_slots, 'callback slot is undefined because all bids passed on bid'); + }); + + it('test_prebid_indexAdapter_response_sizeID_1: multiple prebid size slot, index slots with size for all prebid slots -> all size in AS request, no size ID', function () { + var slotID_1 = '52'; + var slotID_2 = '53'; + var slotSizes_1 = IndexUtils.supportedSizes[0]; + var slotSizes_2 = IndexUtils.supportedSizes[1]; + + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + slotID_1, slotID_1, [ slotSizes_1, slotSizes_2 ], { slotSize: slotSizes_1 }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + slotID_2, slotID_2, [ slotSizes_1, slotSizes_2 ], { siteID: IndexUtils.DefaultSiteID + 1 }) + ]; + + adapter.callBids({ bids: configuredBids }); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + var asResponse = IndexUtils.getBidResponse(configuredBids, requestJSON, undefined, undefined, [[true]]); // pass on bid + cygnus_index_parse_res(asResponse); + + var adapterResponse = {}; + + for (var i = 0; i < bidManager.addBidResponse.callCount; i++) { + var adUnitCode = bidManager.addBidResponse.getCall(i).args[0]; + var bid = bidManager.addBidResponse.getCall(i).args[1]; + + if (typeof adapterResponse[adUnitCode] === 'undefined') { + adapterResponse[adUnitCode] = []; + }; + adapterResponse[adUnitCode].push(bid); + } + }); }); diff --git a/test/spec/adapters/indexExchange_validation_spec.js b/test/spec/adapters/indexExchange_validation_spec.js index 9d448b97629..fbb3e05f5b0 100644 --- a/test/spec/adapters/indexExchange_validation_spec.js +++ b/test/spec/adapters/indexExchange_validation_spec.js @@ -2,1503 +2,1498 @@ import Adapter from '../../../src/adapters/indexExchange'; import bidManager from '../../../src/bidmanager'; import adLoader from '../../../src/adloader'; -var assert = require('chai').assert; -var IndexUtils = require('../../helpers/index_adapter_utils.js'); +var assert = require('chai').assert; +var IndexUtils = require('../../helpers/index_adapter_utils.js'); var HeaderTagRequest = '/cygnus'; -var ADAPTER_CODE = 'indexExchange'; +var ADAPTER_CODE = 'indexExchange'; window.pbjs = window.pbjs || {}; describe('indexExchange adapter - Validation', function () { - let adapter; - let sandbox; - - beforeEach( function() { - window._IndexRequestData = {}; - _IndexRequestData.impIDToSlotID = {}; - _IndexRequestData.reqOptions = {}; - _IndexRequestData.targetIDToResp = {}; - window.cygnus_index_args = {}; - - adapter = new Adapter(); - sandbox = sinon.sandbox.create(); - sandbox.stub(adLoader, 'loadScript'); - }); - - afterEach( function() { - sandbox.restore(); - }); - - it('test_prebid_indexAdapter_sizeValidation_1: request slot has supported and unsupported size -> unsupported size ignored in IX demand request', function () { + let adapter; + let sandbox; + + beforeEach(function() { + window._IndexRequestData = {}; + _IndexRequestData.impIDToSlotID = {}; + _IndexRequestData.reqOptions = {}; + _IndexRequestData.targetIDToResp = {}; + window.cygnus_index_args = {}; + + adapter = new Adapter(); + sandbox = sinon.sandbox.create(); + sandbox.stub(adLoader, 'loadScript'); + }); + + afterEach(function() { + sandbox.restore(); + }); + + it('test_prebid_indexAdapter_sizeValidation_1: request slot has supported and unsupported size -> unsupported size ignored in IX demand request', function () { // create 2 sizes for 1 slot, 1 for supported size, the other is not supported - var unsupportedSize = IndexUtils.unsupportedSizes[0]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], unsupportedSize ] ) - ]; + var unsupportedSize = IndexUtils.unsupportedSizes[0]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], unsupportedSize ]) + ]; - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, unsupportedSize, "configured bid not in impression obj size width is" + JSON.stringify(unsupportedSize) ); - }); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, unsupportedSize, 'configured bid not in impression obj size width is' + JSON.stringify(unsupportedSize)); + }); - it('test_prebid_indexAdapter_sizeValidation_2_1: some slot has unsupported size -> unsupported slot ignored in IX demand request', function () { + it('test_prebid_indexAdapter_sizeValidation_2_1: some slot has unsupported size -> unsupported slot ignored in IX demand request', function () { // create 2 slot, 1 for supported size, the other is not supported - var unsupportedSize = IndexUtils.unsupportedSizes[0]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"supported", "slot_1", [ IndexUtils.supportedSizes[0], ], { siteID:IndexUtils.DefaultSiteID } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"unspported", "slot_2", [ unsupportedSize ], { siteID:IndexUtils.DefaultSiteID+1} ) - ]; + var unsupportedSize = IndexUtils.unsupportedSizes[0]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'supported', 'slot_1', [ IndexUtils.supportedSizes[0], ], { siteID: IndexUtils.DefaultSiteID }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'unspported', 'slot_2', [ unsupportedSize ], { siteID: IndexUtils.DefaultSiteID + 1}) + ]; - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, unsupportedSize, "configured bid not in impression obj size width is" + JSON.stringify(unsupportedSize) ); - assert.equal( sidMatched.unmatched.configured[0].params.id, "slot_2", "configured bid not in impression obj id is slot_2" ); - assert.equal( sidMatched.unmatched.configured[0].params.siteID, IndexUtils.DefaultSiteID+1, "configured bid not in impression obj siteID is "+(IndexUtils.DefaultSiteID+1) ); - }); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, unsupportedSize, 'configured bid not in impression obj size width is' + JSON.stringify(unsupportedSize)); + assert.equal(sidMatched.unmatched.configured[0].params.id, 'slot_2', 'configured bid not in impression obj id is slot_2'); + assert.equal(sidMatched.unmatched.configured[0].params.siteID, IndexUtils.DefaultSiteID + 1, 'configured bid not in impression obj siteID is ' + (IndexUtils.DefaultSiteID + 1)); + }); - it('test_prebid_indexAdapter_sizeValidation_2_2: multiple slots with sinle size, all slot has supported size -> all slots are sent to IX demand', function () { + it('test_prebid_indexAdapter_sizeValidation_2_2: multiple slots with sinle size, all slot has supported size -> all slots are sent to IX demand', function () { // create 2 slot, 1 for supported size, the other is not supported - var unsupportedSize = IndexUtils.unsupportedSizes[0]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"supported1", "slot_1", [ IndexUtils.supportedSizes[0] ], { siteID:IndexUtils.DefaultSiteID } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"supported2", "slot_2", [ IndexUtils.supportedSizes[1] ], { siteID:IndexUtils.DefaultSiteID+1} ) - ]; + var unsupportedSize = IndexUtils.unsupportedSizes[0]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'supported1', 'slot_1', [ IndexUtils.supportedSizes[0] ], { siteID: IndexUtils.DefaultSiteID }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'supported2', 'slot_2', [ IndexUtils.supportedSizes[1] ], { siteID: IndexUtils.DefaultSiteID + 1}) + ]; - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 0, "0 configured bid is not in impression Obj"); - }); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 0, '0 configured bid is not in impression Obj'); + }); - it('test_prebid_indexAdapter_sizeValidation_2_3: multiple slots with sinle size, all slot has unsupported size -> all slots are ignored', function () { + it('test_prebid_indexAdapter_sizeValidation_2_3: multiple slots with sinle size, all slot has unsupported size -> all slots are ignored', function () { // create 2 slot, 1 for supported size, the other is not supported - var unsupportedSize = IndexUtils.unsupportedSizes[0]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"unsupported1", "slot_1", [ IndexUtils.unsupportedSizes[0] ], { siteID:IndexUtils.DefaultSiteID } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"unsupported2", "slot_2", [ IndexUtils.unsupportedSizes[1] ], { siteID:IndexUtils.DefaultSiteID+1} ) - ]; - adapter.callBids({ bids: configuredBids }); + var unsupportedSize = IndexUtils.unsupportedSizes[0]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'unsupported1', 'slot_1', [ IndexUtils.unsupportedSizes[0] ], { siteID: IndexUtils.DefaultSiteID }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'unsupported2', 'slot_2', [ IndexUtils.unsupportedSizes[1] ], { siteID: IndexUtils.DefaultSiteID + 1}) + ]; + adapter.callBids({ bids: configuredBids }); - assert.isUndefined( adLoader.loadScript.firstCall.args[0], "no request made to IX demand"); - }); + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'no request made to IX demand'); + }); - it('test_prebid_indexAdapter_sizeValidation_3_1: one slot has supported, unsupported, supported size -> unsupported slot ignored in IX demand request', function () { + it('test_prebid_indexAdapter_sizeValidation_3_1: one slot has supported, unsupported, supported size -> unsupported slot ignored in IX demand request', function () { // create 2 slot, 1 for supported size, the other is not supported - var unsupportedSize = IndexUtils.unsupportedSizes[0]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"somesupported", "slot_1", [ IndexUtils.supportedSizes[0], unsupportedSize ,IndexUtils.supportedSizes[1] ], { siteID:IndexUtils.DefaultSiteID } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"allsupported", "slot_2", [ IndexUtils.supportedSizes[2], IndexUtils.supportedSizes[3] ], { siteID:IndexUtils.DefaultSiteID+1} ) - ]; + var unsupportedSize = IndexUtils.unsupportedSizes[0]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'somesupported', 'slot_1', [ IndexUtils.supportedSizes[0], unsupportedSize, IndexUtils.supportedSizes[1] ], { siteID: IndexUtils.DefaultSiteID }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'allsupported', 'slot_2', [ IndexUtils.supportedSizes[2], IndexUtils.supportedSizes[3] ], { siteID: IndexUtils.DefaultSiteID + 1}) + ]; - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, unsupportedSize, "configured bid not in impression obj size width is" + JSON.stringify(unsupportedSize) ); - assert.equal( sidMatched.unmatched.configured[0].params.id, "slot_1", "configured bid not in impression obj id is slot_1" ); - assert.equal( sidMatched.unmatched.configured[0].params.siteID, IndexUtils.DefaultSiteID, "configured bid not in impression obj siteID is "+(IndexUtils.DefaultSiteID) ); - }); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, unsupportedSize, 'configured bid not in impression obj size width is' + JSON.stringify(unsupportedSize)); + assert.equal(sidMatched.unmatched.configured[0].params.id, 'slot_1', 'configured bid not in impression obj id is slot_1'); + assert.equal(sidMatched.unmatched.configured[0].params.siteID, IndexUtils.DefaultSiteID, 'configured bid not in impression obj siteID is ' + (IndexUtils.DefaultSiteID)); + }); - it('test_prebid_indexAdapter_sizeValidation_3_2: one slot has unsupported, supported, unsupported size -> unsupported slot ignored in IX demand request', function () { + it('test_prebid_indexAdapter_sizeValidation_3_2: one slot has unsupported, supported, unsupported size -> unsupported slot ignored in IX demand request', function () { // create 2 slot, 1 for supported size, the other is not supported - var unsupportedSize1 = IndexUtils.unsupportedSizes[0]; - var unsupportedSize2 = IndexUtils.unsupportedSizes[1]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"somesupported", "slot_1", [ unsupportedSize1, IndexUtils.supportedSizes[1], unsupportedSize2 ], { siteID:IndexUtils.DefaultSiteID } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"allsupported", "slot_2", [ IndexUtils.supportedSizes[2], IndexUtils.supportedSizes[3] ], { siteID:IndexUtils.DefaultSiteID+1} ) - ]; + var unsupportedSize1 = IndexUtils.unsupportedSizes[0]; + var unsupportedSize2 = IndexUtils.unsupportedSizes[1]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'somesupported', 'slot_1', [ unsupportedSize1, IndexUtils.supportedSizes[1], unsupportedSize2 ], { siteID: IndexUtils.DefaultSiteID }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'allsupported', 'slot_2', [ IndexUtils.supportedSizes[2], IndexUtils.supportedSizes[3] ], { siteID: IndexUtils.DefaultSiteID + 1}) + ]; - adapter.callBids({ bids: configuredBids }); + adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var impressionObj = requestJSON.r.imp; + var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - - assert.equal( sidMatched.unmatched.configured.length, 2, "2 configured bid is not in impression Obj"); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + + assert.equal(sidMatched.unmatched.configured.length, 2, '2 configured bid is not in impression Obj'); - assert.equal( sidMatched.unmatched.configured[0].size, unsupportedSize1, "configured bid not in impression obj size width is" + JSON.stringify(unsupportedSize1) ); - assert.equal( sidMatched.unmatched.configured[0].params.id, "slot_1", "configured bid not in impression obj id is slot_1" ); - assert.equal( sidMatched.unmatched.configured[0].params.siteID, IndexUtils.DefaultSiteID, "configured bid not in impression obj siteID is "+(IndexUtils.DefaultSiteID) ); + assert.equal(sidMatched.unmatched.configured[0].size, unsupportedSize1, 'configured bid not in impression obj size width is' + JSON.stringify(unsupportedSize1)); + assert.equal(sidMatched.unmatched.configured[0].params.id, 'slot_1', 'configured bid not in impression obj id is slot_1'); + assert.equal(sidMatched.unmatched.configured[0].params.siteID, IndexUtils.DefaultSiteID, 'configured bid not in impression obj siteID is ' + (IndexUtils.DefaultSiteID)); - assert.equal( sidMatched.unmatched.configured[1].size, unsupportedSize2, "configured bid not in impression obj size width is" + JSON.stringify(unsupportedSize2) ); - assert.equal( sidMatched.unmatched.configured[1].params.id, "slot_1", "configured bid not in impression obj id is slot_1" ); - assert.equal( sidMatched.unmatched.configured[1].params.siteID, IndexUtils.DefaultSiteID, "configured bid not in impression obj siteID is "+(IndexUtils.DefaultSiteID) ); - }); - - it('test_prebid_indexAdapter_sizeValidation_3_3: multiple slots, all slots have supported size -> all slots are included in IX demand request', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"allsupported1", "slot_1", [ IndexUtils.supportedSizes[0], IndexUtils.supportedSizes[1] ], { siteID:IndexUtils.DefaultSiteID } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"allsupported2", "slot_2", [ IndexUtils.supportedSizes[2], IndexUtils.supportedSizes[3] ], { siteID:IndexUtils.DefaultSiteID+1} ) - ]; - - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(sidMatched.unmatched.configured[1].size, unsupportedSize2, 'configured bid not in impression obj size width is' + JSON.stringify(unsupportedSize2)); + assert.equal(sidMatched.unmatched.configured[1].params.id, 'slot_1', 'configured bid not in impression obj id is slot_1'); + assert.equal(sidMatched.unmatched.configured[1].params.siteID, IndexUtils.DefaultSiteID, 'configured bid not in impression obj siteID is ' + (IndexUtils.DefaultSiteID)); + }); + + it('test_prebid_indexAdapter_sizeValidation_3_3: multiple slots, all slots have supported size -> all slots are included in IX demand request', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'allsupported1', 'slot_1', [ IndexUtils.supportedSizes[0], IndexUtils.supportedSizes[1] ], { siteID: IndexUtils.DefaultSiteID }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'allsupported2', 'slot_2', [ IndexUtils.supportedSizes[2], IndexUtils.supportedSizes[3] ], { siteID: IndexUtils.DefaultSiteID + 1}) + ]; + + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } - - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - - assert.equal( sidMatched.unmatched.configured.length, 0, "0 configured bid is not in impression Obj"); - }); - - it('test_prebid_indexAdapter_sizeValidation_3_4: multiple slots, all slots have unsupported size -> no slots are sent to IX demand', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"allsupported1", "slot_1", [ IndexUtils.unsupportedSizes[0], IndexUtils.unsupportedSizes[1] ], { siteID:IndexUtils.DefaultSiteID } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+"allsupported2", "slot_2", [ IndexUtils.unsupportedSizes[2], IndexUtils.unsupportedSizes[3] ], { siteID:IndexUtils.DefaultSiteID+1} ) - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isUndefined(adLoader.loadScript.firstCall.args[0], "No request to IX demand"); - }); - - it('test_prebid_indexAdapter_param_timeout_integer: timeout is integer -> t parameter that matches with the integer', function () { - var testTimeout = 100; // integer timeout - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout } ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.equal( requestJSON.t, testTimeout, 't parameter matches timeout and is included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_quoted_integer: timeout is quoted integer -> t parameter that matches with the integer', function () { - var testTimeout = '100'; // quoted integer timeout - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout } ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.equal( requestJSON.t, testTimeout, 't parameter matches timeout and is included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_float: timeout is float number -> t parameter is not included in AS request', function () { - var testTimeout = 1.234; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout } ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isUndefined( requestJSON.t, 't parameter is not included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_float: timeout is float number -> t parameter is not included in AS request', function () { - var testTimeout = 1.234; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout } ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isUndefined( requestJSON.t, 't parameter is not included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_string: timeout is string -> t parameter is not included in AS request', function () { - var testTimeout = 'string'; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout } ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isUndefined( requestJSON.t, 't parameter is not included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_array: timeout is array -> t parameter is not included in AS request', function () { - var testTimeout = [ 'abc' ]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout } ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isUndefined( requestJSON.t, 't parameter is not included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_hash: timeout is hash -> t parameter is not included in AS request', function () { - var testTimeout = { 'timeout': 100 }; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout } ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isUndefined( requestJSON.t, 't parameter is not included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_zero: timeout is zero -> t parameter is not included in AS request', function () { - var testTimeout = 0; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout } ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isUndefined( requestJSON.t, 't parameter is not included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_negative: timeout is negative integer -> t parameter is not included in AS request', function () { - var testTimeout = -100; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout } ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isUndefined( requestJSON.t, 't parameter is not included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_too_big: timeout is bigger than AS max timeout -> t parameter is not included in AS request', function () { - var testTimeout = 25000; // very large timeout - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout } ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.equal( requestJSON.t, testTimeout, 't parameter matches timeout and is included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_missing: timeout is missing -> t parameter is not included in AS request', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ] ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isUndefined( requestJSON.t, 't parameter is not included in AS request parameter' ); - }); - - it('test_prebid_indexAdapter_param_timeout_empty_string: timeout is empty string -> t parameter is not included in AS request', function () { - var testTimeout = ''; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout} ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isUndefined( requestJSON.t, 't parameter is not included in AS request parameter' ); - }); - - var test_indexAdapter_slotid = [ - { - 'testname' : 'test_prebid_indexAdapter_slotid_integer: slot ID is integer -> slot ID sent to AS in string', - 'slotID' : 123, - 'expected' : 'pass' - }, - { - 'testname' : 'test_prebid_indexAdapter_slotid_quoted_integer: slot ID is quoted_integer -> slot ID sent to AS in string', - 'slotID' : '123', - 'expected' : 'pass' - }, - { - 'testname' : 'test_prebid_indexAdapter_slotid_float: slot ID is float -> slot ID sent to AS in string', - 'slotID' : 123.45, - 'expected' : 'pass' - }, - { - 'testname' : 'test_prebid_indexAdapter_slotid_string: slot ID is string -> slot ID sent to AS in string', - 'slotID' : 'string', - 'expected' : 'pass' - }, - { - 'testname' : 'test_prebid_indexAdapter_slotid_array: slot ID is array -> slot is not sent to AS', - 'slotID' : [ 'arrayelement1', 'arrayelement2' ], - 'expected' : 'fail' - }, - { - 'testname' : 'test_prebid_indexAdapter_slotid_hash: slot ID is hash -> slot is not sent to AS', - 'slotID' : { "hashName": "hashKey" }, - 'expected' : 'fail' - }, - { - 'testname' : 'test_prebid_indexAdapter_slotid_zero: slot ID is zero integer -> slot ID sent to AS in string', - 'slotID' : 0, - 'expected' : 'pass' - }, - { - 'testname' : 'test_prebid_indexAdapter_slotid_negative: slot ID is negative integer -> slot ID sent to AS in string', - 'slotID' : -100, - 'expected' : 'pass' - }, - { - 'testname' : 'test_prebid_indexAdapter_slotid_undefined: slot ID is undefined -> slot is not sent to AS', - 'slotID' : undefined, - 'expected' : 'fail' - }, - { - 'testname' : 'test_prebid_indexAdapter_slotid_missing: slot ID is missing -> slot is not sent to AS', - 'param' : { 'missingSlotID': true}, - 'expected' : 'invalid' - } - ]; - - function base_prebid_indexAdapter_slotid ( testname, slotID, expected, param ) { - it( testname, function(){ - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotID, [ IndexUtils.supportedSizes[0] ], param ), - ]; - adapter.callBids({ bids: configuredBids }); - if ( expected == 'pass' ) { - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - - var actualSlotID = pair.sent.ext.sid; - var expectedSlotID = pair.configured.params.id + '_1'; - assert.equal(actualSlotID, expectedSlotID, "request " + pair.name + " slot ID is set to " + expectedSlotID); - assert.isString(actualSlotID, "slotID is string"); - } - - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - } else if (expected == 'invalid'){ - //case where callBids throws out request due to missing params - assert.isFalse(adLoader.loadScript.called, 'No request to AS') - } else { - assert.strictEqual(typeof indexBidRequest, 'undefined', 'No request to AS'); - } - }); - }; - - for ( var i=0; i < test_indexAdapter_slotid.length; i++ ){ - var test = test_indexAdapter_slotid[i]; - base_prebid_indexAdapter_slotid( test.testname, test.slotID, test.expected, test.param ); - } - - - it( 'test_prebid_indexAdapter_slotid_multiple_slot: uniqueness for multiple slots -> all slots in ad server request with unique slot id', function(){ - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ] ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, 'slot_2', [ IndexUtils.supportedSizes[1] ] ), - ]; - adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - - var actualSlotID = pair.sent.ext.sid; - var expectedSlotID = pair.configured.params.id + '_1'; - assert.equal(actualSlotID, expectedSlotID, "request " + pair.name + " slot ID is set to " + expectedSlotID); - assert.isString(actualSlotID, "slotID is string"); - } - - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - }); - - it( 'test_prebid_indexAdapter_slotid_multiple_same: same across some slots -> all slots in ad server request with same slot id', function(){ - var slotName = 'slot_same'; - var secondSlotSize = IndexUtils.supportedSizes[1]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotName, [ IndexUtils.supportedSizes[0] ] ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotName, [ secondSlotSize ] ), - ]; - adapter.callBids({ bids: configuredBids }); - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - - var actualSlotID = pair.sent.ext.sid; - var expectedSlotID = pair.configured.params.id + '_1'; - assert.equal(actualSlotID, expectedSlotID, "request " + pair.name + " slot ID is set to " + expectedSlotID); - assert.isString(actualSlotID, "slotID is string"); - } - - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - - assert.equal( sidMatched.unmatched.configured.length, 1, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, secondSlotSize, "configured bid not in impression obj size width is" + JSON.stringify(secondSlotSize) ); - assert.equal( sidMatched.unmatched.configured[0].params.id, slotName, "slot name is " + slotName ); - }); - - var test_indexAdapter_siteid = [ - { - 'testname' : 'test_prebid_indexAdapter_siteid_integer: site ID is integer -> siteID ID sent to AS as integer', - 'param' : { 'siteID': 12345 }, - 'expected' : 'pass', - }, - { - 'testname' : 'test_prebid_indexAdapter_siteid_quoted_integer: site ID is quoted integer -> siteID ID sent to AS as integer', - 'param' : { 'siteID': '12345' }, - 'expected' : 'pass', - }, - { - 'testname' : 'test_prebid_indexAdapter_siteid_float: site ID is float -> slot is ignored', - 'param' : { 'siteID': 12.345 }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_siteid_string: site ID is string -> slot is ignored', - 'param' : { 'siteID': 'string' }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_siteid_array: site ID is array with int -> siteID sent to AS as integer', - 'param' : { 'siteID': [ 12345 ] }, - 'expected' : 'pass', - }, - { - 'testname' : 'test_prebid_indexAdapter_siteid_array: site ID is array with quoted int -> siteID sent to AS as integer', - 'param' : { 'siteID': [ "12345" ] }, - 'expected' : 'pass', - }, - { - 'testname' : 'test_prebid_indexAdapter_siteid_array: site ID is array with alpha string -> slot is ignored', - 'param' : { 'siteID': [ "ABC" ] }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_siteid_hash: site ID is hash -> slot is ignored', - 'param' : { 'siteID': { 12345: 678 } }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_siteid_zero: site ID is zero integer -> slot is ignored', - 'param' : { 'siteID': 0 }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_siteid_negative: site ID is a negative integer -> slot is ignored', - 'param' : { 'siteID': -1234 }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_siteid_missing: site ID is missing -> slot is ignored', - 'param' : { 'missingSiteID': true }, - 'expected' : 'invalid', - }, - ]; - - function base_prebid_indexAdapter_siteid ( testname, param, expected ) { - it( testname, function(){ - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], param ), - ]; - - adapter.callBids({ bids: configuredBids }); - if ( expected == 'pass' ) { - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - - var actualSiteID = pair.sent.ext.siteID; - var expectedSiteID = pair.configured.params.siteID; - assert.equal(actualSiteID, expectedSiteID, "request " + pair.name + " site ID is set to " + expectedSiteID); - assert.isNumber(actualSiteID, "site ID is integer"); - } - - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - } else if (expected == 'invalid') { - //case where callBids throws out request due to missing params - assert.isFalse(adLoader.loadScript.called, 'No request to AS'); - } else { - assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'No request to AS'); - } - }); - }; - - for ( var i=0; i < test_indexAdapter_siteid.length; i++ ){ - var test = test_indexAdapter_siteid[i]; - base_prebid_indexAdapter_siteid( test.testname, test.param, test.expected ); - } + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } + + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + + assert.equal(sidMatched.unmatched.configured.length, 0, '0 configured bid is not in impression Obj'); + }); + + it('test_prebid_indexAdapter_sizeValidation_3_4: multiple slots, all slots have unsupported size -> no slots are sent to IX demand', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'allsupported1', 'slot_1', [ IndexUtils.unsupportedSizes[0], IndexUtils.unsupportedSizes[1] ], { siteID: IndexUtils.DefaultSiteID }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + 'allsupported2', 'slot_2', [ IndexUtils.unsupportedSizes[2], IndexUtils.unsupportedSizes[3] ], { siteID: IndexUtils.DefaultSiteID + 1}) + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'No request to IX demand'); + }); + + it('test_prebid_indexAdapter_param_timeout_integer: timeout is integer -> t parameter that matches with the integer', function () { + var testTimeout = 100; // integer timeout + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout }), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.equal(requestJSON.t, testTimeout, 't parameter matches timeout and is included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_quoted_integer: timeout is quoted integer -> t parameter that matches with the integer', function () { + var testTimeout = '100'; // quoted integer timeout + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout }), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.equal(requestJSON.t, testTimeout, 't parameter matches timeout and is included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_float: timeout is float number -> t parameter is not included in AS request', function () { + var testTimeout = 1.234; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout }), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isUndefined(requestJSON.t, 't parameter is not included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_float: timeout is float number -> t parameter is not included in AS request', function () { + var testTimeout = 1.234; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout }), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isUndefined(requestJSON.t, 't parameter is not included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_string: timeout is string -> t parameter is not included in AS request', function () { + var testTimeout = 'string'; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout }), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isUndefined(requestJSON.t, 't parameter is not included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_array: timeout is array -> t parameter is not included in AS request', function () { + var testTimeout = [ 'abc' ]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout }), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isUndefined(requestJSON.t, 't parameter is not included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_hash: timeout is hash -> t parameter is not included in AS request', function () { + var testTimeout = { 'timeout': 100 }; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout }), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isUndefined(requestJSON.t, 't parameter is not included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_zero: timeout is zero -> t parameter is not included in AS request', function () { + var testTimeout = 0; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout }), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isUndefined(requestJSON.t, 't parameter is not included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_negative: timeout is negative integer -> t parameter is not included in AS request', function () { + var testTimeout = -100; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout }), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isUndefined(requestJSON.t, 't parameter is not included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_too_big: timeout is bigger than AS max timeout -> t parameter is not included in AS request', function () { + var testTimeout = 25000; // very large timeout + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout }), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.equal(requestJSON.t, testTimeout, 't parameter matches timeout and is included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_missing: timeout is missing -> t parameter is not included in AS request', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ]), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isUndefined(requestJSON.t, 't parameter is not included in AS request parameter'); + }); + + it('test_prebid_indexAdapter_param_timeout_empty_string: timeout is empty string -> t parameter is not included in AS request', function () { + var testTimeout = ''; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], { timeout: testTimeout}), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isUndefined(requestJSON.t, 't parameter is not included in AS request parameter'); + }); + + var test_indexAdapter_slotid = [ + { + 'testname': 'test_prebid_indexAdapter_slotid_integer: slot ID is integer -> slot ID sent to AS in string', + 'slotID': 123, + 'expected': 'pass' + }, + { + 'testname': 'test_prebid_indexAdapter_slotid_quoted_integer: slot ID is quoted_integer -> slot ID sent to AS in string', + 'slotID': '123', + 'expected': 'pass' + }, + { + 'testname': 'test_prebid_indexAdapter_slotid_float: slot ID is float -> slot ID sent to AS in string', + 'slotID': 123.45, + 'expected': 'pass' + }, + { + 'testname': 'test_prebid_indexAdapter_slotid_string: slot ID is string -> slot ID sent to AS in string', + 'slotID': 'string', + 'expected': 'pass' + }, + { + 'testname': 'test_prebid_indexAdapter_slotid_array: slot ID is array -> slot is not sent to AS', + 'slotID': [ 'arrayelement1', 'arrayelement2' ], + 'expected': 'fail' + }, + { + 'testname': 'test_prebid_indexAdapter_slotid_hash: slot ID is hash -> slot is not sent to AS', + 'slotID': { 'hashName': 'hashKey' }, + 'expected': 'fail' + }, + { + 'testname': 'test_prebid_indexAdapter_slotid_zero: slot ID is zero integer -> slot ID sent to AS in string', + 'slotID': 0, + 'expected': 'pass' + }, + { + 'testname': 'test_prebid_indexAdapter_slotid_negative: slot ID is negative integer -> slot ID sent to AS in string', + 'slotID': -100, + 'expected': 'pass' + }, + { + 'testname': 'test_prebid_indexAdapter_slotid_undefined: slot ID is undefined -> slot is not sent to AS', + 'slotID': undefined, + 'expected': 'fail' + }, + { + 'testname': 'test_prebid_indexAdapter_slotid_missing: slot ID is missing -> slot is not sent to AS', + 'param': { 'missingSlotID': true}, + 'expected': 'invalid' + } + ]; + + function base_prebid_indexAdapter_slotid (testname, slotID, expected, param) { + it(testname, function() { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotID, [ IndexUtils.supportedSizes[0] ], param), + ]; + adapter.callBids({ bids: configuredBids }); + if (expected == 'pass') { + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + + var actualSlotID = pair.sent.ext.sid; + var expectedSlotID = pair.configured.params.id + '_1'; + assert.equal(actualSlotID, expectedSlotID, 'request ' + pair.name + ' slot ID is set to ' + expectedSlotID); + assert.isString(actualSlotID, 'slotID is string'); + } + + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + } else if (expected == 'invalid') { + // case where callBids throws out request due to missing params + assert.isFalse(adLoader.loadScript.called, 'No request to AS') + } else { + assert.strictEqual(typeof indexBidRequest, 'undefined', 'No request to AS'); + } + }); + }; + + for (var i = 0; i < test_indexAdapter_slotid.length; i++) { + var test = test_indexAdapter_slotid[i]; + base_prebid_indexAdapter_slotid(test.testname, test.slotID, test.expected, test.param); + } + + it('test_prebid_indexAdapter_slotid_multiple_slot: uniqueness for multiple slots -> all slots in ad server request with unique slot id', function() { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ]), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_2', [ IndexUtils.supportedSizes[1] ]), + ]; + adapter.callBids({ bids: configuredBids }); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + + var actualSlotID = pair.sent.ext.sid; + var expectedSlotID = pair.configured.params.id + '_1'; + assert.equal(actualSlotID, expectedSlotID, 'request ' + pair.name + ' slot ID is set to ' + expectedSlotID); + assert.isString(actualSlotID, 'slotID is string'); + } + + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); + + it('test_prebid_indexAdapter_slotid_multiple_same: same across some slots -> all slots in ad server request with same slot id', function() { + var slotName = 'slot_same'; + var secondSlotSize = IndexUtils.supportedSizes[1]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotName, [ IndexUtils.supportedSizes[0] ]), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotName, [ secondSlotSize ]), + ]; + adapter.callBids({ bids: configuredBids }); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + + var actualSlotID = pair.sent.ext.sid; + var expectedSlotID = pair.configured.params.id + '_1'; + assert.equal(actualSlotID, expectedSlotID, 'request ' + pair.name + ' slot ID is set to ' + expectedSlotID); + assert.isString(actualSlotID, 'slotID is string'); + } + + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + + assert.equal(sidMatched.unmatched.configured.length, 1, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, secondSlotSize, 'configured bid not in impression obj size width is' + JSON.stringify(secondSlotSize)); + assert.equal(sidMatched.unmatched.configured[0].params.id, slotName, 'slot name is ' + slotName); + }); + + var test_indexAdapter_siteid = [ + { + 'testname': 'test_prebid_indexAdapter_siteid_integer: site ID is integer -> siteID ID sent to AS as integer', + 'param': { 'siteID': 12345 }, + 'expected': 'pass', + }, + { + 'testname': 'test_prebid_indexAdapter_siteid_quoted_integer: site ID is quoted integer -> siteID ID sent to AS as integer', + 'param': { 'siteID': '12345' }, + 'expected': 'pass', + }, + { + 'testname': 'test_prebid_indexAdapter_siteid_float: site ID is float -> slot is ignored', + 'param': { 'siteID': 12.345 }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_siteid_string: site ID is string -> slot is ignored', + 'param': { 'siteID': 'string' }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_siteid_array: site ID is array with int -> siteID sent to AS as integer', + 'param': { 'siteID': [ 12345 ] }, + 'expected': 'pass', + }, + { + 'testname': 'test_prebid_indexAdapter_siteid_array: site ID is array with quoted int -> siteID sent to AS as integer', + 'param': { 'siteID': [ '12345' ] }, + 'expected': 'pass', + }, + { + 'testname': 'test_prebid_indexAdapter_siteid_array: site ID is array with alpha string -> slot is ignored', + 'param': { 'siteID': [ 'ABC' ] }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_siteid_hash: site ID is hash -> slot is ignored', + 'param': { 'siteID': { 12345: 678 } }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_siteid_zero: site ID is zero integer -> slot is ignored', + 'param': { 'siteID': 0 }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_siteid_negative: site ID is a negative integer -> slot is ignored', + 'param': { 'siteID': -1234 }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_siteid_missing: site ID is missing -> slot is ignored', + 'param': { 'missingSiteID': true }, + 'expected': 'invalid', + }, + ]; + + function base_prebid_indexAdapter_siteid (testname, param, expected) { + it(testname, function() { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], param), + ]; + + adapter.callBids({ bids: configuredBids }); + if (expected == 'pass') { + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + + var actualSiteID = pair.sent.ext.siteID; + var expectedSiteID = pair.configured.params.siteID; + assert.equal(actualSiteID, expectedSiteID, 'request ' + pair.name + ' site ID is set to ' + expectedSiteID); + assert.isNumber(actualSiteID, 'site ID is integer'); + } + + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + } else if (expected == 'invalid') { + // case where callBids throws out request due to missing params + assert.isFalse(adLoader.loadScript.called, 'No request to AS'); + } else { + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'No request to AS'); + } + }); + }; + + for (var i = 0; i < test_indexAdapter_siteid.length; i++) { + var test = test_indexAdapter_siteid[i]; + base_prebid_indexAdapter_siteid(test.testname, test.param, test.expected); + } // TS: case created by PBA-12 - it( 'test_prebid_indexAdapter_second_siteid_float: site ID is float -> slot is ignored', function(){ - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+'1', 'slot_1', [ IndexUtils.supportedSizes[0] ] ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix+'2', 'slot_2', [ IndexUtils.supportedSizes[1] ], { 'siteID': 123.45 } ), - ]; - - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - assert.equal( sidMatched.matched.length, 1, 'one slot is configured and sent to AS'); - - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - - var actualSiteID = pair.sent.ext.siteID; - var expectedSiteID = pair.configured.params.siteID; - assert.equal(actualSiteID, expectedSiteID, "request " + pair.name + " site ID is set to " + expectedSiteID); - assert.isNumber(actualSiteID, "site ID is integer"); - } - - assert.equal( sidMatched.unmatched.configured.length, 1, "float site ID configured bid is missing in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - }); - - - var test_indexAdapter_tier2siteid = [ - { - 'testname' : 'test_prebid_indexAdapter_tier2siteid_integer: tier2 site ID is integer -> siteID ID sent to AS in integer', - 'param' : { 'tier2SiteID': 12345 }, - 'expected' : 'pass', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier2siteid_quoted_integer: tier2 site ID is quoted integer -> siteID ID sent to AS in integer', - 'param' : { 'tier2SiteID': '12345' }, - 'expected' : 'pass', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier2siteid_float: tier2 site ID is float -> slot is ignored', - 'param' : { 'tier2SiteID': 12.345 }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier2siteid_string: tier2 site ID is string -> slot is ignored', - 'param' : { 'tier2SiteID': 'string' }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier2siteid_array: tier2 site ID is array -> slot is ignored', - 'param' : { 'tier2SiteID': [ 12345 ] }, - 'expected' : 'pass', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier2siteid_hash: tier2 site ID is hash -> slot is ignored', - 'param' : { 'tier2SiteID': { 12345: 678 } }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier2siteid_zero: tier2 site ID is zero integer -> slot is ignored', - 'param' : { 'tier2SiteID': 0 }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier2siteid_negative: tier2 site ID is a negative integer -> slot is ignored', - 'param' : { 'tier2SiteID': -1234 }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier2siteid_missing: tier2 site ID is missing -> slot is ignored', - 'param' : { 'missingtier2SiteID': true }, - 'expected' : 'fail', - }, - ]; - function base_prebid_indexAdapter_tier2siteid ( testname, param, expected ) { - it( testname, function(){ - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], param ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - - if ( expected == 'pass' ) { - assert.equal( sidMatched.matched.length, 2, 'Two slots are configured and sent to AS'); + it('test_prebid_indexAdapter_second_siteid_float: site ID is float -> slot is ignored', function() { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + '1', 'slot_1', [ IndexUtils.supportedSizes[0] ]), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix + '2', 'slot_2', [ IndexUtils.supportedSizes[1] ], { 'siteID': 123.45 }), + ]; + + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + assert.equal(sidMatched.matched.length, 1, 'one slot is configured and sent to AS'); + + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + + var actualSiteID = pair.sent.ext.siteID; + var expectedSiteID = pair.configured.params.siteID; + assert.equal(actualSiteID, expectedSiteID, 'request ' + pair.name + ' site ID is set to ' + expectedSiteID); + assert.isNumber(actualSiteID, 'site ID is integer'); + } + + assert.equal(sidMatched.unmatched.configured.length, 1, 'float site ID configured bid is missing in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); + + var test_indexAdapter_tier2siteid = [ + { + 'testname': 'test_prebid_indexAdapter_tier2siteid_integer: tier2 site ID is integer -> siteID ID sent to AS in integer', + 'param': { 'tier2SiteID': 12345 }, + 'expected': 'pass', + }, + { + 'testname': 'test_prebid_indexAdapter_tier2siteid_quoted_integer: tier2 site ID is quoted integer -> siteID ID sent to AS in integer', + 'param': { 'tier2SiteID': '12345' }, + 'expected': 'pass', + }, + { + 'testname': 'test_prebid_indexAdapter_tier2siteid_float: tier2 site ID is float -> slot is ignored', + 'param': { 'tier2SiteID': 12.345 }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_tier2siteid_string: tier2 site ID is string -> slot is ignored', + 'param': { 'tier2SiteID': 'string' }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_tier2siteid_array: tier2 site ID is array -> slot is ignored', + 'param': { 'tier2SiteID': [ 12345 ] }, + 'expected': 'pass', + }, + { + 'testname': 'test_prebid_indexAdapter_tier2siteid_hash: tier2 site ID is hash -> slot is ignored', + 'param': { 'tier2SiteID': { 12345: 678 } }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_tier2siteid_zero: tier2 site ID is zero integer -> slot is ignored', + 'param': { 'tier2SiteID': 0 }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_tier2siteid_negative: tier2 site ID is a negative integer -> slot is ignored', + 'param': { 'tier2SiteID': -1234 }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_tier2siteid_missing: tier2 site ID is missing -> slot is ignored', + 'param': { 'missingtier2SiteID': true }, + 'expected': 'fail', + }, + ]; + function base_prebid_indexAdapter_tier2siteid (testname, param, expected) { + it(testname, function() { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], param), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + + if (expected == 'pass') { + assert.equal(sidMatched.matched.length, 2, 'Two slots are configured and sent to AS'); // check normal site id - var normalSitePair = sidMatched.matched[0]; + var normalSitePair = sidMatched.matched[0]; - var expectedSlotID = normalSitePair.configured.params.id + '_1'; - assert.equal( normalSitePair.sent.ext.sid, expectedSlotID, "request " + normalSitePair.name + " site ID is set to " + expectedSlotID); - assert.isString( normalSitePair.sent.ext.sid, "type of slot ID is string"); + var expectedSlotID = normalSitePair.configured.params.id + '_1'; + assert.equal(normalSitePair.sent.ext.sid, expectedSlotID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedSlotID); + assert.isString(normalSitePair.sent.ext.sid, 'type of slot ID is string'); - var expectedSiteID = normalSitePair.configured.params.siteID; - assert.equal(normalSitePair.sent.ext.siteID, expectedSiteID, "request " + normalSitePair.name + " site ID is set to " + expectedSiteID); - assert.isNumber(normalSitePair.sent.ext.siteID, "site ID is integer"); + var expectedSiteID = normalSitePair.configured.params.siteID; + assert.equal(normalSitePair.sent.ext.siteID, expectedSiteID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedSiteID); + assert.isNumber(normalSitePair.sent.ext.siteID, 'site ID is integer'); // check tier site id - var tier2SitePair = sidMatched.matched[1]; - var expectedTierSlotID = 'T1_' + tier2SitePair.configured.params.id + '_1'; - assert.equal( tier2SitePair.sent.ext.sid, expectedTierSlotID, "request " + tier2SitePair.name + " site ID is set to " + expectedTierSlotID); - assert.isString( tier2SitePair.sent.ext.sid, "type of slot ID is string"); + var tier2SitePair = sidMatched.matched[1]; + var expectedTierSlotID = 'T1_' + tier2SitePair.configured.params.id + '_1'; + assert.equal(tier2SitePair.sent.ext.sid, expectedTierSlotID, 'request ' + tier2SitePair.name + ' site ID is set to ' + expectedTierSlotID); + assert.isString(tier2SitePair.sent.ext.sid, 'type of slot ID is string'); - var expectedTierSiteID = tier2SitePair.configured.params.tier2SiteID; - assert.equal(tier2SitePair.sent.ext.siteID, expectedTierSiteID, "request " + normalSitePair.name + " site ID is set to " + expectedTierSiteID); - assert.isNumber(tier2SitePair.sent.ext.siteID, "site ID is integer"); + var expectedTierSiteID = tier2SitePair.configured.params.tier2SiteID; + assert.equal(tier2SitePair.sent.ext.siteID, expectedTierSiteID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedTierSiteID); + assert.isNumber(tier2SitePair.sent.ext.siteID, 'site ID is integer'); // check unsent bids - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - } else { - assert.equal( sidMatched.matched.length, 1, 'one slot is configured and sent to AS'); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + } else { + assert.equal(sidMatched.matched.length, 1, 'one slot is configured and sent to AS'); // check normal site id - var normalSitePair = sidMatched.matched[0]; + var normalSitePair = sidMatched.matched[0]; - var expectedSlotID = normalSitePair.configured.params.id + '_1'; - assert.equal( normalSitePair.sent.ext.sid, expectedSlotID, "request " + normalSitePair.name + " site ID is set to " + expectedSlotID); - assert.isString( normalSitePair.sent.ext.sid, "type of slot ID is string"); + var expectedSlotID = normalSitePair.configured.params.id + '_1'; + assert.equal(normalSitePair.sent.ext.sid, expectedSlotID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedSlotID); + assert.isString(normalSitePair.sent.ext.sid, 'type of slot ID is string'); - var expectedSiteID = normalSitePair.configured.params.siteID; - assert.equal(normalSitePair.sent.ext.siteID, expectedSiteID, "request " + normalSitePair.name + " site ID is set to " + expectedSiteID); - assert.isNumber(normalSitePair.sent.ext.siteID, "site ID is integer"); + var expectedSiteID = normalSitePair.configured.params.siteID; + assert.equal(normalSitePair.sent.ext.siteID, expectedSiteID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedSiteID); + assert.isNumber(normalSitePair.sent.ext.siteID, 'site ID is integer'); // check unsent bids - if ( param.missingtier2SiteID ){ - assert.equal( sidMatched.unmatched.configured.length, 0, "one configured bid is missing in impression Obj"); - } else { - assert.equal( sidMatched.unmatched.configured.length, 1, "one configured bid is missing in impression Obj"); - } - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - } - }); - }; - - for ( var i=0; i < test_indexAdapter_tier2siteid.length; i++ ){ - var test = test_indexAdapter_tier2siteid[i]; - base_prebid_indexAdapter_tier2siteid( test.testname, test.param, test.expected ); - } - - var test_indexAdapter_tier3siteid = [ - { - 'testname' : 'test_prebid_indexAdapter_tier3siteid_integer: tier3 site ID is integer -> siteID ID sent to AS in integer', - 'param' : { 'tier3SiteID': 12345 }, - 'expected' : 'pass', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier3siteid_quoted_integer: tier3 site ID is quoted integer -> siteID ID sent to AS in integer', - 'param' : { 'tier3SiteID': '12345' }, - 'expected' : 'pass', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier3siteid_float: tier3 site ID is float -> slot is ignored', - 'param' : { 'tier3SiteID': 12.345 }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier3siteid_string: tier3 site ID is string -> slot is ignored', - 'param' : { 'tier3SiteID': 'string' }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier3siteid_array: tier3 site ID is array -> slot is ignored', - 'param' : { 'tier3SiteID': [ 12345 ] }, - 'expected' : 'pass', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier3siteid_hash: tier3 site ID is hash -> slot is ignored', - 'param' : { 'tier3SiteID': { 12345: 678 } }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier3siteid_zero: tier3 site ID is zero integer -> slot is ignored', - 'param' : { 'tier3SiteID': 0 }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier3siteid_negative: tier3 site ID is a negative integer -> slot is ignored', - 'param' : { 'tier3SiteID': -1234 }, - 'expected' : 'fail', - }, - { - 'testname' : 'test_prebid_indexAdapter_tier3siteid_missing: tier3 site ID is missing -> slot is ignored', - 'param' : { 'missingtier3SiteID': true }, - 'expected' : 'fail', - }, - ]; - function base_prebid_indexAdapter_tier3siteid ( testname, param, expected ) { - it( testname, function(){ - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], param ), - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - - if ( expected == 'pass' ) { - assert.equal( sidMatched.matched.length, 2, 'Two slots are configured and sent to AS'); + if (param.missingtier2SiteID) { + assert.equal(sidMatched.unmatched.configured.length, 0, 'one configured bid is missing in impression Obj'); + } else { + assert.equal(sidMatched.unmatched.configured.length, 1, 'one configured bid is missing in impression Obj'); + } + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + } + }); + }; + + for (var i = 0; i < test_indexAdapter_tier2siteid.length; i++) { + var test = test_indexAdapter_tier2siteid[i]; + base_prebid_indexAdapter_tier2siteid(test.testname, test.param, test.expected); + } + + var test_indexAdapter_tier3siteid = [ + { + 'testname': 'test_prebid_indexAdapter_tier3siteid_integer: tier3 site ID is integer -> siteID ID sent to AS in integer', + 'param': { 'tier3SiteID': 12345 }, + 'expected': 'pass', + }, + { + 'testname': 'test_prebid_indexAdapter_tier3siteid_quoted_integer: tier3 site ID is quoted integer -> siteID ID sent to AS in integer', + 'param': { 'tier3SiteID': '12345' }, + 'expected': 'pass', + }, + { + 'testname': 'test_prebid_indexAdapter_tier3siteid_float: tier3 site ID is float -> slot is ignored', + 'param': { 'tier3SiteID': 12.345 }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_tier3siteid_string: tier3 site ID is string -> slot is ignored', + 'param': { 'tier3SiteID': 'string' }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_tier3siteid_array: tier3 site ID is array -> slot is ignored', + 'param': { 'tier3SiteID': [ 12345 ] }, + 'expected': 'pass', + }, + { + 'testname': 'test_prebid_indexAdapter_tier3siteid_hash: tier3 site ID is hash -> slot is ignored', + 'param': { 'tier3SiteID': { 12345: 678 } }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_tier3siteid_zero: tier3 site ID is zero integer -> slot is ignored', + 'param': { 'tier3SiteID': 0 }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_tier3siteid_negative: tier3 site ID is a negative integer -> slot is ignored', + 'param': { 'tier3SiteID': -1234 }, + 'expected': 'fail', + }, + { + 'testname': 'test_prebid_indexAdapter_tier3siteid_missing: tier3 site ID is missing -> slot is ignored', + 'param': { 'missingtier3SiteID': true }, + 'expected': 'fail', + }, + ]; + function base_prebid_indexAdapter_tier3siteid (testname, param, expected) { + it(testname, function() { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0] ], param), + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + + if (expected == 'pass') { + assert.equal(sidMatched.matched.length, 2, 'Two slots are configured and sent to AS'); // check normal site id - var normalSitePair = sidMatched.matched[0]; + var normalSitePair = sidMatched.matched[0]; - var expectedSlotID = normalSitePair.configured.params.id + '_1'; - assert.equal( normalSitePair.sent.ext.sid, expectedSlotID, "request " + normalSitePair.name + " site ID is set to " + expectedSlotID); - assert.isString( normalSitePair.sent.ext.sid, "type of slot ID is string"); + var expectedSlotID = normalSitePair.configured.params.id + '_1'; + assert.equal(normalSitePair.sent.ext.sid, expectedSlotID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedSlotID); + assert.isString(normalSitePair.sent.ext.sid, 'type of slot ID is string'); - var expectedSiteID = normalSitePair.configured.params.siteID; - assert.equal(normalSitePair.sent.ext.siteID, expectedSiteID, "request " + normalSitePair.name + " site ID is set to " + expectedSiteID); - assert.isNumber(normalSitePair.sent.ext.siteID, "site ID is integer"); + var expectedSiteID = normalSitePair.configured.params.siteID; + assert.equal(normalSitePair.sent.ext.siteID, expectedSiteID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedSiteID); + assert.isNumber(normalSitePair.sent.ext.siteID, 'site ID is integer'); // check tier site id - var tier3SitePair = sidMatched.matched[1]; - var expectedTierSlotID = 'T2_' + tier3SitePair.configured.params.id + '_1'; - assert.equal( tier3SitePair.sent.ext.sid, expectedTierSlotID, "request " + tier3SitePair.name + " site ID is set to " + expectedTierSlotID); - assert.isString( tier3SitePair.sent.ext.sid, "type of slot ID is string"); + var tier3SitePair = sidMatched.matched[1]; + var expectedTierSlotID = 'T2_' + tier3SitePair.configured.params.id + '_1'; + assert.equal(tier3SitePair.sent.ext.sid, expectedTierSlotID, 'request ' + tier3SitePair.name + ' site ID is set to ' + expectedTierSlotID); + assert.isString(tier3SitePair.sent.ext.sid, 'type of slot ID is string'); - var expectedTierSiteID = tier3SitePair.configured.params.tier3SiteID; - assert.equal(tier3SitePair.sent.ext.siteID, expectedTierSiteID, "request " + normalSitePair.name + " site ID is set to " + expectedTierSiteID); - assert.isNumber(tier3SitePair.sent.ext.siteID, "site ID is integer"); + var expectedTierSiteID = tier3SitePair.configured.params.tier3SiteID; + assert.equal(tier3SitePair.sent.ext.siteID, expectedTierSiteID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedTierSiteID); + assert.isNumber(tier3SitePair.sent.ext.siteID, 'site ID is integer'); // check unsent bids - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - } else { - assert.equal( sidMatched.matched.length, 1, 'one slot is configured and sent to AS'); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + } else { + assert.equal(sidMatched.matched.length, 1, 'one slot is configured and sent to AS'); // check normal site id - var normalSitePair = sidMatched.matched[0]; + var normalSitePair = sidMatched.matched[0]; - var expectedSlotID = normalSitePair.configured.params.id + '_1'; - assert.equal( normalSitePair.sent.ext.sid, expectedSlotID, "request " + normalSitePair.name + " site ID is set to " + expectedSlotID); - assert.isString( normalSitePair.sent.ext.sid, "type of slot ID is string"); + var expectedSlotID = normalSitePair.configured.params.id + '_1'; + assert.equal(normalSitePair.sent.ext.sid, expectedSlotID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedSlotID); + assert.isString(normalSitePair.sent.ext.sid, 'type of slot ID is string'); - var expectedSiteID = normalSitePair.configured.params.siteID; - assert.equal(normalSitePair.sent.ext.siteID, expectedSiteID, "request " + normalSitePair.name + " site ID is set to " + expectedSiteID); - assert.isNumber(normalSitePair.sent.ext.siteID, "site ID is integer"); + var expectedSiteID = normalSitePair.configured.params.siteID; + assert.equal(normalSitePair.sent.ext.siteID, expectedSiteID, 'request ' + normalSitePair.name + ' site ID is set to ' + expectedSiteID); + assert.isNumber(normalSitePair.sent.ext.siteID, 'site ID is integer'); // check unsent bids - if ( param.missingtier3SiteID ){ - assert.equal( sidMatched.unmatched.configured.length, 0, "one configured bid is missing in impression Obj"); - } else { - assert.equal( sidMatched.unmatched.configured.length, 1, "one configured bid is missing in impression Obj"); - } - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - } - }); - }; - - for ( var i=0; i < test_indexAdapter_tier3siteid.length; i++ ){ - var test = test_indexAdapter_tier3siteid[i]; - base_prebid_indexAdapter_tier3siteid( test.testname, test.param, test.expected ); - } - - - it( 'test_prebid_indexAdapter_siteID_multiple: multiple slots have same siteIDs -> all slots in ad server request with the same site IDs', function(){ - var first_slot = { - slotName: 'slot1', - siteID: 111111, - }; - var second_slot = { - slotName: 'slot2', - siteID: 111111, // same as first slot - }; - - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, first_slot['slotName'], [ IndexUtils.supportedSizes[0] ], { siteID: first_slot['siteID'] } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, second_slot['slotName'], [ IndexUtils.supportedSizes[1] ], { siteID: second_slot['siteID'] }), - ]; - - adapter.callBids({ bids: configuredBids }); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - - var expectedSiteID = pair.configured.params.siteID; - var actualSiteID = pair.sent.ext.siteID; - assert.equal(actualSiteID, expectedSiteID, "request " + pair.name + " site ID is set to " + expectedSiteID); - assert.isNumber( actualSiteID, "site ID is number"); - } - - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - }); - - it( 'test_prebid_indexAdapter_siteID_different: multiple slots have different siteIDs -> all slots in ad server request with the different site IDs', function(){ - var first_slot = { - slotName: 'slot1', - siteID: 111111, - }; - var second_slot = { - slotName: 'slot2', - siteID: 222222, - }; - - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, first_slot['slotName'], [ IndexUtils.supportedSizes[0] ], { siteID: first_slot['siteID'] } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, second_slot['slotName'], [ IndexUtils.supportedSizes[1] ], { siteID: second_slot['siteID'] }), - ]; - - adapter.callBids({ bids: configuredBids }); - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - - var expectedSiteID = pair.configured.params.siteID; - var actualSiteID = pair.sent.ext.siteID; - assert.equal(actualSiteID, expectedSiteID, "request " + pair.name + " site ID is set to " + expectedSiteID); - assert.isNumber( actualSiteID, "site ID is number"); - } - - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - }); - - it('test_prebid_indexAdapter_size_singleArr: single sized array -> width and height in integer in request', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", IndexUtils.supportedSizes[0] ) - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; - - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } - - assert.equal( sidMatched.unmatched.configured.length, 0, "All configured bids are in impression Obj"); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - - }); - - it('test_prebid_indexAdapter_size_singleDim: missing width/height -> size is ignored, no ad server request for bad size', function () { - var oneDimSize = [728]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], oneDimSize, IndexUtils.supportedSizes[1] ] ) - ]; - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + if (param.missingtier3SiteID) { + assert.equal(sidMatched.unmatched.configured.length, 0, 'one configured bid is missing in impression Obj'); + } else { + assert.equal(sidMatched.unmatched.configured.length, 1, 'one configured bid is missing in impression Obj'); + } + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + } + }); + }; + + for (var i = 0; i < test_indexAdapter_tier3siteid.length; i++) { + var test = test_indexAdapter_tier3siteid[i]; + base_prebid_indexAdapter_tier3siteid(test.testname, test.param, test.expected); + } + + it('test_prebid_indexAdapter_siteID_multiple: multiple slots have same siteIDs -> all slots in ad server request with the same site IDs', function() { + var first_slot = { + slotName: 'slot1', + siteID: 111111, + }; + var second_slot = { + slotName: 'slot2', + siteID: 111111, // same as first slot + }; + + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, first_slot['slotName'], [ IndexUtils.supportedSizes[0] ], { siteID: first_slot['siteID'] }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, second_slot['slotName'], [ IndexUtils.supportedSizes[1] ], { siteID: second_slot['siteID'] }), + ]; + + adapter.callBids({ bids: configuredBids }); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + + var expectedSiteID = pair.configured.params.siteID; + var actualSiteID = pair.sent.ext.siteID; + assert.equal(actualSiteID, expectedSiteID, 'request ' + pair.name + ' site ID is set to ' + expectedSiteID); + assert.isNumber(actualSiteID, 'site ID is number'); + } + + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + }); + + it('test_prebid_indexAdapter_siteID_different: multiple slots have different siteIDs -> all slots in ad server request with the different site IDs', function() { + var first_slot = { + slotName: 'slot1', + siteID: 111111, + }; + var second_slot = { + slotName: 'slot2', + siteID: 222222, + }; + + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, first_slot['slotName'], [ IndexUtils.supportedSizes[0] ], { siteID: first_slot['siteID'] }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, second_slot['slotName'], [ IndexUtils.supportedSizes[1] ], { siteID: second_slot['siteID'] }), + ]; + + adapter.callBids({ bids: configuredBids }); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + + var expectedSiteID = pair.configured.params.siteID; + var actualSiteID = pair.sent.ext.siteID; + assert.equal(actualSiteID, expectedSiteID, 'request ' + pair.name + ' site ID is set to ' + expectedSiteID); + assert.isNumber(actualSiteID, 'site ID is number'); + } + + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + }); + + it('test_prebid_indexAdapter_size_singleArr: single sized array -> width and height in integer in request', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', IndexUtils.supportedSizes[0]) + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSID(expandedBids, impressionObj); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } + + assert.equal(sidMatched.unmatched.configured.length, 0, 'All configured bids are in impression Obj'); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + }); + + it('test_prebid_indexAdapter_size_singleDim: missing width/height -> size is ignored, no ad server request for bad size', function () { + var oneDimSize = [728]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], oneDimSize, IndexUtils.supportedSizes[1] ]) + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); + + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); + + var impressionObj = requestJSON.r.imp; + + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - var impressionObj = requestJSON.r.imp; + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; + + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } + + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, oneDimSize, 'configured bid not in impression obj size width is' + JSON.stringify(oneDimSize)); + }); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + it('test_prebid_indexAdapter_size_missing: missing size -> slot is ignored, no ad server request', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', []) + ]; + adapter.callBids({ bids: configuredBids }); + + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'no request made to AS'); + }); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + it('test_prebid_indexAdapter_size_negativeWidth: negative width -> size is ignored, no ad server request for bad size', function () { + var invalidSize = [-728, 90]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], invalidSize, IndexUtils.supportedSizes[1] ]) + ]; + adapter.callBids({ bids: configuredBids }); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, oneDimSize, "configured bid not in impression obj size width is" + JSON.stringify(oneDimSize) ); - }); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - it('test_prebid_indexAdapter_size_missing: missing size -> slot is ignored, no ad server request', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [] ) - ]; - adapter.callBids({ bids: configuredBids }); + var impressionObj = requestJSON.r.imp; - assert.isUndefined( adLoader.loadScript.firstCall.args[0], "no request made to AS"); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - it('test_prebid_indexAdapter_size_negativeWidth: negative width -> size is ignored, no ad server request for bad size', function () { - var invalidSize = [-728,90]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], invalidSize, IndexUtils.supportedSizes[1] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, invalidSize, 'configured bid not in impression obj size width is' + JSON.stringify(invalidSize)); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_size_negativeHeight: negative height -> size is ignored, no ad server request for bad size', function () { + var invalidSize = [728, -90]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], invalidSize, IndexUtils.supportedSizes[1] ]) + ]; + adapter.callBids({ bids: configuredBids }); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var impressionObj = requestJSON.r.imp; - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, invalidSize, "configured bid not in impression obj size width is" + JSON.stringify(invalidSize) ); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - it('test_prebid_indexAdapter_size_negativeHeight: negative height -> size is ignored, no ad server request for bad size', function () { - var invalidSize = [728,-90]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], invalidSize, IndexUtils.supportedSizes[1] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, invalidSize, 'configured bid not in impression obj size width is' + JSON.stringify(invalidSize)); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_size_quoted: height and width quoted -> invalid size, no ad server request for invalid size', function () { + var otherSize = ['300', '250']; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ]) + ]; + adapter.callBids({ bids: configuredBids }); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)) - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var impressionObj = requestJSON.r.imp; - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, invalidSize, "configured bid not in impression obj size width is" + JSON.stringify(invalidSize) ); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - it('test_prebid_indexAdapter_size_quoted: height and width quoted -> invalid size, no ad server request for invalid size', function () { - var otherSize = ['300','250']; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 0, '0 configured bid is not in impression Obj'); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_size_float: height and width float -> invalid size, no ad server request for invalid size ', function () { + var otherSize = [300.1, 250]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ]) + ]; + adapter.callBids({ bids: configuredBids }); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var impressionObj = requestJSON.r.imp; - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 0, "0 configured bid is not in impression Obj"); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - it('test_prebid_indexAdapter_size_float: height and width float -> invalid size, no ad server request for invalid size ', function () { - var otherSize = [300.1,250]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, otherSize, 'configured bid not in impression obj size width is' + JSON.stringify(otherSize)); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_size_string_1_pba23: height and width string -> invalid size, no ad server request for invalid size ', function () { + var otherSize = [String(IndexUtils.supportedSizes[0][0]), String(IndexUtils.supportedSizes[0][1])]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[1], otherSize, IndexUtils.supportedSizes[2] ]) + ]; + adapter.callBids({ bids: configuredBids }); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var impressionObj = requestJSON.r.imp; - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, otherSize, "configured bid not in impression obj size width is" + JSON.stringify(otherSize) ); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - it('test_prebid_indexAdapter_size_string_1_pba23: height and width string -> invalid size, no ad server request for invalid size ', function () { - var otherSize = [String(IndexUtils.supportedSizes[0][0]), String(IndexUtils.supportedSizes[0][1])]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[1], otherSize, IndexUtils.supportedSizes[2] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 0, 'all configured bids are in impression Obj'); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_size_string_2: whole size is string -> invalid size, no ad server request for invalid size ', function () { + var otherSize = 'gallery'; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ]) + ]; + adapter.callBids({ bids: configuredBids }); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var impressionObj = requestJSON.r.imp; - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 0, "all configured bids are in impression Obj"); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - it('test_prebid_indexAdapter_size_string_2: whole size is string -> invalid size, no ad server request for invalid size ', function () { - var otherSize = "gallery"; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, otherSize, 'configured bid not in impression obj size width is' + JSON.stringify(otherSize)); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_size_string_3: entire size structure is string -> no ad server request since size is invalid', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', 'gallery') + ]; + adapter.callBids({ bids: configuredBids }); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'no request made to AS'); + }); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + it('test_prebid_indexAdapter_size_hash_1: height or width hash -> invalid size, no ad server request for invalid size ', function () { + var otherSize = [{728: 1}, 90]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ]) + ]; + adapter.callBids({ bids: configuredBids }); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, otherSize, "configured bid not in impression obj size width is" + JSON.stringify(otherSize) ); - }); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - it('test_prebid_indexAdapter_size_string_3: entire size structure is string -> no ad server request since size is invalid', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", "gallery" ) - ]; - adapter.callBids({ bids: configuredBids }); + var impressionObj = requestJSON.r.imp; - assert.isUndefined( adLoader.loadScript.firstCall.args[0], "no request made to AS"); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - it('test_prebid_indexAdapter_size_hash_1: height or width hash -> invalid size, no ad server request for invalid size ', function () { - var otherSize = [{728:1},90]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, otherSize, 'configured bid not in impression obj size width is' + JSON.stringify(otherSize)); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_size_hash_2: whole size hash -> invalid size, no ad server request for invalid size ', function () { + var otherSize = {728: 1, 90: 1}; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ]) + ]; + adapter.callBids({ bids: configuredBids }); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var impressionObj = requestJSON.r.imp; - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, otherSize, "configured bid not in impression obj size width is" + JSON.stringify(otherSize) ); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - it('test_prebid_indexAdapter_size_hash_2: whole size hash -> invalid size, no ad server request for invalid size ', function () { - var otherSize = {728:1,90:1}; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, otherSize, 'configured bid not in impression obj size width is' + JSON.stringify(otherSize)); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_size_hash_3: entire size structure is hash -> no ad server request since size is invalid', function () { + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', {728: 90}) + ]; + adapter.callBids({ bids: configuredBids }); - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + assert.isUndefined(adLoader.loadScript.firstCall.args[0], 'no request made to AS'); + }); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + it('test_prebid_indexAdapter_size_swap: swap size and width for valid so now its invalid -> unsupportedsize, no ad server request for unsupported size ', function () { + var otherSize = [90, 728]; + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ]) + ]; + adapter.callBids({ bids: configuredBids }); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, otherSize, "configured bid not in impression obj size width is" + JSON.stringify(otherSize) ); - }); + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - it('test_prebid_indexAdapter_size_hash_3: entire size structure is hash -> no ad server request since size is invalid', function () { - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", {728:90} ) - ]; - adapter.callBids({ bids: configuredBids }); + var impressionObj = requestJSON.r.imp; - assert.isUndefined( adLoader.loadScript.firstCall.args[0], "no request made to AS"); - }); + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - it('test_prebid_indexAdapter_size_swap: swap size and width for valid so now its invalid -> unsupportedsize, no ad server request for unsupported size ', function () { - var otherSize = [90,728]; - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ IndexUtils.supportedSizes[0], otherSize, IndexUtils.supportedSizes[1] ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, otherSize, 'configured bid not in impression obj size width is' + JSON.stringify(otherSize)); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_size_sameWidth: same width for all sizes in a slot -> ad server request only for supported sizes', function () { + var valid1Size = [300, 250]; + var otherSize = [300, 999]; + var valid2Size = [300, 600]; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ valid1Size, otherSize, valid2Size ]) + ]; + adapter.callBids({ bids: configuredBids }); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, otherSize, "configured bid not in impression obj size width is" + JSON.stringify(otherSize) ); - }); + var impressionObj = requestJSON.r.imp; - it('test_prebid_indexAdapter_size_sameWidth: same width for all sizes in a slot -> ad server request only for supported sizes', function () { - var valid1Size = [300,250]; - var otherSize = [300,999]; - var valid2Size = [300,600]; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ valid1Size, otherSize, valid2Size ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, otherSize, 'configured bid not in impression obj size width is' + JSON.stringify(otherSize)); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_size_sameHeight: same height for all sizes in a slot -> ad server request only for supported sizes', function () { + var valid1Size = [120, 600]; + var otherSize = [999, 600]; + var valid2Size = [300, 600]; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, 'slot_1', [ valid1Size, otherSize, valid2Size ]) + ]; + adapter.callBids({ bids: configuredBids }); - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, otherSize, "configured bid not in impression obj size width is" + JSON.stringify(otherSize) ); - }); + var impressionObj = requestJSON.r.imp; - it('test_prebid_indexAdapter_size_sameHeight: same height for all sizes in a slot -> ad server request only for supported sizes', function () { - var valid1Size = [120,600]; - var otherSize = [999,600]; - var valid2Size = [300,600]; + var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); + var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, "slot_1", [ valid1Size, otherSize, valid2Size ] ) - ]; - adapter.callBids({ bids: configuredBids }); + for (var i = 0; i < sidMatched.matched.length; i++) { + var pair = sidMatched.matched[i]; - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); + assert.equal(pair.sent.banner.w, pair.configured.size[0], 'request ' + pair.name + ' width is set to ' + pair.configured.size[0]); + assert.equal(pair.sent.banner.h, pair.configured.size[1], 'request ' + pair.name + ' width is set to ' + pair.configured.size[1]); + assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, 'request ' + pair.name + ' siteID is set to ' + pair.configured.params.siteID); + } - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); + assert.equal(sidMatched.unmatched.sent.length, 0, 'All bids in impression object are from configured bids'); + assert.equal(sidMatched.unmatched.configured.length, 1, '1 configured bid is not in impression Obj'); + assert.equal(sidMatched.unmatched.configured[0].size, otherSize, 'configured bid not in impression obj size width is' + JSON.stringify(otherSize)); + }); - var impressionObj = requestJSON.r.imp; + it('test_prebid_indexAdapter_request_sizeID_validation_1: multiple prebid size slot, index slots with size for all prebid slots, 1 slot is not configured properly -> all size in AS request, except misconfigured slot', function () { + var slotID_1 = 52; + var slotID_2 = 53; + var slotSizes_1 = IndexUtils.supportedSizes[0]; + var slotSizes_2 = IndexUtils.supportedSizes[1]; - var expandedBids = configuredBids.map(bid => IndexUtils.expandSizes(bid)); - var sidMatched = IndexUtils.matchBidsOnSize(expandedBids, impressionObj); + var configuredBids = [ + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotID_1, [ slotSizes_1, slotSizes_2 ], { slotSize: [ 728, 'invalid' ] }), + IndexUtils.createBidSlot(IndexUtils.DefaultPlacementCodePrefix, slotID_2, [ slotSizes_1, slotSizes_2 ], { slotSize: slotSizes_2 }) + ]; - for ( var i = 0; i < sidMatched.matched.length; i++) { - var pair = sidMatched.matched[i]; + adapter.callBids({ bids: configuredBids }); - assert.equal(pair.sent.banner.w, pair.configured.size[0], "request " + pair.name + " width is set to " + pair.configured.size[0]); - assert.equal(pair.sent.banner.h, pair.configured.size[1], "request " + pair.name + " width is set to " + pair.configured.size[1]); - assert.equal(pair.sent.ext.siteID, pair.configured.params.siteID, "request " + pair.name + " siteID is set to " + pair.configured.params.siteID); - } + assert.isTrue(adLoader.loadScript.called, 'loadScript get request'); - assert.equal( sidMatched.unmatched.sent.length, 0, "All bids in impression object are from configured bids"); - assert.equal( sidMatched.unmatched.configured.length, 1, "1 configured bid is not in impression Obj"); - assert.equal( sidMatched.unmatched.configured[0].size, otherSize, "configured bid not in impression obj size width is" + JSON.stringify(otherSize) ); - }); + assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, 'request is headertag request'); - it('test_prebid_indexAdapter_request_sizeID_validation_1: multiple prebid size slot, index slots with size for all prebid slots, 1 slot is not configured properly -> all size in AS request, except misconfigured slot', function () { - var slotID_1 = 52; - var slotID_2 = 53; - var slotSizes_1 = IndexUtils.supportedSizes[0]; - var slotSizes_2 = IndexUtils.supportedSizes[1]; + var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); + assert.isNotNull(requestJSON.r.imp, 'headertag request include impression object'); - var configuredBids = [ - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotID_1, [ slotSizes_1, slotSizes_2 ], { slotSize : [ 728, 'invalid' ] } ), - IndexUtils.createBidSlot( IndexUtils.DefaultPlacementCodePrefix, slotID_2, [ slotSizes_1, slotSizes_2 ], { slotSize : slotSizes_2 } ) - ]; - - adapter.callBids({ bids: configuredBids }); - - assert.isTrue(adLoader.loadScript.called, "loadScript get request"); - - assert.include(adLoader.loadScript.firstCall.args[0], HeaderTagRequest, "request is headertag request"); - - var requestJSON = IndexUtils.parseIndexRequest(adLoader.loadScript.firstCall.args[0]); - assert.isNotNull( requestJSON.r.imp, "headertag request include impression object" ); - - var impressionObj = requestJSON.r.imp; - assert.equal(impressionObj.length, 1, "1 slot is made in the request" ); - - assert.equal(impressionObj[0].banner.w, slotSizes_2[0], "the width made in the request matches with request: " + slotSizes_2[0] ); - assert.equal(impressionObj[0].banner.h, slotSizes_2[1], "the height made in the request matches with request: " + slotSizes_2[1] ); - assert.equal(impressionObj[0].ext.sid, slotID_2, "slotID in the request matches with configuration: " + slotID_2 ); - assert.equal(impressionObj[0].ext.siteID, IndexUtils.DefaultSiteID, "siteID in the request matches with request: " + IndexUtils.DefaultSiteID ); - }); + var impressionObj = requestJSON.r.imp; + assert.equal(impressionObj.length, 1, '1 slot is made in the request'); + assert.equal(impressionObj[0].banner.w, slotSizes_2[0], 'the width made in the request matches with request: ' + slotSizes_2[0]); + assert.equal(impressionObj[0].banner.h, slotSizes_2[1], 'the height made in the request matches with request: ' + slotSizes_2[1]); + assert.equal(impressionObj[0].ext.sid, slotID_2, 'slotID in the request matches with configuration: ' + slotID_2); + assert.equal(impressionObj[0].ext.siteID, IndexUtils.DefaultSiteID, 'siteID in the request matches with request: ' + IndexUtils.DefaultSiteID); + }); }); diff --git a/test/spec/adapters/inneractive_spec.js b/test/spec/adapters/inneractive_spec.js index 819e01b0139..1aade6e9c26 100644 --- a/test/spec/adapters/inneractive_spec.js +++ b/test/spec/adapters/inneractive_spec.js @@ -4,7 +4,6 @@ import {expect} from 'chai'; import {default as InneractiveAdapter} from 'src/adapters/inneractive'; import bidmanager from 'src/bidmanager'; - // Using plain-old-style functions, why? see: http://mochajs.org/#arrow-functions describe('InneractiveAdapter', function () { let adapter, @@ -13,60 +12,60 @@ describe('InneractiveAdapter', function () { beforeEach(function () { adapter = InneractiveAdapter.createNew(); bidRequest = { - bidderCode: "inneractive", + bidderCode: 'inneractive', bids: [ { - bidder: "inneractive", + bidder: 'inneractive', params: { - appId: "", + appId: '', }, - placementCode: "div-gpt-ad-1460505748561-0", + placementCode: 'div-gpt-ad-1460505748561-0', sizes: [[300, 250], [300, 600]], - bidId: "507e8db167d219", - bidderRequestId: "49acc957f92917", - requestId: "51381cd0-c29c-405b-9145-20f60abb1e76" + bidId: '507e8db167d219', + bidderRequestId: '49acc957f92917', + requestId: '51381cd0-c29c-405b-9145-20f60abb1e76' }, { - bidder: "inneractive", + bidder: 'inneractive', params: { - noappId: "...", + noappId: '...', }, - placementCode: "div-gpt-ad-1460505661639-0", + placementCode: 'div-gpt-ad-1460505661639-0', sizes: [[728, 90], [970, 90]], - bidId: "507e8db167d220", - bidderRequestId: "49acc957f92917", - requestId: "51381cd0-c29c-405b-9145-20f60abb1e76" + bidId: '507e8db167d220', + bidderRequestId: '49acc957f92917', + requestId: '51381cd0-c29c-405b-9145-20f60abb1e76' }, { - bidder: "inneractive", + bidder: 'inneractive', params: { - APP_ID: "Inneractive_AndroidHelloWorld_Android", - spotType: "rectangle", + APP_ID: 'Inneractive_AndroidHelloWorld_Android', + spotType: 'rectangle', customParams: { Portal: 7002, } }, - placementCode: "div-gpt-ad-1460505748561-0", + placementCode: 'div-gpt-ad-1460505748561-0', sizes: [[320, 50], [300, 600]], - bidId: "507e8db167d221", - bidderRequestId: "49acc957f92917", - requestId: "51381cd0-c29c-405b-9145-20f60abb1e76" + bidId: '507e8db167d221', + bidderRequestId: '49acc957f92917', + requestId: '51381cd0-c29c-405b-9145-20f60abb1e76' }, { - bidder: "inneractive", + bidder: 'inneractive', params: { - appId: "Inneractive_IosHelloWorld_iPhone", - spotType: "banner", // Just for coverage considerations, no real impact in production + appId: 'Inneractive_IosHelloWorld_iPhone', + spotType: 'banner', // Just for coverage considerations, no real impact in production customParams: { portal: 7001, gender: '' } }, - placementCode: "div-gpt-ad-1460505661639-0", + placementCode: 'div-gpt-ad-1460505661639-0', sizes: [[728, 90], [970, 90]], - bidId: "507e8db167d222", - bidderRequestId: "49acc957f92917", - requestId: "51381cd0-c29c-405b-9145-20f60abb1e76" + bidId: '507e8db167d222', + bidderRequestId: '49acc957f92917', + requestId: '51381cd0-c29c-405b-9145-20f60abb1e76' }] }; }); @@ -76,9 +75,9 @@ describe('InneractiveAdapter', function () { it('should contain "mbwError" the inside event report url', function () { const Reporter = InneractiveAdapter._getUtils().Reporter; const extraDetailsParam = { - "appId": "CrunchMind_DailyDisclosure_other", - "spotType": "rectangle", - "portal": 7002 + 'appId': 'CrunchMind_DailyDisclosure_other', + 'spotType': 'rectangle', + 'portal': 7002 }; let eventReportUrl = Reporter.getEventUrl('HBPreBidError', extraDetailsParam); expect(eventReportUrl).to.include('mbwError'); @@ -115,9 +114,9 @@ describe('InneractiveAdapter', function () { it('should not issue a request', function () { const Reporter = InneractiveAdapter._getUtils().Reporter; Reporter.getEventUrl('HBPreBidError', { - "appId": "CrunchMind_DailyDisclosure_other", - "spotType": "rectangle", - "portal": 7002 + 'appId': 'CrunchMind_DailyDisclosure_other', + 'spotType': 'rectangle', + 'portal': 7002 }); delete bidRequest.bids; @@ -133,7 +132,6 @@ describe('InneractiveAdapter', function () { sinon.spy(adapter, '_isValidRequest'); adapter.callBids(bidRequest); - for (let id = 0; id < INVALID_BIDS_COUNT; id++) { expect(adapter._isValidRequest.getCall(id).returned(false)).to.be.true; // jshint ignore:line } @@ -175,30 +173,30 @@ describe('InneractiveAdapter', function () { beforeEach(function () { adServerResponse = { headers: { - "X-IA-Ad-Height": 250, - "X-IA-Ad-Width": 300, - "X-IA-Error": "OK", - "X-IA-Pricing": "CPM", - "X-IA-Pricing-Currency": "USD", - "X-IA-Pricing-Value": 0.0005 + 'X-IA-Ad-Height': 250, + 'X-IA-Ad-Width': 300, + 'X-IA-Error': 'OK', + 'X-IA-Pricing': 'CPM', + 'X-IA-Pricing-Currency': 'USD', + 'X-IA-Pricing-Value': 0.0005 }, body: { ad: { - html: "
" + html: '' }, config: { tracking: { impressions: [ - "http://event.inner-active.mobi/simpleM2M/reportEvent?eventArchetype=impress…pe=3&network=Inneractive_CS&acp=&pcp=&secure=false&rtb=false&houseAd=false" + 'http://event.inner-active.mobi/simpleM2M/reportEvent?eventArchetype=impress…pe=3&network=Inneractive_CS&acp=&pcp=&secure=false&rtb=false&houseAd=false' ], clicks: [ - "http://event.inner-active.mobi/simpleM2M/reportEvent?eventArchetype=richMed…pe=3&network=Inneractive_CS&acp=&pcp=&secure=false&rtb=false&houseAd=false", - "" + 'http://event.inner-active.mobi/simpleM2M/reportEvent?eventArchetype=richMed…pe=3&network=Inneractive_CS&acp=&pcp=&secure=false&rtb=false&houseAd=false', + '' ], - passback: "http://event.inner-active.mobi/simpleM2M/reportEvent?eventArchetype=passbac…pe=3&network=Inneractive_CS&acp=&pcp=&secure=false&rtb=false&houseAd=false" + passback: 'http://event.inner-active.mobi/simpleM2M/reportEvent?eventArchetype=passbac…pe=3&network=Inneractive_CS&acp=&pcp=&secure=false&rtb=false&houseAd=false' }, moat: { - countryCode: "IL" + countryCode: 'IL' } } } @@ -238,20 +236,20 @@ describe('InneractiveAdapter', function () { beforeEach(function () { passbackAdServerResponse = { headers: { - "X-IA-Error": "House Ad", - "X-IA-Content": 600145, - "X-IA-Cid": 99999, - "X-IA-Publisher": 206536, - "Content-Type": "application/json; charset=UTF-8", - "X-IA-Session": 6512147119979250840, - "X-IA-AdNetwork": "inneractive360" + 'X-IA-Error': 'House Ad', + 'X-IA-Content': 600145, + 'X-IA-Cid': 99999, + 'X-IA-Publisher': 206536, + 'Content-Type': 'application/json; charset=UTF-8', + 'X-IA-Session': 6512147119979250840, + 'X-IA-AdNetwork': 'inneractive360' }, body: { - "ad": { - "html": "" + 'ad': { + 'html': '' }, - "config": { - "passback": "http://event.inner-active.mobi/simpleM2M/reportEvent?eventArchetype=passbac…pe=3&network=Inneractive_CS&acp=&pcp=&secure=false&rtb=false&houseAd=false" + 'config': { + 'passback': 'http://event.inner-active.mobi/simpleM2M/reportEvent?eventArchetype=passbac…pe=3&network=Inneractive_CS&acp=&pcp=&secure=false&rtb=false&houseAd=false' } } }; @@ -271,7 +269,7 @@ describe('InneractiveAdapter', function () { it('should handle responses from our server in case we had no ad to offer', function () { const n = bidRequest.bids.length; - bidRequest.bids[n - 1].params.appId = "Komoona_InquisitrRectangle2_other"; + bidRequest.bids[n - 1].params.appId = 'Komoona_InquisitrRectangle2_other'; server.respondWith([200, headers, body]); adapter.callBids(bidRequest); server.respond(); diff --git a/test/spec/adapters/innity_spec.js b/test/spec/adapters/innity_spec.js index 850cdf99041..c87c8deca22 100644 --- a/test/spec/adapters/innity_spec.js +++ b/test/spec/adapters/innity_spec.js @@ -1,162 +1,157 @@ describe('innity adapter tests', function () { - - var expect = require('chai').expect; - var urlParse = require('url-parse'); - var querystringify = require('querystringify'); - var adapter = require('src/adapters/innity'); - var adLoader = require('src/adloader'); - var bidmanager = require('src/bidmanager'); - - var stubLoadScript; - - beforeEach(function () { - stubLoadScript = sinon.stub(adLoader, 'loadScript'); + var expect = require('chai').expect; + var urlParse = require('url-parse'); + var querystringify = require('querystringify'); + var adapter = require('src/adapters/innity'); + var adLoader = require('src/adloader'); + var bidmanager = require('src/bidmanager'); + + var stubLoadScript; + + beforeEach(function () { + stubLoadScript = sinon.stub(adLoader, 'loadScript'); + }); + + afterEach(function () { + stubLoadScript.restore(); + }); + + describe('creation of bid url', function () { + if (typeof ($$PREBID_GLOBAL$$._bidsReceived) === 'undefined') { + $$PREBID_GLOBAL$$._bidsReceived = []; + } + if (typeof ($$PREBID_GLOBAL$$._bidsRequested) === 'undefined') { + $$PREBID_GLOBAL$$._bidsRequested = []; + } + + it('bid request for single placement', function () { + var params = { + bids: [{ + placementCode: '/19968336/header-bid-tag-0', + sizes: [[300, 250]], + bidId: 'b12345', + bidder: 'innity', + params: { pub: '267', zone: '62546' } + }] + }; + + adapter().callBids(params); + + var bidUrl = stubLoadScript.getCall(0).args[0]; + + sinon.assert.calledOnce(stubLoadScript); + + var parsedBidUrl = urlParse(bidUrl); + var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); + + expect(parsedBidUrlQueryString).to.have.property('pub').and.to.equal('267'); + expect(parsedBidUrlQueryString).to.have.property('zone').and.to.equal('62546'); + expect(parsedBidUrlQueryString).to.have.property('width').and.to.equal('300'); + expect(parsedBidUrlQueryString).to.have.property('height').and.to.equal('250'); }); - - afterEach(function () { - stubLoadScript.restore(); - }); - - describe('creation of bid url', function () { - - if (typeof($$PREBID_GLOBAL$$._bidsReceived) === "undefined") { - $$PREBID_GLOBAL$$._bidsReceived = []; - } - if (typeof($$PREBID_GLOBAL$$._bidsRequested) === "undefined") { - $$PREBID_GLOBAL$$._bidsRequested = []; - } - - it('bid request for single placement', function () { - - var params = { - bids: [{ - placementCode: '/19968336/header-bid-tag-0', - sizes: [[300,250]], - bidId: 'b12345', - bidder: 'innity', - params: { pub: '267', zone: '62546' } - }] - }; - - adapter().callBids(params); - - var bidUrl = stubLoadScript.getCall(0).args[0]; - - sinon.assert.calledOnce(stubLoadScript); - - var parsedBidUrl = urlParse(bidUrl); - var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - - expect(parsedBidUrlQueryString).to.have.property('pub').and.to.equal('267'); - expect(parsedBidUrlQueryString).to.have.property('zone').and.to.equal('62546'); - expect(parsedBidUrlQueryString).to.have.property('width').and.to.equal('300'); - expect(parsedBidUrlQueryString).to.have.property('height').and.to.equal('250'); - }); + }); + + describe('handling bid response', function () { + it('should return complete bid response', function() { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + + var params = { + bids: [{ + placementCode: '/19968336/header-bid-tag-0', + sizes: [[300, 250]], + bidId: 'b12345', + bidder: 'innity', + params: { pub: '267', zone: '62546' } + }] + }; + + var response = { + cpm: 100, + width: 300, + height: 250, + callback_uid: 'b12345', + tag: '" + 'placementid': 'abcd123123dcba', + 'uuid': '30e5e911c00703', + 'width': 728, + 'height': 90, + 'cpm': 0.5, + 'creative': '' } ] }; describe('komoonaAdapter', () => { - let adapter; beforeEach(() => adapter = Adapter.createNew()); describe('request function', () => { - let xhr; let requests; let pbConfig; @@ -58,7 +55,7 @@ describe('komoonaAdapter', () => { requests = []; xhr.onCreate = request => requests.push(request); pbConfig = REQUEST; - //just a single slot + // just a single slot pbConfig.bids = [pbConfig.bids[0]]; }); @@ -75,11 +72,11 @@ describe('komoonaAdapter', () => { it('requires placementid and hbid', () => { let backup = pbConfig.bids[0].params; - pbConfig.bids[0].params = {placementid : 1234}; //no hbid + pbConfig.bids[0].params = {placementid: 1234}; // no hbid adapter.callBids(pbConfig); expect(requests).to.be.empty; - pbConfig.bids[0].params = {hbid : 1234}; //no placementid + pbConfig.bids[0].params = {hbid: 1234}; // no placementid adapter.callBids(pbConfig); expect(requests).to.be.empty; @@ -94,7 +91,6 @@ describe('komoonaAdapter', () => { }); describe('response handler', () => { - let server; beforeEach(() => { @@ -121,10 +117,10 @@ describe('komoonaAdapter', () => { it('handles nobid responses', () => { server.respondWith(JSON.stringify({ - "bids": [{ - "cpm": 0, - "creative": "", - "uuid": "30e5e911c00703" + 'bids': [{ + 'cpm': 0, + 'creative': '', + 'uuid': '30e5e911c00703' }] })); @@ -152,7 +148,5 @@ describe('komoonaAdapter', () => { 'Bid returned empty or error response' ); }); - }); - }); diff --git a/test/spec/adapters/lifestreet_spec.js b/test/spec/adapters/lifestreet_spec.js index 848c899fcbf..63922799a4c 100644 --- a/test/spec/adapters/lifestreet_spec.js +++ b/test/spec/adapters/lifestreet_spec.js @@ -28,7 +28,7 @@ const BIDDER_REQUEST = { timeout: 3000 }; -describe ('LifestreetAdapter', () => { +describe('LifestreetAdapter', () => { let adapter; beforeEach(() => adapter = new LifestreetAdapter()); @@ -100,7 +100,7 @@ describe ('LifestreetAdapter', () => { expect(tagRequests).to.be.empty; }); - it ('adkey is not provided', () => { + it('adkey is not provided', () => { request.bids[0].params.adkey = ''; adapter.callBids(request); expect(tagRequests).to.be.empty; @@ -228,4 +228,4 @@ describe ('LifestreetAdapter', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/spec/adapters/mantis_spec.js b/test/spec/adapters/mantis_spec.js index 4e277d2d848..29332dacf7e 100644 --- a/test/spec/adapters/mantis_spec.js +++ b/test/spec/adapters/mantis_spec.js @@ -1,170 +1,168 @@ 'use strict'; describe('mantis adapter tests', function () { - const expect = require('chai').expect; - const adapter = require('src/adapters/mantis.js'); - const bidmanager = require('src/bidmanager'); - const adloader = require('src/adloader'); - const constants = require('src/constants.json'); - - var mantis, sandbox; - - beforeEach(() => { - mantis = new adapter(); - sandbox = sinon.sandbox.create(); - }); - - - afterEach(() => { - sandbox.restore(); - - delete window.context; - delete window.mantis_link; - delete window.mantis_breakpoint; - delete window.mantis_uuid; - }); - - var callBidExample = { - bidderCode: 'mantis', - bids: [ - { - bidId: 'bidId1', - bidder: 'mantis', - placementCode: 'foo', - sizes: [[728, 90]], - params: { - property: '1234', - zoneId: 'zone1' - } - }, - { - bidId: 'bidId2', - bidder: 'mantis', - placementCode: 'bar', - sizes: [[300, 600], [300, 250]], - params: { - property: '1234', - zoneId: 'zone2' - } - } - ] - }; - - describe('callBids', () => { - it('should create appropriate bid responses', () => { - sandbox.stub(bidmanager, 'addBidResponse'); - sandbox.stub(adloader, 'loadScript', function (url) { - var jsonp = eval(decodeURIComponent(url.match(/jsonp=(.*)&property/)[1])); - - jsonp({ - ads: { - bidId1: { - cpm: 1, - html: '', - width: 300, - height: 600 - } - } - }); - }); - - mantis.callBids(callBidExample); - - sinon.assert.calledTwice(bidmanager.addBidResponse); - - expect(bidmanager.addBidResponse.firstCall.args[0]).to.eql('foo'); - - var bid1 = bidmanager.addBidResponse.firstCall.args[1]; - expect(bid1.getStatusCode()).to.eql(constants.STATUS.GOOD); - expect(bid1.bidderCode).to.eql('mantis'); - expect(bid1.cpm).to.eql(1); - expect(bid1.ad).to.eql(''); - expect(bid1.width).to.eql(300); - expect(bid1.height).to.eql(600); - - expect(bidmanager.addBidResponse.secondCall.args[0]).to.eql('bar'); - - var bid2 = bidmanager.addBidResponse.secondCall.args[1]; - expect(bid2.getStatusCode()).to.eql(constants.STATUS.NO_BID); - expect(bid2.bidderCode).to.eql('mantis'); - }); - - it('should load script with relevant bid data', () => { - sandbox.stub(adloader, 'loadScript'); - - mantis.callBids(callBidExample); - - sinon.assert.calledOnce(adloader.loadScript); - - var serverCall = adloader.loadScript.firstCall.args[0]; - - expect(serverCall).to.match(/buster=[0-9]+&/); - expect(serverCall).to.match(/tz=-?[0-9]+&/); - expect(serverCall).to.match(/secure=(true|false)&/); - expect(serverCall).to.string('property=1234&'); - expect(serverCall).to.string('bids[0][bidId]=bidId1&'); - expect(serverCall).to.string('bids[0][sizes][0][width]=728&'); - expect(serverCall).to.string('bids[0][sizes][0][height]=90&'); - expect(serverCall).to.string('bids[0][config][zoneId]=zone1&'); - expect(serverCall).to.string('bids[1][bidId]=bidId2&'); - expect(serverCall).to.string('bids[1][sizes][0][width]=300&'); - expect(serverCall).to.string('bids[1][sizes][0][height]=600&'); - expect(serverCall).to.string('bids[1][sizes][1][width]=300&'); - expect(serverCall).to.string('bids[1][sizes][1][height]=250&'); - expect(serverCall).to.string('bids[1][config][zoneId]=zone2&'); - expect(serverCall).to.string('version=1'); - }); + const expect = require('chai').expect; + const adapter = require('src/adapters/mantis.js'); + const bidmanager = require('src/bidmanager'); + const adloader = require('src/adloader'); + const constants = require('src/constants.json'); + + var mantis, sandbox; + + beforeEach(() => { + mantis = new adapter(); + sandbox = sinon.sandbox.create(); + }); + + afterEach(() => { + sandbox.restore(); + + delete window.context; + delete window.mantis_link; + delete window.mantis_breakpoint; + delete window.mantis_uuid; + }); + + var callBidExample = { + bidderCode: 'mantis', + bids: [ + { + bidId: 'bidId1', + bidder: 'mantis', + placementCode: 'foo', + sizes: [[728, 90]], + params: { + property: '1234', + zoneId: 'zone1' + } + }, + { + bidId: 'bidId2', + bidder: 'mantis', + placementCode: 'bar', + sizes: [[300, 600], [300, 250]], + params: { + property: '1234', + zoneId: 'zone2' + } + } + ] + }; + + describe('callBids', () => { + it('should create appropriate bid responses', () => { + sandbox.stub(bidmanager, 'addBidResponse'); + sandbox.stub(adloader, 'loadScript', function (url) { + var jsonp = eval(decodeURIComponent(url.match(/jsonp=(.*)&property/)[1])); + + jsonp({ + ads: { + bidId1: { + cpm: 1, + html: '', + width: 300, + height: 600 + } + } + }); + }); + + mantis.callBids(callBidExample); + + sinon.assert.calledTwice(bidmanager.addBidResponse); + + expect(bidmanager.addBidResponse.firstCall.args[0]).to.eql('foo'); + + var bid1 = bidmanager.addBidResponse.firstCall.args[1]; + expect(bid1.getStatusCode()).to.eql(constants.STATUS.GOOD); + expect(bid1.bidderCode).to.eql('mantis'); + expect(bid1.cpm).to.eql(1); + expect(bid1.ad).to.eql(''); + expect(bid1.width).to.eql(300); + expect(bid1.height).to.eql(600); + + expect(bidmanager.addBidResponse.secondCall.args[0]).to.eql('bar'); + + var bid2 = bidmanager.addBidResponse.secondCall.args[1]; + expect(bid2.getStatusCode()).to.eql(constants.STATUS.NO_BID); + expect(bid2.bidderCode).to.eql('mantis'); + }); + + it('should load script with relevant bid data', () => { + sandbox.stub(adloader, 'loadScript'); + + mantis.callBids(callBidExample); + + sinon.assert.calledOnce(adloader.loadScript); + + var serverCall = adloader.loadScript.firstCall.args[0]; + + expect(serverCall).to.match(/buster=[0-9]+&/); + expect(serverCall).to.match(/tz=-?[0-9]+&/); + expect(serverCall).to.match(/secure=(true|false)&/); + expect(serverCall).to.string('property=1234&'); + expect(serverCall).to.string('bids[0][bidId]=bidId1&'); + expect(serverCall).to.string('bids[0][sizes][0][width]=728&'); + expect(serverCall).to.string('bids[0][sizes][0][height]=90&'); + expect(serverCall).to.string('bids[0][config][zoneId]=zone1&'); + expect(serverCall).to.string('bids[1][bidId]=bidId2&'); + expect(serverCall).to.string('bids[1][sizes][0][width]=300&'); + expect(serverCall).to.string('bids[1][sizes][0][height]=600&'); + expect(serverCall).to.string('bids[1][sizes][1][width]=300&'); + expect(serverCall).to.string('bids[1][sizes][1][height]=250&'); + expect(serverCall).to.string('bids[1][config][zoneId]=zone2&'); + expect(serverCall).to.string('version=1'); + }); /* tests below are to just adhere to code coverage requirements, but it is already tested in our own libraries/deployment process */ - it('should send uuid from window if set', () => { - sandbox.stub(adloader, 'loadScript'); + it('should send uuid from window if set', () => { + sandbox.stub(adloader, 'loadScript'); - window.mantis_uuid = '4321'; + window.mantis_uuid = '4321'; - mantis.callBids(callBidExample); + mantis.callBids(callBidExample); - sinon.assert.calledOnce(adloader.loadScript); + sinon.assert.calledOnce(adloader.loadScript); - var serverCall = adloader.loadScript.firstCall.args[0]; + var serverCall = adloader.loadScript.firstCall.args[0]; - expect(serverCall).to.string('uuid=4321&'); - }); + expect(serverCall).to.string('uuid=4321&'); + }); - it('should send mobile = true if breakpoint is hit', () => { - sandbox.stub(adloader, 'loadScript'); + it('should send mobile = true if breakpoint is hit', () => { + sandbox.stub(adloader, 'loadScript'); - window.mantis_link = true; // causes iframe detection to not work - window.mantis_breakpoint = 100000000; // force everything to be mobile + window.mantis_link = true; // causes iframe detection to not work + window.mantis_breakpoint = 100000000; // force everything to be mobile - mantis.callBids(callBidExample); + mantis.callBids(callBidExample); - sinon.assert.calledOnce(adloader.loadScript); + sinon.assert.calledOnce(adloader.loadScript); - var serverCall = adloader.loadScript.firstCall.args[0]; + var serverCall = adloader.loadScript.firstCall.args[0]; - expect(serverCall).to.string('mobile=true&'); - }); + expect(serverCall).to.string('mobile=true&'); + }); - it('should send different params if amp is detected', () => { - sandbox.stub(adloader, 'loadScript'); + it('should send different params if amp is detected', () => { + sandbox.stub(adloader, 'loadScript'); - window.context = { - tagName: "AMP-AD", - location: { - href: 'bar', - referrer: 'baz' - } - }; + window.context = { + tagName: 'AMP-AD', + location: { + href: 'bar', + referrer: 'baz' + } + }; - mantis.callBids(callBidExample); + mantis.callBids(callBidExample); - sinon.assert.calledOnce(adloader.loadScript); + sinon.assert.calledOnce(adloader.loadScript); - var serverCall = adloader.loadScript.firstCall.args[0]; + var serverCall = adloader.loadScript.firstCall.args[0]; - expect(serverCall).to.string('mobile=true&'); + expect(serverCall).to.string('mobile=true&'); // expect(serverCall).to.string('url=bar&'); - }); - }); + }); + }); }); - diff --git a/test/spec/adapters/memeglobal_spec.js b/test/spec/adapters/memeglobal_spec.js index 278d7986000..6aeaf161838 100644 --- a/test/spec/adapters/memeglobal_spec.js +++ b/test/spec/adapters/memeglobal_spec.js @@ -6,13 +6,13 @@ describe('memeglobal adapter tests', function () { var bidderName = 'memeglobal'; let stubLoadScript; - beforeEach(function () { - stubLoadScript = sinon.stub(adLoader, 'loadScript'); - }); + beforeEach(function () { + stubLoadScript = sinon.stub(adLoader, 'loadScript'); + }); - afterEach(function () { - stubLoadScript.restore(); - }); + afterEach(function () { + stubLoadScript.restore(); + }); function getBidSetForBidder() { return pbjs._bidsRequested.find(bidSet => bidSet.bidderCode === bidderName); @@ -20,7 +20,7 @@ describe('memeglobal adapter tests', function () { function checkBidsRequestedInit() { var bidSet = getBidSetForBidder(); - if (!bidSet){ + if (!bidSet) { var bidderRequest = { start: null, requestId: null, @@ -39,17 +39,17 @@ describe('memeglobal adapter tests', function () { it('callBids with params', function () { var params = { - bidderCode: 'memeglobal', + bidderCode: 'memeglobal', + bidder: 'memeglobal', + bids: [{ + bidId: '3c9408cdbf2f68', + sizes: [[300, 250]], bidder: 'memeglobal', - bids: [{ - bidId: '3c9408cdbf2f68', - sizes: [[300, 250]], - bidder: 'memeglobal', - params: { siteId: '3608', adSizes:'300x250' }, - requestId: '10b327aa396609', - placementCode: 'header-bid-tag-0' - } - ] + params: { siteId: '3608', adSizes: '300x250' }, + requestId: '10b327aa396609', + placementCode: 'header-bid-tag-0' + } + ] }; adapter().callBids(params); @@ -58,17 +58,17 @@ describe('memeglobal adapter tests', function () { it('callBids empty params', function () { var params = { - bidderCode: 'memeglobal', + bidderCode: 'memeglobal', + bidder: 'memeglobal', + bids: [{ + bidId: '3c9408cdbf2f68', + sizes: [[300, 250]], bidder: 'memeglobal', - bids: [{ - bidId: '3c9408cdbf2f68', - sizes: [[300, 250]], - bidder: 'memeglobal', - params: { siteId: '3608', adSizes:'300x250' }, - requestId: '10b327aa396609', - placementCode: 'header-bid-tag-0' - } - ] + params: { siteId: '3608', adSizes: '300x250' }, + requestId: '10b327aa396609', + placementCode: 'header-bid-tag-0' + } + ] }; adapter().callBids({}); @@ -88,12 +88,12 @@ describe('memeglobal adapter tests', function () { tagid: '007' }, sizes: [[300, 250]], - placementCode: "test-1" + placementCode: 'test-1' } // no bids returned in the response. var response = { - "id": "54321", - "seatbid": [] + 'id': '54321', + 'seatbid': [] }; var bidSet = getBidSetForBidder(); bidSet.bids.push(bid); @@ -131,22 +131,21 @@ describe('memeglobal adapter tests', function () { // Returning a single bid in the response. var response = { - "id": "54321111", - "seatbid": [ { - "bid" : [ { - "id" : "1111111", - "impid" : "bidId2", - "price" : 0.09, - "nurl" : "http://url", - "adm" : "ad-code", - "h" : 250, - "w" : 300, - "ext" : { } + 'id': '54321111', + 'seatbid': [ { + 'bid': [ { + 'id': '1111111', + 'impid': 'bidId2', + 'price': 0.09, + 'nurl': 'http://url', + 'adm': 'ad-code', + 'h': 250, + 'w': 300, + 'ext': { } } ] } ] }; - var bidSet = getBidSetForBidder(); bidSet.bids.push(bid); adapter() diff --git a/test/spec/adapters/openx_spec.js b/test/spec/adapters/openx_spec.js index 50d71064da7..437561a9621 100644 --- a/test/spec/adapters/openx_spec.js +++ b/test/spec/adapters/openx_spec.js @@ -1,5 +1,4 @@ describe('openx adapter tests', function () { - const expect = require('chai').expect; const assert = require('chai').assert; const adapter = require('src/adapters/openx'); @@ -11,7 +10,6 @@ describe('openx adapter tests', function () { after(() => document.body.appendChild.restore()); describe('test openx callback responce', function () { - it('should exist and be a function', function () { expect(pbjs.oxARJResponse).to.exist.and.to.be.a('function'); }); @@ -37,12 +35,12 @@ describe('openx adapter tests', function () { // empty ads in bidresponse let response = { - "ads": + 'ads': { - "version": 1, - "count": 1, - "pixels": "http://testpixels.net", - "ad": [] + 'version': 1, + 'count': 1, + 'pixels': 'http://testpixels.net', + 'ad': [] } }; @@ -82,35 +80,35 @@ describe('openx adapter tests', function () { // empty ads in bidresponse let response = { - "ads": + 'ads': { - "version": 1, - "count": 1, - "pixels": "http://testpixels.net", - "ad": [ + 'version': 1, + 'count': 1, + 'pixels': 'http://testpixels.net', + 'ad': [ { - "adunitid": 1234, - "adid": 5678, - "type": "html", - "html": "test_html", - "framed": 1, - "is_fallback": 0, - "ts": "ts", - "cpipc": 1000, - "pub_rev": "1000", - "adv_id": "adv_id", - "brand_id": "", - "creative": [ + 'adunitid': 1234, + 'adid': 5678, + 'type': 'html', + 'html': 'test_html', + 'framed': 1, + 'is_fallback': 0, + 'ts': 'ts', + 'cpipc': 1000, + 'pub_rev': '1000', + 'adv_id': 'adv_id', + 'brand_id': '', + 'creative': [ { - "width": "300", - "height": "250", - "target": "_blank", - "mime": "text/html", - "media": "test_media", - "tracking": { - "impression": "test_impression", - "inview": "test_inview", - "click": "test_click" + 'width': '300', + 'height': '250', + 'target': '_blank', + 'mime': 'text/html', + 'media': 'test_media', + 'tracking': { + 'impression': 'test_impression', + 'inview': 'test_inview', + 'click': 'test_click' } } ] @@ -159,35 +157,35 @@ describe('openx adapter tests', function () { // Empty pub rev in bid response let response = { - "ads": + 'ads': { - "version": 1, - "count": 1, - "pixels": "http://testpixels.net", - "ad": [ + 'version': 1, + 'count': 1, + 'pixels': 'http://testpixels.net', + 'ad': [ { - "adunitid": 1234, - "adid": 5678, - "type": "html", - "html": "test_html", - "framed": 1, - "is_fallback": 1, - "ts": "ts", - "cpipc": 1000, - "pub_rev": "", - "adv_id": "adv_id", - "brand_id": "", - "creative": [ + 'adunitid': 1234, + 'adid': 5678, + 'type': 'html', + 'html': 'test_html', + 'framed': 1, + 'is_fallback': 1, + 'ts': 'ts', + 'cpipc': 1000, + 'pub_rev': '', + 'adv_id': 'adv_id', + 'brand_id': '', + 'creative': [ { - "width": "300", - "height": "250", - "target": "_blank", - "mime": "text/html", - "media": "test_media", - "tracking": { - "impression": "test_impression", - "inview": "test_inview", - "click": "test_click" + 'width': '300', + 'height': '250', + 'target': '_blank', + 'mime': 'text/html', + 'media': 'test_media', + 'tracking': { + 'impression': 'test_impression', + 'inview': 'test_inview', + 'click': 'test_click' } } ] @@ -265,5 +263,4 @@ describe('openx adapter tests', function () { expect(bidUrl).to.include('c.test1=testval1'); spyLoadScript.restore(); }); - }); diff --git a/test/spec/adapters/piximedia_spec.js b/test/spec/adapters/piximedia_spec.js index e5e8b3f17f9..f6168390182 100644 --- a/test/spec/adapters/piximedia_spec.js +++ b/test/spec/adapters/piximedia_spec.js @@ -1,418 +1,417 @@ describe('Piximedia adapter tests', function () { + var expect = require('chai').expect; + var urlParse = require('url-parse'); + + // var querystringify = require('querystringify'); + + var adapter = require('src/adapters/piximedia'); + var adLoader = require('src/adloader'); + var bidmanager = require('src/bidmanager'); + var utils = require('src/utils'); + var CONSTANTS = require('src/constants.json'); + + var pbjs = window.pbjs = window.pbjs || {}; + let stubLoadScript; + + beforeEach(function () { + stubLoadScript = sinon.stub(adLoader, 'loadScript'); + }); + + afterEach(function () { + stubLoadScript.restore(); + }); + + describe('creation of prebid url', function () { + if (typeof (pbjs._bidsReceived) === 'undefined') { + pbjs._bidsReceived = []; + } + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = []; + } + if (typeof (pbjs._adsReceived) === 'undefined') { + pbjs._adsReceived = []; + } + + it('should call the Piximedia prebid URL once on valid calls', function () { + var params = { + bidderCode: 'piximedia', + bidder: 'piximedia', + bids: [ + { + bidId: '4d3819cffc4d12', + sizes: [[300, 250]], + bidder: 'piximedia', + params: { siteId: 'TEST', placementId: 'TEST', prebidUrl: '//resources.pm/tests/prebid/bids.js' }, + requestId: '59c318fd382219', + placementCode: '/20164912/header-bid-tag-0' + } + ] + }; + + adapter().callBids(params); + sinon.assert.calledOnce(stubLoadScript); + }); - var expect = require('chai').expect; - var urlParse = require('url-parse'); + it('should not call the Piximedia prebid URL once on invalid calls', function () { + var params = { + bidderCode: 'piximedia', + bidder: 'piximedia', + bids: [ + { + bidId: '4d3819cffc4d12', + sizes: [[300, 250]], + bidder: 'piximedia', + params: { prebidUrl: '//resources.pm/tests/prebid/bids.js' }, // this is invalid: site and placement ID are missing + requestId: '59c318fd382219', + placementCode: '/20164912/header-bid-tag-0' + } + ] + }; + + adapter().callBids(params); + sinon.assert.notCalled(stubLoadScript); + }); - //var querystringify = require('querystringify'); + it('should call the correct Prebid URL when using the default URL', function () { + var params = { + bidderCode: 'piximedia', + bidder: 'piximedia', + bids: [ + { + bidId: '4d3819cffc4d12', + sizes: [[300, 250]], + bidder: 'piximedia', + params: { siteId: 'TEST', placementId: 'TEST' }, + requestId: '59c318fd382219', + placementCode: '/20164912/header-bid-tag-0' + } + ] + }; + + adapter().callBids(params); + var bidUrl = stubLoadScript.getCall(0).args[0]; - var adapter = require('src/adapters/piximedia'); - var adLoader = require('src/adloader'); - var bidmanager = require('src/bidmanager'); - var utils = require('src/utils'); - var CONSTANTS = require('src/constants.json'); + sinon.assert.calledWith(stubLoadScript, bidUrl); - var pbjs = window.pbjs = window.pbjs || {}; - let stubLoadScript; + var parsedBidUrl = urlParse(bidUrl); - beforeEach(function () { - stubLoadScript = sinon.stub(adLoader, 'loadScript'); + expect(parsedBidUrl.hostname).to.equal('static.adserver.pm'); + expect(parsedBidUrl.query).to.equal(''); + expect(parsedBidUrl.pathname.replace(/cbid=[a-f0-9]+/, 'cbid=210af5668b1e23').replace(/rand=[0-9]+$/, 'rand=42')).to.equal('/prebid/site_id=TEST/placement_id=TEST/jsonp=pbjs.handlePiximediaCallback/sizes=300x250/cbid=210af5668b1e23/rand=42'); }); - afterEach(function () { - stubLoadScript.restore(); + it('should call the correct Prebid URL when using the default URL with a deal and custom data', function () { + var params = { + bidderCode: 'piximedia', + bidder: 'piximedia', + bids: [ + { + bidId: '4d3819cffc4d12', + sizes: [[300, 250]], + bidder: 'piximedia', + params: { siteId: 'TEST', placementId: 'TEST', dealId: 1295, custom: 'bespoke', custom2: function() { return 'bespoke2'; }, custom3: null, custom4: function() {} }, + requestId: '59c318fd382219', + placementCode: '/20164912/header-bid-tag-0' + } + ] + }; + + adapter().callBids(params); + var bidUrl = stubLoadScript.getCall(0).args[0]; + + sinon.assert.calledWith(stubLoadScript, bidUrl); + + var parsedBidUrl = urlParse(bidUrl); + + expect(parsedBidUrl.hostname).to.equal('static.adserver.pm'); + expect(parsedBidUrl.query).to.equal(''); + expect(parsedBidUrl.pathname.replace(/cbid=[a-f0-9]+/, 'cbid=210af5668b1e23').replace(/rand=[0-9]+$/, 'rand=42')).to.equal('/prebid/site_id=TEST/placement_id=TEST/l_id=1295/custom=bespoke/custom2=bespoke2/custom3=/custom4=/jsonp=pbjs.handlePiximediaCallback/sizes=300x250/cbid=210af5668b1e23/rand=42'); }); - describe('creation of prebid url', function () { - if (typeof(pbjs._bidsReceived)==="undefined"){ - pbjs._bidsReceived = []; - } - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = []; - } - if (typeof(pbjs._adsReceived)==="undefined"){ - pbjs._adsReceived = []; - } - - it('should call the Piximedia prebid URL once on valid calls', function () { - var params = { - bidderCode: 'piximedia', - bidder: 'piximedia', - bids: [ - { - bidId: '4d3819cffc4d12', - sizes: [[300, 250]], - bidder: 'piximedia', - params: { siteId: 'TEST', placementId: "TEST", prebidUrl: "//resources.pm/tests/prebid/bids.js" }, - requestId: '59c318fd382219', - placementCode: '/20164912/header-bid-tag-0' - } - ] - }; - - adapter().callBids(params); - sinon.assert.calledOnce(stubLoadScript); - }); - - it('should not call the Piximedia prebid URL once on invalid calls', function () { - var params = { - bidderCode: 'piximedia', - bidder: 'piximedia', - bids: [ - { - bidId: '4d3819cffc4d12', - sizes: [[300, 250]], - bidder: 'piximedia', - params: { prebidUrl: "//resources.pm/tests/prebid/bids.js" }, // this is invalid: site and placement ID are missing - requestId: '59c318fd382219', - placementCode: '/20164912/header-bid-tag-0' - } - ] - }; - - adapter().callBids(params); - sinon.assert.notCalled(stubLoadScript); - }); - - it('should call the correct Prebid URL when using the default URL', function () { - var params = { - bidderCode: 'piximedia', - bidder: 'piximedia', - bids: [ - { - bidId: '4d3819cffc4d12', - sizes: [[300, 250]], - bidder: 'piximedia', - params: { siteId: 'TEST', placementId: "TEST" }, - requestId: '59c318fd382219', - placementCode: '/20164912/header-bid-tag-0' - } - ] - }; - - adapter().callBids(params); - var bidUrl = stubLoadScript.getCall(0).args[0]; - - sinon.assert.calledWith(stubLoadScript, bidUrl); - - var parsedBidUrl = urlParse(bidUrl); - - expect(parsedBidUrl.hostname).to.equal("static.adserver.pm"); - expect(parsedBidUrl.query).to.equal(""); - expect(parsedBidUrl.pathname.replace(/cbid=[a-f0-9]+/, "cbid=210af5668b1e23").replace(/rand=[0-9]+$/, "rand=42")).to.equal("/prebid/site_id=TEST/placement_id=TEST/jsonp=pbjs.handlePiximediaCallback/sizes=300x250/cbid=210af5668b1e23/rand=42"); - }); - - it('should call the correct Prebid URL when using the default URL with a deal and custom data', function () { - var params = { - bidderCode: 'piximedia', - bidder: 'piximedia', - bids: [ - { - bidId: '4d3819cffc4d12', - sizes: [[300, 250]], - bidder: 'piximedia', - params: { siteId: 'TEST', placementId: "TEST", dealId: 1295, custom: "bespoke", custom2: function() { return "bespoke2"; }, custom3: null, custom4: function() {} }, - requestId: '59c318fd382219', - placementCode: '/20164912/header-bid-tag-0' - } - ] - }; - - adapter().callBids(params); - var bidUrl = stubLoadScript.getCall(0).args[0]; - - sinon.assert.calledWith(stubLoadScript, bidUrl); - - var parsedBidUrl = urlParse(bidUrl); - - expect(parsedBidUrl.hostname).to.equal("static.adserver.pm"); - expect(parsedBidUrl.query).to.equal(""); - expect(parsedBidUrl.pathname.replace(/cbid=[a-f0-9]+/, "cbid=210af5668b1e23").replace(/rand=[0-9]+$/, "rand=42")).to.equal("/prebid/site_id=TEST/placement_id=TEST/l_id=1295/custom=bespoke/custom2=bespoke2/custom3=/custom4=/jsonp=pbjs.handlePiximediaCallback/sizes=300x250/cbid=210af5668b1e23/rand=42"); - }); - - it('should call the correct Prebid URL when using the default URL and overridding sizes', function () { - var params = { - bidderCode: 'piximedia', - bidder: 'piximedia', - bids: [ - { - bidId: '4d3819cffc4d12', - sizes: [[300, 250]], - bidder: 'piximedia', - params: { siteId: 'TEST', placementId: "TEST", sizes: [[300,600],[728,90]] }, - requestId: '59c318fd382219', - placementCode: '/20164912/header-bid-tag-0' - } - ] - }; - - adapter().callBids(params); - var bidUrl = stubLoadScript.getCall(0).args[0]; - - sinon.assert.calledWith(stubLoadScript, bidUrl); - - var parsedBidUrl = urlParse(bidUrl); - - expect(parsedBidUrl.hostname).to.equal("static.adserver.pm"); - expect(parsedBidUrl.query).to.equal(""); - expect(parsedBidUrl.pathname.replace(/cbid=[a-f0-9]+/, "cbid=210af5668b1e23").replace(/rand=[0-9]+$/, "rand=42")).to.equal("/prebid/site_id=TEST/placement_id=TEST/jsonp=pbjs.handlePiximediaCallback/sizes=300x600%2C728x90/cbid=210af5668b1e23/rand=42"); - }); - - it('should call the correct Prebid URL when supplying a custom URL', function () { - var params = { - bidderCode: 'piximedia', - bidder: 'piximedia', - bids: [ - { - bidId: '4d3819cffc4d12', - sizes: [[300, 250]], - bidder: 'piximedia', - params: { siteId: 'TEST', placementId: "TEST", prebidUrl: "//resources.pm/tests/prebid/bids.js" }, - requestId: '59c318fd382219', - placementCode: '/20164912/header-bid-tag-0' - } - ] - }; - - adapter().callBids(params); - var bidUrl = stubLoadScript.getCall(0).args[0]; - - sinon.assert.calledWith(stubLoadScript, bidUrl); - - var parsedBidUrl = urlParse(bidUrl); - - expect(parsedBidUrl.hostname).to.equal("resources.pm"); - expect(parsedBidUrl.query).to.equal(""); - expect(parsedBidUrl.pathname.replace(/cbid=[a-f0-9]+/, "cbid=210af5668b1e23").replace(/rand=[0-9]+$/, "rand=42")).to.equal("/tests/prebid/bids.js/site_id=TEST/placement_id=TEST/jsonp=pbjs.handlePiximediaCallback/sizes=300x250/cbid=210af5668b1e23/rand=42"); - }); + it('should call the correct Prebid URL when using the default URL and overridding sizes', function () { + var params = { + bidderCode: 'piximedia', + bidder: 'piximedia', + bids: [ + { + bidId: '4d3819cffc4d12', + sizes: [[300, 250]], + bidder: 'piximedia', + params: { siteId: 'TEST', placementId: 'TEST', sizes: [[300, 600], [728, 90]] }, + requestId: '59c318fd382219', + placementCode: '/20164912/header-bid-tag-0' + } + ] + }; + + adapter().callBids(params); + var bidUrl = stubLoadScript.getCall(0).args[0]; + + sinon.assert.calledWith(stubLoadScript, bidUrl); + + var parsedBidUrl = urlParse(bidUrl); + + expect(parsedBidUrl.hostname).to.equal('static.adserver.pm'); + expect(parsedBidUrl.query).to.equal(''); + expect(parsedBidUrl.pathname.replace(/cbid=[a-f0-9]+/, 'cbid=210af5668b1e23').replace(/rand=[0-9]+$/, 'rand=42')).to.equal('/prebid/site_id=TEST/placement_id=TEST/jsonp=pbjs.handlePiximediaCallback/sizes=300x600%2C728x90/cbid=210af5668b1e23/rand=42'); }); - describe('handling of the callback response', function () { - if (typeof(pbjs._bidsReceived)==="undefined"){ - pbjs._bidsReceived = []; - } - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = []; - } - if (typeof(pbjs._adsReceived)==="undefined"){ - pbjs._adsReceived = []; + it('should call the correct Prebid URL when supplying a custom URL', function () { + var params = { + bidderCode: 'piximedia', + bidder: 'piximedia', + bids: [ + { + bidId: '4d3819cffc4d12', + sizes: [[300, 250]], + bidder: 'piximedia', + params: { siteId: 'TEST', placementId: 'TEST', prebidUrl: '//resources.pm/tests/prebid/bids.js' }, + requestId: '59c318fd382219', + placementCode: '/20164912/header-bid-tag-0' + } + ] + }; + + adapter().callBids(params); + var bidUrl = stubLoadScript.getCall(0).args[0]; + + sinon.assert.calledWith(stubLoadScript, bidUrl); + + var parsedBidUrl = urlParse(bidUrl); + + expect(parsedBidUrl.hostname).to.equal('resources.pm'); + expect(parsedBidUrl.query).to.equal(''); + expect(parsedBidUrl.pathname.replace(/cbid=[a-f0-9]+/, 'cbid=210af5668b1e23').replace(/rand=[0-9]+$/, 'rand=42')).to.equal('/tests/prebid/bids.js/site_id=TEST/placement_id=TEST/jsonp=pbjs.handlePiximediaCallback/sizes=300x250/cbid=210af5668b1e23/rand=42'); + }); + }); + + describe('handling of the callback response', function () { + if (typeof (pbjs._bidsReceived) === 'undefined') { + pbjs._bidsReceived = []; + } + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = []; + } + if (typeof (pbjs._adsReceived) === 'undefined') { + pbjs._adsReceived = []; + } + + var params = { + bidderCode: 'piximedia', + bidder: 'piximedia', + bids: [ + { + bidId: '4d3819cffc4d12', + sizes: [[300, 250]], + bidder: 'piximedia', + params: { siteId: 'TEST', placementId: 'TEST', prebidUrl: '//resources.pm/tests/prebid/bids.js' }, + requestId: '59c318fd382219', + placementCode: '/20164912/header-bid-tag-0' } + ] + }; - var params = { - bidderCode: 'piximedia', - bidder: 'piximedia', - bids: [ - { - bidId: '4d3819cffc4d12', - sizes: [[300, 250]], - bidder: 'piximedia', - params: { siteId: 'TEST', placementId: "TEST", prebidUrl: "//resources.pm/tests/prebid/bids.js" }, - requestId: '59c318fd382219', - placementCode: '/20164912/header-bid-tag-0' - } - ] - }; - - it('Piximedia callback function should exist', function () { - expect(pbjs.handlePiximediaCallback).to.exist.and.to.be.a('function'); - }); - - it('bidmanager.addBidResponse should be called once with correct arguments', function () { - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - var stubGetUniqueIdentifierStr = sinon.spy(utils, "getUniqueIdentifierStr"); - - var response = { - foundbypm: true, - currency: "EUR", - cpm: 1.23, - dealId: 9948, - width: 300, - height: 250, - html: "
ad
" - }; - - adapter().callBids(params); - - var adUnits = []; - var unit = {}; - unit.bids = [params]; - unit.code = '/20164912/header-bid-tag'; - unit.sizes=[[300,250],[728,90]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } else { - pbjs._bidsRequested.push(params); - } - pbjs.adUnits = adUnits; - response.cbid = stubGetUniqueIdentifierStr.returnValues[0]; - - pbjs.handlePiximediaCallback(response); - - sinon.assert.calledOnce(stubAddBidResponse); - var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - - expect(bidPlacementCode1).to.equal('/20164912/header-bid-tag-0'); - expect(bidObject1.cpm).to.equal(1.23); - expect(bidObject1.ad).to.equal("
ad
"); - expect(bidObject1.width).to.equal(300); - expect(bidObject1.dealId).to.equal(9948); - expect(bidObject1.height).to.equal(250); - expect(bidObject1.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); - expect(bidObject1.bidderCode).to.equal('piximedia'); - - stubAddBidResponse.restore(); - stubGetUniqueIdentifierStr.restore(); - }); - - it('bidmanager.addBidResponse should be called once with correct arguments on partial response', function () { - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - var stubGetUniqueIdentifierStr = sinon.spy(utils, "getUniqueIdentifierStr"); + it('Piximedia callback function should exist', function () { + expect(pbjs.handlePiximediaCallback).to.exist.and.to.be.a('function'); + }); + + it('bidmanager.addBidResponse should be called once with correct arguments', function () { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + var stubGetUniqueIdentifierStr = sinon.spy(utils, 'getUniqueIdentifierStr'); + + var response = { + foundbypm: true, + currency: 'EUR', + cpm: 1.23, + dealId: 9948, + width: 300, + height: 250, + html: '
ad
' + }; + + adapter().callBids(params); + + var adUnits = []; + var unit = {}; + unit.bids = [params]; + unit.code = '/20164912/header-bid-tag'; + unit.sizes = [[300, 250], [728, 90]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + pbjs.adUnits = adUnits; + response.cbid = stubGetUniqueIdentifierStr.returnValues[0]; + + pbjs.handlePiximediaCallback(response); + + sinon.assert.calledOnce(stubAddBidResponse); + var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + + expect(bidPlacementCode1).to.equal('/20164912/header-bid-tag-0'); + expect(bidObject1.cpm).to.equal(1.23); + expect(bidObject1.ad).to.equal('
ad
'); + expect(bidObject1.width).to.equal(300); + expect(bidObject1.dealId).to.equal(9948); + expect(bidObject1.height).to.equal(250); + expect(bidObject1.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); + expect(bidObject1.bidderCode).to.equal('piximedia'); + + stubAddBidResponse.restore(); + stubGetUniqueIdentifierStr.restore(); + }); + + it('bidmanager.addBidResponse should be called once with correct arguments on partial response', function () { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + var stubGetUniqueIdentifierStr = sinon.spy(utils, 'getUniqueIdentifierStr'); // this time, we do not provide dealId - var response = { - foundbypm: true, - cpm: 1.23, - width: 300, - height: 250, - currency: "EUR", - html: "
ad
" - }; - - adapter().callBids(params); - - var adUnits = []; - var unit = {}; - unit.bids = [params]; - unit.code = '/20164912/header-bid-tag'; - unit.sizes=[[300,250],[728,90]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } else { - pbjs._bidsRequested.push(params); - } - pbjs.adUnits = adUnits; - response.cbid = stubGetUniqueIdentifierStr.returnValues[0]; - - pbjs.handlePiximediaCallback(response); - - sinon.assert.calledOnce(stubAddBidResponse); - var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - - expect(bidPlacementCode1).to.equal('/20164912/header-bid-tag-0'); - expect(bidObject1.cpm).to.equal(1.23); - expect(bidObject1.ad).to.equal("
ad
"); - expect(bidObject1.width).to.equal(300); - expect(bidObject1.height).to.equal(250); - expect(bidObject1.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); - expect(bidObject1.bidderCode).to.equal('piximedia'); - - stubAddBidResponse.restore(); - stubGetUniqueIdentifierStr.restore(); - }); - - it('bidmanager.addBidResponse should be called once without any ads', function () { - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - var stubGetUniqueIdentifierStr = sinon.spy(utils, "getUniqueIdentifierStr"); - - var response = { - foundbypm: false - }; - - adapter().callBids(params); - - var adUnits = []; - var unit = {}; - unit.bids = [params]; - unit.code = '/20164912/header-bid-tag'; - unit.sizes=[[300,250],[728,90]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } else { - pbjs._bidsRequested.push(params); - } - pbjs.adUnits = adUnits; - response.cbid = stubGetUniqueIdentifierStr.returnValues[0]; - - pbjs.handlePiximediaCallback(response); - - sinon.assert.calledOnce(stubAddBidResponse); - var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; - var bidObject1 = stubAddBidResponse.getCall(0).args[1]; - - expect(bidPlacementCode1).to.equal('/20164912/header-bid-tag-0'); - expect(bidObject1.getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); - expect(bidObject1.bidderCode).to.equal('piximedia'); - - stubAddBidResponse.restore(); - stubGetUniqueIdentifierStr.restore(); - }); - - it('bidmanager.addBidResponse should not be called on bogus cbid', function () { - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - var stubGetUniqueIdentifierStr = sinon.spy(utils, "getUniqueIdentifierStr"); - - var response = { - foundbypm: false - }; - - adapter().callBids(params); - - var adUnits = []; - var unit = {}; - unit.bids = [params]; - unit.code = '/20164912/header-bid-tag'; - unit.sizes=[[300,250],[728,90]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } else { - pbjs._bidsRequested.push(params); - } - pbjs.adUnits = adUnits; - response.cbid = stubGetUniqueIdentifierStr.returnValues[0] + "_BOGUS"; - - pbjs.handlePiximediaCallback(response); - - sinon.assert.notCalled(stubAddBidResponse); - - stubAddBidResponse.restore(); - stubGetUniqueIdentifierStr.restore(); - }); - - it('bidmanager.addBidResponse should not be called on bogus response', function () { - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - - var response = null; // this is bogus: we expect an object - - adapter().callBids(params); - - var adUnits = []; - var unit = {}; - unit.bids = [params]; - unit.code = '/20164912/header-bid-tag'; - unit.sizes=[[300,250],[728,90]]; - adUnits.push(unit); - - if (typeof(pbjs._bidsRequested)==="undefined"){ - pbjs._bidsRequested = [params]; - } else { - pbjs._bidsRequested.push(params); - } - pbjs.adUnits = adUnits; + var response = { + foundbypm: true, + cpm: 1.23, + width: 300, + height: 250, + currency: 'EUR', + html: '
ad
' + }; + + adapter().callBids(params); + + var adUnits = []; + var unit = {}; + unit.bids = [params]; + unit.code = '/20164912/header-bid-tag'; + unit.sizes = [[300, 250], [728, 90]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + pbjs.adUnits = adUnits; + response.cbid = stubGetUniqueIdentifierStr.returnValues[0]; + + pbjs.handlePiximediaCallback(response); + + sinon.assert.calledOnce(stubAddBidResponse); + var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + + expect(bidPlacementCode1).to.equal('/20164912/header-bid-tag-0'); + expect(bidObject1.cpm).to.equal(1.23); + expect(bidObject1.ad).to.equal('
ad
'); + expect(bidObject1.width).to.equal(300); + expect(bidObject1.height).to.equal(250); + expect(bidObject1.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); + expect(bidObject1.bidderCode).to.equal('piximedia'); + + stubAddBidResponse.restore(); + stubGetUniqueIdentifierStr.restore(); + }); + + it('bidmanager.addBidResponse should be called once without any ads', function () { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + var stubGetUniqueIdentifierStr = sinon.spy(utils, 'getUniqueIdentifierStr'); + + var response = { + foundbypm: false + }; + + adapter().callBids(params); + + var adUnits = []; + var unit = {}; + unit.bids = [params]; + unit.code = '/20164912/header-bid-tag'; + unit.sizes = [[300, 250], [728, 90]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + pbjs.adUnits = adUnits; + response.cbid = stubGetUniqueIdentifierStr.returnValues[0]; + + pbjs.handlePiximediaCallback(response); + + sinon.assert.calledOnce(stubAddBidResponse); + var bidPlacementCode1 = stubAddBidResponse.getCall(0).args[0]; + var bidObject1 = stubAddBidResponse.getCall(0).args[1]; + + expect(bidPlacementCode1).to.equal('/20164912/header-bid-tag-0'); + expect(bidObject1.getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); + expect(bidObject1.bidderCode).to.equal('piximedia'); + + stubAddBidResponse.restore(); + stubGetUniqueIdentifierStr.restore(); + }); + + it('bidmanager.addBidResponse should not be called on bogus cbid', function () { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + var stubGetUniqueIdentifierStr = sinon.spy(utils, 'getUniqueIdentifierStr'); + + var response = { + foundbypm: false + }; + + adapter().callBids(params); + + var adUnits = []; + var unit = {}; + unit.bids = [params]; + unit.code = '/20164912/header-bid-tag'; + unit.sizes = [[300, 250], [728, 90]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + pbjs.adUnits = adUnits; + response.cbid = stubGetUniqueIdentifierStr.returnValues[0] + '_BOGUS'; + + pbjs.handlePiximediaCallback(response); + + sinon.assert.notCalled(stubAddBidResponse); + + stubAddBidResponse.restore(); + stubGetUniqueIdentifierStr.restore(); + }); + + it('bidmanager.addBidResponse should not be called on bogus response', function () { + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + + var response = null; // this is bogus: we expect an object + + adapter().callBids(params); + + var adUnits = []; + var unit = {}; + unit.bids = [params]; + unit.code = '/20164912/header-bid-tag'; + unit.sizes = [[300, 250], [728, 90]]; + adUnits.push(unit); + + if (typeof (pbjs._bidsRequested) === 'undefined') { + pbjs._bidsRequested = [params]; + } else { + pbjs._bidsRequested.push(params); + } + pbjs.adUnits = adUnits; - pbjs.handlePiximediaCallback(response); + pbjs.handlePiximediaCallback(response); - sinon.assert.notCalled(stubAddBidResponse); + sinon.assert.notCalled(stubAddBidResponse); - stubAddBidResponse.restore(); - }); + stubAddBidResponse.restore(); }); + }); }); diff --git a/test/spec/adapters/prebidServer_spec.js b/test/spec/adapters/prebidServer_spec.js index ca8a76ea9c0..a14a64dc8a7 100644 --- a/test/spec/adapters/prebidServer_spec.js +++ b/test/spec/adapters/prebidServer_spec.js @@ -4,41 +4,41 @@ import bidmanager from 'src/bidmanager'; import CONSTANTS from 'src/constants.json'; let CONFIG = { - accountId : '1', - enabled : true, - bidders : ['appnexus'], - timeout : 1000, - endpoint : CONSTANTS.S2S.DEFAULT_ENDPOINT + accountId: '1', + enabled: true, + bidders: ['appnexus'], + timeout: 1000, + endpoint: CONSTANTS.S2S.DEFAULT_ENDPOINT }; const REQUEST = { - "account_id": "1", - "tid": "437fbbf5-33f5-487a-8e16-a7112903cfe5", - "max_bids": 1, - "timeout_millis": 1000, - "url": "", - "prebid_version": "0.21.0-pre", - "ad_units": [ + 'account_id': '1', + 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', + 'max_bids': 1, + 'timeout_millis': 1000, + 'url': '', + 'prebid_version': '0.21.0-pre', + 'ad_units': [ { - "code": "div-gpt-ad-1460505748561-0", - "sizes": [ + 'code': 'div-gpt-ad-1460505748561-0', + 'sizes': [ { - "w": 300, - "h": 250 + 'w': 300, + 'h': 250 }, { - "w": 300, - "h": 600 + 'w': 300, + 'h': 600 } ], - "transactionId": "4ef956ad-fd83-406d-bd35-e4bb786ab86c", - "bids": [ + 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', + 'bids': [ { - "bid_id" : "123", - "bidder": "appnexus", - "params": { - "placementId": "10433394", - "member" : 123 + 'bid_id': '123', + 'bidder': 'appnexus', + 'params': { + 'placementId': '10433394', + 'member': 123 } } ] @@ -47,37 +47,35 @@ const REQUEST = { }; const RESPONSE = { - "tid": "437fbbf5-33f5-487a-8e16-a7112903cfe5", - "status": "OK", - "bidder_status": [ + 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', + 'status': 'OK', + 'bidder_status': [ { - "bidder": "appnexus", - "response_time_ms": 52, - "num_bids": 1 + 'bidder': 'appnexus', + 'response_time_ms': 52, + 'num_bids': 1 } ], - "bids": [ + 'bids': [ { - "bid_id": "123", - "code": "div-gpt-ad-1460505748561-0", - "creative_id": "29681110", - "bidder": "appnexus", - "price": 0.5, - "adm": "", - "width": 300, - "height": 250 + 'bid_id': '123', + 'code': 'div-gpt-ad-1460505748561-0', + 'creative_id': '29681110', + 'bidder': 'appnexus', + 'price': 0.5, + 'adm': '', + 'width': 300, + 'height': 250 } ] }; describe('S2S Adapter', () => { - let adapter; beforeEach(() => adapter = Adapter.createNew()); describe('request function', () => { - let xhr; let requests; @@ -103,7 +101,6 @@ describe('S2S Adapter', () => { }); describe('response handler', () => { - let server; beforeEach(() => { @@ -128,7 +125,5 @@ describe('S2S Adapter', () => { expect(response).to.have.property('statusMessage', 'Bid available'); expect(response).to.have.property('cpm', 0.5); }); - }); - }); diff --git a/test/spec/adapters/pubgears_spec.js b/test/spec/adapters/pubgears_spec.js index 329d74bb5b3..724b9dcd368 100644 --- a/test/spec/adapters/pubgears_spec.js +++ b/test/spec/adapters/pubgears_spec.js @@ -3,296 +3,285 @@ import Adapter from 'src/adapters/pubgears' import bidmanager from 'src/bidmanager' describe('PubGearsAdapter', () => { - - var adapter, mockScript - , params = { - bids: [] - } - - beforeEach( () => { - adapter = new Adapter() - mockScript = document.createElement('script') - sinon.spy(mockScript, 'setAttribute') - } ) - - describe('request function', () => { - - beforeEach( () => { - sinon.spy(document, 'createElement') - }) - - afterEach( () => { - document.createElement.restore && document.createElement.restore() - var s = document.getElementById('pg-header-tag') - if(s) - s.parentNode.removeChild(s) - } ) - - it('has `#callBids()` method', () => { - expect(adapter.callBids).to.exist.and.to.be.a('function') - }) - - it('requires bids to make script', () => { - - adapter.callBids({bids: []}) - expect(document.createElement.notCalled).to.be.ok - }) - - it('creates script when passed bids', () => { - - adapter.callBids({ - bidderCode: "pubgears", - bids: [ - { - bidder: "pubgears", - sizes: [ [300,250] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - } - ] - }) - - sinon.assert.calledWith(document.createElement, 'script') - }) - - it('should assign attributes to script', () => { - - adapter.callBids({ - bidderCode: "pubgears", - bids: [ - { - bidder: "pubgears", - sizes: [ [300,250] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - }, - { - bidder: "pubgears", - sizes: [ [160,600] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - } - ] - }) - var script = document.createElement.returnValues[0] - var slots = script.getAttribute('data-bsm-slot-list') - expect(slots).to.equal('testpub.com/combined@300x250 testpub.com/combined@160x600') - expect(script.getAttribute('data-bsm-flag')).to.equal('true') - expect(script.getAttribute('data-bsm-pub')).to.equal('integration') - expect(script.getAttribute('src')).to.equal('//c.pubgears.com/tags/h') - expect(script.id).to.equal('pg-header-tag') - }) - - it('should reuse existing script when called twice', () => { - - var params = { - bidderCode: "pubgears", - bids: [ - { - bidder: "pubgears", - sizes: [ [300,250] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - }, - { - bidder: "pubgears", - sizes: [ [160,600] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - } - ] - } - adapter.callBids(params) - expect(document.createElement.calledOnce).to.be.true - adapter.callBids(params) - expect(document.createElement.calledOnce).to.be.true - }) - - it('should register event listeners', () => { - - var script = document.createElement('script') - script.id = 'pg-header-tag' - var spy = sinon.spy(script, 'addEventListener') - document.body.appendChild(script) - var params = { - bidderCode: "pubgears", - bids: [ - { - bidder: "pubgears", - sizes: [ [300,250] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - }, - { - bidder: "pubgears", - sizes: [ [160,600] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - } - ] - } - adapter.callBids(params) - - expect(spy.calledWith('onBidResponse')).to.be.ok - expect(spy.calledWith('onResourceComplete')).to.be.ok - }) - }) - - describe('bids received', () => { - - beforeEach(() => { - sinon.spy(bidmanager, 'addBidResponse') - }) - - afterEach(() => { - bidmanager.addBidResponse.restore() - }) - - it('should call bidManager.addBidResponse() when bid received', () => { - - var options = { - bubbles: false, - cancelable: false, - detail: { - gross_price: 1000, - resource: { - position: 'atf', - pub_zone: 'testpub.com/combined', - size: '300x250' - } - } - } - - adapter.callBids({ - bidderCode: "pubgears", - bids: [ - { - bidder: "pubgears", - sizes: [ [300,250] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - }, - { - bidder: "pubgears", - sizes: [ [160,600] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - } - ] - - }) - var script = document.getElementById('pg-header-tag') - var event = new CustomEvent('onBidResponse', options) - script.dispatchEvent(event) - - expect(bidmanager.addBidResponse.calledOnce).to.be.ok - }) - - it('should send correct bid response object when receiving onBidResponse event', () => { - expect(bidmanager.addBidResponse.calledOnce).to.not.be.ok - var bid = { - bidder: "pubgears", - sizes: [ [300,250] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - } - - adapter.callBids({ - bidderCode: "pubgears", - bids: [ bid ] - }) - - var options = { - bubbles: false, - cancelable: false, - detail: { - gross_price: 1000, - resource: { - position: 'atf', - pub_zone: 'testpub.com/combined', - size: '300x250' - } - } - } - var script = document.getElementById('pg-header-tag') - var event = new CustomEvent('onBidResponse', options) - script.dispatchEvent(event) - - var args = bidmanager.addBidResponse.getCall(1).args - expect(args).to.have.length(2) - var bidResponse = args[1] - expect(bidResponse.ad).to.contain(bid.params.pubZone) - }) - - it('should send $0 bid as no-bid response', () => { - - var bid = { - bidder: "pubgears", - sizes: [ [300,250] ], - adUnitCode: "foo123/header-bid-tag", - params: { - publisherName: "integration", - pubZone: "testpub.com/combined" - } - } - - adapter.callBids({ - bidderCode: "pubgears", - bids: [ bid ] - }) - - var options = { - bubbles: false, - cancelable: false, - detail: { - gross_price: 0, - resource: { - position: 'atf', - pub_zone: 'testpub.com/combined', - size: '300x250' - } - } - } - var script = document.getElementById('pg-header-tag') - var event = new CustomEvent('onBidResponse', options) - - bidmanager.addBidResponse.reset() - script.dispatchEvent(event) - - var args = bidmanager.addBidResponse.getCall(1).args - var bidResponse = args[1] - expect(bidResponse).to.be.a('object') - expect(bidResponse.getStatusCode()).to.equal(2) - }) - }) + var adapter, mockScript, + params = { + bids: [] + } + + beforeEach(() => { + adapter = new Adapter() + mockScript = document.createElement('script') + sinon.spy(mockScript, 'setAttribute') + }) + + describe('request function', () => { + beforeEach(() => { + sinon.spy(document, 'createElement') + }) + + afterEach(() => { + document.createElement.restore && document.createElement.restore() + var s = document.getElementById('pg-header-tag') + if (s) { s.parentNode.removeChild(s) } + }) + + it('has `#callBids()` method', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function') + }) + + it('requires bids to make script', () => { + adapter.callBids({bids: []}) + expect(document.createElement.notCalled).to.be.ok + }) + + it('creates script when passed bids', () => { + adapter.callBids({ + bidderCode: 'pubgears', + bids: [ + { + bidder: 'pubgears', + sizes: [ [300, 250] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + } + ] + }) + + sinon.assert.calledWith(document.createElement, 'script') + }) + + it('should assign attributes to script', () => { + adapter.callBids({ + bidderCode: 'pubgears', + bids: [ + { + bidder: 'pubgears', + sizes: [ [300, 250] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + }, + { + bidder: 'pubgears', + sizes: [ [160, 600] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + } + ] + }) + var script = document.createElement.returnValues[0] + var slots = script.getAttribute('data-bsm-slot-list') + expect(slots).to.equal('testpub.com/combined@300x250 testpub.com/combined@160x600') + expect(script.getAttribute('data-bsm-flag')).to.equal('true') + expect(script.getAttribute('data-bsm-pub')).to.equal('integration') + expect(script.getAttribute('src')).to.equal('//c.pubgears.com/tags/h') + expect(script.id).to.equal('pg-header-tag') + }) + + it('should reuse existing script when called twice', () => { + var params = { + bidderCode: 'pubgears', + bids: [ + { + bidder: 'pubgears', + sizes: [ [300, 250] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + }, + { + bidder: 'pubgears', + sizes: [ [160, 600] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + } + ] + } + adapter.callBids(params) + expect(document.createElement.calledOnce).to.be.true + adapter.callBids(params) + expect(document.createElement.calledOnce).to.be.true + }) + + it('should register event listeners', () => { + var script = document.createElement('script') + script.id = 'pg-header-tag' + var spy = sinon.spy(script, 'addEventListener') + document.body.appendChild(script) + var params = { + bidderCode: 'pubgears', + bids: [ + { + bidder: 'pubgears', + sizes: [ [300, 250] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + }, + { + bidder: 'pubgears', + sizes: [ [160, 600] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + } + ] + } + adapter.callBids(params) + + expect(spy.calledWith('onBidResponse')).to.be.ok + expect(spy.calledWith('onResourceComplete')).to.be.ok + }) + }) + + describe('bids received', () => { + beforeEach(() => { + sinon.spy(bidmanager, 'addBidResponse') + }) + + afterEach(() => { + bidmanager.addBidResponse.restore() + }) + + it('should call bidManager.addBidResponse() when bid received', () => { + var options = { + bubbles: false, + cancelable: false, + detail: { + gross_price: 1000, + resource: { + position: 'atf', + pub_zone: 'testpub.com/combined', + size: '300x250' + } + } + } + + adapter.callBids({ + bidderCode: 'pubgears', + bids: [ + { + bidder: 'pubgears', + sizes: [ [300, 250] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + }, + { + bidder: 'pubgears', + sizes: [ [160, 600] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + } + ] + + }) + var script = document.getElementById('pg-header-tag') + var event = new CustomEvent('onBidResponse', options) + script.dispatchEvent(event) + + expect(bidmanager.addBidResponse.calledOnce).to.be.ok + }) + + it('should send correct bid response object when receiving onBidResponse event', () => { + expect(bidmanager.addBidResponse.calledOnce).to.not.be.ok + var bid = { + bidder: 'pubgears', + sizes: [ [300, 250] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + } + + adapter.callBids({ + bidderCode: 'pubgears', + bids: [ bid ] + }) + + var options = { + bubbles: false, + cancelable: false, + detail: { + gross_price: 1000, + resource: { + position: 'atf', + pub_zone: 'testpub.com/combined', + size: '300x250' + } + } + } + var script = document.getElementById('pg-header-tag') + var event = new CustomEvent('onBidResponse', options) + script.dispatchEvent(event) + + var args = bidmanager.addBidResponse.getCall(1).args + expect(args).to.have.length(2) + var bidResponse = args[1] + expect(bidResponse.ad).to.contain(bid.params.pubZone) + }) + + it('should send $0 bid as no-bid response', () => { + var bid = { + bidder: 'pubgears', + sizes: [ [300, 250] ], + adUnitCode: 'foo123/header-bid-tag', + params: { + publisherName: 'integration', + pubZone: 'testpub.com/combined' + } + } + + adapter.callBids({ + bidderCode: 'pubgears', + bids: [ bid ] + }) + + var options = { + bubbles: false, + cancelable: false, + detail: { + gross_price: 0, + resource: { + position: 'atf', + pub_zone: 'testpub.com/combined', + size: '300x250' + } + } + } + var script = document.getElementById('pg-header-tag') + var event = new CustomEvent('onBidResponse', options) + + bidmanager.addBidResponse.reset() + script.dispatchEvent(event) + + var args = bidmanager.addBidResponse.getCall(1).args + var bidResponse = args[1] + expect(bidResponse).to.be.a('object') + expect(bidResponse.getStatusCode()).to.equal(2) + }) + }) }) diff --git a/test/spec/adapters/pulsepointLite_spec.js b/test/spec/adapters/pulsepointLite_spec.js index 811ed583dcb..85eb28ef46b 100644 --- a/test/spec/adapters/pulsepointLite_spec.js +++ b/test/spec/adapters/pulsepointLite_spec.js @@ -1,11 +1,10 @@ import {expect} from 'chai'; import PulsePointAdapter from 'src/adapters/pulsepointLite'; import bidManager from 'src/bidmanager'; -import * as ajax from "src/ajax"; +import * as ajax from 'src/ajax'; import {parse as parseURL} from 'src/url'; -describe("PulsePoint Lite Adapter Tests", () => { - +describe('PulsePoint Lite Adapter Tests', () => { let pulsepointAdapter = new PulsePointAdapter(); let slotConfigs; let ajaxStub; @@ -17,22 +16,22 @@ describe("PulsePoint Lite Adapter Tests", () => { slotConfigs = { bids: [ { - placementCode: "/DfpAccount1/slot1", - bidder: "pulsepoint", + placementCode: '/DfpAccount1/slot1', + bidder: 'pulsepoint', bidId: 'bid12345', params: { - cp: "p10000", - ct: "t10000", - cf: "300x250" + cp: 'p10000', + ct: 't10000', + cf: '300x250' } - },{ - placementCode: "/DfpAccount2/slot2", - bidder: "pulsepoint", + }, { + placementCode: '/DfpAccount2/slot2', + bidder: 'pulsepoint', bidId: 'bid23456', params: { - cp: "p20000", - ct: "t20000", - cf: "728x90" + cp: 'p20000', + ct: 't20000', + cf: '728x90' } } ] @@ -47,13 +46,13 @@ describe("PulsePoint Lite Adapter Tests", () => { it('Verify requests sent to PulsePoint', () => { pulsepointAdapter.callBids(slotConfigs); var call = parseURL(ajaxStub.firstCall.args[0]).search; - //slot 1 + // slot 1 // expect(call.cp).to.equal('p10000'); // expect(call.ct).to.equal('t10000'); // expect(call.cf).to.equal('300x250'); expect(call.ca).to.equal('BID'); expect(call.cn).to.equal('1'); - //slot 2 + // slot 2 call = parseURL(ajaxStub.secondCall.args[0]).search; // expect(call.cp).to.equal('p20000'); // expect(call.ct).to.equal('t20000'); @@ -64,7 +63,7 @@ describe("PulsePoint Lite Adapter Tests", () => { it('Verify bid', () => { pulsepointAdapter.callBids(slotConfigs); - //trigger a mock ajax callback with bid. + // trigger a mock ajax callback with bid. ajaxStub.firstCall.args[1](JSON.stringify({ html: 'This is an Ad', bidCpm: 1.25 @@ -82,7 +81,7 @@ describe("PulsePoint Lite Adapter Tests", () => { it('Verify passback', () => { pulsepointAdapter.callBids(slotConfigs); - //trigger a mock ajax callback with no bid. + // trigger a mock ajax callback with no bid. ajaxStub.firstCall.args[1](null); let placement = bidManager.addBidResponse.firstCall.args[0]; let bid = bidManager.addBidResponse.firstCall.args[1]; @@ -104,5 +103,4 @@ describe("PulsePoint Lite Adapter Tests", () => { expect(bid).to.not.have.property('cpm'); expect(bid.adId).to.equal('bid12345'); }); - }); diff --git a/test/spec/adapters/pulsepoint_spec.js b/test/spec/adapters/pulsepoint_spec.js index b3c24d38890..cd56485b91a 100644 --- a/test/spec/adapters/pulsepoint_spec.js +++ b/test/spec/adapters/pulsepoint_spec.js @@ -3,8 +3,7 @@ import PulsePointAdapter from '../../../src/adapters/pulsepoint'; import bidManager from '../../../src/bidmanager'; import adLoader from '../../../src/adloader'; -describe("PulsePoint Adapter Tests", () => { - +describe('PulsePoint Adapter Tests', () => { let pulsepointAdapter = new PulsePointAdapter(); let slotConfigs; let requests = []; @@ -17,7 +16,7 @@ describe("PulsePoint Adapter Tests", () => { BID: 0 } }; - /* Ad object*/ + /* Ad object */ window.pp.Ad = function(config) { this.display = function() { requests.push(config); @@ -38,24 +37,24 @@ describe("PulsePoint Adapter Tests", () => { slotConfigs = { bids: [ { - placementCode: "/DfpAccount1/slot1", - bidder: "pulsepoint", + placementCode: '/DfpAccount1/slot1', + bidder: 'pulsepoint', bidId: 'bid12345', params: { - cp: "p10000", - ct: "t10000", - cf: "300x250", - param1: "value1", + cp: 'p10000', + ct: 't10000', + cf: '300x250', + param1: 'value1', param2: 2 } - },{ - placementCode: "/DfpAccount2/slot2", - bidder: "pulsepoint", + }, { + placementCode: '/DfpAccount2/slot2', + bidder: 'pulsepoint', bidId: 'bid23456', params: { - cp: "p20000", - ct: "t20000", - cf: "728x90" + cp: 'p20000', + ct: 't20000', + cf: '728x90' } } ] @@ -72,7 +71,7 @@ describe("PulsePoint Adapter Tests", () => { it('Verify requests sent to PulsePoint library', () => { pulsepointAdapter.callBids(slotConfigs); expect(requests).to.have.length(2); - //slot 1 + // slot 1 expect(requests[0].cp).to.equal('p10000'); expect(requests[0].ct).to.equal('t10000'); expect(requests[0].cf).to.equal('300x250'); @@ -138,7 +137,7 @@ describe("PulsePoint Adapter Tests", () => { let bidCall = bidManager.addBidResponse.firstCall; expect(callback).to.be.a('function'); expect(bidCall).to.be.a('null'); - //the library load should initialize pulsepoint lib + // the library load should initialize pulsepoint lib initPulsepointLib(); callback(); expect(requests.length).to.equal(2); @@ -148,18 +147,17 @@ describe("PulsePoint Adapter Tests", () => { expect(bidCall.args[1]).to.be.a('object'); }); - //related to issue https://github.com/prebid/Prebid.js/issues/866 + // related to issue https://github.com/prebid/Prebid.js/issues/866 it('Verify Passbacks when window.pp is not available', () => { window.pp = function() {}; pulsepointAdapter.callBids(slotConfigs); let placement = bidManager.addBidResponse.firstCall.args[0]; let bid = bidManager.addBidResponse.firstCall.args[1]; - //verify that we passed back without exceptions, should window.pp be already taken. + // verify that we passed back without exceptions, should window.pp be already taken. expect(placement).to.equal('/DfpAccount1/slot1'); expect(bid.bidderCode).to.equal('pulsepoint'); expect(bid).to.not.have.property('ad'); expect(bid).to.not.have.property('cpm'); expect(bid.adId).to.equal('bid12345'); }); - }); diff --git a/test/spec/adapters/quantcast_spec.js b/test/spec/adapters/quantcast_spec.js index ceca035d671..daebdd4e470 100644 --- a/test/spec/adapters/quantcast_spec.js +++ b/test/spec/adapters/quantcast_spec.js @@ -5,7 +5,6 @@ import bidManager from '../../../src/bidmanager'; import adLoader from '../../../src/adloader'; describe('quantcast adapter', () => { - let bidsRequestedOriginal; let adapter; let sandbox; @@ -13,17 +12,17 @@ describe('quantcast adapter', () => { const bidderRequest = { bidderCode: 'quantcast', - requestId : "595ffa73-d78a-46c9-b18e-f99548a5be6b", - bidderRequestId:"1cc026909c24c8", + requestId: '595ffa73-d78a-46c9-b18e-f99548a5be6b', + bidderRequestId: '1cc026909c24c8', bids: [ { bidId: '2f7b179d443f14', bidder: 'quantcast', placementCode: 'div-gpt-ad-1438287399331-0', - sizes: [[300,250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { publisherId: 'test-publisher', - battr : [1,2], + battr: [1, 2], } } ] @@ -47,17 +46,17 @@ describe('quantcast adapter', () => { describe('sizes', () => { let bidderRequest = { bidderCode: 'quantcast', - requestId : "595ffa73-d78a-46c9-b18e-f99548a5be6b", - bidderRequestId:"1cc026909c24c8", + requestId: '595ffa73-d78a-46c9-b18e-f99548a5be6b', + bidderRequestId: '1cc026909c24c8', bids: [ { bidId: '2f7b179d443f14', bidder: 'quantcast', placementCode: 'div-gpt-ad-1438287399331-0', - sizes: [[300,250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { publisherId: 'test-publisher', - battr : [1,2], + battr: [1, 2], } } ] @@ -77,7 +76,7 @@ describe('quantcast adapter', () => { expect(ajaxStub.firstCall.args[2]).to.include('div-gpt-ad-1438287399331-0'); expect(ajaxStub.firstCall.args[2]).to.include('test-publisher'); expect(ajaxStub.firstCall.args[2]).to.include('2f7b179d443f14'); - expect(ajaxStub.firstCall.args[3]).to.eql({method : 'POST', withCredentials: true}); + expect(ajaxStub.firstCall.args[3]).to.eql({method: 'POST', withCredentials: true}); }); it('should call server once when one size is passed', () => { @@ -87,51 +86,48 @@ describe('quantcast adapter', () => { expect(ajaxStub.firstCall.args[0]).to.eql(adapter.QUANTCAST_CALLBACK_URL); expect(ajaxStub.firstCall.args[1]).to.exist.and.to.be.a('function'); - expect(ajaxStub.firstCall.args[3]).to.eql({method : 'POST', withCredentials: true}); + expect(ajaxStub.firstCall.args[3]).to.eql({method: 'POST', withCredentials: true}); }); it('should call server once when size is passed as string', () => { - bidderRequest.bids[0].sizes = "728x90"; + bidderRequest.bids[0].sizes = '728x90'; adapter.callBids(bidderRequest); sinon.assert.calledOnce(ajaxStub); expect(ajaxStub.firstCall.args[0]).to.eql(adapter.QUANTCAST_CALLBACK_URL); expect(ajaxStub.firstCall.args[1]).to.exist.and.to.be.a('function'); - expect(ajaxStub.firstCall.args[3]).to.eql({method : 'POST', withCredentials: true}); + expect(ajaxStub.firstCall.args[3]).to.eql({method: 'POST', withCredentials: true}); }); it('should call server once when sizes are passed as a comma-separated string', () => { - bidderRequest.bids[0].sizes = "728x90,360x240"; + bidderRequest.bids[0].sizes = '728x90,360x240'; adapter.callBids(bidderRequest); sinon.assert.calledOnce(ajaxStub); expect(ajaxStub.firstCall.args[0]).to.eql(adapter.QUANTCAST_CALLBACK_URL); expect(ajaxStub.firstCall.args[1]).to.exist.and.to.be.a('function'); - expect(ajaxStub.firstCall.args[3]).to.eql({method : 'POST', withCredentials: true}); + expect(ajaxStub.firstCall.args[3]).to.eql({method: 'POST', withCredentials: true}); }); - - }); describe('handleQuantcastCB add bids to the manager', () => { - let firstBid; let addBidReponseStub; let bidsRequestedOriginal; // respond let bidderReponse = { - "bidderCode": "quantcast", - "requestId" : bidderRequest.requestId, - "bids" : [ - { - "statusCode" : 1, - "placementCode" : bidderRequest.bids[0].bidId, - "cpm": 4.5, - "ad": "\n\n\n
\n
\n\n \n\n\"Quantcast\"/\n\n
\n
", - "width": 300, - "height": 250 - } - ] + 'bidderCode': 'quantcast', + 'requestId': bidderRequest.requestId, + 'bids': [ + { + 'statusCode': 1, + 'placementCode': bidderRequest.bids[0].bidId, + 'cpm': 4.5, + 'ad': '\n\n\n
\n
\n\n \n\nQuantcast\n\n
\n
', + 'width': 300, + 'height': 250 + } + ] }; beforeEach(() => { @@ -169,26 +165,25 @@ describe('quantcast adapter', () => { adapter.callBids(bidderRequest); $$PREBID_GLOBAL$$.handleQuantcastCB(JSON.stringify(bidderReponse)); sinon.assert.calledOnce(addBidReponseStub); - expect(addBidReponseStub.firstCall.args[0]).to.eql("div-gpt-ad-1438287399331-0"); + expect(addBidReponseStub.firstCall.args[0]).to.eql('div-gpt-ad-1438287399331-0'); }); - it('should return no bid even when requestId and sizes are missing', () =>{ + it('should return no bid even when requestId and sizes are missing', () => { let bidderReponse = { - "bidderCode": "quantcast", - "bids" : [ - { - "statusCode" : 0, - "placementCode" : bidderRequest.bids[0].bidId, - } - ] - }; + 'bidderCode': 'quantcast', + 'bids': [ + { + 'statusCode': 0, + 'placementCode': bidderRequest.bids[0].bidId, + } + ] + }; // You need the following call so that the in-memory storage of the bidRequest is carried out. Without this the callback won't work correctly. adapter.callBids(bidderRequest); $$PREBID_GLOBAL$$.handleQuantcastCB(JSON.stringify(bidderReponse)); - //sinon.assert.calledOnce(addBidReponseStub); - //expect(addBidReponseStub.firstCall.args[0]).to.eql("div-gpt-ad-1438287399331-0"); + // sinon.assert.calledOnce(addBidReponseStub); + // expect(addBidReponseStub.firstCall.args[0]).to.eql("div-gpt-ad-1438287399331-0"); }); }); - }); diff --git a/test/spec/adapters/rhythmone_spec.js b/test/spec/adapters/rhythmone_spec.js index 00f19a551d3..efc964b6b6e 100644 --- a/test/spec/adapters/rhythmone_spec.js +++ b/test/spec/adapters/rhythmone_spec.js @@ -2,90 +2,89 @@ var r1 = require('../../../src/adapters/rhythmone.js'); var assert = require('assert'); describe('rhythmone adapter tests', function () { - describe('rhythmoneResponse', function () { + describe('rhythmoneResponse', function () { + var fakeResponse = { + 'id': '1fe94c2e-4b31-4e09-b074-ba90fe7ce92d', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'ff8b09b1-5264-52be-4b7b-0156526452bf', + 'impid': 'div-gpt-ad-1438287399331-0', + 'price': 1.0, + 'adid': '35858', + 'adm': "\"\"", + 'adomain': ['www.rhythmone.com'], + 'cid': '35857', + 'cat': [], + 'h': 250, + 'w': 300 + } + ], + 'seat': '14', + 'group': 0 + } + ], + 'bidid': 'ff8b09b1-5264-52be-4b7b-0156526452bf' + }; + + var endEvent = function() {}, + wonEvent = function() {}; ; - var fakeResponse = { - "id": "1fe94c2e-4b31-4e09-b074-ba90fe7ce92d", - "seatbid": [ - { - "bid": [ - { - "id": "ff8b09b1-5264-52be-4b7b-0156526452bf", - "impid": "div-gpt-ad-1438287399331-0", - "price": 1.0, - "adid": "35858", - "adm": "\"\"", - "adomain": ["www.rhythmone.com"], - "cid": "35857", - "cat": [], - "h": 250, - "w": 300 - } - ], - "seat": "14", - "group": 0 - } - ], - "bidid": "ff8b09b1-5264-52be-4b7b-0156526452bf" - }; - - var endEvent = function(){}, - wonEvent = function(){};; - - var z = new r1( - { - addBidResponse: function(placementcode, adResponse){ - it("should echo placementcode div-gpt-ad-1438287399331-0", function(){ - assert.equal(placementcode, "div-gpt-ad-1438287399331-0"); - }); - it("should have the expected ad response", function(){ - assert.equal((adResponse.ad === undefined || adResponse.ad.length > 0), true); - assert.equal(adResponse.width, 300); - assert.equal(adResponse.height, 250); - assert.equal(adResponse.cpm, 1); - assert.equal(adResponse.bidderCode, "rhythmone"); - }); - } - }, + var z = new r1( + { + addBidResponse: function(placementcode, adResponse) { + it('should echo placementcode div-gpt-ad-1438287399331-0', function() { + assert.equal(placementcode, 'div-gpt-ad-1438287399331-0'); + }); + it('should have the expected ad response', function() { + assert.equal((adResponse.ad === undefined || adResponse.ad.length > 0), true); + assert.equal(adResponse.width, 300); + assert.equal(adResponse.height, 250); + assert.equal(adResponse.cpm, 1); + assert.equal(adResponse.bidderCode, 'rhythmone'); + }); + } + }, { - "navigator":{}, - "pbjs":{ - "onEvent":function(e, f){ - if(e.toLowerCase() === "auctionend") endEvent = f; - if(e.toLowerCase() === "bidwon") wonEvent = f; + 'navigator': {}, + 'pbjs': { + 'onEvent': function(e, f) { + if (e.toLowerCase() === 'auctionend') endEvent = f; + if (e.toLowerCase() === 'bidwon') wonEvent = f; }, - "getBidResponses":function(){return {"div-gpt-ad-1438287399331-0":{"bids":[{cpm:1,bidderCode:"rhythmone"},{cpm:2,bidderCode:"rhythmone"}]}};}, - "version": "v0.20.0-pre" + 'getBidResponses': function() { return {'div-gpt-ad-1438287399331-0': {'bids': [{cpm: 1, bidderCode: 'rhythmone'}, {cpm: 2, bidderCode: 'rhythmone'}]}}; }, + 'version': 'v0.20.0-pre' } }, - function(url, callback){ - callback(JSON.stringify(fakeResponse), {status:200, responseText: JSON.stringify(fakeResponse)}); - }); - - z.callBids({ - "bidderCode":"rhythmone", - "bids":[ - { - "bidder":"rhythmone", - "params":{ - "placementId":"xyz", - "keywords":"", - "categories":[], - "trace":true, - "method":"get", - "endpoint":"http://fakedomain.com" - }, - "mediaType": "video", - "placementCode":"div-gpt-ad-1438287399331-0", - "sizes":[[300,250]] - } - ] - }); - + function(url, callback) { + callback(JSON.stringify(fakeResponse), {status: 200, responseText: JSON.stringify(fakeResponse)}); + }); + + z.callBids({ + 'bidderCode': 'rhythmone', + 'bids': [ + { + 'bidder': 'rhythmone', + 'params': { + 'placementId': 'xyz', + 'keywords': '', + 'categories': [], + 'trace': true, + 'method': 'get', + 'endpoint': 'http://fakedomain.com' + }, + 'mediaType': 'video', + 'placementCode': 'div-gpt-ad-1438287399331-0', + 'sizes': [[300, 250]] + } + ] + }); + endEvent(); wonEvent({ - bidderCode: "rhythmone", - adUnitCode: "div-gpt-ad-1438287399331-0" + bidderCode: 'rhythmone', + adUnitCode: 'div-gpt-ad-1438287399331-0' }); - }); -}); \ No newline at end of file + }); +}); diff --git a/test/spec/adapters/roxot_spec.js b/test/spec/adapters/roxot_spec.js index 468d3f22ce1..471d97d9a22 100644 --- a/test/spec/adapters/roxot_spec.js +++ b/test/spec/adapters/roxot_spec.js @@ -1,10 +1,9 @@ -describe('Roxot adapter tests', function(){ +describe('Roxot adapter tests', function() { const expect = require('chai').expect; const adapter = require('src/adapters/roxot'); const bidmanager = require('src/bidmanager'); describe('roxotResponseHandler', function () { - it('should exist and be a function', function () { expect(pbjs.roxotResponseHandler).to.exist.and.to.be.a('function'); }); @@ -30,11 +29,10 @@ describe('Roxot adapter tests', function(){ ] }; - // no bids returned in the response. var response = { - "id": "123", - "bids": [] + 'id': '123', + 'bids': [] }; pbjs._bidsRequested.push(bidderRequest); @@ -61,7 +59,6 @@ describe('Roxot adapter tests', function(){ }); it('should add a bid response for bids returned and empty bid responses for the rest', () => { - var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); var bidderRequest = { @@ -84,15 +81,15 @@ describe('Roxot adapter tests', function(){ // Returning a single bid in the response. var response = { - "id": "12345", - "bids": [ + 'id': '12345', + 'bids': [ { - "bidId" : "id1", - "cpm" : 0.09, - "nurl" : "http://roxot.example.com", - "adm" : "<>", - "h" : 320, - "w" : 50 + 'bidId': 'id1', + 'cpm': 0.09, + 'nurl': 'http://roxot.example.com', + 'adm': '<>', + 'h': 320, + 'w': 50 } ]}; @@ -123,4 +120,4 @@ describe('Roxot adapter tests', function(){ stubAddBidResponse.restore(); }); }); -}); \ No newline at end of file +}); diff --git a/test/spec/adapters/rubicon_spec.js b/test/spec/adapters/rubicon_spec.js index 1d966f8691c..75ecdbef0d4 100644 --- a/test/spec/adapters/rubicon_spec.js +++ b/test/spec/adapters/rubicon_spec.js @@ -10,10 +10,9 @@ var CONSTANTS = require('src/constants.json'); const INTEGRATION = `pbjs_lite_v$prebid.version$`; // $prebid.version$ will be substituted in by gulp in built prebid describe('the rubicon adapter', () => { - let sandbox, - adUnit, - bidderRequest; + adUnit, + bidderRequest; function createVideoBidderRequest() { let bid = bidderRequest.bids[0]; @@ -68,14 +67,14 @@ describe('the rubicon adapter', () => { siteId: '70608', zoneId: '335918', userId: '12346', - keywords: ['a','b','c'], + keywords: ['a', 'b', 'c'], inventory: { - rating:'5-star', - prodtype:'tech' + rating: '5-star', + prodtype: 'tech' }, visitor: { - ucat:'new', - lastsearch:'iphone' + ucat: 'new', + lastsearch: 'iphone' }, position: 'atf', referrer: 'localhost' @@ -96,14 +95,14 @@ describe('the rubicon adapter', () => { siteId: '70608', zoneId: '335918', userId: '12346', - keywords: ['a','b','c'], + keywords: ['a', 'b', 'c'], inventory: { - rating:'5-star', - prodtype:'tech' + rating: '5-star', + prodtype: 'tech' }, visitor: { - ucat:'new', - lastsearch:'iphone' + ucat: 'new', + lastsearch: 'iphone' }, position: 'atf', referrer: 'localhost' @@ -119,7 +118,6 @@ describe('the rubicon adapter', () => { auctionStart: 1472239426000, timeout: 5000 }; - }); afterEach(() => { @@ -127,11 +125,9 @@ describe('the rubicon adapter', () => { }); describe('callBids public interface', () => { - let rubiconAdapter = adapterManager.bidderRegistry['rubicon']; it('should receive a well-formed bidRequest from the adaptermanager', () => { - sandbox.stub(rubiconAdapter, 'callBids'); adapterManager.callBids({ @@ -162,13 +158,10 @@ describe('the rubicon adapter', () => { expect(bidderRequest).to.have.deep.property('bids[0]') .with.property('params') .that.deep.equals(adUnit.bids[0].params) - }); - }); describe('MAS mapping / ordering', () => { - let masSizeOrdering = RubiconAdapter.masSizeOrdering; it('should not include values without a proper mapping', () => { @@ -185,26 +178,23 @@ describe('the rubicon adapter', () => { }); it('should sort MAS priority sizes in the proper order w/ rest ascending', () => { - let ordering = masSizeOrdering([[320, 50], [160,600], [640, 480], [300, 250],[336, 280], [200, 600]]); + let ordering = masSizeOrdering([[320, 50], [160, 600], [640, 480], [300, 250], [336, 280], [200, 600]]); expect(ordering).to.deep.equal([15, 9, 16, 43, 65, 126]); - ordering = masSizeOrdering([[320, 50], [300, 250], [160,600], [640, 480],[336, 280], [200, 600], [728, 90]]); + ordering = masSizeOrdering([[320, 50], [300, 250], [160, 600], [640, 480], [336, 280], [200, 600], [728, 90]]); expect(ordering).to.deep.equal([15, 2, 9, 16, 43, 65, 126]); - ordering = masSizeOrdering([[120, 600], [320, 50], [160,600], [640, 480],[336, 280], [200, 600], [728, 90]]); + ordering = masSizeOrdering([[120, 600], [320, 50], [160, 600], [640, 480], [336, 280], [200, 600], [728, 90]]); expect(ordering).to.deep.equal([2, 9, 8, 16, 43, 65, 126]); }); - }); describe('callBids implementation', () => { - let rubiconAdapter; describe('for requests', () => { - let xhr, - bids; + bids; beforeEach(() => { rubiconAdapter = new RubiconAdapter(); @@ -223,9 +213,7 @@ describe('the rubicon adapter', () => { }); describe('to fastlane', () => { - it('should make a well-formed request', () => { - rubiconAdapter.callBids(bidderRequest); let request = xhr.requests[0]; @@ -260,7 +248,7 @@ describe('the rubicon adapter', () => { // test that all values above are both present and correct Object.keys(expectedQuery).forEach(key => { let value = expectedQuery[key]; - if(value instanceof RegExp) { + if (value instanceof RegExp) { expect(query[key]).to.match(value); } else { expect(query[key]).to.equal(value); @@ -268,11 +256,9 @@ describe('the rubicon adapter', () => { }); expect(query).to.have.property('rand'); - }); it('should use rubicon sizes if present', () => { - var sizesBidderRequest = clone(bidderRequest); sizesBidderRequest.bids[0].params.sizes = [55, 57, 59]; @@ -282,13 +268,11 @@ describe('the rubicon adapter', () => { expect(query['size_id']).to.equal('55'); expect(query['alt_size_ids']).to.equal('57,59'); - }); it('should not send a request and register an error bid if no valid sizes', () => { - var sizesBidderRequest = clone(bidderRequest); - sizesBidderRequest.bids[0].sizes = [[620,250],[300,251]]; + sizesBidderRequest.bids[0].sizes = [[620, 250], [300, 251]]; rubiconAdapter.callBids(sizesBidderRequest); @@ -297,11 +281,9 @@ describe('the rubicon adapter', () => { expect(bidManager.addBidResponse.calledOnce).to.equal(true); expect(bids).to.be.lengthOf(1); expect(bids[0].getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); - }); it('should not send a request and register an error if no account id is present', () => { - var noAccountBidderRequest = clone(bidderRequest); delete noAccountBidderRequest.bids[0].params.accountId; @@ -311,11 +293,9 @@ describe('the rubicon adapter', () => { expect(bidManager.addBidResponse.calledOnce).to.equal(true); expect(bids).to.be.lengthOf(1); expect(bids[0].getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); - }); it('should allow a floor override', () => { - var floorBidderRequest = clone(bidderRequest); floorBidderRequest.bids[0].params.floor = 2; @@ -324,13 +304,10 @@ describe('the rubicon adapter', () => { let query = parseQuery(xhr.requests[0].url.split('?')[1]); expect(query['rp_floor']).to.equal('2'); - }); - }); describe('for video requests', () => { - /* beforeEach(() => { createVideoBidderRequest(); @@ -381,7 +358,7 @@ describe('the rubicon adapter', () => { expect(slot.site_id).to.equal('70608'); expect(slot.zone_id).to.equal('335918'); expect(slot.position).to.equal('atf'); - expect(slot.floor).to.equal(.01); + expect(slot.floor).to.equal(0.01); expect(slot.element_id).to.equal(bidderRequest.bids[0].placementCode); expect(slot.name).to.equal(bidderRequest.bids[0].placementCode); expect(slot.language).to.equal('en'); @@ -401,7 +378,6 @@ describe('the rubicon adapter', () => { expect(slot).to.have.property('visitor').that.is.an('object'); expect(slot.visitor).to.have.property('ucat').that.equals('new'); expect(slot.visitor).to.have.property('lastsearch').that.equals('iphone'); - }); it('should allow a floor price override', () => { @@ -424,7 +400,6 @@ describe('the rubicon adapter', () => { let floor = post.slots[0].floor; expect(floor).to.equal(3.25); - }); it('should trap when no video object is passed in', () => { @@ -456,18 +431,13 @@ describe('the rubicon adapter', () => { expect(post.slots[0].width).to.equal(300); expect(post.slots[0].height).to.equal(250); }); - }); - }); - - - describe('response handler', () => { let bids, - server, - addBidResponseAction; + server, + addBidResponseAction; beforeEach(() => { bids = []; @@ -476,7 +446,7 @@ describe('the rubicon adapter', () => { sandbox.stub(bidManager, 'addBidResponse', (elemId, bid) => { bids.push(bid); - if(addBidResponseAction) { + if (addBidResponseAction) { addBidResponseAction(); addBidResponseAction = undefined; } @@ -488,9 +458,7 @@ describe('the rubicon adapter', () => { }); describe('for fastlane', () => { - it('should handle a success response and sort by cpm', () => { - server.respondWith(JSON.stringify({ 'status': 'ok', 'account_id': 14062, @@ -592,10 +560,10 @@ describe('the rubicon adapter', () => { 'tracking': '', 'inventory': {}, 'ads': [{ - 'status': 'ok', - 'cpm': 0, - 'size_id': 15 - }] + 'status': 'ok', + 'cpm': 0, + 'size_id': 15 + }] })); rubiconAdapter.callBids(bidderRequest); @@ -644,8 +612,8 @@ describe('the rubicon adapter', () => { 'tracking': '', 'inventory': {}, 'ads': [{ - 'status': 'not_ok', - }] + 'status': 'not_ok', + }] })); rubiconAdapter.callBids(bidderRequest); @@ -670,7 +638,7 @@ describe('the rubicon adapter', () => { }); it('should handle error contacting endpoint', () => { - server.respondWith([404, {}, ""]); + server.respondWith([404, {}, '']); rubiconAdapter.callBids(bidderRequest); @@ -682,7 +650,6 @@ describe('the rubicon adapter', () => { }); it('should not register an error bid when a success call to addBidResponse throws an error', () => { - server.respondWith(JSON.stringify({ 'status': 'ok', 'account_id': 14062, @@ -695,10 +662,10 @@ describe('the rubicon adapter', () => { 'tracking': '', 'inventory': {}, 'ads': [{ - 'status': 'ok', - 'cpm': .8, - 'size_id': 15 - }] + 'status': 'ok', + 'cpm': 0.8, + 'size_id': 15 + }] })); addBidResponseAction = function() { @@ -712,19 +679,15 @@ describe('the rubicon adapter', () => { // was calling twice for same bid, but should only call once expect(bidManager.addBidResponse.calledOnce).to.equal(true); expect(bids).to.be.lengthOf(1); - }); - }); describe('for video', () => { - beforeEach(() => { createVideoBidderRequest(); }); it('should register a successful bid', () => { - server.respondWith(JSON.stringify({ 'status': 'ok', 'ads': { @@ -769,16 +732,10 @@ describe('the rubicon adapter', () => { 'https://fastlane-adv.rubiconproject.com/v1/creative/a40fe16e-d08d-46a9-869d-2e1573599e0c.xml' ); expect(bids[0].impression_id).to.equal('a40fe16e-d08d-46a9-869d-2e1573599e0c'); - }); - }); - }); - - }); - }); function clone(obj) { diff --git a/test/spec/adapters/sekindoUM_spec.js b/test/spec/adapters/sekindoUM_spec.js index ff59b247550..d1bd1d4b9f5 100644 --- a/test/spec/adapters/sekindoUM_spec.js +++ b/test/spec/adapters/sekindoUM_spec.js @@ -2,85 +2,77 @@ import {expect} from 'chai'; import sekindoUMAdapter from '../../../src/adapters/sekindoUM'; var bidManager = require('src/bidmanager'); - -describe("sekindoUM Adapter Tests", () => { - - let _sekindoUMAdapter; - var addBidResponseSpy; - - const bidderRequest = { - bidderCode: 'sekindoUM', - bids: [{ - bidder: 'sekindoUM', - bidId: 'sekindo_bidId', - bidderRequestId: 'sekindo_bidderRequestId', - requestId: 'sekindo_requestId', - placementCode: 'foo', - params: { - spaceId: 14071 - } - }] - }; - - beforeEach(() => { - _sekindoUMAdapter = new sekindoUMAdapter(); - }); - - describe('sekindoUM callBids', () => { - - beforeEach(() => { - _sekindoUMAdapter.callBids(bidderRequest); - }); - - it('Verify sekindo script tag was created', () => { - var scriptTags = document.getElementsByTagName('script'); - var sekindoTagExists=0; - for (var i=0; i { + let _sekindoUMAdapter; + var addBidResponseSpy; + + const bidderRequest = { + bidderCode: 'sekindoUM', + bids: [{ + bidder: 'sekindoUM', + bidId: 'sekindo_bidId', + bidderRequestId: 'sekindo_bidderRequestId', + requestId: 'sekindo_requestId', + placementCode: 'foo', + params: { + spaceId: 14071 + } + }] + }; + + beforeEach(() => { + _sekindoUMAdapter = new sekindoUMAdapter(); + }); + + describe('sekindoUM callBids', () => { + beforeEach(() => { + _sekindoUMAdapter.callBids(bidderRequest); }); + it('Verify sekindo script tag was created', () => { + var scriptTags = document.getElementsByTagName('script'); + var sekindoTagExists = 0; + for (var i = 0; i < scriptTags.length; i++) { + if (scriptTags[i].src.match('hb.sekindo.com') != null) { + sekindoTagExists = 1; + break; + } + } + expect(sekindoTagExists).to.equal(1); + }); + }); - describe('Should submit bid responses correctly', function () { - - beforeEach(function () { - addBidResponseSpy = sinon.stub(bidManager, 'addBidResponse'); - $$PREBID_GLOBAL$$._bidsRequested.push(bidderRequest); - _sekindoUMAdapter = new sekindoUMAdapter(); - }); - - afterEach(function () { - addBidResponseSpy.restore(); - }); - - it('Should correctly submit valid bid to the bid manager', function () { - var HB_bid = { - adId : 'sekindoUM_bidId', - cpm :0.23, - width : 300, - height : 250, - ad : '

test ad

' - }; - - $$PREBID_GLOBAL$$.sekindoCB(bidderRequest.bids[0].bidId, HB_bid); - var firstBid = addBidResponseSpy.getCall(0).args[1]; - var placementCode1 = addBidResponseSpy.getCall(0).args[0]; - - expect(firstBid.getStatusCode()).to.equal(1); - expect(firstBid.bidderCode).to.equal('sekindoUM'); - expect(firstBid.cpm).to.equal(0.23); - expect(firstBid.ad).to.equal('

test ad

'); - expect(placementCode1).to.equal('foo'); + describe('Should submit bid responses correctly', function () { + beforeEach(function () { + addBidResponseSpy = sinon.stub(bidManager, 'addBidResponse'); + $$PREBID_GLOBAL$$._bidsRequested.push(bidderRequest); + _sekindoUMAdapter = new sekindoUMAdapter(); + }); - expect(addBidResponseSpy.getCalls().length).to.equal(1); - }); + afterEach(function () { + addBidResponseSpy.restore(); }); + it('Should correctly submit valid bid to the bid manager', function () { + var HB_bid = { + adId: 'sekindoUM_bidId', + cpm: 0.23, + width: 300, + height: 250, + ad: '

test ad

' + }; + + $$PREBID_GLOBAL$$.sekindoCB(bidderRequest.bids[0].bidId, HB_bid); + var firstBid = addBidResponseSpy.getCall(0).args[1]; + var placementCode1 = addBidResponseSpy.getCall(0).args[0]; + + expect(firstBid.getStatusCode()).to.equal(1); + expect(firstBid.bidderCode).to.equal('sekindoUM'); + expect(firstBid.cpm).to.equal(0.23); + expect(firstBid.ad).to.equal('

test ad

'); + expect(placementCode1).to.equal('foo'); + + expect(addBidResponseSpy.getCalls().length).to.equal(1); + }); + }); }); diff --git a/test/spec/adapters/serverbid_spec.js b/test/spec/adapters/serverbid_spec.js index 3a7408c34e5..29d51058888 100644 --- a/test/spec/adapters/serverbid_spec.js +++ b/test/spec/adapters/serverbid_spec.js @@ -9,77 +9,74 @@ import * as utils from 'src/utils'; const ENDPOINT = '//e.serverbid.com/api/v2'; const REQUEST = { - "bidderCode": "serverbid", - "requestId": "a4713c32-3762-4798-b342-4ab810ca770d", - "bidderRequestId": "109f2a181342a9", - "bids": [{ - "bidder": "serverbid", - "params": { - "networkId": 9969, - "siteId": 730181 + 'bidderCode': 'serverbid', + 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d', + 'bidderRequestId': '109f2a181342a9', + 'bids': [{ + 'bidder': 'serverbid', + 'params': { + 'networkId': 9969, + 'siteId': 730181 }, - "placementCode": "div-gpt-ad-1487778092495-0", - "sizes": [ + 'placementCode': 'div-gpt-ad-1487778092495-0', + 'sizes': [ [728, 90], [970, 90] ], - "bidId": "2b0f82502298c9", - "bidderRequestId": "109f2a181342a9", - "requestId": "a4713c32-3762-4798-b342-4ab810ca770d" + 'bidId': '2b0f82502298c9', + 'bidderRequestId': '109f2a181342a9', + 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d' }], - "start": 1487883186070, - "auctionStart": 1487883186069, - "timeout": 3000 + 'start': 1487883186070, + 'auctionStart': 1487883186069, + 'timeout': 3000 }; const RESPONSE = { - "user": { "key": "ue1-2d33e91b71e74929b4aeecc23f4376f1" }, - "decisions": { - "2b0f82502298c9": { - "adId": 2364764, - "creativeId": 1950991, - "flightId": 2788300, - "campaignId": 542982, - "clickUrl": "http://e.serverbid.com/r", - "impressionUrl": "http://e.serverbid.com/i.gif", - "contents": [{ - "type": "html", - "body": "", - "data": { - "height": 90, - "width": 728, - "imageUrl": "http://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif", - "fileName": "b0ab77db8a7848c8b78931aed022a5ef.gif" + 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, + 'decisions': { + '2b0f82502298c9': { + 'adId': 2364764, + 'creativeId': 1950991, + 'flightId': 2788300, + 'campaignId': 542982, + 'clickUrl': 'http://e.serverbid.com/r', + 'impressionUrl': 'http://e.serverbid.com/i.gif', + 'contents': [{ + 'type': 'html', + 'body': '', + 'data': { + 'height': 90, + 'width': 728, + 'imageUrl': 'http://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', + 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' }, - "template": "image" + 'template': 'image' }], - "height": 90, - "width": 728, - "events": [], - "pricing":{"price":0.5,"clearPrice":0.5,"revenue":0.0005,"rateType":2,"eCPM":0.5} + 'height': 90, + 'width': 728, + 'events': [], + 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} }, } }; describe('serverbidAdapter', () => { - let adapter; beforeEach(() => adapter = Adapter.createNew()); describe('request function', () => { - let xhr; let requests; let pbConfig; - beforeEach(() => { xhr = sinon.useFakeXMLHttpRequest(); requests = []; xhr.onCreate = request => requests.push(request); pbConfig = REQUEST; - //just a single slot + // just a single slot pbConfig.bids = [pbConfig.bids[0]]; }); @@ -96,11 +93,11 @@ describe('serverbidAdapter', () => { it('requires networkId and siteId', () => { let backup = pbConfig.bids[0].params; - pbConfig.bids[0].params = { networkId: 1234 }; //no hbid + pbConfig.bids[0].params = { networkId: 1234 }; // no hbid adapter.callBids(pbConfig); expect(requests).to.be.empty; - pbConfig.bids[0].params = { siteId: 1234 }; //no placementid + pbConfig.bids[0].params = { siteId: 1234 }; // no placementid adapter.callBids(pbConfig); expect(requests).to.be.empty; @@ -115,13 +112,12 @@ describe('serverbidAdapter', () => { }); describe('response handler', () => { - let server; beforeEach(() => { server = sinon.fakeServer.create(); sinon.stub(bidmanager, 'addBidResponse'); - sinon.stub(utils, "getBidRequest").returns(REQUEST); + sinon.stub(utils, 'getBidRequest').returns(REQUEST); }); afterEach(() => { @@ -145,7 +141,7 @@ describe('serverbidAdapter', () => { it('handles nobid responses', () => { server.respondWith(JSON.stringify({ - "decisions": [] + 'decisions': [] })); adapter.callBids(REQUEST); @@ -172,7 +168,5 @@ describe('serverbidAdapter', () => { 'Bid returned empty or error response' ); }); - }); - -}); \ No newline at end of file +}); diff --git a/test/spec/adapters/sharethrough_spec.js b/test/spec/adapters/sharethrough_spec.js index 24884b87ffb..8f0bef53a4a 100644 --- a/test/spec/adapters/sharethrough_spec.js +++ b/test/spec/adapters/sharethrough_spec.js @@ -3,7 +3,6 @@ import Adapter from '../../../src/adapters/sharethrough'; import bidManager from '../../../src/bidmanager'; describe('sharethrough adapter', () => { - let adapter; let sandbox; let bidsRequestedOriginal; @@ -14,7 +13,7 @@ describe('sharethrough adapter', () => { { bidder: 'sharethrough', bidId: 'bidId1', - sizes: [[600,300]], + sizes: [[600, 300]], placementCode: 'foo', params: { pkey: 'aaaa1111' @@ -23,7 +22,7 @@ describe('sharethrough adapter', () => { { bidder: 'sharethrough', bidId: 'bidId2', - sizes: [[700,400]], + sizes: [[700, 400]], placementCode: 'bar', params: { pkey: 'bbbb2222' @@ -46,16 +45,14 @@ describe('sharethrough adapter', () => { }); describe('callBids', () => { - let firstBidUrl; let secondBidUrl; beforeEach(() => { - sandbox.spy(adapter.str, 'ajax'); + sandbox.spy(adapter.str, 'ajax'); }); it('should call ajax to make a request for each bid', () => { - adapter.callBids(bidderRequest); firstBidUrl = adapter.str.ajax.firstCall.args[0]; @@ -66,11 +63,9 @@ describe('sharethrough adapter', () => { expect(firstBidUrl).to.contain(adapter.str.STR_BTLR_HOST + '/header-bid/v1?bidId=bidId1&placement_key=aaaa1111&hbVersion=%24prebid.version%24&strVersion=1.2.0&hbSource=prebid&'); expect(secondBidUrl).to.contain(adapter.str.STR_BTLR_HOST + '/header-bid/v1?bidId=bidId2&placement_key=bbbb2222&hbVersion=%24prebid.version%24&strVersion=1.2.0&hbSource=prebid&'); }); - }); describe('bid requests', () => { - let firstBid; let secondBid; let server; @@ -85,33 +80,33 @@ describe('sharethrough adapter', () => { // respond let bidderResponse1 = { - "adserverRequestId": "40b6afd5-6134-4fbb-850a-bb8972a46994", - "bidId": "bidId1", - "creatives": [ - { - "cpm": 12.34, - "auctionWinId": "b2882d5e-bf8b-44da-a91c-0c11287b8051", - "version": 1 - } - ], - "stxUserId": "" - }; + 'adserverRequestId': '40b6afd5-6134-4fbb-850a-bb8972a46994', + 'bidId': 'bidId1', + 'creatives': [ + { + 'cpm': 12.34, + 'auctionWinId': 'b2882d5e-bf8b-44da-a91c-0c11287b8051', + 'version': 1 + } + ], + 'stxUserId': '' + }; let bidderResponse2 = { - "adserverRequestId": "40b6afd5-6134-4fbb-850a-bb8972a46994", - "bidId": "bidId2", - "creatives": [ - { - "cpm": 12.35, - "auctionWinId": "b2882d5e-bf8b-44da-a91c-0c11287b8051", - "version": 1 - } - ], - "stxUserId": "" - }; - - server.respondWith(/aaaa1111/,JSON.stringify(bidderResponse1)); - server.respondWith(/bbbb2222/,JSON.stringify(bidderResponse2)); + 'adserverRequestId': '40b6afd5-6134-4fbb-850a-bb8972a46994', + 'bidId': 'bidId2', + 'creatives': [ + { + 'cpm': 12.35, + 'auctionWinId': 'b2882d5e-bf8b-44da-a91c-0c11287b8051', + 'version': 1 + } + ], + 'stxUserId': '' + }; + + server.respondWith(/aaaa1111/, JSON.stringify(bidderResponse1)); + server.respondWith(/bbbb2222/, JSON.stringify(bidderResponse2)); adapter.callBids(bidderRequest); server.respond(); @@ -172,7 +167,5 @@ describe('sharethrough adapter', () => { expect(firstBid).to.have.property('pkey', 'aaaa1111'); expect(secondBid).to.have.property('pkey', 'bbbb2222'); }); - }); - }); diff --git a/test/spec/adapters/smartadserver_spec.js b/test/spec/adapters/smartadserver_spec.js index f9ebcac2fb7..9f0b736d2d5 100644 --- a/test/spec/adapters/smartadserver_spec.js +++ b/test/spec/adapters/smartadserver_spec.js @@ -1,66 +1,66 @@ -describe("smartadserver adapter tests", function () { - var urlParse = require("url-parse"); - var querystringify = require("querystringify"); - var adapter = require("src/adapters/smartadserver"); - var adLoader = require("src/adloader"); - var expect = require("chai").expect; - var bidmanager = require("src/bidmanager"); +describe('smartadserver adapter tests', function () { + var urlParse = require('url-parse'); + var querystringify = require('querystringify'); + var adapter = require('src/adapters/smartadserver'); + var adLoader = require('src/adloader'); + var expect = require('chai').expect; + var bidmanager = require('src/bidmanager'); var CONSTANTS = require('src/constants.json'); var DEFAULT_PARAMS = { - bidderCode: "smartadserver", - bids: [{ - bidId: "abcd1234", - sizes: [[300, 250], [300, 200]], - bidder: "smartadserver", - params: { - domain: "http://www.smartadserver.com", - siteId: "1234", - pageId: "5678", - formatId: "90", - target: "test=prebid", - currency: "EUR", - bidfloor: 0.420 - }, - requestId: "efgh5678", - placementCode: "sas_42" - } - ] + bidderCode: 'smartadserver', + bids: [{ + bidId: 'abcd1234', + sizes: [[300, 250], [300, 200]], + bidder: 'smartadserver', + params: { + domain: 'http://www.smartadserver.com', + siteId: '1234', + pageId: '5678', + formatId: '90', + target: 'test=prebid', + currency: 'EUR', + bidfloor: 0.420 + }, + requestId: 'efgh5678', + placementCode: 'sas_42' + } + ] }; var DEFAULT_PARAMS_WO_OPTIONAL = { - bidderCode: "smartadserver", + bidderCode: 'smartadserver', bids: [{ - bidId: "abcd1234", - sizes: [[300, 250], [300, 200]], - bidder: "smartadserver", - params: { - domain: "http://www.smartadserver.com", - siteId: "1234", - pageId: "5678", - formatId: "90" - }, - requestId: "efgh5678", - placementCode: "sas_42" - } + bidId: 'abcd1234', + sizes: [[300, 250], [300, 200]], + bidder: 'smartadserver', + params: { + domain: 'http://www.smartadserver.com', + siteId: '1234', + pageId: '5678', + formatId: '90' + }, + requestId: 'efgh5678', + placementCode: 'sas_42' + } ] }; var BID_RESPONSE = { cpm: 0.42, - ad: "fake ad content", + ad: 'fake ad content', width: 300, height: 250 }; - it("set url parameters", function () { - var stubLoadScript = sinon.stub(adLoader, "loadScript"); + it('set url parameters', function () { + var stubLoadScript = sinon.stub(adLoader, 'loadScript'); adapter().callBids(DEFAULT_PARAMS); var smartCallback; for (var k in $$PREBID_GLOBAL$$) { - if (k.lastIndexOf("sas_", 0) === 0) { + if (k.lastIndexOf('sas_', 0) === 0) { smartCallback = k; break; } @@ -70,25 +70,25 @@ describe("smartadserver adapter tests", function () { var parsedBidUrl = urlParse(bidUrl); var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - expect(parsedBidUrl.hostname).to.equal("www.smartadserver.com"); - expect(parsedBidUrl.pathname).to.equal("/prebid"); + expect(parsedBidUrl.hostname).to.equal('www.smartadserver.com'); + expect(parsedBidUrl.pathname).to.equal('/prebid'); - expect(parsedBidUrlQueryString).to.have.property("pbjscbk").and.to.equal("pbjs." + smartCallback); - expect(parsedBidUrlQueryString).to.have.property("siteid").and.to.equal("1234"); - expect(parsedBidUrlQueryString).to.have.property("pgid").and.to.equal("5678"); - expect(parsedBidUrlQueryString).to.have.property("fmtid").and.to.equal("90"); - expect(parsedBidUrlQueryString).to.have.property("tgt").and.to.equal("test=prebid"); - expect(parsedBidUrlQueryString).to.have.property("ccy").and.to.equal("EUR"); - expect(parsedBidUrlQueryString).to.have.property("bidfloor").and.to.equal("0.42"); - expect(parsedBidUrlQueryString).to.have.property("tag").and.to.equal("sas_42"); - expect(parsedBidUrlQueryString).to.have.property("sizes").and.to.equal("300x250,300x200"); - expect(parsedBidUrlQueryString).to.have.property("async").and.to.equal("1"); + expect(parsedBidUrlQueryString).to.have.property('pbjscbk').and.to.equal('pbjs.' + smartCallback); + expect(parsedBidUrlQueryString).to.have.property('siteid').and.to.equal('1234'); + expect(parsedBidUrlQueryString).to.have.property('pgid').and.to.equal('5678'); + expect(parsedBidUrlQueryString).to.have.property('fmtid').and.to.equal('90'); + expect(parsedBidUrlQueryString).to.have.property('tgt').and.to.equal('test=prebid'); + expect(parsedBidUrlQueryString).to.have.property('ccy').and.to.equal('EUR'); + expect(parsedBidUrlQueryString).to.have.property('bidfloor').and.to.equal('0.42'); + expect(parsedBidUrlQueryString).to.have.property('tag').and.to.equal('sas_42'); + expect(parsedBidUrlQueryString).to.have.property('sizes').and.to.equal('300x250,300x200'); + expect(parsedBidUrlQueryString).to.have.property('async').and.to.equal('1'); stubLoadScript.restore(); }); - it("test optional parameters default value", function () { - var stubLoadScript = sinon.stub(adLoader, "loadScript"); + it('test optional parameters default value', function () { + var stubLoadScript = sinon.stub(adLoader, 'loadScript'); adapter().callBids(DEFAULT_PARAMS_WO_OPTIONAL); @@ -96,21 +96,21 @@ describe("smartadserver adapter tests", function () { var parsedBidUrl = urlParse(bidUrl); var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - expect(parsedBidUrlQueryString).to.have.property("tgt").and.to.equal(""); - expect(parsedBidUrlQueryString).to.have.property("ccy").and.to.equal("USD"); + expect(parsedBidUrlQueryString).to.have.property('tgt').and.to.equal(''); + expect(parsedBidUrlQueryString).to.have.property('ccy').and.to.equal('USD'); stubLoadScript.restore(); }); - it("creates an empty bid response if no bids", function() { - var stubLoadScript = sinon.stub(adLoader, "loadScript", function(url) { + it('creates an empty bid response if no bids', function() { + var stubLoadScript = sinon.stub(adLoader, 'loadScript', function(url) { var bidUrl = stubLoadScript.getCall(0).args[0]; var parsedBidUrl = urlParse(bidUrl); var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - pbjs[parsedBidUrlQueryString.pbjscbk.split(".")[1]](null); + pbjs[parsedBidUrlQueryString.pbjscbk.split('.')[1]](null); }); - var stubAddBidResponse = sinon.stub(bidmanager, "addBidResponse"); + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); adapter().callBids(DEFAULT_PARAMS); @@ -119,21 +119,21 @@ describe("smartadserver adapter tests", function () { expect(bidResponsePlacementCode).to.equal(DEFAULT_PARAMS.bids[0].placementCode); expect(bidResponseAd.getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); - expect(bidResponseAd).to.have.property("bidderCode").and.to.equal("smartadserver"); + expect(bidResponseAd).to.have.property('bidderCode').and.to.equal('smartadserver'); stubLoadScript.restore(); stubAddBidResponse.restore(); }); - it("creates a bid response if bid is returned", function() { - var stubLoadScript = sinon.stub(adLoader, "loadScript", function(url) { + it('creates a bid response if bid is returned', function() { + var stubLoadScript = sinon.stub(adLoader, 'loadScript', function(url) { var bidUrl = stubLoadScript.getCall(0).args[0]; var parsedBidUrl = urlParse(bidUrl); var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - pbjs[parsedBidUrlQueryString.pbjscbk.split(".")[1]](BID_RESPONSE); + pbjs[parsedBidUrlQueryString.pbjscbk.split('.')[1]](BID_RESPONSE); }); - var stubAddBidResponse = sinon.stub(bidmanager, "addBidResponse"); + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); adapter().callBids(DEFAULT_PARAMS); @@ -142,11 +142,11 @@ describe("smartadserver adapter tests", function () { expect(bidResponsePlacementCode).to.equal(DEFAULT_PARAMS.bids[0].placementCode); expect(bidResponseAd.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); - expect(bidResponseAd).to.have.property("bidderCode").and.to.equal("smartadserver"); - expect(bidResponseAd).to.have.property("cpm").and.to.equal(BID_RESPONSE.cpm); - expect(bidResponseAd).to.have.property("ad").and.to.equal(BID_RESPONSE.ad); - expect(bidResponseAd).to.have.property("width").and.to.equal(BID_RESPONSE.width); - expect(bidResponseAd).to.have.property("height").and.to.equal(BID_RESPONSE.height); + expect(bidResponseAd).to.have.property('bidderCode').and.to.equal('smartadserver'); + expect(bidResponseAd).to.have.property('cpm').and.to.equal(BID_RESPONSE.cpm); + expect(bidResponseAd).to.have.property('ad').and.to.equal(BID_RESPONSE.ad); + expect(bidResponseAd).to.have.property('width').and.to.equal(BID_RESPONSE.width); + expect(bidResponseAd).to.have.property('height').and.to.equal(BID_RESPONSE.height); stubLoadScript.restore(); stubAddBidResponse.restore(); diff --git a/test/spec/adapters/smartyads_spec.js b/test/spec/adapters/smartyads_spec.js index 357599e69cd..7d568573646 100644 --- a/test/spec/adapters/smartyads_spec.js +++ b/test/spec/adapters/smartyads_spec.js @@ -5,127 +5,124 @@ import bidManager from 'src/bidmanager'; import CONSTANTS from 'src/constants.json'; describe('Smartyads adapter tests', function () { - - let sandbox; - const adUnit = { // TODO CHANGE - code: 'smartyads', - sizes: [[300, 250], [300,600], [320, 80]], - bids: [{ - bidder: 'smartyads', - params: { - banner_id: 0 - } - }] - }; - - const response = { - ad_id: 0, - adm: "Test Response", - cpm: 0.5, - deal: "bf063e2e025c", - height: 240, - width: 360 - }; + let sandbox; + const adUnit = { // TODO CHANGE + code: 'smartyads', + sizes: [[300, 250], [300, 600], [320, 80]], + bids: [{ + bidder: 'smartyads', + params: { + banner_id: 0 + } + }] + }; + + const response = { + ad_id: 0, + adm: 'Test Response', + cpm: 0.5, + deal: 'bf063e2e025c', + height: 240, + width: 360 + }; + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + + afterEach(() => { + sandbox.restore(); + }); + + describe('Smartyads callBids validation', () => { + let bids, + server; beforeEach(() => { - sandbox = sinon.sandbox.create(); + bids = []; + server = sinon.fakeServer.create(); + + sandbox.stub(bidManager, 'addBidResponse', (elemId, bid) => { + bids.push(bid); + }); }); afterEach(() => { - sandbox.restore(); + server.restore(); }); - describe('Smartyads callBids validation', () => { - - let bids, - server; - - beforeEach(() => { - bids = []; - server = sinon.fakeServer.create(); - - sandbox.stub(bidManager, 'addBidResponse', (elemId, bid) => { - bids.push(bid); - }); - }); - - afterEach(() => { - server.restore(); - }); + let adapter = adapterManager.bidderRegistry['smartyads']; - let adapter = adapterManager.bidderRegistry['smartyads']; + it('Valid bid-request', () => { + sandbox.stub(adapter, 'callBids'); + adapterManager.callBids({ + adUnits: [clone(adUnit)] + }); - it('Valid bid-request', () => { - sandbox.stub(adapter, 'callBids'); - adapterManager.callBids({ - adUnits: [clone(adUnit)] - }); + let bidderRequest = adapter.callBids.getCall(0).args[0]; - let bidderRequest = adapter.callBids.getCall(0).args[0]; - - expect(bidderRequest).to.have.property('bids') + expect(bidderRequest).to.have.property('bids') .that.is.an('array') .with.lengthOf(1); - expect(bidderRequest).to.have.deep.property('bids[0]') + expect(bidderRequest).to.have.deep.property('bids[0]') .to.have.property('bidder', 'smartyads'); - expect(bidderRequest).to.have.deep.property('bids[0]') + expect(bidderRequest).to.have.deep.property('bids[0]') .with.property('sizes') .that.is.an('array') .with.lengthOf(3) .that.deep.equals(adUnit.sizes); - expect(bidderRequest).to.have.deep.property('bids[0]') + expect(bidderRequest).to.have.deep.property('bids[0]') .with.property('params') .to.have.property('banner_id', 0); - }); + }); - it('Valid bid-response', ()=>{ - server.respondWith(JSON.stringify( + it('Valid bid-response', () => { + server.respondWith(JSON.stringify( response )); - adapterManager.callBids({ - adUnits: [clone(adUnit)] - }); - server.respond(); - - expect(bids).to.be.lengthOf(1); - expect(bids[0].getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); - expect(bids[0].bidderCode).to.equal("smartyads"); - expect(bids[0].width).to.equal(360); - expect(bids[0].height).to.equal(240); - expect(bids[0].cpm).to.equal(0.5); - expect(bids[0].dealId).to.equal("bf063e2e025c"); - }); + adapterManager.callBids({ + adUnits: [clone(adUnit)] + }); + server.respond(); + + expect(bids).to.be.lengthOf(1); + expect(bids[0].getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); + expect(bids[0].bidderCode).to.equal('smartyads'); + expect(bids[0].width).to.equal(360); + expect(bids[0].height).to.equal(240); + expect(bids[0].cpm).to.equal(0.5); + expect(bids[0].dealId).to.equal('bf063e2e025c'); }); + }); - describe('MAS mapping / ordering', () => { - - let masSizeOrdering = Adapter.masSizeOrdering; + describe('MAS mapping / ordering', () => { + let masSizeOrdering = Adapter.masSizeOrdering; - it('should not include values without a proper mapping', () => { - let ordering = masSizeOrdering([[320, 50], [42, 42], [300, 250], [640, 480], [1, 1], [336, 280]]); - expect(ordering).to.deep.equal([15, 16, 43, 65]); - }); + it('should not include values without a proper mapping', () => { + let ordering = masSizeOrdering([[320, 50], [42, 42], [300, 250], [640, 480], [1, 1], [336, 280]]); + expect(ordering).to.deep.equal([15, 16, 43, 65]); + }); - it('should sort values without any MAS priority sizes in regular ascending order', () => { - let ordering = masSizeOrdering([[320, 50], [640, 480], [336, 280], [200, 600]]); - expect(ordering).to.deep.equal([16, 43, 65, 126]); - }); + it('should sort values without any MAS priority sizes in regular ascending order', () => { + let ordering = masSizeOrdering([[320, 50], [640, 480], [336, 280], [200, 600]]); + expect(ordering).to.deep.equal([16, 43, 65, 126]); + }); - it('should sort MAS priority sizes in the proper order w/ rest ascending', () => { - let ordering = masSizeOrdering([[320, 50], [160,600], [640, 480], [300, 250],[336, 280], [200, 600]]); - expect(ordering).to.deep.equal([15, 9, 16, 43, 65, 126]); + it('should sort MAS priority sizes in the proper order w/ rest ascending', () => { + let ordering = masSizeOrdering([[320, 50], [160, 600], [640, 480], [300, 250], [336, 280], [200, 600]]); + expect(ordering).to.deep.equal([15, 9, 16, 43, 65, 126]); - ordering = masSizeOrdering([[320, 50], [300, 250], [160,600], [640, 480],[336, 280], [200, 600], [728, 90]]); - expect(ordering).to.deep.equal([15, 2, 9, 16, 43, 65, 126]); + ordering = masSizeOrdering([[320, 50], [300, 250], [160, 600], [640, 480], [336, 280], [200, 600], [728, 90]]); + expect(ordering).to.deep.equal([15, 2, 9, 16, 43, 65, 126]); - ordering = masSizeOrdering([[120, 600], [320, 50], [160,600], [640, 480],[336, 280], [200, 600], [728, 90]]); - expect(ordering).to.deep.equal([2, 9, 8, 16, 43, 65, 126]); - }) - }); + ordering = masSizeOrdering([[120, 600], [320, 50], [160, 600], [640, 480], [336, 280], [200, 600], [728, 90]]); + expect(ordering).to.deep.equal([2, 9, 8, 16, 43, 65, 126]); + }) + }); }); function clone(obj) { - return JSON.parse(JSON.stringify(obj)); -} \ No newline at end of file + return JSON.parse(JSON.stringify(obj)); +} diff --git a/test/spec/adapters/sonobi_spec.js b/test/spec/adapters/sonobi_spec.js index ca0cd6735ee..f5f4ab49a52 100644 --- a/test/spec/adapters/sonobi_spec.js +++ b/test/spec/adapters/sonobi_spec.js @@ -15,7 +15,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_p', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { placement_id: '1a2b3c4d5e6f1a2b3c4d' } @@ -27,7 +27,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_pd', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { placement_id: '1a2b3c4d5e6f1a2b3c4d', dom_id: 'div-gpt-ad-12345-0' @@ -40,7 +40,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_pdf', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { placement_id: '1a2b3c4d5e6f1a2b3c4d', dom_id: 'div-gpt-ad-12345-0', @@ -54,7 +54,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_a', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '/7780971/sparks_prebid_MR', } @@ -79,7 +79,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_ad', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '/7780971/sparks_prebid_MR', dom_id: 'div-gpt-ad-12345-0' @@ -92,7 +92,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_af', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '/7780971/sparks_prebid_MR', floor: '1' @@ -105,7 +105,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_adf', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '/7780971/sparks_prebid_MR', dom_id: 'div-gpt-ad-12345-0', @@ -119,7 +119,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_A', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '/7780971/sparks_prebid_MR', } @@ -131,7 +131,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_Ad', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '7780971/sparks_prebid_MR', dom_id: 'div-gpt-ad-12345-0' @@ -144,7 +144,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_Af', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '7780971/sparks_prebid_MR', floor: '1' @@ -157,7 +157,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_Adf', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '7780971/sparks_prebid_MR', dom_id: 'div-gpt-ad-12345-0', @@ -172,7 +172,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_m1hb', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '1a2b3c4d5e6f1a2b3c4d', dom_id: 'div-gpt-ad-12345-0' @@ -185,7 +185,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_m2hb', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '/7780971/sparks_prebid_MR', placement_id: 'OPTIONAL', @@ -199,7 +199,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_m3hb', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '/7780971/sparks_prebid_MR', placement_id: '', @@ -213,7 +213,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_m4hb', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { ad_unit: '', placement_id: '1a2b3c4d5e6f1a2b3c4d', @@ -227,7 +227,7 @@ describe('Sonobi adapter tests', () => { bidId: 'testbid', bidder: 'sonobi', placementCode: 'adUnit_m5hb', - sizes: [[300, 250],[300,600]], + sizes: [[300, 250], [300, 600]], params: { placement_id: '/7780971/sparks_prebid_MR', dom_id: 'div-gpt-ad-12345-0' @@ -236,29 +236,28 @@ describe('Sonobi adapter tests', () => { }; // FTFY const sbi_adUnits = { - 'adUnit_p' : adUnit_p, - 'adUnit_pd' : adUnit_pd, - 'adUnit_pdf' : adUnit_pdf, - 'adUnit_a' : adUnit_a, - 'adUnit_as' : adUnit_as, - 'adUnit_ad' : adUnit_ad, - 'adUnit_af' : adUnit_af, - 'adUnit_adf' : adUnit_adf, - 'adUnit_A' : adUnit_A, - 'adUnit_Ad' : adUnit_Ad, - 'adUnit_Af' : adUnit_Af, - 'adUnit_Adf' : adUnit_Adf, - 'adUnit_m1hb' : adUnit_m1hb, - 'adUnit_m2hb' : adUnit_m2hb, - 'adUnit_m3hb' : adUnit_m3hb, - 'adUnit_m4hb' : adUnit_m4hb, - 'adUnit_m5hb' : adUnit_m5hb + 'adUnit_p': adUnit_p, + 'adUnit_pd': adUnit_pd, + 'adUnit_pdf': adUnit_pdf, + 'adUnit_a': adUnit_a, + 'adUnit_as': adUnit_as, + 'adUnit_ad': adUnit_ad, + 'adUnit_af': adUnit_af, + 'adUnit_adf': adUnit_adf, + 'adUnit_A': adUnit_A, + 'adUnit_Ad': adUnit_Ad, + 'adUnit_Af': adUnit_Af, + 'adUnit_Adf': adUnit_Adf, + 'adUnit_m1hb': adUnit_m1hb, + 'adUnit_m2hb': adUnit_m2hb, + 'adUnit_m3hb': adUnit_m3hb, + 'adUnit_m4hb': adUnit_m4hb, + 'adUnit_m5hb': adUnit_m5hb }; // Run the same test against all the (now tons of) different configurations utils._each(sbi_adUnits, (adUnit, adUnitName) => { describe('should form valid bid requests', () => { - let adapter = new Adapter(); let stubLoadScript; let stubFailBid; @@ -291,71 +290,68 @@ describe('Sonobi adapter tests', () => { expect(stubLoadScript.callCount).to.equal(1); expect(stubFailBid.callCount).to.equal(0); }); - }); - }); describe('should parse bid returns and register bid objects', () => { - let adapter = new Adapter(); let spyAddBidResponse; let stubFailBid; let stubGoodBid; const sbi_bid = { - "slots": + 'slots': { - "sbi_a": + 'sbi_a': { - "sbi_size": "300x250", - "sbi_apoc": "premium", - "sbi_aid": "159.60.7533347", - "sbi_mouse": 4.20 + 'sbi_size': '300x250', + 'sbi_apoc': 'premium', + 'sbi_aid': '159.60.7533347', + 'sbi_mouse': 4.20 } }, - "sbi_dc": "mco-1-" + 'sbi_dc': 'mco-1-' }; const sbi_video_bid = { - "slots": + 'slots': { - "sbi_a": + 'sbi_a': { - "sbi_size": "outstream", - "sbi_apoc": "premium", - "sbi_aid": "159.60.7533347", - "sbi_mouse": 4.20, + 'sbi_size': 'outstream', + 'sbi_apoc': 'premium', + 'sbi_aid': '159.60.7533347', + 'sbi_mouse': 4.20, } }, - "sbi_dc": "mco-1-" + 'sbi_dc': 'mco-1-' }; const sbi_deal_bid = { - "slots": + 'slots': { - "sbi_a": + 'sbi_a': { - "sbi_size": "300x250", - "sbi_apoc": "premium", - "sbi_aid": "159.60.7533347", - "sbi_mouse": 4.20, - "sbi_dozer": "apex-test-deal" + 'sbi_size': '300x250', + 'sbi_apoc': 'premium', + 'sbi_aid': '159.60.7533347', + 'sbi_mouse': 4.20, + 'sbi_dozer': 'apex-test-deal' } }, - "sbi_dc": "mco-1-" + 'sbi_dc': 'mco-1-' }; const sbi_noBid = { - "slots": + 'slots': { - "sbi_a": {} + 'sbi_a': {} }, - "sbi_dc": "mco-1-" + 'sbi_dc': 'mco-1-' }; beforeEach(() => { - spyAddBidResponse = sinon.spy(bidManager, "addBidResponse"); + spyAddBidResponse = sinon.spy(bidManager, 'addBidResponse'); stubFailBid = sinon.stub(adapter, 'failure'); stubGoodBid = sinon.stub(adapter, 'success'); }); @@ -389,8 +385,5 @@ describe('Sonobi adapter tests', () => { expect(spyAddBidResponse.called).to.be.true; expect(stubGoodBid.callCount).to.equal(0); }); - }); - - -}); \ No newline at end of file +}); diff --git a/test/spec/adapters/sovrn_spec.js b/test/spec/adapters/sovrn_spec.js index 2ffed6f6774..ee36fee5f3b 100644 --- a/test/spec/adapters/sovrn_spec.js +++ b/test/spec/adapters/sovrn_spec.js @@ -4,7 +4,6 @@ describe('sovrn adapter tests', function () { const bidmanager = require('src/bidmanager'); describe('sovrnResponse', function () { - it('should exist and be a function', function () { expect(pbjs.sovrnResponse).to.exist.and.to.be.a('function'); }); @@ -47,8 +46,8 @@ describe('sovrn adapter tests', function () { // no bids returned in the response. var response = { - "id": "54321", - "seatbid": [] + 'id': '54321', + 'seatbid': [] }; pbjs._bidsRequested.push(bidderRequest); @@ -119,17 +118,17 @@ describe('sovrn adapter tests', function () { // Returning a single bid in the response. var response = { - "id": "54321111", - "seatbid": [ { - "bid" : [ { - "id" : "1111111", - "impid" : "bidId2", - "price" : 0.09, - "nurl" : "http://url", - "adm" : "ad-code", - "h" : 250, - "w" : 300, - "ext" : { } + 'id': '54321111', + 'seatbid': [ { + 'bid': [ { + 'id': '1111111', + 'impid': 'bidId2', + 'price': 0.09, + 'nurl': 'http://url', + 'adm': 'ad-code', + 'h': 250, + 'w': 300, + 'ext': { } } ] } ] }; @@ -171,4 +170,3 @@ describe('sovrn adapter tests', function () { }); }); }); - diff --git a/test/spec/adapters/stickyadstv_spec.js b/test/spec/adapters/stickyadstv_spec.js index b485416f614..96a589ea07d 100644 --- a/test/spec/adapters/stickyadstv_spec.js +++ b/test/spec/adapters/stickyadstv_spec.js @@ -5,215 +5,205 @@ import bidManager from '../../../src/bidmanager'; import adLoader from '../../../src/adloader'; describe('StickyAdsTV Adapter', function () { - var adapter = void 0; - var sandbox = void 0; - var bidsRequestBuff = void 0; - var bidderRequest = { - bidderCode: 'stickyadstv', - bids: [{ - bidId: 'bidId1', - bidder: 'stickyadstv', - placementCode: 'foo', - sizes: [[300, 250]], - params: { - zoneId: '2003', - format:"screen-roll" - } - }, { - bidId: 'bidId2', - bidder: 'stickyadstv', - placementCode: 'bar', - sizes: [[728, 90]], - params: { - zoneId: '5562003' - } - }, { - bidId: 'bidId3', - bidder: 'stickyadstv', - placementCode: '', - sizes: [[300, 600]], - params: { - zoneId: '123456' + var adapter = void 0; + var sandbox = void 0; + var bidsRequestBuff = void 0; + var bidderRequest = { + bidderCode: 'stickyadstv', + bids: [{ + bidId: 'bidId1', + bidder: 'stickyadstv', + placementCode: 'foo', + sizes: [[300, 250]], + params: { + zoneId: '2003', + format: 'screen-roll' + } + }, { + bidId: 'bidId2', + bidder: 'stickyadstv', + placementCode: 'bar', + sizes: [[728, 90]], + params: { + zoneId: '5562003' + } + }, { + bidId: 'bidId3', + bidder: 'stickyadstv', + placementCode: '', + sizes: [[300, 600]], + params: { + zoneId: '123456' + } + }, { + bidId: 'bidId4', + bidder: 'stickyadstv', + placementCode: 'coo', + sizes: [[300, 600]], + params: { + wrong: 'missing zoneId' + } + }] + }; + + beforeEach(function () { + adapter = new Adapter(); + sandbox = sinon.sandbox.create(); + bidsRequestBuff = pbjs._bidsRequested; + pbjs._bidsRequested = []; + }); + + afterEach(function () { + sandbox.restore(); + pbjs._bidsRequested = bidsRequestBuff; + }); + + describe('callBids', function () { + beforeEach(function () { + sandbox.stub(adLoader, 'loadScript'); + adapter.callBids(bidderRequest); + }); + + it('should be called twice', function () { + sinon.assert.calledTwice(adLoader.loadScript); + }); + + it('should have load screenroll and mustang script', function () { + var url = void 0; + + url = adLoader.loadScript.firstCall.args[0]; + expect(url).to.equal('//cdn.stickyadstv.com/prime-time/screen-roll.min.js'); + + url = adLoader.loadScript.secondCall.args[0]; + expect(url).to.equal('//cdn.stickyadstv.com/mustang/mustang.min.js'); + }); + }); + + describe('getBid', function () { + let bidResponse; + let loadConfig; + let getPricingCalled; + + beforeEach(function () { + // Mock VastLoader for test purpose + window.com = { + stickyadstv: { + vast: { + VastLoader: function() { + this.getVast = function() { + return { + getPricing: function() { + getPricingCalled = true; + return {currency: 'USD', price: 4.000} + } + }; + }; + + this.load = function(config, listener) { + loadConfig = config; + listener.onSuccess(); + }; } - }, { - bidId: 'bidId4', - bidder: 'stickyadstv', - placementCode: 'coo', - sizes: [[300, 600]], - params: { - wrong: "missing zoneId" + }, + screenroll: { + getPlayerSize: function() { + return '123x456'; } - }] - }; + } + } + }; - beforeEach(function () { - adapter = new Adapter(); - sandbox = sinon.sandbox.create(); - bidsRequestBuff = pbjs._bidsRequested; - pbjs._bidsRequested = []; - }); - - afterEach(function () { - sandbox.restore(); - pbjs._bidsRequested = bidsRequestBuff; - }); - - describe('callBids', function () { - beforeEach(function () { - sandbox.stub(adLoader, 'loadScript'); - adapter.callBids(bidderRequest); - }); - - it('should be called twice', function () { - sinon.assert.calledTwice(adLoader.loadScript); - }); - - it('should have load screenroll and mustang script', function () { - var url = void 0; - - url = adLoader.loadScript.firstCall.args[0]; - expect(url).to.equal("//cdn.stickyadstv.com/prime-time/screen-roll.min.js"); - - url = adLoader.loadScript.secondCall.args[0]; - expect(url).to.equal("//cdn.stickyadstv.com/mustang/mustang.min.js"); - }); - }); - - describe('getBid', function () { - let bidResponse; - let loadConfig; - let getPricingCalled; - - beforeEach(function () { - //Mock VastLoader for test purpose - window.com = { - stickyadstv : { - vast : { - VastLoader : function(){ - this.getVast = function(){ - return { - getPricing : function(){ - getPricingCalled = true; - return {currency:"USD", price: 4.000} - } - }; - }; - - this.load = function(config, listener){ - loadConfig = config; - listener.onSuccess(); - }; - } - }, - screenroll : { - getPlayerSize: function(){ - return "123x456"; - } - } - } - }; - - adapter.getBid(bidderRequest.bids[0], function(bidObject){ - bidResponse = bidObject; - }); - }); - - afterEach(function() { - delete window.com.stickyadstv.vast.VastLoader; - delete window.com.stickyadstv.vast; - delete window.com.stickyadstv.screenroll; - delete window.com.stickyadstv; - }); - - it('should have returned a valid bidObject', function () { - - expect(bidResponse).to.have.property('cpm', 4.000); - expect(bidResponse).to.have.property('ad', ""); - expect(bidResponse).to.have.property('bidderCode', "stickyadstv"); - expect(bidResponse).to.have.property('currencyCode', "USD"); - expect(bidResponse).to.have.property('width', 300); - expect(bidResponse).to.have.property('height', 250); - expect(bidResponse.getStatusCode()).to.equal(1); - }); - - it('should have called load with proper config', function () { - - expect(loadConfig).to.have.property('playerSize', "123x456"); - expect(loadConfig).to.have.property('zoneId', "2003"); - - }); - - it('should have called getPricing', function () { - - expect(getPricingCalled).to.equal(true); - - }); - }); - - describe('formatBidObject', function () { - - it('should create a valid bid object', function () { - let result = adapter.formatBidObject("", true, {currency:"EUR",price:"1.2345"}, "
sample
", 200, 300); - - expect(result).to.have.property('cpm', '1.2345'); - expect(result).to.have.property('ad', "
sample
"); - expect(result).to.have.property('currencyCode', "EUR"); - expect(result).to.have.property('width', 200); - expect(result).to.have.property('height', 300); - expect(result.getStatusCode()).to.equal(1); - }); - - it('should create a invalid bid object because price is not defined', function () { - let result = adapter.formatBidObject("", true, null, "
sample
", 200, 300); - - expect(result.getStatusCode()).to.equal(2); - }); - - it('should create a invalid bid object', function () { - let result = adapter.formatBidObject("", false, {currency:"EUR",price:"1.2345"}, "
sample
", 200, 300); - - expect(result.getStatusCode()).to.equal(2); - }); - }); - - describe('formatAdHTML', function () { - - it('should create an inBanner ad format', function () { - let result = adapter.formatAdHTML({placementCode:"placementCodeValue", params:{}}, [200,300]); - - expect(result).to.equal('
'); - }); - - it('should create an intext ad format', function () { - let result = adapter.formatAdHTML({placementCode:"placementCodeValue", params:{format:"intext-roll", auto:"v2", smartPlay:"true"}}, [200,300]); - - expect(result).to.equal(''); - }); - - it('should create a screenroll ad format', function () { - let result = adapter.formatAdHTML({placementCode:"placementCodeValue", params:{format:"screen-roll", smartPlay:"true"}}, [200,300]); - - expect(result).to.equal(''); - }); - }); - - describe('getBiggerSize', function () { - - it('should returns the bigger size', function () { - let result = adapter.getBiggerSize([[1,4000],[4000,1],[200,300],[0,0]]); - - expect(result[0]).to.equal(200); - expect(result[1]).to.equal(300); - }); - }); - - describe('top most window', function () { - - it('should returns the top most window', function () { - let result = adapter.getTopMostWindow(); - - expect(result).to.equal(window.top); - }); - }); - -}); \ No newline at end of file + adapter.getBid(bidderRequest.bids[0], function(bidObject) { + bidResponse = bidObject; + }); + }); + + afterEach(function() { + delete window.com.stickyadstv.vast.VastLoader; + delete window.com.stickyadstv.vast; + delete window.com.stickyadstv.screenroll; + delete window.com.stickyadstv; + }); + + it('should have returned a valid bidObject', function () { + expect(bidResponse).to.have.property('cpm', 4.000); + expect(bidResponse).to.have.property('ad', ""); + expect(bidResponse).to.have.property('bidderCode', 'stickyadstv'); + expect(bidResponse).to.have.property('currencyCode', 'USD'); + expect(bidResponse).to.have.property('width', 300); + expect(bidResponse).to.have.property('height', 250); + expect(bidResponse.getStatusCode()).to.equal(1); + }); + + it('should have called load with proper config', function () { + expect(loadConfig).to.have.property('playerSize', '123x456'); + expect(loadConfig).to.have.property('zoneId', '2003'); + }); + + it('should have called getPricing', function () { + expect(getPricingCalled).to.equal(true); + }); + }); + + describe('formatBidObject', function () { + it('should create a valid bid object', function () { + let result = adapter.formatBidObject('', true, {currency: 'EUR', price: '1.2345'}, '
sample
', 200, 300); + + expect(result).to.have.property('cpm', '1.2345'); + expect(result).to.have.property('ad', '
sample
'); + expect(result).to.have.property('currencyCode', 'EUR'); + expect(result).to.have.property('width', 200); + expect(result).to.have.property('height', 300); + expect(result.getStatusCode()).to.equal(1); + }); + + it('should create a invalid bid object because price is not defined', function () { + let result = adapter.formatBidObject('', true, null, '
sample
', 200, 300); + + expect(result.getStatusCode()).to.equal(2); + }); + + it('should create a invalid bid object', function () { + let result = adapter.formatBidObject('', false, {currency: 'EUR', price: '1.2345'}, '
sample
', 200, 300); + + expect(result.getStatusCode()).to.equal(2); + }); + }); + + describe('formatAdHTML', function () { + it('should create an inBanner ad format', function () { + let result = adapter.formatAdHTML({placementCode: 'placementCodeValue', params: {}}, [200, 300]); + + expect(result).to.equal('
'); + }); + + it('should create an intext ad format', function () { + let result = adapter.formatAdHTML({placementCode: 'placementCodeValue', params: {format: 'intext-roll', auto: 'v2', smartPlay: 'true'}}, [200, 300]); + + expect(result).to.equal(''); + }); + + it('should create a screenroll ad format', function () { + let result = adapter.formatAdHTML({placementCode: 'placementCodeValue', params: {format: 'screen-roll', smartPlay: 'true'}}, [200, 300]); + + expect(result).to.equal(''); + }); + }); + + describe('getBiggerSize', function () { + it('should returns the bigger size', function () { + let result = adapter.getBiggerSize([[1, 4000], [4000, 1], [200, 300], [0, 0]]); + + expect(result[0]).to.equal(200); + expect(result[1]).to.equal(300); + }); + }); + + describe('top most window', function () { + it('should returns the top most window', function () { + let result = adapter.getTopMostWindow(); + + expect(result).to.equal(window.top); + }); + }); +}); diff --git a/test/spec/adapters/tapsense_spec.js b/test/spec/adapters/tapsense_spec.js index 72d189ef81e..162a8307443 100644 --- a/test/spec/adapters/tapsense_spec.js +++ b/test/spec/adapters/tapsense_spec.js @@ -1,78 +1,78 @@ import { expect } from 'chai'; import Adapter from 'src/adapters/tapsense'; import bidmanager from 'src/bidmanager'; -import adloader from "src/adloader"; -import * as utils from "src/utils"; +import adloader from 'src/adloader'; +import * as utils from 'src/utils'; window.pbjs = window.pbjs || {}; const DEFAULT_BIDDER_REQUEST = { - "bidderCode": "tapsense", - "bidderRequestId": "141ed07a281ca3", - "requestId": "b202e550-b0f7-4fb9-bfb4-1aa80f1795b4", - "start": new Date().getTime(), - "bids": [ + 'bidderCode': 'tapsense', + 'bidderRequestId': '141ed07a281ca3', + 'requestId': 'b202e550-b0f7-4fb9-bfb4-1aa80f1795b4', + 'start': new Date().getTime(), + 'bids': [ { - "sizes": undefined, //set values in tests - "bidder": "tapsense", - "bidId": "2b211418dd0575", - "bidderRequestId": "141ed07a281ca3", - "placementCode": "thisisatest", - "params": { - "ufid": "thisisaufid", - "refer": "thisisarefer", - "version": "0.0.1", - "ad_unit_id": "thisisanadunitid", - "device_id": "thisisadeviceid", - "lat": "thisislat", - "long": "thisisalong", - "user": "thisisanidfa", - "price_floor": 0.01 + 'sizes': undefined, // set values in tests + 'bidder': 'tapsense', + 'bidId': '2b211418dd0575', + 'bidderRequestId': '141ed07a281ca3', + 'placementCode': 'thisisatest', + 'params': { + 'ufid': 'thisisaufid', + 'refer': 'thisisarefer', + 'version': '0.0.1', + 'ad_unit_id': 'thisisanadunitid', + 'device_id': 'thisisadeviceid', + 'lat': 'thisislat', + 'long': 'thisisalong', + 'user': 'thisisanidfa', + 'price_floor': 0.01 } } ] } const SUCCESSFUL_RESPONSE = { - "count_ad_units": 1, - "status": { - "value": "ok", + 'count_ad_units': 1, + 'status': { + 'value': 'ok', }, - "ad_units": [ + 'ad_units': [ { - html: "", - imp_url: "https://i.tapsense.com" + html: '', + imp_url: 'https://i.tapsense.com' } ], - "id": "thisisanid", - "width": 320, - "height": 50, - "time": new Date().getTime() + 'id': 'thisisanid', + 'width': 320, + 'height': 50, + 'time': new Date().getTime() } const UNSUCCESSFUL_RESPONSE = { - "count_ad_units": 0, - "status": { - "value": "nofill" //will be set in test + 'count_ad_units': 0, + 'status': { + 'value': 'nofill' // will be set in test }, - "time": new Date().getTime() + 'time': new Date().getTime() } function duplicate(obj) { return JSON.parse(JSON.stringify(obj)); } -function makeSuccessfulRequest(adapter){ +function makeSuccessfulRequest(adapter) { let modifiedReq = duplicate(DEFAULT_BIDDER_REQUEST); - modifiedReq.bids[0].sizes = [[320,50], [500,500]]; + modifiedReq.bids[0].sizes = [[320, 50], [500, 500]]; adapter.callBids(modifiedReq); return modifiedReq.bids; } -describe ("TapSenseAdapter", () => { +describe('TapSenseAdapter', () => { let adapter, sandbox; beforeEach(() => { - adapter = new Adapter; + adapter = new Adapter(); sandbox = sinon.sandbox.create(); }); afterEach(() => { @@ -107,7 +107,7 @@ describe ("TapSenseAdapter", () => { }); it('does not make a request if ad sizes are incorrect', () => { let modifiedReq = duplicate(DEFAULT_BIDDER_REQUEST); - modifiedReq.bids[0].sizes = [[500,500]]; + modifiedReq.bids[0].sizes = [[500, 500]]; adapter.callBids(modifiedReq); sinon.assert.notCalled(adloader.loadScript); }); @@ -118,42 +118,42 @@ describe ("TapSenseAdapter", () => { sinon.assert.notCalled(adloader.loadScript); }); - describe("requesting an ad", () => { + describe('requesting an ad', () => { afterEach(() => { sandbox.restore(); }) - it("makes a request if valid sizes are provided (nested array)", () => { + it('makes a request if valid sizes are provided (nested array)', () => { makeSuccessfulRequest(adapter); sinon.assert.calledOnce(adloader.loadScript); expect(adloader.loadScript.firstCall.args[0]).to.contain( - "ads04.tapsense.com" + 'ads04.tapsense.com' ); }); - it("handles a singles array for size parameter", () => { + it('handles a singles array for size parameter', () => { let modifiedReq = duplicate(DEFAULT_BIDDER_REQUEST); - modifiedReq.bids[0].sizes = [320,50]; + modifiedReq.bids[0].sizes = [320, 50]; adapter.callBids(modifiedReq); expect(adloader.loadScript.firstCall.args[0]).to.contain( - "ads04.tapsense.com" + 'ads04.tapsense.com' ); }); - it("handles a string for size parameter", () => { + it('handles a string for size parameter', () => { let modifiedReq = duplicate(DEFAULT_BIDDER_REQUEST); - modifiedReq.bids[0].sizes = "320x50"; + modifiedReq.bids[0].sizes = '320x50'; adapter.callBids(modifiedReq); expect(adloader.loadScript.firstCall.args[0]).to.contain( - "ads04.tapsense.com" + 'ads04.tapsense.com' ); }); - it("handles a string with multiple sizes for size parameter", () => { + it('handles a string with multiple sizes for size parameter', () => { let modifiedReq = duplicate(DEFAULT_BIDDER_REQUEST); - modifiedReq.bids[0].sizes = "320x50,500x500"; + modifiedReq.bids[0].sizes = '320x50,500x500'; adapter.callBids(modifiedReq); expect(adloader.loadScript.firstCall.args[0]).to.contain( - "ads04.tapsense.com" + 'ads04.tapsense.com' ); }); - it("appends bid params as a query string when requesting ad", () => { + it('appends bid params as a query string when requesting ad', () => { makeSuccessfulRequest(adapter); sinon.assert.calledOnce(adloader.loadScript); expect(adloader.loadScript.firstCall.args[0]).to.match( @@ -193,68 +193,67 @@ describe ("TapSenseAdapter", () => { }) }); - describe("generateCallback", () => { + describe('generateCallback', () => { beforeEach(() => { sandbox.stub(adloader, 'loadScript'); }); afterEach(() => { sandbox.restore(); }); - it("generates callback in namespaced object with correct bidder id", () => { + it('generates callback in namespaced object with correct bidder id', () => { makeSuccessfulRequest(adapter); expect(pbjs.tapsense.callback_with_price_2b211418dd0575).to.exist.and.to.be.a('function'); }) }); - describe("response", () => { + describe('response', () => { beforeEach(() => { sandbox.stub(bidmanager, 'addBidResponse'); sandbox.stub(adloader, 'loadScript'); let bids = makeSuccessfulRequest(adapter); - sandbox.stub(utils, "getBidRequest", (id) => { - return bids.find((item) => { return item.bidId === id}); + sandbox.stub(utils, 'getBidRequest', (id) => { + return bids.find((item) => { return item.bidId === id }); }) }); afterEach(() => { sandbox.restore(); }); - describe("successful response", () => { + describe('successful response', () => { beforeEach(() => { pbjs.tapsense.callback_with_price_2b211418dd0575(SUCCESSFUL_RESPONSE, 1.2); }); - it("called the bidmanager and registers a bid", () => { + it('called the bidmanager and registers a bid', () => { sinon.assert.calledOnce(bidmanager.addBidResponse); expect(bidmanager.addBidResponse.firstCall.args[1].getStatusCode()).to.equal(1); }); - it("should have the correct placementCode", () => { + it('should have the correct placementCode', () => { sinon.assert.calledOnce(bidmanager.addBidResponse); - expect(bidmanager.addBidResponse.firstCall.args[0]).to.equal("thisisatest"); + expect(bidmanager.addBidResponse.firstCall.args[0]).to.equal('thisisatest'); }); }); - describe("unsuccessful response", () => { + describe('unsuccessful response', () => { beforeEach(() => { pbjs.tapsense.callback_with_price_2b211418dd0575(UNSUCCESSFUL_RESPONSE, 1.2); }) - it("should call the bidmanger and register an invalid bid", () => { + it('should call the bidmanger and register an invalid bid', () => { sinon.assert.calledOnce(bidmanager.addBidResponse); expect(bidmanager.addBidResponse.firstCall.args[1].getStatusCode()).to.equal(2); }); - it("should have the correct placementCode", () => { - expect(bidmanager.addBidResponse.firstCall.args[0]).to.equal("thisisatest"); + it('should have the correct placementCode', () => { + expect(bidmanager.addBidResponse.firstCall.args[0]).to.equal('thisisatest'); }) }); - describe("no response/timeout", () => { - it("should not register any bids", () => { + describe('no response/timeout', () => { + it('should not register any bids', () => { sinon.assert.notCalled(bidmanager.addBidResponse); }) }); - describe("edge cases", () => { - it("does not register a bid if no price is supplied", () => { - sandbox.stub(utils, "logMessage"); + describe('edge cases', () => { + it('does not register a bid if no price is supplied', () => { + sandbox.stub(utils, 'logMessage'); pbjs.tapsense.callback_with_price_2b211418dd0575(SUCCESSFUL_RESPONSE); sinon.assert.notCalled(bidmanager.addBidResponse); }); }); }); - }) diff --git a/test/spec/adapters/thoughtleadr_spec.js b/test/spec/adapters/thoughtleadr_spec.js index 67be54f3aef..7fa6703ae10 100644 --- a/test/spec/adapters/thoughtleadr_spec.js +++ b/test/spec/adapters/thoughtleadr_spec.js @@ -1,8 +1,8 @@ -"use strict"; -var chai_1 = require("chai"); -var ta = require("../../../src/adapters/thoughtleadr"); -var adloader = require("../../../src/adloader"); -var bidfactory = require("../../../src/bidfactory"); +'use strict'; +var chai_1 = require('chai'); +var ta = require('../../../src/adapters/thoughtleadr'); +var adloader = require('../../../src/adloader'); +var bidfactory = require('../../../src/bidfactory'); var Adapter = ta; function setupResponse(resp) { @@ -17,7 +17,7 @@ function setupResponse(resp) { return stub; } -describe("thoughtleadr adapter tests", function () { +describe('thoughtleadr adapter tests', function () { var sandbox; var adapter; var request; @@ -30,18 +30,18 @@ describe("thoughtleadr adapter tests", function () { }); beforeEach(function () { - loadScript = sandbox.stub(adloader, "loadScript"); - createBid = sandbox.spy(bidfactory, "createBid"); + loadScript = sandbox.stub(adloader, 'loadScript'); + createBid = sandbox.spy(bidfactory, 'createBid'); adapter = new Adapter(); loadScript.reset(); request = { - bidderCode: "thoughtleadr", + bidderCode: 'thoughtleadr', bids: [{ - bidder: "thoughtleadr", - placementCode: "abc-123", + bidder: 'thoughtleadr', + placementCode: 'abc-123', sizes: [[300, 250], [400, 400]], params: { - placementId: "test-placement" + placementId: 'test-placement' } }] }; @@ -53,8 +53,7 @@ describe("thoughtleadr adapter tests", function () { sandbox.restore(); }); - describe("callBids", function () { - + describe('callBids', function () { beforeEach(function () { tldrRequestPrebid = setupResponse({}); }); @@ -62,55 +61,53 @@ describe("thoughtleadr adapter tests", function () { it("should request page.js from cdn if there wasn't before", function () { delete window.tldr; adapter.callBids(request); - chai_1.expect(loadScript.getCall(0).args[0]).to.be.equal("//cdn.thoughtleadr.com/v4/page.js"); + chai_1.expect(loadScript.getCall(0).args[0]).to.be.equal('//cdn.thoughtleadr.com/v4/page.js'); }); - it("should use window.tldr.config.root_url", function () { + it('should use window.tldr.config.root_url', function () { window.tldr = { config: { - root_url: "http://example.loc/" + root_url: 'http://example.loc/' } }; adapter.callBids(request); - chai_1.expect(loadScript.getCall(0).args[0]).to.be.equal("http://example.loc/page.js"); + chai_1.expect(loadScript.getCall(0).args[0]).to.be.equal('http://example.loc/page.js'); }); - it("should not request page.js if api is present", function () { + it('should not request page.js if api is present', function () { adapter.callBids(request); chai_1.expect(loadScript.notCalled).to.be.ok; }); }); - describe("handleBids", function () { - + describe('handleBids', function () { beforeEach(function () { tldrRequestPrebid = setupResponse({}); }); - it("should filter invalid bids", function () { + it('should filter invalid bids', function () { request.bids.unshift({ - bidder: "thoughtleadr", - placementCode: "abc-123", + bidder: 'thoughtleadr', + placementCode: 'abc-123', sizes: [[300, 250], [400, 400]], params: {} }); request.bids.push({ - bidder: "thoughtleadr", - placementCode: "abc-123", + bidder: 'thoughtleadr', + placementCode: 'abc-123', sizes: [[300, 250], [400, 400]], params: { incorrectParam: 123 } }); - var requestPlacement = sinon.spy(adapter, "requestPlacement"); + var requestPlacement = sinon.spy(adapter, 'requestPlacement'); adapter.callBids(request); chai_1.expect(requestPlacement.callCount).to.be.equal(1); chai_1.expect(requestPlacement.getCall(0).args[0]).to.be.equal(request.bids[1]); }); }); - describe("requestPlacement", function () { - + describe('requestPlacement', function () { beforeEach(function () { tldrRequestPrebid = setupResponse({ config: { @@ -119,19 +116,19 @@ describe("thoughtleadr adapter tests", function () { bid: { code: 1, cpm: 12, - ad: "asd" + ad: 'asd' } }); }); - it("should made request through page.js api", function () { + it('should made request through page.js api', function () { adapter.callBids(request); chai_1.expect(tldrRequestPrebid.callCount).to.be.equal(1); chai_1.expect(tldrRequestPrebid.firstCall.args[0]).to.be.equal(request.bids[0].params.placementId); chai_1.expect(tldrRequestPrebid.firstCall.args[1]).to.be.length(36); }); - it("should call bidfactory.createBid with code 1 if ad is ok", function () { + it('should call bidfactory.createBid with code 1 if ad is ok', function () { var bid = request.bids[0]; adapter.requestPlacement(bid); chai_1.expect(createBid.callCount).to.be.equal(1); @@ -151,26 +148,24 @@ describe("thoughtleadr adapter tests", function () { chai_1.expect(createBid.firstCall.args[0]).to.be.equal(2); }); - it.skip("should response on the postMessage request", function (done) { + it.skip('should response on the postMessage request', function (done) { var bid = request.bids[0]; adapter.requestPlacement(bid); var rid = tldrRequestPrebid.firstCall.args[1]; chai_1.expect(rid).to.be.ok; - window.addEventListener("message", function (ev) { + window.addEventListener('message', function (ev) { if (ev.data && ev.data.TLDR_RESPONSE) { chai_1.expect(ev.data.TLDR_RESPONSE.rid).to.be.equal(rid); chai_1.expect(JSON.stringify(ev.data.TLDR_RESPONSE.config)).to.be.equal('{"abc":567}'); done(); - } - else if (ev.data && ev.data.TLDR_REQUEST) { + } else if (ev.data && ev.data.TLDR_REQUEST) { chai_1.expect(ev.data.TLDR_REQUEST.rid).to.be.equal(rid); - } - else { - throw new Error("should not be any other messages"); + } else { + throw new Error('should not be any other messages'); } }, false); - window.postMessage({TLDR_REQUEST: {rid: rid}}, "*"); + window.postMessage({TLDR_REQUEST: {rid: rid}}, '*'); }); }); }); diff --git a/test/spec/adapters/trion_spec.js b/test/spec/adapters/trion_spec.js index 416d4313c87..b5e79cf7312 100644 --- a/test/spec/adapters/trion_spec.js +++ b/test/spec/adapters/trion_spec.js @@ -5,41 +5,40 @@ const CONSTANTS = require('src/constants.json'); const adloader = require('src/adloader'); const PLACEMENT_CODE = 'ad-tag'; -const BID_REQUEST_BASE_URL = "https://in-appadvertising.com/api/bidRequest?"; -const USER_SYNC_URL = "https://in-appadvertising.com/api/userSync.js"; +const BID_REQUEST_BASE_URL = 'https://in-appadvertising.com/api/bidRequest?'; +const USER_SYNC_URL = 'https://in-appadvertising.com/api/userSync.js'; const TRION_BID_REQUEST = { - bidderCode: "trion", + bidderCode: 'trion', bids: [ { - bidder: "trion", + bidder: 'trion', params: { - pubId : '1', - sectionId : '2' + pubId: '1', + sectionId: '2' }, placementCode: PLACEMENT_CODE, sizes: [[300, 250], [300, 600]], - bidId: "test-bid-id" + bidId: 'test-bid-id' } ] }; const TRION_BID_RESPONSE = { - bidId : 'test-bid-id', + bidId: 'test-bid-id', sizes: [[300, 250], [300, 600]], - result : { - cpm : 100, + result: { + cpm: 100, placeBid: true, - height: "250", - width: "300", - ad : 'test', - msg : 'response messaging' + height: '250', + width: '300', + ad: 'test', + msg: 'response messaging' } }; describe('Trion adapter tests', () => { - let adapter; beforeEach(() => { @@ -59,7 +58,7 @@ describe('Trion adapter tests', () => { beforeEach(() => { spyLoadScript = sinon.spy(adloader, 'loadScript'); window.TRION_INT = { - int_t : -1 + int_t: -1 }; }); @@ -85,7 +84,7 @@ describe('Trion adapter tests', () => { let bidUrl = spyLoadScript.getCall(0).args[0]; expect(bidUrl).to.include(BID_REQUEST_BASE_URL); }); - + it('should call loadscript with the correct required params', function () { adapter.callBids(TRION_BID_REQUEST); @@ -110,26 +109,25 @@ describe('Trion adapter tests', () => { expect(bidUrl).to.include(window.location.href); delete params.re; }); - - describe('user sync', ()=> { - + + describe('user sync', () => { beforeEach(() => { delete window.TRION_INT; delete window.TR_INT_T; }); - - it('user sync is called', ()=> { + + it('user sync is called', () => { adapter.callBids(TRION_BID_REQUEST); sinon.assert.calledWith(spyLoadScript, USER_SYNC_URL); }); - it('user sync tag is included in bid url', ()=> { + it('user sync tag is included in bid url', () => { window.TRION_INT = { - campaigns : [ + campaigns: [ 'campaign1', 'campaign2' ], - int_t : 'int_t' + int_t: 'int_t' }; let userTag = encodeURIComponent(JSON.stringify(window.TRION_INT)); adapter.callBids(TRION_BID_REQUEST); @@ -138,20 +136,20 @@ describe('Trion adapter tests', () => { expect(bidUrl).to.include(userTag); }); - it('user sync tag is included in bid url and includes the correct int_t', ()=> { + it('user sync tag is included in bid url and includes the correct int_t', () => { window.TRION_INT = { - campaigns : [ + campaigns: [ 'campaign1', 'campaign2' ] }; let int_t = 'test'; let expectedObject = { - campaigns : [ + campaigns: [ 'campaign1', 'campaign2' ], - int_t : int_t + int_t: int_t }; window.TR_INT_T = int_t; let userTag = encodeURIComponent(JSON.stringify(expectedObject)); @@ -160,21 +158,21 @@ describe('Trion adapter tests', () => { let bidUrl = spyLoadScript.getCall(0).args[0]; expect(bidUrl).to.include(userTag); }); - - it('user sync tag variable int_t cannot be changed once set', ()=> { + + it('user sync tag variable int_t cannot be changed once set', () => { window.TRION_INT = { - campaigns : [ + campaigns: [ 'campaign1', 'campaign2' ] }; let int_t = 'test'; let expectedObject = { - campaigns : [ + campaigns: [ 'campaign1', 'campaign2' ], - int_t : int_t + int_t: int_t }; window.TR_INT_T = int_t; let userTag = encodeURIComponent(JSON.stringify(expectedObject)); @@ -185,13 +183,10 @@ describe('Trion adapter tests', () => { expect(bidUrl).to.include(userTag); expect(bidUrl).to.not.include('bad'); }); - }); - }); describe('response handler', () => { - beforeEach(() => { sinon.stub(bidmanager, 'addBidResponse'); }); @@ -272,6 +267,5 @@ describe('Trion adapter tests', () => { expect(response.cpm).to.equal(bidCpm); TRION_BID_RESPONSE.result.cpm = 100; }); - }); }); diff --git a/test/spec/adapters/triplelift_spec.js b/test/spec/adapters/triplelift_spec.js index 6e2b748c7d6..cae78d95e30 100644 --- a/test/spec/adapters/triplelift_spec.js +++ b/test/spec/adapters/triplelift_spec.js @@ -5,7 +5,6 @@ import adLoader from '../../../src/adloader'; import {parse as parseURL} from '../../../src/url'; describe('triplelift adapter', () => { - let bidsRequestedOriginal; let adapter; let sandbox; @@ -50,7 +49,6 @@ describe('triplelift adapter', () => { }); describe('callBids', () => { - let firstBidScriptURL; let secondBidScriptURL; @@ -70,33 +68,29 @@ describe('triplelift adapter', () => { expect(secondBidScriptURL).to.contain(route); let firstScriptParams = parseURL(firstBidScriptURL).search; - expect(firstScriptParams).to.have.property('callback','pbjs.TLCB'); - expect(firstScriptParams).to.have.property('callback_id','bidId1'); - expect(firstScriptParams).to.have.property('inv_code','codeA'); - expect(firstScriptParams).to.have.property('size','728x90'); + expect(firstScriptParams).to.have.property('callback', 'pbjs.TLCB'); + expect(firstScriptParams).to.have.property('callback_id', 'bidId1'); + expect(firstScriptParams).to.have.property('inv_code', 'codeA'); + expect(firstScriptParams).to.have.property('size', '728x90'); expect(firstScriptParams).to.have.property('referrer'); let secondScriptParams = parseURL(secondBidScriptURL).search; - expect(secondScriptParams).to.have.property('callback','pbjs.TLCB'); - expect(secondScriptParams).to.have.property('callback_id','bidId2'); - expect(secondScriptParams).to.have.property('inv_code','codeB'); - expect(secondScriptParams).to.have.property('size','300x600'); - expect(secondScriptParams).to.have.property('floor','1'); + expect(secondScriptParams).to.have.property('callback', 'pbjs.TLCB'); + expect(secondScriptParams).to.have.property('callback_id', 'bidId2'); + expect(secondScriptParams).to.have.property('inv_code', 'codeB'); + expect(secondScriptParams).to.have.property('size', '300x600'); + expect(secondScriptParams).to.have.property('floor', '1'); expect(secondScriptParams).to.have.property('referrer'); }); - }); describe('TLCB', () => { - it('should exist and be a function', () => { expect(pbjs.TLCB).to.exist.and.to.be.a('function'); }); - }); describe('add bids to the manager', () => { - let firstBid; let secondBid; @@ -107,22 +101,22 @@ describe('triplelift adapter', () => { // respond let bidderReponse1 = { - "ad": "", - "callback_id": "bidId1", - "cpm": 0.20, - "height": 90, - "iurl": "", - "width": 728 + 'ad': '', + 'callback_id': 'bidId1', + 'cpm': 0.20, + 'height': 90, + 'iurl': '', + 'width': 728 }; let bidderReponse2 = { - "ad": "", - "callback_id": "bidId2", - "cpm": 0.30, - "height": 600, - "iurl": "", - "width": 300, - "deal_id": "dealA" + 'ad': '', + 'callback_id': 'bidId2', + 'cpm': 0.30, + 'height': 600, + 'iurl': '', + 'width': 300, + 'deal_id': 'dealA' }; pbjs.TLCB(bidderReponse1); @@ -183,7 +177,6 @@ describe('triplelift adapter', () => { }); describe('add empty bids if no bid returned', () => { - let firstBid; let secondBid; @@ -193,8 +186,8 @@ describe('triplelift adapter', () => { pbjs._bidsRequested.push(bidderRequest); // respond - let bidderReponse1 = {"status":"no_bid","callback_id":"bidId1"}; - let bidderReponse2 = {"status":"no_bid","callback_id":"bidId2"}; + let bidderReponse1 = {'status': 'no_bid', 'callback_id': 'bidId1'}; + let bidderReponse2 = {'status': 'no_bid', 'callback_id': 'bidId2'}; pbjs.TLCB(bidderReponse1); pbjs.TLCB(bidderReponse2); @@ -229,6 +222,5 @@ describe('triplelift adapter', () => { expect(firstBid).to.have.property('bidderCode', 'triplelift'); expect(secondBid).to.have.property('bidderCode', 'triplelift'); }); - }); }); diff --git a/test/spec/adapters/twenga_spec.js b/test/spec/adapters/twenga_spec.js index 141b4c4e22b..9bbeb4c1d7b 100644 --- a/test/spec/adapters/twenga_spec.js +++ b/test/spec/adapters/twenga_spec.js @@ -1,120 +1,119 @@ -describe("twenga adapter tests", function () { - - var urlParse = require("url-parse"); - var querystringify = require("querystringify"); - var adapter = require("src/adapters/twenga"); - var adLoader = require("src/adloader"); - var expect = require("chai").expect; - var bidmanager = require("src/bidmanager"); - var CONSTANTS = require('src/constants.json'); - - var DEFAULT_PARAMS = { - bidderCode: "twenga", - bids: [{ - bidId: "tw_abcd1234", - sizes: [[300, 250], [300, 200]], - bidder: "twenga", - params: { - placementId: "test", - siteId: 1234, - publisherId: 5678, - currency: "USD", - bidFloor: 0.5, - country: "DE" - }, - requestId: "tw_efgh5678", - placementCode: "tw_42" - }] - }; - - var BID_RESPONSE = { - result: { - cpm: 10000, - width: 300, - height: 250, - ad: "//rtb.t.c4tw.net", - creative_id: "test" - }, - callback_uid: "tw_abcd1234" - }; - - it("sets url parameters", function () { - var stubLoadScript = sinon.stub(adLoader, "loadScript"); - - adapter().callBids(DEFAULT_PARAMS); - - var bidUrl = stubLoadScript.getCall(0).args[0]; - var parsedBidUrl = urlParse(bidUrl); - var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - - expect(parsedBidUrl.hostname).to.equal("rtb.t.c4tw.net"); - expect(parsedBidUrl.pathname).to.equal("/Bid"); - - expect(parsedBidUrlQueryString).to.have.property("s").and.to.equal("h"); - expect(parsedBidUrlQueryString).to.have.property("callback").and.to.equal("$$PREBID_GLOBAL$$.handleTwCB"); - expect(parsedBidUrlQueryString).to.have.property("callback_uid").and.to.equal("tw_abcd1234"); - expect(parsedBidUrlQueryString).to.have.property("id").and.to.equal("test"); - - stubLoadScript.restore(); +describe('twenga adapter tests', function () { + var urlParse = require('url-parse'); + var querystringify = require('querystringify'); + var adapter = require('src/adapters/twenga'); + var adLoader = require('src/adloader'); + var expect = require('chai').expect; + var bidmanager = require('src/bidmanager'); + var CONSTANTS = require('src/constants.json'); + + var DEFAULT_PARAMS = { + bidderCode: 'twenga', + bids: [{ + bidId: 'tw_abcd1234', + sizes: [[300, 250], [300, 200]], + bidder: 'twenga', + params: { + placementId: 'test', + siteId: 1234, + publisherId: 5678, + currency: 'USD', + bidFloor: 0.5, + country: 'DE' + }, + requestId: 'tw_efgh5678', + placementCode: 'tw_42' + }] + }; + + var BID_RESPONSE = { + result: { + cpm: 10000, + width: 300, + height: 250, + ad: '//rtb.t.c4tw.net', + creative_id: 'test' + }, + callback_uid: 'tw_abcd1234' + }; + + it('sets url parameters', function () { + var stubLoadScript = sinon.stub(adLoader, 'loadScript'); + + adapter().callBids(DEFAULT_PARAMS); + + var bidUrl = stubLoadScript.getCall(0).args[0]; + var parsedBidUrl = urlParse(bidUrl); + var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); + + expect(parsedBidUrl.hostname).to.equal('rtb.t.c4tw.net'); + expect(parsedBidUrl.pathname).to.equal('/Bid'); + + expect(parsedBidUrlQueryString).to.have.property('s').and.to.equal('h'); + expect(parsedBidUrlQueryString).to.have.property('callback').and.to.equal('$$PREBID_GLOBAL$$.handleTwCB'); + expect(parsedBidUrlQueryString).to.have.property('callback_uid').and.to.equal('tw_abcd1234'); + expect(parsedBidUrlQueryString).to.have.property('id').and.to.equal('test'); + + stubLoadScript.restore(); + }); + + var stringToFunction = function (s) { + var scope = global; + var scopeSplit = s.split('.'); + for (var i = 0; i < scopeSplit.length - 1; i++) { + scope = scope[scopeSplit[i]]; + if (scope == undefined) return; + } + return scope[scopeSplit[scopeSplit.length - 1]]; + }; + + it('creates an empty bid response if no bids', function() { + var stubLoadScript = sinon.stub(adLoader, 'loadScript', function(url) { + var bidUrl = stubLoadScript.getCall(0).args[0]; + var parsedBidUrl = urlParse(bidUrl); + var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); + + var callback = stringToFunction(parsedBidUrlQueryString.callback); + expect(callback).to.exist.and.to.be.a('function'); + callback(undefined); }); + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - var stringToFunction = function (s) { - var scope = global; - var scopeSplit = s.split('.'); - for (var i = 0; i < scopeSplit.length - 1; i++) { - scope = scope[scopeSplit[i]]; - if (scope == undefined) return; - } - return scope[scopeSplit[scopeSplit.length - 1]]; - }; - - it("creates an empty bid response if no bids", function() { - var stubLoadScript = sinon.stub(adLoader, "loadScript", function(url) { - var bidUrl = stubLoadScript.getCall(0).args[0]; - var parsedBidUrl = urlParse(bidUrl); - var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - - var callback = stringToFunction(parsedBidUrlQueryString.callback); - expect(callback).to.exist.and.to.be.a('function'); - callback(undefined); - }); - var stubAddBidResponse = sinon.stub(bidmanager, "addBidResponse"); - - adapter.createNew().callBids(DEFAULT_PARAMS); - - expect(stubAddBidResponse.getCall(0)).to.be.null; - - stubAddBidResponse.restore(); - stubLoadScript.restore(); - }); + adapter.createNew().callBids(DEFAULT_PARAMS); - it("creates a bid response if bid is returned", function() { - var stubLoadScript = sinon.stub(adLoader, "loadScript", function(url) { - var bidUrl = stubLoadScript.getCall(0).args[0]; - var parsedBidUrl = urlParse(bidUrl); - var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); + expect(stubAddBidResponse.getCall(0)).to.be.null; - $$PREBID_GLOBAL$$._bidsRequested. - push({ bidderCode: DEFAULT_PARAMS.bidderCode, - bids: [{ bidId: parsedBidUrlQueryString.callback_uid, - placementCode: DEFAULT_PARAMS.bids[0].placementCode }]}); + stubAddBidResponse.restore(); + stubLoadScript.restore(); + }); - var callback = stringToFunction(parsedBidUrlQueryString.callback); - expect(callback).to.exist.and.to.be.a('function'); - callback(BID_RESPONSE); - }); - var stubAddBidResponse = sinon.stub(bidmanager, "addBidResponse"); + it('creates a bid response if bid is returned', function() { + var stubLoadScript = sinon.stub(adLoader, 'loadScript', function(url) { + var bidUrl = stubLoadScript.getCall(0).args[0]; + var parsedBidUrl = urlParse(bidUrl); + var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - adapter.createNew().callBids(DEFAULT_PARAMS); + $$PREBID_GLOBAL$$._bidsRequested + .push({ bidderCode: DEFAULT_PARAMS.bidderCode, + bids: [{ bidId: parsedBidUrlQueryString.callback_uid, + placementCode: DEFAULT_PARAMS.bids[0].placementCode }]}); - var bidResponseAd = stubAddBidResponse.getCall(0).args[1]; + var callback = stringToFunction(parsedBidUrlQueryString.callback); + expect(callback).to.exist.and.to.be.a('function'); + callback(BID_RESPONSE); + }); + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); - expect(bidResponseAd).to.have.property("cpm").and.to.equal(BID_RESPONSE.result.cpm / 10000); - expect(bidResponseAd).to.have.property("adUrl").and.to.equal(BID_RESPONSE.result.ad); - expect(bidResponseAd).to.have.property("width").and.to.equal(BID_RESPONSE.result.width); - expect(bidResponseAd).to.have.property("height").and.to.equal(BID_RESPONSE.result.height); + adapter.createNew().callBids(DEFAULT_PARAMS); - stubAddBidResponse.restore(); - stubLoadScript.restore(); - }); + var bidResponseAd = stubAddBidResponse.getCall(0).args[1]; + + expect(bidResponseAd).to.have.property('cpm').and.to.equal(BID_RESPONSE.result.cpm / 10000); + expect(bidResponseAd).to.have.property('adUrl').and.to.equal(BID_RESPONSE.result.ad); + expect(bidResponseAd).to.have.property('width').and.to.equal(BID_RESPONSE.result.width); + expect(bidResponseAd).to.have.property('height').and.to.equal(BID_RESPONSE.result.height); + + stubAddBidResponse.restore(); + stubLoadScript.restore(); + }); }); diff --git a/test/spec/adapters/underdogmedia_spec.js b/test/spec/adapters/underdogmedia_spec.js index 3c8639fd56a..9b1a15793ad 100644 --- a/test/spec/adapters/underdogmedia_spec.js +++ b/test/spec/adapters/underdogmedia_spec.js @@ -9,7 +9,6 @@ import { } from 'chai'; describe('underdogmedia adapter test', () => { - let adapter; let server; @@ -18,55 +17,54 @@ describe('underdogmedia adapter test', () => { var bidderRequest = { bidderCode: 'underdogmedia', bids: [{ - bidder: 'underdogmedia', - adUnitCode: 'foo', - sizes: [ + bidder: 'underdogmedia', + adUnitCode: 'foo', + sizes: [ [728, 90] - ], - params: { - siteId: '10272' - } - }, - { - bidder: 'underdogmedia', - adUnitCode: 'bar', - sizes: [ + ], + params: { + siteId: '10272' + } + }, + { + bidder: 'underdogmedia', + adUnitCode: 'bar', + sizes: [ [300, 250] - ], - params: { - siteId: '10272', - subId: 'TEST_SUBID' - } - }, - { - bidder: 'underdogmedia', - adUnitCode: 'nothing', - sizes: [160, 600], - params: { - siteId: '31337' - } + ], + params: { + siteId: '10272', + subId: 'TEST_SUBID' + } + }, + { + bidder: 'underdogmedia', + adUnitCode: 'nothing', + sizes: [160, 600], + params: { + siteId: '31337' } + } ] }; var response = { - "mids": [{ - "width": 728, - "notification_url": "//udmserve.net/notification_url", - "height": 90, - "cpm": 2.5, - "ad_code_html": "Ad HTML for site ID 10272 size 728x90" - }, - { - "width": 300, - "notification_url": "//udmserve.net/notification_url", - "height": 250, - "cpm": 2.0, - "ad_code_html": "Ad HTML for site ID 10272 size 300x250" - } + 'mids': [{ + 'width': 728, + 'notification_url': '//udmserve.net/notification_url', + 'height': 90, + 'cpm': 2.5, + 'ad_code_html': 'Ad HTML for site ID 10272 size 728x90' + }, + { + 'width': 300, + 'notification_url': '//udmserve.net/notification_url', + 'height': 250, + 'cpm': 2.0, + 'ad_code_html': 'Ad HTML for site ID 10272 size 300x250' + } ] }; - beforeEach(() => { adapter = new Adapter(); }); @@ -74,7 +72,6 @@ describe('underdogmedia adapter test', () => { afterEach(() => {}); describe('adding bids to the manager', () => { - let firstBid; let secondBid; let thirdBid; @@ -100,14 +97,12 @@ describe('underdogmedia adapter test', () => { }); it('will add the ad html to the bid object', () => { - expect(firstBid).to.have.property('ad').includes('Ad HTML for site ID 10272 size 728x90'); expect(secondBid).to.have.property('ad').includes('Ad HTML for site ID 10272 size 300x250').and.includes('TEST_SUBID'); expect(thirdBid).to.not.have.property('ad'); }); it('will have the right size attached', () => { - expect(firstBid).to.have.property('width', 728); expect(firstBid).to.have.property('height', 90); expect(secondBid).to.have.property('width', 300); @@ -125,7 +120,5 @@ describe('underdogmedia adapter test', () => { expect(secondBid).to.have.property('bidderCode', 'underdogmedia'); expect(thirdBid).to.have.property('bidderCode', 'underdogmedia'); }); - }); - }); diff --git a/test/spec/adapters/vertamedia_spec.js b/test/spec/adapters/vertamedia_spec.js index 2b6e9e466e4..c96103ce61f 100644 --- a/test/spec/adapters/vertamedia_spec.js +++ b/test/spec/adapters/vertamedia_spec.js @@ -5,143 +5,137 @@ import bidmanager from 'src/bidmanager'; const ENDPOINT = 'http://rtb.vertamedia.com/hb/?aid=22489&w=640&h=480&domain=localhost'; const REQUEST = { - "bidderCode": "vertamedia", - "requestId": "d3e07445-ab06-44c8-a9dd-5ef9af06d2a6", - "bidderRequestId": "7101db09af0db2", - "bids": [ - { - "bidder": "vertamedia", - "params": { - aid: 22489, - placementId: '123456' - }, - "placementCode": "/19968336/header-bid-tag1", - "sizes": [640, 480], - "bidId": "84ab500420319d", - "bidderRequestId": "7101db09af0db2", - "requestId": "d3e07445-ab06-44c8-a9dd-5ef9af06d2a6" - } - ], - "start": 1469479810130 + 'bidderCode': 'vertamedia', + 'requestId': 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', + 'bidderRequestId': '7101db09af0db2', + 'bids': [ + { + 'bidder': 'vertamedia', + 'params': { + aid: 22489, + placementId: '123456' + }, + 'placementCode': '/19968336/header-bid-tag1', + 'sizes': [640, 480], + 'bidId': '84ab500420319d', + 'bidderRequestId': '7101db09af0db2', + 'requestId': 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6' + } + ], + 'start': 1469479810130 }; var RESPONSE = { - "source": { - "aid": 22489, - "pubId": 18016, - "sid": "0" - }, - "bids": [ - { - "cmpId": 9541, - "cpm": 4.5, - "url": "http://rtb.vertamedia.com/vast?adid=BFDB9CC0038AD918", - "cur": "USD" - } - ] + 'source': { + 'aid': 22489, + 'pubId': 18016, + 'sid': '0' + }, + 'bids': [ + { + 'cmpId': 9541, + 'cpm': 4.5, + 'url': 'http://rtb.vertamedia.com/vast?adid=BFDB9CC0038AD918', + 'cur': 'USD' + } + ] }; - describe('VertamediaAdater', () => { + let adapter; - let adapter; - - beforeEach(() => adapter = Adapter.createNew()); - - describe('request function', () => { - - let xhr; - let requests; + beforeEach(() => adapter = Adapter.createNew()); - beforeEach(() => { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); - }); + describe('request function', () => { + let xhr; + let requests; - afterEach(() => xhr.restore()); - - it('exists and is a function', () => { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - - it('requires paramters to make request', () => { - adapter.callBids({}); - expect(requests).to.be.empty; - }); + beforeEach(() => { + xhr = sinon.useFakeXMLHttpRequest(); + requests = []; + xhr.onCreate = request => requests.push(request); + }); - it('requires member && invCode', () => { - let backup = REQUEST.bids[0].params; - REQUEST.bids[0].params = {member: 1234}; - adapter.callBids(REQUEST); - expect(requests).to.be.empty; - REQUEST.bids[0].params = backup; - }); + afterEach(() => xhr.restore()); + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); - it('sends bid request to ENDPOINT via POST', () => { - adapter.callBids(REQUEST); - expect(requests[0].url).to.equal(ENDPOINT); - expect(requests[0].method).to.equal('GET'); - }); + it('requires paramters to make request', () => { + adapter.callBids({}); + expect(requests).to.be.empty; + }); + it('requires member && invCode', () => { + let backup = REQUEST.bids[0].params; + REQUEST.bids[0].params = {member: 1234}; + adapter.callBids(REQUEST); + expect(requests).to.be.empty; + REQUEST.bids[0].params = backup; }); - describe('response handler', () => { + it('sends bid request to ENDPOINT via POST', () => { + adapter.callBids(REQUEST); + expect(requests[0].url).to.equal(ENDPOINT); + expect(requests[0].method).to.equal('GET'); + }); + }); - let server; + describe('response handler', () => { + let server; - beforeEach(() => { - server = sinon.fakeServer.create(); - sinon.stub(bidmanager, 'addBidResponse'); - }); + beforeEach(() => { + server = sinon.fakeServer.create(); + sinon.stub(bidmanager, 'addBidResponse'); + }); - afterEach(() => { - server.restore(); - bidmanager.addBidResponse.restore(); - }); + afterEach(() => { + server.restore(); + bidmanager.addBidResponse.restore(); + }); - it('registers bids', () => { - server.respondWith(JSON.stringify(RESPONSE)); + it('registers bids', () => { + server.respondWith(JSON.stringify(RESPONSE)); - adapter.callBids(REQUEST); - server.respond(); - sinon.assert.calledOnce(bidmanager.addBidResponse); + adapter.callBids(REQUEST); + server.respond(); + sinon.assert.calledOnce(bidmanager.addBidResponse); - const response = bidmanager.addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('cpm', 4.5); - }); + const response = bidmanager.addBidResponse.firstCall.args[1]; + expect(response).to.have.property('statusMessage', 'Bid available'); + expect(response).to.have.property('cpm', 4.5); + }); - it('handles nobid responses', () => { - server.respondWith(JSON.stringify({ - aid: 356465468, - w: 640, - h: 480, - domain: 'localhost' - })); + it('handles nobid responses', () => { + server.respondWith(JSON.stringify({ + aid: 356465468, + w: 640, + h: 480, + domain: 'localhost' + })); - adapter.callBids(REQUEST); - server.respond(); - sinon.assert.calledOnce(bidmanager.addBidResponse); + adapter.callBids(REQUEST); + server.respond(); + sinon.assert.calledOnce(bidmanager.addBidResponse); - const response = bidmanager.addBidResponse.firstCall.args[1]; - expect(response).to.have.property( + const response = bidmanager.addBidResponse.firstCall.args[1]; + expect(response).to.have.property( 'statusMessage', 'Bid returned empty or error response' ); - }); + }); - it('handles JSON.parse errors', () => { - server.respondWith(''); + it('handles JSON.parse errors', () => { + server.respondWith(''); - adapter.callBids(REQUEST); - server.respond(); - sinon.assert.calledOnce(bidmanager.addBidResponse); + adapter.callBids(REQUEST); + server.respond(); + sinon.assert.calledOnce(bidmanager.addBidResponse); - expect(bidmanager.addBidResponse.firstCall.args[1]).to.have.property( + expect(bidmanager.addBidResponse.firstCall.args[1]).to.have.property( 'statusMessage', 'Bid returned empty or error response' ); - }); }); + }); }); diff --git a/test/spec/adapters/vertoz_spec.js b/test/spec/adapters/vertoz_spec.js index 76ef50ad7a3..b3881091df4 100755 --- a/test/spec/adapters/vertoz_spec.js +++ b/test/spec/adapters/vertoz_spec.js @@ -5,141 +5,136 @@ import bidManager from '../../../src/bidmanager'; import adLoader from '../../../src/adloader'; describe('Vertoz Adapter', () => { - let adapter; - let sandbox; - let bidsRequestBuff; - const bidderRequest = { - bidderCode: 'vertoz', - bids: [{ - bidId: 'bidId1', - bidder: 'vertoz', - placementCode: 'foo', - sizes: [ + let adapter; + let sandbox; + let bidsRequestBuff; + const bidderRequest = { + bidderCode: 'vertoz', + bids: [{ + bidId: 'bidId1', + bidder: 'vertoz', + placementCode: 'foo', + sizes: [ [300, 250] - ], - params: { - placementId: 'VZ-HB-123' - } - },{ - bidId: 'bidId2', - bidder: 'vertoz', - placementCode: 'bar', - sizes: [ + ], + params: { + placementId: 'VZ-HB-123' + } + }, { + bidId: 'bidId2', + bidder: 'vertoz', + placementCode: 'bar', + sizes: [ [728, 90] - ], - params: { - placementId: 'VZ-HB-456' - } - },{ - bidId: 'bidId3', - bidder: 'vertoz', - placementCode: 'coo', - sizes: [ + ], + params: { + placementId: 'VZ-HB-456' + } + }, { + bidId: 'bidId3', + bidder: 'vertoz', + placementCode: 'coo', + sizes: [ [300, 600] - ], - params: { - placementId: '' - } - }] - }; - + ], + params: { + placementId: '' + } + }] + }; + + beforeEach(() => { + adapter = new Adapter(); + sandbox = sinon.sandbox.create(); + bidsRequestBuff = pbjs._bidsRequested; + pbjs._bidsRequested = []; + }); + + afterEach(() => { + sandbox.restore(); + pbjs._bidsRequested = bidsRequestBuff; + }); + + describe('callBids', () => { beforeEach(() => { - adapter = new Adapter(); - sandbox = sinon.sandbox.create(); - bidsRequestBuff = pbjs._bidsRequested; - pbjs._bidsRequested = []; + sandbox.stub(adLoader, 'loadScript'); + adapter.callBids(bidderRequest); }); - afterEach(() => { - sandbox.restore(); - pbjs._bidsRequested = bidsRequestBuff; + it('should be called twice', () => { + sinon.assert.calledTwice(adLoader.loadScript); }); + }); + + describe('Bid response', () => { + let vzBidRequest; + let bidderReponse = { + 'vzhPlacementId': 'VZ-HB-123', + 'bid': '0fac1b8a-6ba0-4641-bd57-2899b1bedeae_0', + 'adWidth': '300', + 'adHeight': '250', + 'cpm': '1.00000000000000', + 'ad': '
', + 'slotBidId': 'bidId1', + 'nurl': '', + 'statusText': 'vertoz:success' + }; - describe('callBids', () => { - beforeEach(() => { - sandbox.stub(adLoader, 'loadScript'); - adapter.callBids(bidderRequest); - }); - - it('should be called twice', () => { - sinon.assert.calledTwice(adLoader.loadScript); - }); - + beforeEach(() => { + pbjs._bidsRequested.push(bidderRequest); }); - describe('Bid response', () => { - let vzBidRequest; - let bidderReponse = { - "vzhPlacementId": "VZ-HB-123", - "bid": "0fac1b8a-6ba0-4641-bd57-2899b1bedeae_0", - "adWidth": "300", - "adHeight": "250", - "cpm": "1.00000000000000", - "ad": "
", - "slotBidId": "bidId1", - "nurl": "", - "statusText": "vertoz:success" - }; - - beforeEach(() => { - pbjs._bidsRequested.push(bidderRequest); - }); - - describe('success', () => { - let firstBidReg; - let adSpaceId; - - beforeEach(() => { - sandbox.stub(bidManager, 'addBidResponse'); - pbjs.vzResponse(bidderReponse); - firstBidReg = bidManager.addBidResponse.firstCall.args[1]; - adSpaceId = bidManager.addBidResponse.firstCall.args[0]; - }); - - it('cpm to have property 1.000000', () => { - expect(firstBidReg).to.have.property('cpm', 1.00); - }); - it('adSpaceId should exist and be equal to placementCode', () => { - expect(adSpaceId).to.equal("foo"); - }); - it('should have property ad', () => { - expect(firstBidReg).to.have.property('ad'); - }); - it('should include the size to the bid object', () => { - expect(firstBidReg).to.have.property('width', '300'); - expect(firstBidReg).to.have.property('height', '250'); - }); - - }); - - describe('failure', () => { - let secondBidReg; - let adSpaceId; - let bidderResponse = { - "vzhPlacementId": "VZ-HB-456", - "slotBidId": "bidId2", - "statusText": "vertoz:NO_BIDS" - } - - beforeEach(() => { - sandbox.stub(bidManager, 'addBidResponse'); - pbjs.vzResponse(bidderResponse); - secondBidReg = bidManager.addBidResponse.firstCall.args[1]; - adSpaceId = bidManager.addBidResponse.firstCall.args[0]; - }); - - it('should not have cpm property', () => { - expect(secondBidReg.cpm).to.be.undefined; - }); - it('adSpaceId should exist and be equal to placementCode', () => { - expect(adSpaceId).to.equal("bar"); - }); - it('should not have ad property', () => { - expect(secondBidReg.ad).to.be.undefined; - }); - - }); - + describe('success', () => { + let firstBidReg; + let adSpaceId; + + beforeEach(() => { + sandbox.stub(bidManager, 'addBidResponse'); + pbjs.vzResponse(bidderReponse); + firstBidReg = bidManager.addBidResponse.firstCall.args[1]; + adSpaceId = bidManager.addBidResponse.firstCall.args[0]; + }); + + it('cpm to have property 1.000000', () => { + expect(firstBidReg).to.have.property('cpm', 1.00); + }); + it('adSpaceId should exist and be equal to placementCode', () => { + expect(adSpaceId).to.equal('foo'); + }); + it('should have property ad', () => { + expect(firstBidReg).to.have.property('ad'); + }); + it('should include the size to the bid object', () => { + expect(firstBidReg).to.have.property('width', '300'); + expect(firstBidReg).to.have.property('height', '250'); + }); }); + describe('failure', () => { + let secondBidReg; + let adSpaceId; + let bidderResponse = { + 'vzhPlacementId': 'VZ-HB-456', + 'slotBidId': 'bidId2', + 'statusText': 'vertoz:NO_BIDS' + } + + beforeEach(() => { + sandbox.stub(bidManager, 'addBidResponse'); + pbjs.vzResponse(bidderResponse); + secondBidReg = bidManager.addBidResponse.firstCall.args[1]; + adSpaceId = bidManager.addBidResponse.firstCall.args[0]; + }); + + it('should not have cpm property', () => { + expect(secondBidReg.cpm).to.be.undefined; + }); + it('adSpaceId should exist and be equal to placementCode', () => { + expect(adSpaceId).to.equal('bar'); + }); + it('should not have ad property', () => { + expect(secondBidReg.ad).to.be.undefined; + }); + }); + }); }); diff --git a/test/spec/adapters/wideorbit_spec.js b/test/spec/adapters/wideorbit_spec.js index 552f8c39cdc..c2b8d416e1e 100644 --- a/test/spec/adapters/wideorbit_spec.js +++ b/test/spec/adapters/wideorbit_spec.js @@ -1,290 +1,275 @@ describe('wideorbit adapter tests', function () { - - var expect = require('chai').expect; - var urlParse = require('url-parse'); + var expect = require('chai').expect; + var urlParse = require('url-parse'); // FYI: querystringify will perform encoding/decoding - var querystringify = require('querystringify'); - - var adapter = require('src/adapters/wideorbit'); - var adLoader = require('src/adloader'); - var bidmanager = require('src/bidmanager'); - - describe('creation of bid url', function () { - - let stubLoadScript; - - beforeEach(function () { - stubLoadScript = sinon.stub(adLoader, 'loadScript'); - }); - - afterEach(function () { - stubLoadScript.restore(); - }); - - it('should be called only once', function () { - - var params = { - bidderCode: 'wideorbit', - bids: [ - { - bidder: 'wideorbit', - params: { - pbId: 1, - pId: 101 - }, - placementCode: 'div-gpt-ad-12345-1' - }, - { - bidder: 'wideorbit', - params: { - pbId: 1, - site: 'Site 1', - page: 'Page 1', - width: 100, - height: 200, - subPublisher: 'Sub Publisher 1' - }, - placementCode: 'div-gpt-ad-12345-2' - } - ] - }; - - adapter().callBids(params); - - sinon.assert.calledOnce(stubLoadScript); - - }); - - it('should fix parameters name', function () { - - var params = { - bidderCode: 'wideorbit', - bids: [ - { - bidder: 'wideorbit', - params: { - PBiD: 1, - PID: 101, - ReferRer: 'http://www.foo.com?param1=param1¶m2=param2' - }, - placementCode: 'div-gpt-ad-12345-1' - }, - { - bidder: 'wideorbit', - params: { - pbid: 1, - SiTe: 'Site 1', - Page: 'Page 1', - widTH: 100, - HEIGHT: 200, - SUBPublisher: 'Sub Publisher 1' - }, - placementCode: 'div-gpt-ad-12345-2' - } - ] - }; - - adapter().callBids(params); - - var bidUrl = stubLoadScript.getCall(0).args[0]; - - sinon.assert.calledWith(stubLoadScript, bidUrl); - - var parsedBidUrl = urlParse(bidUrl); - var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - - expect(parsedBidUrl.hostname).to.equal('p1.atemda.com') - expect(parsedBidUrl.pathname).to.equal('/JSAdservingMP.ashx') - expect(parsedBidUrlQueryString).to.have.property('pc').and.to.equal('2'); - expect(parsedBidUrlQueryString).to.have.property('pbId').and.to.equal('1'); - expect(parsedBidUrlQueryString).to.have.property('jsv').and.to.equal('1.0'); - expect(parsedBidUrlQueryString).to.have.property('tsv').and.to.equal('1.0'); - expect(parsedBidUrlQueryString).to.have.property('cts').to.have.length.above(0); - expect(parsedBidUrlQueryString).to.have.property('arp').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('fl').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('jscb').and.to.equal('window.$$PREBID_GLOBAL$$.handleWideOrbitCallback'); - expect(parsedBidUrlQueryString).to.have.property('mpp').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('cb').to.have.length.above(0); - expect(parsedBidUrlQueryString).to.have.property('hb').and.to.equal('1'); - expect(parsedBidUrlQueryString).to.have.property('url').and.to.equal('http://www.foo.com?param1=param1¶m2=param2'); - - expect(parsedBidUrlQueryString).to.have.property('gid0').and.to.equal('div-gpt-ad-12345-1'); - expect(parsedBidUrlQueryString).to.have.property('rpos0').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('ecpm0').and.to.equal(''); - - expect(parsedBidUrlQueryString).to.have.property('gid1').and.to.equal('div-gpt-ad-12345-2'); - expect(parsedBidUrlQueryString).to.have.property('rpos1').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('ecpm1').and.to.equal(''); - - expect(parsedBidUrlQueryString).to.have.property('pId0').and.to.equal('101'); - expect(parsedBidUrlQueryString).to.have.property('rank0').and.to.equal('0'); - - expect(parsedBidUrlQueryString).to.have.property('wsName1').and.to.equal('Site 1'); - expect(parsedBidUrlQueryString).to.have.property('wName1').and.to.equal('Page 1'); - expect(parsedBidUrlQueryString).to.have.property('rank1').and.to.equal('1'); - expect(parsedBidUrlQueryString).to.have.property('bfDim1').and.to.equal('100x200'); - expect(parsedBidUrlQueryString).to.have.property('subp1').and.to.equal('Sub Publisher 1'); - - }); - - describe('placement by name', function () { - - it('should be called with specific parameters for two bids', function () { - - var params = { - bidderCode: 'wideorbit', - bids: [ - { - bidder: 'wideorbit', - params: { - pbId: 1, - site: 'Site 1', - page: 'Page 1', - width: 100, - height: 200, - subPublisher: 'Sub Publisher 1', - atf: true - }, - placementCode: 'div-gpt-ad-12345-1' - }, - { - bidder: 'wideorbit', - params: { - pbId: 1, - site: 'Site 2', - page: 'Page 2', - width: 200, - height: 300, - rank: 123, - ecpm: 1.8 - }, - placementCode: 'div-gpt-ad-12345-2' - } - ] - }; - - adapter().callBids(params); - - var bidUrl = stubLoadScript.getCall(0).args[0]; - - sinon.assert.calledWith(stubLoadScript, bidUrl); - - var parsedBidUrl = urlParse(bidUrl); - var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - - expect(parsedBidUrl.hostname).to.equal('p1.atemda.com') - expect(parsedBidUrl.pathname).to.equal('/JSAdservingMP.ashx') - expect(parsedBidUrlQueryString).to.have.property('pc').and.to.equal('2'); - expect(parsedBidUrlQueryString).to.have.property('pbId').and.to.equal('1'); - expect(parsedBidUrlQueryString).to.have.property('jsv').and.to.equal('1.0'); - expect(parsedBidUrlQueryString).to.have.property('tsv').and.to.equal('1.0'); - expect(parsedBidUrlQueryString).to.have.property('cts').to.have.length.above(0); - expect(parsedBidUrlQueryString).to.have.property('arp').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('fl').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('jscb').and.to.equal('window.$$PREBID_GLOBAL$$.handleWideOrbitCallback'); - expect(parsedBidUrlQueryString).to.have.property('mpp').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('cb').to.have.length.above(0); - expect(parsedBidUrlQueryString).to.have.property('hb').and.to.equal('1'); - expect(parsedBidUrlQueryString).to.have.property('url').and.to.be.empty; - - expect(parsedBidUrlQueryString).to.have.property('gid0').and.to.equal('div-gpt-ad-12345-1'); - expect(parsedBidUrlQueryString).to.have.property('rpos0').and.to.equal('1001'); - expect(parsedBidUrlQueryString).to.have.property('ecpm0').and.to.equal(''); - - expect(parsedBidUrlQueryString).to.have.property('gid1').and.to.equal('div-gpt-ad-12345-2'); - expect(parsedBidUrlQueryString).to.have.property('rpos1').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('ecpm1').and.to.equal('1.8'); - - expect(parsedBidUrlQueryString).to.have.property('wsName0').and.to.equal('Site 1'); - expect(parsedBidUrlQueryString).to.have.property('wName0').and.to.equal('Page 1'); - expect(parsedBidUrlQueryString).to.have.property('rank0').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('bfDim0').and.to.equal('100x200'); - expect(parsedBidUrlQueryString).to.have.property('subp0').and.to.equal('Sub Publisher 1'); - - expect(parsedBidUrlQueryString).to.have.property('wsName1').and.to.equal('Site 2'); - expect(parsedBidUrlQueryString).to.have.property('wName1').and.to.equal('Page 2'); - expect(parsedBidUrlQueryString).to.have.property('rank1').and.to.equal('123'); - expect(parsedBidUrlQueryString).to.have.property('bfDim1').and.to.equal('200x300'); - expect(parsedBidUrlQueryString).to.have.property('subp1').and.to.equal(''); - - }); - - }); - - describe('placement by id', function () { - - it('should be called with specific parameters for two bids', function () { - - var params = { - bidderCode: 'wideorbit', - bids: [ - { - bidder: 'wideorbit', - params: { - pbId: 1, - pId: 101, - atf: true, - ecpm: 0.8 - }, - placementCode: 'div-gpt-ad-12345-1' - }, - { - bidder: 'wideorbit', - params: { - pbId: 1, - pId: 102, - rank: 123 - }, - placementCode: 'div-gpt-ad-12345-2' - } - ] - }; - - adapter().callBids(params); - - var bidUrl = stubLoadScript.getCall(0).args[0]; - - sinon.assert.calledWith(stubLoadScript, bidUrl); - - var parsedBidUrl = urlParse(bidUrl); - var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); - - expect(parsedBidUrl.hostname).to.equal('p1.atemda.com') - expect(parsedBidUrl.pathname).to.equal('/JSAdservingMP.ashx') - expect(parsedBidUrlQueryString).to.have.property('pc').and.to.equal('2'); - expect(parsedBidUrlQueryString).to.have.property('pbId').and.to.equal('1'); - expect(parsedBidUrlQueryString).to.have.property('jsv').and.to.equal('1.0'); - expect(parsedBidUrlQueryString).to.have.property('tsv').and.to.equal('1.0'); - expect(parsedBidUrlQueryString).to.have.property('cts').to.have.length.above(0); - expect(parsedBidUrlQueryString).to.have.property('arp').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('fl').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('jscb').and.to.equal('window.$$PREBID_GLOBAL$$.handleWideOrbitCallback'); - expect(parsedBidUrlQueryString).to.have.property('mpp').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('cb').to.have.length.above(0); - expect(parsedBidUrlQueryString).to.have.property('hb').and.to.equal('1'); - expect(parsedBidUrlQueryString).to.have.property('url').and.to.be.empty; - - expect(parsedBidUrlQueryString).to.have.property('gid0').and.to.equal('div-gpt-ad-12345-1'); - expect(parsedBidUrlQueryString).to.have.property('rpos0').and.to.equal('1001'); - expect(parsedBidUrlQueryString).to.have.property('ecpm0').and.to.equal('0.8'); - - expect(parsedBidUrlQueryString).to.have.property('gid1').and.to.equal('div-gpt-ad-12345-2'); - expect(parsedBidUrlQueryString).to.have.property('rpos1').and.to.equal('0'); - expect(parsedBidUrlQueryString).to.have.property('ecpm1').and.to.equal(''); - - expect(parsedBidUrlQueryString).to.have.property('pId0').and.to.equal('101'); - expect(parsedBidUrlQueryString).to.have.property('rank0').and.to.equal('0'); - - expect(parsedBidUrlQueryString).to.have.property('pId1').and.to.equal('102'); - expect(parsedBidUrlQueryString).to.have.property('rank1').and.to.equal('123'); - - }); - - }); + var querystringify = require('querystringify'); + + var adapter = require('src/adapters/wideorbit'); + var adLoader = require('src/adloader'); + var bidmanager = require('src/bidmanager'); + + describe('creation of bid url', function () { + let stubLoadScript; + + beforeEach(function () { + stubLoadScript = sinon.stub(adLoader, 'loadScript'); + }); + + afterEach(function () { + stubLoadScript.restore(); + }); + it('should be called only once', function () { + var params = { + bidderCode: 'wideorbit', + bids: [ + { + bidder: 'wideorbit', + params: { + pbId: 1, + pId: 101 + }, + placementCode: 'div-gpt-ad-12345-1' + }, + { + bidder: 'wideorbit', + params: { + pbId: 1, + site: 'Site 1', + page: 'Page 1', + width: 100, + height: 200, + subPublisher: 'Sub Publisher 1' + }, + placementCode: 'div-gpt-ad-12345-2' + } + ] + }; + + adapter().callBids(params); + + sinon.assert.calledOnce(stubLoadScript); }); + it('should fix parameters name', function () { + var params = { + bidderCode: 'wideorbit', + bids: [ + { + bidder: 'wideorbit', + params: { + PBiD: 1, + PID: 101, + ReferRer: 'http://www.foo.com?param1=param1¶m2=param2' + }, + placementCode: 'div-gpt-ad-12345-1' + }, + { + bidder: 'wideorbit', + params: { + pbid: 1, + SiTe: 'Site 1', + Page: 'Page 1', + widTH: 100, + HEIGHT: 200, + SUBPublisher: 'Sub Publisher 1' + }, + placementCode: 'div-gpt-ad-12345-2' + } + ] + }; + + adapter().callBids(params); + + var bidUrl = stubLoadScript.getCall(0).args[0]; + + sinon.assert.calledWith(stubLoadScript, bidUrl); + + var parsedBidUrl = urlParse(bidUrl); + var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); + + expect(parsedBidUrl.hostname).to.equal('p1.atemda.com') + expect(parsedBidUrl.pathname).to.equal('/JSAdservingMP.ashx') + expect(parsedBidUrlQueryString).to.have.property('pc').and.to.equal('2'); + expect(parsedBidUrlQueryString).to.have.property('pbId').and.to.equal('1'); + expect(parsedBidUrlQueryString).to.have.property('jsv').and.to.equal('1.0'); + expect(parsedBidUrlQueryString).to.have.property('tsv').and.to.equal('1.0'); + expect(parsedBidUrlQueryString).to.have.property('cts').to.have.length.above(0); + expect(parsedBidUrlQueryString).to.have.property('arp').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('fl').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('jscb').and.to.equal('window.$$PREBID_GLOBAL$$.handleWideOrbitCallback'); + expect(parsedBidUrlQueryString).to.have.property('mpp').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('cb').to.have.length.above(0); + expect(parsedBidUrlQueryString).to.have.property('hb').and.to.equal('1'); + expect(parsedBidUrlQueryString).to.have.property('url').and.to.equal('http://www.foo.com?param1=param1¶m2=param2'); + + expect(parsedBidUrlQueryString).to.have.property('gid0').and.to.equal('div-gpt-ad-12345-1'); + expect(parsedBidUrlQueryString).to.have.property('rpos0').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('ecpm0').and.to.equal(''); + + expect(parsedBidUrlQueryString).to.have.property('gid1').and.to.equal('div-gpt-ad-12345-2'); + expect(parsedBidUrlQueryString).to.have.property('rpos1').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('ecpm1').and.to.equal(''); + + expect(parsedBidUrlQueryString).to.have.property('pId0').and.to.equal('101'); + expect(parsedBidUrlQueryString).to.have.property('rank0').and.to.equal('0'); + + expect(parsedBidUrlQueryString).to.have.property('wsName1').and.to.equal('Site 1'); + expect(parsedBidUrlQueryString).to.have.property('wName1').and.to.equal('Page 1'); + expect(parsedBidUrlQueryString).to.have.property('rank1').and.to.equal('1'); + expect(parsedBidUrlQueryString).to.have.property('bfDim1').and.to.equal('100x200'); + expect(parsedBidUrlQueryString).to.have.property('subp1').and.to.equal('Sub Publisher 1'); + }); + + describe('placement by name', function () { + it('should be called with specific parameters for two bids', function () { + var params = { + bidderCode: 'wideorbit', + bids: [ + { + bidder: 'wideorbit', + params: { + pbId: 1, + site: 'Site 1', + page: 'Page 1', + width: 100, + height: 200, + subPublisher: 'Sub Publisher 1', + atf: true + }, + placementCode: 'div-gpt-ad-12345-1' + }, + { + bidder: 'wideorbit', + params: { + pbId: 1, + site: 'Site 2', + page: 'Page 2', + width: 200, + height: 300, + rank: 123, + ecpm: 1.8 + }, + placementCode: 'div-gpt-ad-12345-2' + } + ] + }; + + adapter().callBids(params); + + var bidUrl = stubLoadScript.getCall(0).args[0]; + + sinon.assert.calledWith(stubLoadScript, bidUrl); + + var parsedBidUrl = urlParse(bidUrl); + var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); + + expect(parsedBidUrl.hostname).to.equal('p1.atemda.com') + expect(parsedBidUrl.pathname).to.equal('/JSAdservingMP.ashx') + expect(parsedBidUrlQueryString).to.have.property('pc').and.to.equal('2'); + expect(parsedBidUrlQueryString).to.have.property('pbId').and.to.equal('1'); + expect(parsedBidUrlQueryString).to.have.property('jsv').and.to.equal('1.0'); + expect(parsedBidUrlQueryString).to.have.property('tsv').and.to.equal('1.0'); + expect(parsedBidUrlQueryString).to.have.property('cts').to.have.length.above(0); + expect(parsedBidUrlQueryString).to.have.property('arp').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('fl').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('jscb').and.to.equal('window.$$PREBID_GLOBAL$$.handleWideOrbitCallback'); + expect(parsedBidUrlQueryString).to.have.property('mpp').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('cb').to.have.length.above(0); + expect(parsedBidUrlQueryString).to.have.property('hb').and.to.equal('1'); + expect(parsedBidUrlQueryString).to.have.property('url').and.to.be.empty; + + expect(parsedBidUrlQueryString).to.have.property('gid0').and.to.equal('div-gpt-ad-12345-1'); + expect(parsedBidUrlQueryString).to.have.property('rpos0').and.to.equal('1001'); + expect(parsedBidUrlQueryString).to.have.property('ecpm0').and.to.equal(''); + + expect(parsedBidUrlQueryString).to.have.property('gid1').and.to.equal('div-gpt-ad-12345-2'); + expect(parsedBidUrlQueryString).to.have.property('rpos1').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('ecpm1').and.to.equal('1.8'); + + expect(parsedBidUrlQueryString).to.have.property('wsName0').and.to.equal('Site 1'); + expect(parsedBidUrlQueryString).to.have.property('wName0').and.to.equal('Page 1'); + expect(parsedBidUrlQueryString).to.have.property('rank0').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('bfDim0').and.to.equal('100x200'); + expect(parsedBidUrlQueryString).to.have.property('subp0').and.to.equal('Sub Publisher 1'); + + expect(parsedBidUrlQueryString).to.have.property('wsName1').and.to.equal('Site 2'); + expect(parsedBidUrlQueryString).to.have.property('wName1').and.to.equal('Page 2'); + expect(parsedBidUrlQueryString).to.have.property('rank1').and.to.equal('123'); + expect(parsedBidUrlQueryString).to.have.property('bfDim1').and.to.equal('200x300'); + expect(parsedBidUrlQueryString).to.have.property('subp1').and.to.equal(''); + }); + }); + + describe('placement by id', function () { + it('should be called with specific parameters for two bids', function () { + var params = { + bidderCode: 'wideorbit', + bids: [ + { + bidder: 'wideorbit', + params: { + pbId: 1, + pId: 101, + atf: true, + ecpm: 0.8 + }, + placementCode: 'div-gpt-ad-12345-1' + }, + { + bidder: 'wideorbit', + params: { + pbId: 1, + pId: 102, + rank: 123 + }, + placementCode: 'div-gpt-ad-12345-2' + } + ] + }; + + adapter().callBids(params); + + var bidUrl = stubLoadScript.getCall(0).args[0]; + + sinon.assert.calledWith(stubLoadScript, bidUrl); + + var parsedBidUrl = urlParse(bidUrl); + var parsedBidUrlQueryString = querystringify.parse(parsedBidUrl.query); + + expect(parsedBidUrl.hostname).to.equal('p1.atemda.com') + expect(parsedBidUrl.pathname).to.equal('/JSAdservingMP.ashx') + expect(parsedBidUrlQueryString).to.have.property('pc').and.to.equal('2'); + expect(parsedBidUrlQueryString).to.have.property('pbId').and.to.equal('1'); + expect(parsedBidUrlQueryString).to.have.property('jsv').and.to.equal('1.0'); + expect(parsedBidUrlQueryString).to.have.property('tsv').and.to.equal('1.0'); + expect(parsedBidUrlQueryString).to.have.property('cts').to.have.length.above(0); + expect(parsedBidUrlQueryString).to.have.property('arp').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('fl').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('jscb').and.to.equal('window.$$PREBID_GLOBAL$$.handleWideOrbitCallback'); + expect(parsedBidUrlQueryString).to.have.property('mpp').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('cb').to.have.length.above(0); + expect(parsedBidUrlQueryString).to.have.property('hb').and.to.equal('1'); + expect(parsedBidUrlQueryString).to.have.property('url').and.to.be.empty; + + expect(parsedBidUrlQueryString).to.have.property('gid0').and.to.equal('div-gpt-ad-12345-1'); + expect(parsedBidUrlQueryString).to.have.property('rpos0').and.to.equal('1001'); + expect(parsedBidUrlQueryString).to.have.property('ecpm0').and.to.equal('0.8'); + + expect(parsedBidUrlQueryString).to.have.property('gid1').and.to.equal('div-gpt-ad-12345-2'); + expect(parsedBidUrlQueryString).to.have.property('rpos1').and.to.equal('0'); + expect(parsedBidUrlQueryString).to.have.property('ecpm1').and.to.equal(''); + + expect(parsedBidUrlQueryString).to.have.property('pId0').and.to.equal('101'); + expect(parsedBidUrlQueryString).to.have.property('rank0').and.to.equal('0'); + + expect(parsedBidUrlQueryString).to.have.property('pId1').and.to.equal('102'); + expect(parsedBidUrlQueryString).to.have.property('rank1').and.to.equal('123'); + }); + }); + }); + // describe('handling of the callback response', function () { // // var placements = [ @@ -509,5 +494,4 @@ describe('wideorbit adapter tests', function () { // }); // // }); - }); diff --git a/test/spec/adapters/widespace_spec.js b/test/spec/adapters/widespace_spec.js index 51e8254ffcd..95f4a16458c 100644 --- a/test/spec/adapters/widespace_spec.js +++ b/test/spec/adapters/widespace_spec.js @@ -3,72 +3,68 @@ import adLoader from '../../../src/adloader'; import bidManager from '../../../src/bidmanager'; import Adapter from '../../../src/adapters/widespace'; - const ENDPOINT = '//engine.widespace.com/map/engine/hb/dynamic'; - const TEST = { - BIDDER_CODE: 'widespace', - CPM: 2.0, - PLACEMENT_CODE: 'aPlacementCode', - SID: 'f666bfaf-69cf-4ed9-9262-08247bb274e4', - CUR: 'EUR' - }; - - const BID_REQUEST = { - "bidderCode": TEST.BIDDER_CODE, - "requestId": "e155185b-3eac-4f3c-8182-cdb57a69df3c", - "bidderRequestId": "38993e482321e7", - "bids": [ - { - "bidder": TEST.BIDDER_CODE, - "params": { - "sid": TEST.SID, - "cur": TEST.CUR - }, - "placementCode": TEST.PLACEMENT_CODE, - "sizes": [ +const TEST = { + BIDDER_CODE: 'widespace', + CPM: 2.0, + PLACEMENT_CODE: 'aPlacementCode', + SID: 'f666bfaf-69cf-4ed9-9262-08247bb274e4', + CUR: 'EUR' +}; + +const BID_REQUEST = { + 'bidderCode': TEST.BIDDER_CODE, + 'requestId': 'e155185b-3eac-4f3c-8182-cdb57a69df3c', + 'bidderRequestId': '38993e482321e7', + 'bids': [ + { + 'bidder': TEST.BIDDER_CODE, + 'params': { + 'sid': TEST.SID, + 'cur': TEST.CUR + }, + 'placementCode': TEST.PLACEMENT_CODE, + 'sizes': [ [320, 320], [320, 250] - ], - "bidId": "45c7f5afb996c1", - "bidderRequestId": "7101db09af0db3", - "requestId": "e155185b-3eac-4f3c-8182-cdb57a69df3d" - } - ], - "start": 1479664180396, - "timeout": 5000 - }; - - - const BID_RESPONSE = [{ - "status": "ok", - "reqId": "140590112507", - "adId": 13963, - "width": 320, - "height": 320, - "cpm": 2.0, - "currency": "EUR", - "code": "

This is a banner

", - "callbackUid": "45c7f5afb996c1", - "callback": "pbjs.widespaceHandleCB" - }]; - - const BID_NOAD_RESPONSE = [{ - "status": "noad", - "reqId": "143509454349", - "adId": 22, - "width": 1, - "height": 1, - "cpm": 0.0, - "currency": "EUR", - "code": "", - "callbackUid": "45c7f5afb996c1", - "callback": "pbjs.widespaceHandleCB" + ], + 'bidId': '45c7f5afb996c1', + 'bidderRequestId': '7101db09af0db3', + 'requestId': 'e155185b-3eac-4f3c-8182-cdb57a69df3d' + } + ], + 'start': 1479664180396, + 'timeout': 5000 +}; + +const BID_RESPONSE = [{ + 'status': 'ok', + 'reqId': '140590112507', + 'adId': 13963, + 'width': 320, + 'height': 320, + 'cpm': 2.0, + 'currency': 'EUR', + 'code': '

This is a banner

', + 'callbackUid': '45c7f5afb996c1', + 'callback': 'pbjs.widespaceHandleCB' +}]; + +const BID_NOAD_RESPONSE = [{ + 'status': 'noad', + 'reqId': '143509454349', + 'adId': 22, + 'width': 1, + 'height': 1, + 'cpm': 0.0, + 'currency': 'EUR', + 'code': '', + 'callbackUid': '45c7f5afb996c1', + 'callback': 'pbjs.widespaceHandleCB' }] - describe('WidespaceAdapter', () => { - let adapter; let sandbox; @@ -81,13 +77,11 @@ describe('WidespaceAdapter', () => { sandbox.restore(); }); - describe('callBids', () => { it('should exists and be a function', () => { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); - describe('with valid request parameters', () => { beforeEach(() => { sandbox.stub(adLoader, 'loadScript'); @@ -122,7 +116,6 @@ describe('WidespaceAdapter', () => { }); }); - describe('widespaceHandleCB', () => { it('should exist and be a function', () => { expect(pbjs.widespaceHandleCB).to.exist.and.to.be.a('function'); @@ -131,7 +124,7 @@ describe('WidespaceAdapter', () => { describe('respond with a successful bid', () => { let successfulBid, - placementCode; + placementCode; beforeEach(() => { sandbox.stub(bidManager, 'addBidResponse'); @@ -143,7 +136,6 @@ describe('WidespaceAdapter', () => { successfulBid = bidManager.addBidResponse.firstCall.args[1]; placementCode = bidManager.addBidResponse.firstCall.args[0]; - }); it('should add one bid', () => { @@ -159,9 +151,8 @@ describe('WidespaceAdapter', () => { }); it('should have a valid size', () => { - const bidSize = [successfulBid.width,successfulBid.height] + const bidSize = [successfulBid.width, successfulBid.height] expect(bidSize).to.eql(BID_REQUEST.bids[0].sizes[0]); - }); it('should recive right placementCode', () => { @@ -169,7 +160,6 @@ describe('WidespaceAdapter', () => { }); }); - describe('respond with a no-ad', () => { let noadBid; @@ -188,7 +178,4 @@ describe('WidespaceAdapter', () => { expect(noadBid.getStatusCode()).to.eql(2); }); }); - - - }); diff --git a/test/spec/adapters/yieldbot_spec.js b/test/spec/adapters/yieldbot_spec.js index 19de14380df..bce80df0b84 100644 --- a/test/spec/adapters/yieldbot_spec.js +++ b/test/spec/adapters/yieldbot_spec.js @@ -51,7 +51,7 @@ function createYieldbotMockLib() { go: () => { window.yieldbot._initialized = true; }, nextPageview: (slots, callback) => {}, getSlotCriteria: (slotName) => { - return YB_BID_FIXTURE[slotName] || {ybot_ad: "n"}; + return YB_BID_FIXTURE[slotName] || {ybot_ad: 'n'}; } }; // jshint unused:true @@ -78,10 +78,8 @@ before(function() { }); describe('Yieldbot adapter tests', function() { - describe('callBids', function() { beforeEach(function () { - sandbox = sinon.sandbox.create(); createYieldbotMockLib(); diff --git a/test/spec/aliasBidder_spec.js b/test/spec/aliasBidder_spec.js index 883576e5546..61a654dcb90 100644 --- a/test/spec/aliasBidder_spec.js +++ b/test/spec/aliasBidder_spec.js @@ -7,7 +7,6 @@ describe('Publisher API _ Alias Bidder', function () { var prebid = require('../../src/prebid'); before(function () { - var topSlotCode = '/19968336/header-bid-tag1'; var topSlotSizes = [[728, 90], [970, 90]]; var adUnit = { @@ -31,12 +30,8 @@ describe('Publisher API _ Alias Bidder', function () { }); describe('set Alias Bidder', function () { - it('should have both of target bidder and alias bidder', function () { - $$PREBID_GLOBAL$$.aliasBidder('appnexus', 'bRealTime1'); - }); }); - }); diff --git a/test/spec/api_spec.js b/test/spec/api_spec.js index 4fde6965975..8e5bdd94272 100755 --- a/test/spec/api_spec.js +++ b/test/spec/api_spec.js @@ -5,7 +5,6 @@ describe('Publisher API', function () { // var assert = chai.assert; describe('api of command queue', function () { - it('should have a global variable $$PREBID_GLOBAL$$', function () { assert.isObject($$PREBID_GLOBAL$$); }); @@ -20,7 +19,6 @@ describe('Publisher API', function () { }); describe('has function', function () { - it('should have function $$PREBID_GLOBAL$$.getAdserverTargeting', function () { assert.isFunction($$PREBID_GLOBAL$$.getAdserverTargeting); }); @@ -76,7 +74,5 @@ describe('Publisher API', function () { it('should have function $$PREBID_GLOBAL$$.getAllWinningBids', function () { assert.isFunction($$PREBID_GLOBAL$$.getAllWinningBids); }); - }); - }); diff --git a/test/spec/bidmanager_spec.js b/test/spec/bidmanager_spec.js index 602f0beacfc..a269d091eeb 100644 --- a/test/spec/bidmanager_spec.js +++ b/test/spec/bidmanager_spec.js @@ -1,34 +1,32 @@ -var assert = require("assert"); +var assert = require('assert'); /* use this method to test individual files instead of the whole prebid.js project */ -//TODO refactor to use the spec files +// TODO refactor to use the spec files var utils = require('../../src/utils'); var bidmanager = require('../../src/bidmanager'); var bidfactory = require('../../src/bidfactory'); var fixtures = require('../fixtures/fixtures'); describe('replaceTokenInString', function () { - it('should replace all given tokens in a String', function () { var tokensToReplace = { 'foo': 'bar', 'zap': 'quux' }; - var output = utils.replaceTokenInString("hello %FOO%, I am %ZAP%", tokensToReplace, "%"); - assert.equal(output, "hello bar, I am quux"); + var output = utils.replaceTokenInString('hello %FOO%, I am %ZAP%', tokensToReplace, '%'); + assert.equal(output, 'hello bar, I am quux'); }); it('should ignore tokens it does not see', function () { - var output = utils.replaceTokenInString("hello %FOO%", {}, "%"); + var output = utils.replaceTokenInString('hello %FOO%', {}, '%'); - assert.equal(output, "hello %FOO%"); + assert.equal(output, 'hello %FOO%'); }); }); describe('bidmanager.js', function () { - describe('getKeyValueTargetingPairs', function () { var bid = {}; var bidPriceCpm = 5.578; @@ -57,19 +55,17 @@ describe('bidmanager.js', function () { }; bid.bidderCode = bidderCode; bid.adId = adId; - }); it('No bidder level configuration defined - default', function () { var expected = { - "hb_bidder": bidderCode, - "hb_adid": adId, - "hb_pb": bidPbMg, - "hb_size": size + 'hb_bidder': bidderCode, + 'hb_adid': adId, + 'hb_pb': bidPbMg, + 'hb_size': size }; var response = bidmanager.getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected); - }); it('Custom configuration for all bidders', function () { @@ -78,26 +74,25 @@ describe('bidmanager.js', function () { standard: { adserverTargeting: [ { - key: "hb_bidder", + key: 'hb_bidder', val: function (bidResponse) { return bidResponse.bidderCode; } }, { - key: "hb_adid", + key: 'hb_adid', val: function (bidResponse) { return bidResponse.adId; } }, { - key: "hb_pb", + key: 'hb_pb', val: function (bidResponse) { - //change default here + // change default here return bidResponse.pbHg; } }, { - key: "hb_size", + key: 'hb_size', val: function (bidResponse) { return bidResponse.size; - } } ] @@ -106,14 +101,13 @@ describe('bidmanager.js', function () { }; var expected = { - "hb_bidder": bidderCode, - "hb_adid": adId, - "hb_pb": bidPbHg, - "hb_size": size + 'hb_bidder': bidderCode, + 'hb_adid': adId, + 'hb_pb': bidPbHg, + 'hb_size': size }; var response = bidmanager.getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected); - }); it('Custom configuration for one bidder', function () { @@ -122,26 +116,25 @@ describe('bidmanager.js', function () { appnexus: { adserverTargeting: [ { - key: "hb_bidder", + key: 'hb_bidder', val: function (bidResponse) { return bidResponse.bidderCode; } }, { - key: "hb_adid", + key: 'hb_adid', val: function (bidResponse) { return bidResponse.adId; } }, { - key: "hb_pb", + key: 'hb_pb', val: function (bidResponse) { - //change default here + // change default here return bidResponse.pbHg; } }, { - key: "hb_size", + key: 'hb_size', val: function (bidResponse) { return bidResponse.size; - } } ] @@ -150,14 +143,13 @@ describe('bidmanager.js', function () { }; var expected = { - "hb_bidder": bidderCode, - "hb_adid": adId, - "hb_pb": bidPbHg, - "hb_size": size + 'hb_bidder': bidderCode, + 'hb_adid': adId, + 'hb_pb': bidPbHg, + 'hb_size': size }; var response = bidmanager.getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected); - }); it('Custom configuration for one bidder - not matched', function () { @@ -166,26 +158,25 @@ describe('bidmanager.js', function () { nonExistentBidder: { adserverTargeting: [ { - key: "hb_bidder", + key: 'hb_bidder', val: function (bidResponse) { return bidResponse.bidderCode; } }, { - key: "hb_adid", + key: 'hb_adid', val: function (bidResponse) { return bidResponse.adId; } }, { - key: "hb_pb", + key: 'hb_pb', val: function (bidResponse) { - //change default here + // change default here return bidResponse.pbHg; } }, { - key: "hb_size", + key: 'hb_size', val: function (bidResponse) { return bidResponse.size; - } } ] @@ -194,14 +185,13 @@ describe('bidmanager.js', function () { }; var expected = { - "hb_bidder": bidderCode, - "hb_adid": adId, - "hb_pb": bidPbMg, - "hb_size": size + 'hb_bidder': bidderCode, + 'hb_adid': adId, + 'hb_pb': bidPbMg, + 'hb_size': size }; var response = bidmanager.getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected); - }); it('Custom bidCpmAdjustment for one bidder and inherit standard', function () { @@ -215,19 +205,19 @@ describe('bidmanager.js', function () { standard: { adserverTargeting: [ { - key: "hb_bidder", + key: 'hb_bidder', val: function (bidResponse) { return bidResponse.bidderCode; } }, { - key: "hb_adid", + key: 'hb_adid', val: function (bidResponse) { return bidResponse.adId; } }, { - key: "hb_pb", + key: 'hb_pb', val: function (bidResponse) { - //change default here + // change default here return 10.00; } } @@ -236,10 +226,9 @@ describe('bidmanager.js', function () { } }; - var expected = { "hb_bidder": bidderCode, "hb_adid": adId, "hb_pb": 10.0 }; + var expected = { 'hb_bidder': bidderCode, 'hb_adid': adId, 'hb_pb': 10.0 }; var response = bidmanager.getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected); - }); it('Custom bidCpmAdjustment AND custom configuration for one bidder and inherit standard settings', function () { @@ -251,19 +240,19 @@ describe('bidmanager.js', function () { }, adserverTargeting: [ { - key: "hb_bidder", + key: 'hb_bidder', val: function (bidResponse) { return bidResponse.bidderCode; } }, { - key: "hb_adid", + key: 'hb_adid', val: function (bidResponse) { return bidResponse.adId; } }, { - key: "hb_pb", + key: 'hb_pb', val: function (bidResponse) { - //change default here + // change default here return 15.00; } } @@ -272,27 +261,26 @@ describe('bidmanager.js', function () { standard: { adserverTargeting: [ { - key: "hb_bidder", + key: 'hb_bidder', val: function (bidResponse) { return bidResponse.bidderCode; } }, { - key: "hb_adid", + key: 'hb_adid', val: function (bidResponse) { return bidResponse.adId; } }, { - key: "hb_pb", + key: 'hb_pb', val: function (bidResponse) { - //change default here + // change default here return 10.00; }, }, { - key: "hb_size", + key: 'hb_size', val: function (bidResponse) { return bidResponse.size; - } } ] @@ -301,14 +289,13 @@ describe('bidmanager.js', function () { }; var expected = { - "hb_bidder": bidderCode, - "hb_adid": adId, - "hb_pb": 15.0, - "hb_size": "300x250" + 'hb_bidder': bidderCode, + 'hb_adid': adId, + 'hb_pb': 15.0, + 'hb_size': '300x250' }; var response = bidmanager.getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected); - }); it('alwaysUseBid=true, sendStandardTargeting=false, and inherit custom', function () { @@ -319,17 +306,17 @@ describe('bidmanager.js', function () { sendStandardTargeting: false, adserverTargeting: [ { - key: "hb_bidder", + key: 'hb_bidder', val: function (bidResponse) { return bidResponse.bidderCode; } }, { - key: "hb_adid", + key: 'hb_adid', val: function (bidResponse) { return bidResponse.adId; } }, { - key: "hb_pb", + key: 'hb_pb', val: function (bidResponse) { return bidResponse.pbHg; } @@ -339,10 +326,10 @@ describe('bidmanager.js', function () { }; var expected = { - "hb_bidder": bidderCode, - "hb_adid": adId, - "hb_pb": 5.57, - "hb_size": "300x250" + 'hb_bidder': bidderCode, + 'hb_adid': adId, + 'hb_pb': 5.57, + 'hb_size': '300x250' }; var response = bidmanager.getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected); @@ -350,32 +337,31 @@ describe('bidmanager.js', function () { assert.equal(bid.sendStandardTargeting, false); }); - it('suppressEmptyKeys=true' , function() { + it('suppressEmptyKeys=true', function() { $$PREBID_GLOBAL$$.bidderSettings = { standard: { suppressEmptyKeys: true, adserverTargeting: [ { - key: "aKeyWithAValue", + key: 'aKeyWithAValue', val: 42 }, { - key: "aKeyWithAnEmptyValue", - val: "" + key: 'aKeyWithAnEmptyValue', + val: '' } ] } }; var expected = { - "aKeyWithAValue": 42 + 'aKeyWithAValue': 42 }; var response = bidmanager.getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected); }); - }); describe('adjustBids', () => { @@ -385,7 +371,7 @@ describe('bidmanager.js', function () { fixtures.getBidResponses()[5] ); - assert.equal(bid.cpm, .5); + assert.equal(bid.cpm, 0.5); $$PREBID_GLOBAL$$.bidderSettings = { @@ -410,12 +396,12 @@ describe('bidmanager.js', function () { // negative bid.adUnitCode = 'negative'; bidmanager.adjustBids(bid) - assert.equal(bid.cpm, .5); + assert.equal(bid.cpm, 0.5); // positive bid.adUnitCode = 'normal'; bidmanager.adjustBids(bid) - assert.equal(bid.cpm, .25); + assert.equal(bid.cpm, 0.25); // zero bid.adUnitCode = 'zero'; @@ -424,7 +410,6 @@ describe('bidmanager.js', function () { // reset bidderSettings so we don't mess up further tests $$PREBID_GLOBAL$$.bidderSettings = {}; - }); }); @@ -474,7 +459,7 @@ describe('bidmanager.js', function () { fixtures.getBidResponses()[0] ); - bid.dealId = "test deal"; + bid.dealId = 'test deal'; bidmanager.addBidResponse(bid.adUnitCode, bid); const addedBid = $$PREBID_GLOBAL$$._bidsReceived.pop(); assert.equal(addedBid.adserverTargeting[`hb_deal`], bid.dealId, 'dealId placed in adserverTargeting'); @@ -490,8 +475,8 @@ describe('bidmanager.js', function () { fixtures.getBidResponses()[3] ); - bidmanager.addBidResponse(bid1.adUnitCode, Object.assign({},bid1)); - bidmanager.addBidResponse(bid2.adUnitCode, Object.assign({},bid2)); + bidmanager.addBidResponse(bid1.adUnitCode, Object.assign({}, bid1)); + bidmanager.addBidResponse(bid2.adUnitCode, Object.assign({}, bid2)); const addedBid2 = $$PREBID_GLOBAL$$._bidsReceived.pop(); assert.equal(addedBid2.adId, bid2.adId); diff --git a/test/spec/cookie_spec.js b/test/spec/cookie_spec.js index 1cf3fa80b02..9c7dcaebf3a 100644 --- a/test/spec/cookie_spec.js +++ b/test/spec/cookie_spec.js @@ -3,7 +3,6 @@ import { expect } from 'chai'; var utils = require('../../src/utils'); describe('cookie.queueSync', () => { - let insertCookieSyncIframeStub = sinon.stub(utils, 'insertCookieSyncIframe'); let insertPixelStub = sinon.stub(utils, 'insertPixel'); @@ -13,7 +12,7 @@ describe('cookie.queueSync', () => { }); it('queues and fires a pixel URL', () => { - cookie.queueSync({'bidder' : 'testBidder', 'url': 'http://url.com'}); + cookie.queueSync({'bidder': 'testBidder', 'url': 'http://url.com'}); cookie.syncCookies(); expect(insertPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://url.com'); }); @@ -29,5 +28,4 @@ describe('cookie.queueSync', () => { expect(insertCookieSyncIframeStub.callCount).to.equal(0); expect(insertPixelStub.callCount).to.equal(0); }); - }); diff --git a/test/spec/cpmBucketManager_spec.js b/test/spec/cpmBucketManager_spec.js index 8b9d71c7c55..18ca2c38bdd 100644 --- a/test/spec/cpmBucketManager_spec.js +++ b/test/spec/cpmBucketManager_spec.js @@ -3,10 +3,9 @@ import {getPriceBucketString, isValidePriceConfig} from 'src/cpmBucketManager'; let cpmFixtures = require('test/fixtures/cpmInputsOutputs.json'); describe('cpmBucketManager', () => { - it('getPriceBucketString function generates the correct price strings', () => { let input = cpmFixtures.cpmInputs; - for(let i = 0; i < input.length; i++){ + for (let i = 0; i < input.length; i++) { let output = getPriceBucketString(input[i]); let jsonOutput = JSON.stringify(output); expect(jsonOutput).to.deep.equal(JSON.stringify(cpmFixtures.priceStringOutputs[i])); @@ -16,19 +15,19 @@ describe('cpmBucketManager', () => { it('gets the correct custom bucket strings', () => { let cpm = 16.50908; let customConfig = { - "buckets" : [{ - "precision" : 4, - "min" : 0, - "max" : 3, - "increment" : 0.01, - }, - { - "precision" : 4, - "min" : 3, - "max" : 18, - "increment" : 0.05, - "cap" : true - } + 'buckets': [{ + 'precision': 4, + 'min': 0, + 'max': 3, + 'increment': 0.01, + }, + { + 'precision': 4, + 'min': 3, + 'max': 18, + 'increment': 0.05, + 'cap': true + } ] }; let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"16.5000"}'; @@ -38,21 +37,20 @@ describe('cpmBucketManager', () => { it('checks whether custom config is valid', () => { let badConfig = { - "buckets" : [{ - "min" : 0, - "max" : 3, - "increment" : 0.01, - }, - { - //missing min prop - "max" : 18, - "increment" : 0.05, - "cap" : true - } + 'buckets': [{ + 'min': 0, + 'max': 3, + 'increment': 0.01, + }, + { + // missing min prop + 'max': 18, + 'increment': 0.05, + 'cap': true + } ] }; expect(isValidePriceConfig(badConfig)).to.be.false; }); - }); diff --git a/test/spec/e2e/common/globals.js b/test/spec/e2e/common/globals.js index 153670f15f7..3e781d5fa21 100644 --- a/test/spec/e2e/common/globals.js +++ b/test/spec/e2e/common/globals.js @@ -1,9 +1,9 @@ var HtmlReporter = require('nightwatch-html-reporter'); var reporter = new HtmlReporter({ - openBrowser: true, - reportsDirectory: __dirname + '/reports', - themeName: 'cover', + openBrowser: true, + reportsDirectory: __dirname + '/reports', + themeName: 'cover', }); module.exports = { - reporter: reporter.fn + reporter: reporter.fn }; diff --git a/test/spec/e2e/common/utils.js b/test/spec/e2e/common/utils.js index c745610f564..2c9fee68eda 100644 --- a/test/spec/e2e/common/utils.js +++ b/test/spec/e2e/common/utils.js @@ -1,10 +1,10 @@ module.exports = { - findIframeInDiv : function(divid) { + findIframeInDiv: function(divid) { var div = document.getElementById(divid); var iframes = div.getElementsByTagName('iframe'); console.log(iframes.length); try { - if(iframes.length === 1 && iframes[0].contentWindow.document.body.innerHTML === "") { + if (iframes.length === 1 && iframes[0].contentWindow.document.body.innerHTML === '') { return false; } else { return true; diff --git a/test/spec/e2e/custom-assertions/first.js b/test/spec/e2e/custom-assertions/first.js index 296dc86d352..e393e8c15a0 100644 --- a/test/spec/e2e/custom-assertions/first.js +++ b/test/spec/e2e/custom-assertions/first.js @@ -43,7 +43,7 @@ exports.assertion = function(expected, msg) { this.command = function(callback) { var _this = this; var execcallback = function(result) { - //console.log(_this); + // console.log(_this); console.log('**********'); console.log(result); console.log(callback.toString()); @@ -52,14 +52,13 @@ exports.assertion = function(expected, msg) { } }; - this.api.execute(function(){ - //cusotm logic + this.api.execute(function() { + // cusotm logic return 'hello'; }, [], execcallback); - //var result = {'value':'hello'}; + // var result = {'value':'hello'}; return this; }; - }; diff --git a/test/spec/e2e/custom-reporter/pbjs-html-reporter.js b/test/spec/e2e/custom-reporter/pbjs-html-reporter.js index b5cb55b3ecc..bcd5eab1e21 100644 --- a/test/spec/e2e/custom-reporter/pbjs-html-reporter.js +++ b/test/spec/e2e/custom-reporter/pbjs-html-reporter.js @@ -3,8 +3,7 @@ var mkpath = require('mkpath'); var path = require('path'); var ejs = require('ejs'); -module.exports = new (function() { - +module.exports = new function() { var tmpl = __dirname + '/junit.xml.ejs'; var tmplData; var globalResults; @@ -50,10 +49,10 @@ module.exports = new (function() { adaptAssertions(module); var rendered = ejs.render(data, { - module : module, - moduleName : moduleName, - systemerr : globalResults.errmessages.join('\n'), - }); + module: module, + moduleName: moduleName, + systemerr: globalResults.errmessages.join('\n'), + }); if (pathParts.length) { output_folder = path.join(output_folder, pathParts.join(path.sep)); @@ -70,9 +69,9 @@ module.exports = new (function() { function stackTraceFilter(parts) { var stack = parts.reduce(function(list, line) { if (contains(line, [ - 'node_modules', - '(node.js:', - '(events.js:' + 'node_modules', + '(node.js:', + '(events.js:' ])) { return list; } @@ -85,7 +84,7 @@ module.exports = new (function() { } function contains(str, text) { - if( Object.prototype.toString.call( text ) === '[object Array]' ) { + if (Object.prototype.toString.call(text) === '[object Array]') { for (var i = 0; i < text.length; i++) { if (contains(str, text[i])) { return true; @@ -96,7 +95,7 @@ module.exports = new (function() { } this.write = function(results, options, callback) { - options.filename_prefix = process.env.__NIGHTWATCH_ENV+'_'; + options.filename_prefix = process.env.__NIGHTWATCH_ENV + '_'; globalResults = results; var keys = Object.keys(results.modules); @@ -112,5 +111,4 @@ module.exports = new (function() { }); }); }; - -})(); +}(); diff --git a/test/spec/e2e/testcase1/dom-group/allbidders_dom_spec.js b/test/spec/e2e/testcase1/dom-group/allbidders_dom_spec.js index f4fa7e754cf..5803ad5ceb3 100644 --- a/test/spec/e2e/testcase1/dom-group/allbidders_dom_spec.js +++ b/test/spec/e2e/testcase1/dom-group/allbidders_dom_spec.js @@ -1,8 +1,8 @@ -//var verify = require('verify'); +// var verify = require('verify'); var util = require('../../common/utils.js'); module.exports = { - 'adequant ad rendering' : function (browser) { + 'adequant ad rendering': function (browser) { browser .url('http://an.localhost:9999/test/spec/e2e/gpt-examples/all_bidders_instant_load.html') .waitForElementVisible('body', 5000) @@ -11,115 +11,115 @@ module.exports = { this.verify.equal(result.value, true, 'adequant ad not rendered'); }); }, - 'adform ad rendering' : function (browser) { + 'adform ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-2'], function(result) { this.verify.equal(result.value, true, 'adform ad not rendered'); }); }, - 'aol ad rendering' : function (browser) { + 'aol ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-3'], function(result) { this.verify.equal(result.value, true, 'aol ad not rendered'); }); }, - 'appnexus ad rendering' : function (browser) { + 'appnexus ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-4'], function(result) { this.verify.equal(result.value, true, 'appnexus ad not rendered'); }); }, - 'indexExchange ad rendering' : function (browser) { + 'indexExchange ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-5'], function(result) { this.verify.equal(result.value, true, 'indexExchange ad not rendered'); }); }, - 'openx ad rendering' : function (browser) { + 'openx ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-6'], function(result) { this.verify.equal(result.value, true, 'openx ad not rendered'); }); }, - 'pubmatic ad rendering' : function (browser) { + 'pubmatic ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-7'], function(result) { this.verify.equal(result.value, true, 'pubmatic ad not rendered'); }); }, - 'pulsepoint ad rendering' : function (browser) { + 'pulsepoint ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-8'], function(result) { this.verify.equal(result.value, true, 'pulsepoint ad not rendered'); }); }, - 'rubicon ad rendering' : function (browser) { + 'rubicon ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-9'], function(result) { this.verify.equal(result.value, true, 'rubicon ad not rendered'); }); }, - 'sonobi ad rendering' : function (browser) { + 'sonobi ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-10'], function(result) { this.verify.equal(result.value, true, 'sonobi ad not rendered'); }); }, - 'sovrn ad rendering' : function (browser) { + 'sovrn ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-11'], function(result) { this.verify.equal(result.value, true, 'sovrn ad not rendered'); }); }, - 'springserve ad rendering' : function (browser) { + 'springserve ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-12'], function(result) { this.verify.equal(result.value, true, 'springserve ad not rendered'); }); }, - 'triplelift ad rendering' : function (browser) { + 'triplelift ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-13'], function(result) { this.verify.equal(result.value, true, 'triplelift ad not rendered'); }); }, - 'yieldbot ad rendering' : function (browser) { + 'yieldbot ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-14'], function(result) { this.verify.equal(result.value, true, 'yieldbot ad not rendered'); }); }, - 'nginad ad rendering' : function (browser) { + 'nginad ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-15'], function(result) { this.verify.equal(result.value, true, 'nginad ad not rendered'); }); }, - 'brightcom ad rendering' : function (browser) { + 'brightcom ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-16'], function(result) { this.verify.equal(result.value, true, 'brightcom ad not rendered'); }); }, - 'sekindo ad rendering' : function (browser) { + 'sekindo ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-17'], function(result) { this.verify.equal(result.value, true, 'sekindo ad not rendered'); }); }, - 'kruxlink ad rendering' : function (browser) { + 'kruxlink ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-18'], function(result) { this.verify.equal(result.value, true, 'kruxlink ad not rendered'); }); }, - 'AdMedia ad rendering' : function (browser) { + 'AdMedia ad rendering': function (browser) { browser .execute(util.findIframeInDiv, ['div-19'], function(result) { this.verify.equal(result.value, true, 'AdMedia ad not rendered'); }); }, - after : function(browser) { + after: function(browser) { browser.end(); } }; diff --git a/test/spec/e2e/testcase1/dom-group/dom_spec.js b/test/spec/e2e/testcase1/dom-group/dom_spec.js index 3ed5252bf26..a58030c32b7 100644 --- a/test/spec/e2e/testcase1/dom-group/dom_spec.js +++ b/test/spec/e2e/testcase1/dom-group/dom_spec.js @@ -1,14 +1,13 @@ -//var assert = require('assert'); +// var assert = require('assert'); module.exports = { - 'Test rendering ad div-2' : function (browser) { - + 'Test rendering ad div-2': function (browser) { var checkAdRendering2 = function() { var div = document.getElementById('div-2'); var iframes = div.getElementsByTagName('iframe'); try { - if(iframes.length == 1 && iframes[0].contentWindow.document.body.innerHTML == "") { + if (iframes.length == 1 && iframes[0].contentWindow.document.body.innerHTML == '') { return false; } else { return true; @@ -26,13 +25,12 @@ module.exports = { this.assert.equal(result.value, true, 'Ad of div-2 not rendered'); }); }, - 'Test rendering ad div-1' : function (browser) { - + 'Test rendering ad div-1': function (browser) { var checkAdRendering = function() { var div = document.getElementById('div-1'); var iframes = div.getElementsByTagName('iframe'); try { - if(iframes.length == 1 && iframes[0].contentWindow.document.body.innerHTML == "") { + if (iframes.length == 1 && iframes[0].contentWindow.document.body.innerHTML == '') { return false; } else { return true; @@ -47,7 +45,7 @@ module.exports = { this.assert.equal(result.value, true, 'Ad of div-1 not rendered'); }); }, - after : function(browser) { + after: function(browser) { browser.end(); } }; diff --git a/test/spec/e2e/testcase1/pbjsapi-group/adservertargeting_spec.js b/test/spec/e2e/testcase1/pbjsapi-group/adservertargeting_spec.js index 67d0306d438..796707641cd 100644 --- a/test/spec/e2e/testcase1/pbjsapi-group/adservertargeting_spec.js +++ b/test/spec/e2e/testcase1/pbjsapi-group/adservertargeting_spec.js @@ -2,31 +2,30 @@ var assert = require('assert'); var utils = require('util'); module.exports = { - 'AdserverTargeting Test Case 1' : function (browser) { + 'AdserverTargeting Test Case 1': function (browser) { browser .url('http://localhost:9999/test/spec/e2e/gpt-examples/gpt_default.html') .waitForElementVisible('body', 3000) .pause(3000) - .execute(function(){ - - if(typeof window.pbjs.bidderSettings == "undefined") { + .execute(function() { + if (typeof window.pbjs.bidderSettings === 'undefined') { var pbjsBidderSettingsObject = [ - "hb_bidder", - "hb_adid", - "hb_pb", - "hb_size" + 'hb_bidder', + 'hb_adid', + 'hb_pb', + 'hb_size' ]; } else { var pbjsBidderSettings = window.pbjs.bidderSettings; var pbjsBidderSettingsObject = {}; Object.keys(pbjsBidderSettings).forEach(function (prop) { - //if(prop == 'standard') return; + // if(prop == 'standard') return; var value = pbjsBidderSettings[prop]; - var bs = value.adserverTargeting.map(function(item){ + var bs = value.adserverTargeting.map(function(item) { return item.key; }); - pbjsBidderSettings.standard.adserverTargeting.map(function(value){ - if(bs.indexOf(value.key) == -1 ) { + pbjsBidderSettings.standard.adserverTargeting.map(function(value) { + if (bs.indexOf(value.key) == -1) { bs.push(value.key) } }); @@ -36,18 +35,18 @@ module.exports = { var adserverTargetingObject = {}; var adserverTargeting = window.pbjs.getAdserverTargeting(); - Object.keys(adserverTargeting).forEach(function(value){ - if(Object.keys(adserverTargeting[value]).length == 0) return; + Object.keys(adserverTargeting).forEach(function(value) { + if (Object.keys(adserverTargeting[value]).length == 0) return; adserverTargetingObject[adserverTargeting[value].hb_bidder] = Object.keys(adserverTargeting[value]) }); return [pbjsBidderSettingsObject, adserverTargetingObject]; }, [], function(result) { Object.keys(result.value[1]).forEach(function(key) { - if(utils.isArray(result.value[0])) { + if (utils.isArray(result.value[0])) { assert.deepEqual(result.value[0].sort(), result.value[1][key].sort()); } else { - if(result.value[0].hasOwnProperty(key)) { + if (result.value[0].hasOwnProperty(key)) { var obj1 = result.value[0][key].sort(); } else { var obj1 = result.value[0]['standard'].sort(); @@ -57,7 +56,7 @@ module.exports = { }); }); }, - after : function(browser) { + after: function(browser) { browser.end(); } }; diff --git a/test/spec/e2e/testcase1/pbjsapi-group/getbidresponses_spec.js b/test/spec/e2e/testcase1/pbjsapi-group/getbidresponses_spec.js index ed260f7f33f..c7921709c0f 100644 --- a/test/spec/e2e/testcase1/pbjsapi-group/getbidresponses_spec.js +++ b/test/spec/e2e/testcase1/pbjsapi-group/getbidresponses_spec.js @@ -1,34 +1,34 @@ -//var assert = require('assert'); +// var assert = require('assert'); var assert = require('chai').assert; var utils = require('util'); module.exports = { - 'bidReceived not empty' : function(browser) { + 'bidReceived not empty': function(browser) { browser .url('http://localhost:9999/test/spec/e2e/gpt-examples/gpt_default.html') .waitForElementVisible('body', 3000) .pause(5000) .execute(function() { - return window.pbjs._bidsReceived.length; + return window.pbjs._bidsReceived.length; }, [], function(result) { - //browser.assert.first(false, 'Bid response empty'); + // browser.assert.first(false, 'Bid response empty'); assert.isOk(result.value, 'Bid response empty'); }); }, - 'check keys' : function(browser) { + 'check keys': function(browser) { browser .execute(function() { return window.pbjs._bidsReceived; }, [], function(result) { - //minimum expected keys in bid received - var expected = ["bidderCode", "width", "height", "adId", "cpm", "requestId", "bidder", "adUnitCode", "timeToRespond"]; - Object.keys(result.value).forEach(function(key){ + // minimum expected keys in bid received + var expected = ['bidderCode', 'width', 'height', 'adId', 'cpm', 'requestId', 'bidder', 'adUnitCode', 'timeToRespond']; + Object.keys(result.value).forEach(function(key) { var compare = Object.keys(result.value[key]); assert.includeMembers(compare, expected, 'include members'); }); }); }, - after : function(browser) { + after: function(browser) { browser.end(); } }; diff --git a/test/spec/ga_spec.js b/test/spec/ga_spec.js index 65012811f54..ffbaf3a94a1 100644 --- a/test/spec/ga_spec.js +++ b/test/spec/ga_spec.js @@ -2,9 +2,7 @@ var assert = require('assert'); var ga = require('../../src/adapters/analytics/ga'); describe('Ga', function () { - describe('enableAnalytics', function () { - it('should accept a tracker name option and output prefixed send string', function () { var config = { options: { trackerName: 'foo' } }; ga.enableAnalytics(config); diff --git a/test/spec/integration/faker/fixtures.js b/test/spec/integration/faker/fixtures.js index df625a57093..643b531ad42 100644 --- a/test/spec/integration/faker/fixtures.js +++ b/test/spec/integration/faker/fixtures.js @@ -39,4 +39,4 @@ export function makeRequest(overrides = {}) { }, overrides); } -export function randomFive() { return faker.random.number({ min: 10000, max: 99999 }); } \ No newline at end of file +export function randomFive() { return faker.random.number({ min: 10000, max: 99999 }); } diff --git a/test/spec/loaders/adapterLoader_spec.js b/test/spec/loaders/adapterLoader_spec.js index b68fb692110..f5687e6f3f2 100644 --- a/test/spec/loaders/adapterLoader_spec.js +++ b/test/spec/loaders/adapterLoader_spec.js @@ -5,7 +5,7 @@ const allAdapters = require('../../fixtures/allAdapters'); const expect = require('chai').expect; require('../../../loaders/adapterLoader'); -const defaultAdapters = ["aardvark","adblade","adbutler","adequant","adform","admedia","aol","appnexus","appnexusAst","getintent","hiromedia","indexExchange","kruxlink","komoona","openx","piximedia","pubmatic","pulsepoint","rubicon","sonobi","sovrn","springserve","thoughtleadr","triplelift","twenga","yieldbot","nginad","brightcom","wideorbit","jcm","underdogmedia","memeglobal","centro","roxot",{"appnexus":{"alias":"brealtime"}},{"appnexus":{"alias":"pagescience"}},{"appnexus":{"alias":"defymedia"}},{"appnexusAst":{"supportedMediaTypes":["video"]}}]; +const defaultAdapters = ['aardvark', 'adblade', 'adbutler', 'adequant', 'adform', 'admedia', 'aol', 'appnexus', 'appnexusAst', 'getintent', 'hiromedia', 'indexExchange', 'kruxlink', 'komoona', 'openx', 'piximedia', 'pubmatic', 'pulsepoint', 'rubicon', 'sonobi', 'sovrn', 'springserve', 'thoughtleadr', 'triplelift', 'twenga', 'yieldbot', 'nginad', 'brightcom', 'wideorbit', 'jcm', 'underdogmedia', 'memeglobal', 'centro', 'roxot', {'appnexus': {'alias': 'brealtime'}}, {'appnexus': {'alias': 'pagescience'}}, {'appnexus': {'alias': 'defymedia'}}, {'appnexusAst': {'supportedMediaTypes': ['video']}}]; const input = `/** INSERT ADAPTERS - DO NOT EDIT OR REMOVE */ /** END INSERT ADAPTERS */`; @@ -13,28 +13,26 @@ const input = `/** INSERT ADAPTERS - DO NOT EDIT OR REMOVE */ describe('adapterLoader.js', () => { it('should replace with the default set of adapters', () => { const getAdapterStub = () => defaultAdapters; - const loader = proxyquire('../../../loaders/adapterLoader', {'./getAdapters' : getAdapterStub}); + const loader = proxyquire('../../../loaders/adapterLoader', {'./getAdapters': getAdapterStub}); let output = loader(input); expect(output).to.equal(allAdapters.getAllAdaptersString()); - }); it('should return custom adapter list if file exists', () => { - const customAdapter = [{customAdapterName :{srcPath: '/somepath/customAdapterName.js'}}]; + const customAdapter = [{customAdapterName: {srcPath: '/somepath/customAdapterName.js'}}]; const getAdapterStub = () => customAdapter; - const loader = proxyquire('../../../loaders/adapterLoader', {'fs': {existsSync : ()=> true }, './getAdapters' : getAdapterStub}); + const loader = proxyquire('../../../loaders/adapterLoader', {'fs': {existsSync: () => true }, './getAdapters': getAdapterStub}); let output = loader(input); const expected = 'let customAdapterName = require(\'/somepath/customAdapterName.js\');\n exports.registerBidAdapter(new customAdapterName, \'customAdapterName\');\nexports.videoAdapters = [];'; expect(output).to.equal(expected); }); it('should ignore custom adapters that that do not exist', () => { - const customAdapter = ['appnexus', {customAdapterName :{srcPath: '/somepath/customAdapterName.js'}}]; + const customAdapter = ['appnexus', {customAdapterName: {srcPath: '/somepath/customAdapterName.js'}}]; const getAdapterStub = () => customAdapter; - const loader = proxyquire('../../../loaders/adapterLoader', {'fs': {existsSync : ()=> false }, './getAdapters' : getAdapterStub}); + const loader = proxyquire('../../../loaders/adapterLoader', {'fs': {existsSync: () => false }, './getAdapters': getAdapterStub}); let output = loader(input); const expected = 'var AppnexusAdapter = require(\'./adapters/appnexus.js\');\n exports.registerBidAdapter(new AppnexusAdapter(), \'appnexus\');\nexports.videoAdapters = [];'; expect(output).to.equal(expected); }); - }); diff --git a/test/spec/loaders/getAdapters_spec.js b/test/spec/loaders/getAdapters_spec.js index 3cb6a4db74a..cd544b1acb3 100644 --- a/test/spec/loaders/getAdapters_spec.js +++ b/test/spec/loaders/getAdapters_spec.js @@ -7,7 +7,6 @@ const expect = require('chai').expect; require('../../../loaders/getAdapters'); describe('loaders/getAdapters', () => { - let defaultAdapters; let customAdapters; const defaultAdaptersFile = 'adapters.json'; @@ -23,9 +22,7 @@ describe('loaders/getAdapters', () => { }); describe('when custom adapter list is defined', () => { - describe('and exists', () => { - it('should return custom adapter list', () => { mockfs({ 'adapters.json': JSON.stringify(defaultAdapters), @@ -36,11 +33,9 @@ describe('loaders/getAdapters', () => { }); expect(getAdapters(defaultAdaptersFile, adaptersArg)).to.deep.equal(customAdapters); }); - }); describe('and does not exist', () => { - it('should return default adapter list and show warning', () => { let log; const consoleLog = console.log.bind(console); @@ -57,13 +52,10 @@ describe('loaders/getAdapters', () => { expect(log).to.match(/non-existent-adapters.json/); console.log = consoleLog; }); - }); - }); describe('when custom adapter list is not defined', () => { - it('should return default adapter list', () => { mockfs({ 'adapters.json': JSON.stringify(defaultAdapters) @@ -73,11 +65,9 @@ describe('loaders/getAdapters', () => { }); expect(getAdapters(defaultAdaptersFile, adaptersArg)).to.deep.equal(defaultAdapters); }); - }); describe('when default adapter list cannot be found', () => { - it('should return empty array', () => { mockfs({ 'adapters.json': mockfs.file({ mode: 0x000 }) @@ -87,7 +77,5 @@ describe('loaders/getAdapters', () => { }); expect(getAdapters(defaultAdaptersFile, adaptersArg)).to.deep.equal([]); }); - }); - }); diff --git a/test/spec/sizeMapping_spec.js b/test/spec/sizeMapping_spec.js index 55b3080f312..a69e0bbde4d 100644 --- a/test/spec/sizeMapping_spec.js +++ b/test/spec/sizeMapping_spec.js @@ -2,83 +2,82 @@ import { expect } from 'chai'; import * as sizeMapping from 'src/sizeMapping'; var validAdUnit = { - 'sizes': [300,250], + 'sizes': [300, 250], 'sizeMapping': [ { 'minWidth': 1024, - 'sizes': [[300,250],[728,90]] + 'sizes': [[300, 250], [728, 90]] }, { 'minWidth': 480, - 'sizes': [120,60] + 'sizes': [120, 60] }, { 'minWidth': 0, - 'sizes': [20,20] + 'sizes': [20, 20] } ] }; var invalidAdUnit = { - 'sizes': [300,250], + 'sizes': [300, 250], 'sizeMapping': {} // wrong type }; var invalidAdUnit2 = { - 'sizes': [300,250], + 'sizes': [300, 250], 'sizeMapping': [{ - foo : 'bar' //bad + foo: 'bar' // bad }] }; let mockWindow = {}; function resetMockWindow() { - mockWindow = { - document: { - body: { - clientWidth: 1024 - }, - documentElement: { - clientWidth: 1024 - } - }, - innerWidth: 1024 - }; + mockWindow = { + document: { + body: { + clientWidth: 1024 + }, + documentElement: { + clientWidth: 1024 + } + }, + innerWidth: 1024 + }; } describe('sizeMapping', function() { - beforeEach(resetMockWindow); it('mapSizes 1029 width', function() { mockWindow.innerWidth = 1029; sizeMapping.setWindow(mockWindow); let sizes = sizeMapping.mapSizes(validAdUnit); - expect(sizes).to.deep.equal([[300,250],[728,90]]); - expect(validAdUnit.sizes).to.deep.equal([300,250]); + expect(sizes).to.deep.equal([[300, 250], [728, 90]]); + expect(validAdUnit.sizes).to.deep.equal([300, 250]); }); it('mapSizes 400 width', function() { mockWindow.innerWidth = 400; sizeMapping.setWindow(mockWindow); let sizes = sizeMapping.mapSizes(validAdUnit); - expect(sizes).to.deep.equal([20,20]); - expect(validAdUnit.sizes).to.deep.equal([300,250]); + expect(sizes).to.deep.equal([20, 20]); + expect(validAdUnit.sizes).to.deep.equal([300, 250]); }); it('mapSizes - invalid adUnit - should return sizes', function() { mockWindow.innerWidth = 1029; sizeMapping.setWindow(mockWindow); let sizes = sizeMapping.mapSizes(invalidAdUnit); - expect(sizes).to.deep.equal([300,250]); - expect(invalidAdUnit.sizes).to.deep.equal([300,250]); + expect(sizes).to.deep.equal([300, 250]); + expect(invalidAdUnit.sizes).to.deep.equal([300, 250]); mockWindow.innerWidth = 400; sizeMapping.setWindow(mockWindow); sizes = sizeMapping.mapSizes(invalidAdUnit); - expect(sizes).to.deep.equal([300,250]); - expect(invalidAdUnit.sizes).to.deep.equal([300,250]); + expect(sizes).to.deep.equal([300, 250]); + expect(invalidAdUnit.sizes).to.deep.equal([300, 250]); }); it('mapSizes - should return desktop (largest) sizes if screen width not detected', function() { @@ -88,21 +87,19 @@ describe('sizeMapping', function() { sizeMapping.setWindow(mockWindow); let sizes = sizeMapping.mapSizes(validAdUnit); expect(sizes).to.deep.equal([[300, 250], [728, 90]]); - expect(validAdUnit.sizes).to.deep.equal([300,250]); + expect(validAdUnit.sizes).to.deep.equal([300, 250]); }); - it('mapSizes - should return sizes if sizemapping improperly defined ', function() { mockWindow.innerWidth = 0; mockWindow.document.body.clientWidth = 0; mockWindow.document.documentElement.clientWidth = 0; sizeMapping.setWindow(mockWindow); let sizes = sizeMapping.mapSizes(invalidAdUnit2); - expect(sizes).to.deep.equal([300,250]); - expect(validAdUnit.sizes).to.deep.equal([300,250]); + expect(sizes).to.deep.equal([300, 250]); + expect(validAdUnit.sizes).to.deep.equal([300, 250]); }); - it('getScreenWidth', function() { mockWindow.innerWidth = 900; mockWindow.document.body.clientWidth = 900; @@ -116,5 +113,4 @@ describe('sizeMapping', function() { mockWindow.document.documentElement.clientWidth = null; expect(sizeMapping.getScreenWidth(mockWindow)).to.equal(0); }); - }); diff --git a/test/spec/unit/adapters/analytics/AnalyticsAdapter_spec.js b/test/spec/unit/adapters/analytics/AnalyticsAdapter_spec.js index 4e6b862742b..2301ce177c2 100644 --- a/test/spec/unit/adapters/analytics/AnalyticsAdapter_spec.js +++ b/test/spec/unit/adapters/analytics/AnalyticsAdapter_spec.js @@ -22,159 +22,152 @@ FEATURE: Analytics Adapters API SCENARIO: A publisher enables analytics GIVEN a global object \`window['testGlobal']\` AND an \`example\` instance of \`AnalyticsAdapter\`\n`, () => { + describe(`WHEN an event occurs that is to be tracked\n`, () => { + const eventType = BID_REQUESTED; + const args = { some: 'data' }; + const adapter = new AnalyticsAdapter(config); + var spyTestGlobal = sinon.spy(window, config.global); - describe(`WHEN an event occurs that is to be tracked\n`, () => { - const eventType = BID_REQUESTED; - const args = { some: 'data' }; - const adapter = new AnalyticsAdapter(config); - var spyTestGlobal = sinon.spy(window, config.global); + adapter.track({ eventType, args }); - adapter.track({ eventType, args }); - - it(`THEN should call \`window.${config.global}\` function\n`, () => { - assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); - assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); - }); - window[config.global].restore(); - }); - - describe(`WHEN an event occurs before tracking library is available\n`, () => { - const eventType = BID_RESPONSE; - const args = { wat: 'wot' }; - const adapter = new AnalyticsAdapter(config); + it(`THEN should call \`window.${config.global}\` function\n`, () => { + assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); + assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); + }); + window[config.global].restore(); + }); - window[config.global] = null; - events.emit(BID_RESPONSE, args); + describe(`WHEN an event occurs before tracking library is available\n`, () => { + const eventType = BID_RESPONSE; + const args = { wat: 'wot' }; + const adapter = new AnalyticsAdapter(config); - describe(`AND the adapter is then enabled\n`, () => { - window[config.global] = () => {}; + window[config.global] = null; + events.emit(BID_RESPONSE, args); - var spyTestGlobal = sinon.spy(window, config.global); + describe(`AND the adapter is then enabled\n`, () => { + window[config.global] = () => {}; - adapter.enableAnalytics(); + var spyTestGlobal = sinon.spy(window, config.global); - it(`THEN should queue the event first and then track it\n`, () => { - assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); - assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); - }); + adapter.enableAnalytics(); - adapter.disableAnalytics(); - window[config.global].restore(); - }); + it(`THEN should queue the event first and then track it\n`, () => { + assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); + assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); }); - describe(`WHEN an event occurs after enable analytics\n`, () => { - - var spyTestGlobal, - adapter; - - beforeEach(() => { - adapter = new AnalyticsAdapter(config); - spyTestGlobal = sinon.spy(window, config.global); - - sinon.stub(events, "getEvents", () => []); // these tests shouldn't be affected by previous tests - }); + adapter.disableAnalytics(); + window[config.global].restore(); + }); + }); - afterEach(() => { - adapter.disableAnalytics(); - window[config.global].restore(); + describe(`WHEN an event occurs after enable analytics\n`, () => { + var spyTestGlobal, + adapter; - events.getEvents.restore(); - }); + beforeEach(() => { + adapter = new AnalyticsAdapter(config); + spyTestGlobal = sinon.spy(window, config.global); - it('SHOULD call global when a bidWon event occurs', () => { - const eventType = BID_WON; - const args = { more: 'info' }; - - adapter.enableAnalytics(); - events.emit(eventType, args); + sinon.stub(events, 'getEvents', () => []); // these tests shouldn't be affected by previous tests + }); - assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); - assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); - }); + afterEach(() => { + adapter.disableAnalytics(); + window[config.global].restore(); - it('SHOULD call global when a bidRequest event occurs', () => { - const eventType = BID_REQUESTED; - const args = { call: 'request' }; + events.getEvents.restore(); + }); - adapter.enableAnalytics(); - events.emit(eventType, args); + it('SHOULD call global when a bidWon event occurs', () => { + const eventType = BID_WON; + const args = { more: 'info' }; - assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); - assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); - }); + adapter.enableAnalytics(); + events.emit(eventType, args); - it('SHOULD call global when a bidResponse event occurs', () => { - const eventType = BID_RESPONSE; - const args = { call: 'response' }; + assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); + assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); + }); - adapter.enableAnalytics(); - events.emit(eventType, args); + it('SHOULD call global when a bidRequest event occurs', () => { + const eventType = BID_REQUESTED; + const args = { call: 'request' }; - assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); - assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); - }); + adapter.enableAnalytics(); + events.emit(eventType, args); - it('SHOULD call global when a bidTimeout event occurs', () => { - const eventType = BID_TIMEOUT; - const args = { call: 'timeout' }; + assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); + assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); + }); - adapter.enableAnalytics(); - events.emit(eventType, args); + it('SHOULD call global when a bidResponse event occurs', () => { + const eventType = BID_RESPONSE; + const args = { call: 'response' }; - assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); - assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); - }); + adapter.enableAnalytics(); + events.emit(eventType, args); - it('SHOULD NOT call global again when adapter.enableAnalytics is called with previous timeout', () => { - const eventType = BID_TIMEOUT; - const args = { call: 'timeout' }; + assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); + assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); + }); - events.emit(eventType, args); - adapter.enableAnalytics(); - events.emit(eventType, args); + it('SHOULD call global when a bidTimeout event occurs', () => { + const eventType = BID_TIMEOUT; + const args = { call: 'timeout' }; - assert(spyTestGlobal.calledOnce === true); - }); + adapter.enableAnalytics(); + events.emit(eventType, args); - describe(`AND sampling is enabled\n`, () => { - const eventType = BID_WON; - const args = { more: 'info' }; + assert.ok(spyTestGlobal.args[0][1] === eventType, `with expected event type\n`); + assert.deepEqual(spyTestGlobal.args[0][2], args, `with expected event data\n`); + }); - beforeEach(() => { - sinon.stub(Math, "random", () => .5); - }); + it('SHOULD NOT call global again when adapter.enableAnalytics is called with previous timeout', () => { + const eventType = BID_TIMEOUT; + const args = { call: 'timeout' }; - afterEach(() => { - Math.random.restore(); - }); + events.emit(eventType, args); + adapter.enableAnalytics(); + events.emit(eventType, args); - it(`THEN should enable analytics when random number is in sample range`, () => { - adapter.enableAnalytics({ - options: { - sampling: .75 - } - }); - events.emit(eventType, args); + assert(spyTestGlobal.calledOnce === true); + }); - assert(spyTestGlobal.called === true); - }); + describe(`AND sampling is enabled\n`, () => { + const eventType = BID_WON; + const args = { more: 'info' }; - it(`THEN should disable analytics when random number is outside sample range`, () => { - adapter.enableAnalytics({ - options: { - sampling: .25 - } - }); - events.emit(eventType, args); + beforeEach(() => { + sinon.stub(Math, 'random', () => 0.5); + }); - assert(spyTestGlobal.called === false); - }); + afterEach(() => { + Math.random.restore(); + }); + it(`THEN should enable analytics when random number is in sample range`, () => { + adapter.enableAnalytics({ + options: { + sampling: 0.75 + } }); + events.emit(eventType, args); - + assert(spyTestGlobal.called === true); }); + it(`THEN should disable analytics when random number is outside sample range`, () => { + adapter.enableAnalytics({ + options: { + sampling: 0.25 + } + }); + events.emit(eventType, args); + assert(spyTestGlobal.called === false); + }); }); + }); +}); diff --git a/test/spec/unit/adapters/analytics/sharethrough_analytics_spec.js b/test/spec/unit/adapters/analytics/sharethrough_analytics_spec.js index 81a46205d88..0a1ad57ce43 100644 --- a/test/spec/unit/adapters/analytics/sharethrough_analytics_spec.js +++ b/test/spec/unit/adapters/analytics/sharethrough_analytics_spec.js @@ -4,7 +4,7 @@ import { expect } from 'chai'; describe('sharethrough analytics adapter', () => { let sandbox; - beforeEach(() =>{ + beforeEach(() => { sandbox = sinon.sandbox.create(); }); @@ -13,24 +13,20 @@ describe('sharethrough analytics adapter', () => { }); describe('track', () => { - describe('when event type is bidRequested', () => { - beforeEach(() => { let eventType = 'bidRequested'; - let args = {"bidderCode" : "sharethrough", "bids":{"0" : {"placementCode" : "fake placement Code"}}}; + let args = {'bidderCode': 'sharethrough', 'bids': {'0': {'placementCode': 'fake placement Code'}}}; sharethroughAnalytics.track({eventType, args}) }); it('placementCodeSet contains a value', () => { - expect(sharethroughAnalytics.placementCodeSet["fake placement Code"] == undefined).to.equal(false) + expect(sharethroughAnalytics.placementCodeSet['fake placement Code'] == undefined).to.equal(false) }); }); - }); describe('bid won handler', () => { - let fireLoseBeaconStub; beforeEach(() => { @@ -39,61 +35,56 @@ describe('sharethrough analytics adapter', () => { describe('when bidderCode is not sharethrough and sharethrough is in bid', () => { beforeEach(() => { - sharethroughAnalytics.placementCodeSet["div-gpt-ad-1460505748561-0"] = {"adserverRequestId" : "0eca470d-fcac-48e6-845a-c86483ccaa0c"} + sharethroughAnalytics.placementCodeSet['div-gpt-ad-1460505748561-0'] = {'adserverRequestId': '0eca470d-fcac-48e6-845a-c86483ccaa0c'} var args = { - "bidderCode": "someoneelse", - "width": 600, - "height": 300, - "statusMessage": "Bid available", - "adId": "23fbe93a90c924", - "cpm": 3.984986853301525, - "adserverRequestId": "0eca470d-fcac-48e6-845a-c86483ccaa0c", - "winId": "1c404469-f7bb-4e50-b6f6-a8eaf0808999", - "pkey": "xKcxTTHyndFyVx7T8GKSzxPE", - "ad": "
", - "requestId": "dd2420bd-cdc2-4c66-8479-f3499ece73da", - "responseTimestamp": 1473983655565, - "requestTimestamp": 1473983655458, - "bidder": "sharethrough", - "adUnitCode": "div-gpt-ad-1460505748561-0", - "timeToRespond": 107, - "pbLg": "3.50", - "pbMg": "3.90", - "pbHg": "3.98", - "pbAg": "3.95", - "pbDg": "3.95", - "size": "600x300", - "adserverTargeting": { - "hb_bidder": "sharethrough", - "hb_adid": "23fbe93a90c924", - "hb_pb": "3.90", - "hb_size": "600x300" - } - }; + 'bidderCode': 'someoneelse', + 'width': 600, + 'height': 300, + 'statusMessage': 'Bid available', + 'adId': '23fbe93a90c924', + 'cpm': 3.984986853301525, + 'adserverRequestId': '0eca470d-fcac-48e6-845a-c86483ccaa0c', + 'winId': '1c404469-f7bb-4e50-b6f6-a8eaf0808999', + 'pkey': 'xKcxTTHyndFyVx7T8GKSzxPE', + 'ad': '
', + 'requestId': 'dd2420bd-cdc2-4c66-8479-f3499ece73da', + 'responseTimestamp': 1473983655565, + 'requestTimestamp': 1473983655458, + 'bidder': 'sharethrough', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'timeToRespond': 107, + 'pbLg': '3.50', + 'pbMg': '3.90', + 'pbHg': '3.98', + 'pbAg': '3.95', + 'pbDg': '3.95', + 'size': '600x300', + 'adserverTargeting': { + 'hb_bidder': 'sharethrough', + 'hb_adid': '23fbe93a90c924', + 'hb_pb': '3.90', + 'hb_size': '600x300' + } + }; sharethroughAnalytics.bidWon(args); - }); it('should fire lose beacon', () => { sinon.assert.calledOnce(fireLoseBeaconStub); }); - }); - }); describe('lose beacon is fired', () => { - beforeEach(() => { sandbox.stub(sharethroughAnalytics, 'fireBeacon'); sharethroughAnalytics.fireLoseBeacon('someoneelse', 10.0, 'arid', 'losebeacontype'); }); it('should call correct url', () => { - let winUrl = sharethroughAnalytics.fireBeacon.firstCall.args[0]; - expect(winUrl).to.contain(sharethroughAnalytics.STR_BEACON_HOST + 'winnerBidderCode=someoneelse&winnerCpm=10&arid=arid&type=losebeacontype&hbVersion=%24prebid.version%24&strVersion=0.1.0&hbSource=prebid&'); + let winUrl = sharethroughAnalytics.fireBeacon.firstCall.args[0]; + expect(winUrl).to.contain(sharethroughAnalytics.STR_BEACON_HOST + 'winnerBidderCode=someoneelse&winnerCpm=10&arid=arid&type=losebeacontype&hbVersion=%24prebid.version%24&strVersion=0.1.0&hbSource=prebid&'); }); }); - -}); \ No newline at end of file +}); diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index a2d218048dc..1e716f1bf2e 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -111,34 +111,29 @@ window.googletag = { var createTagAST = function() { var tags = {}; tags[config.adUnitCodes[0]] = { - keywords : {} + keywords: {} }; return tags; }; window.apntag = { keywords: [], - tags : createTagAST(), + tags: createTagAST(), setKeywords: function(key, params) { var self = this; - if(!self.tags.hasOwnProperty(key)) { + if (!self.tags.hasOwnProperty(key)) { return; } self.tags[key].keywords = this.tags[key].keywords || {}; - utils._each(params,function(param,id){ - if (!self.tags[key].keywords.hasOwnProperty(id)) - self.tags[key].keywords[id] = param; - else if (!utils.isArray(self.tags[key].keywords[id])) - self.tags[key].keywords[id] = [self.tags[key].keywords[id]].concat(param); - else - self.tags[key].keywords[id] = self.tags[key].keywords[id].concat(param); + utils._each(params, function(param, id) { + if (!self.tags[key].keywords.hasOwnProperty(id)) { self.tags[key].keywords[id] = param; } else if (!utils.isArray(self.tags[key].keywords[id])) { self.tags[key].keywords[id] = [self.tags[key].keywords[id]].concat(param); } else { self.tags[key].keywords[id] = self.tags[key].keywords[id].concat(param); } }); } }; describe('Unit: Prebid Module', function () { - after(function(){ + after(function() { $$PREBID_GLOBAL$$.adUnits = []; }) describe('getAdserverTargetingForAdUnitCodeStr', function () { @@ -171,7 +166,6 @@ describe('Unit: Prebid Module', function () { }); describe('getAdServerTargeting', function () { - beforeEach(() => { resetAuction(); }); @@ -216,7 +210,6 @@ describe('Unit: Prebid Module', function () { }); it("should include a losing bid's custom ad targeting key when the bid has `alwaysUseBid` set to `true`", () => { - // Let's make sure we're getting the expected losing bid. assert.equal($$PREBID_GLOBAL$$._bidsReceived[0]['bidderCode'], 'triplelift'); assert.equal($$PREBID_GLOBAL$$._bidsReceived[0]['cpm'], 0.112256); @@ -256,32 +249,31 @@ describe('Unit: Prebid Module', function () { assert.deepEqual(targeting, expected); }); - it("should not overwrite winning bids custom keys targeting key when the bid has `alwaysUseBid` set to `true`", () => { - - //mimic a bidderSetting.standard key here for each bid and alwaysUseBid true for every bid + it('should not overwrite winning bids custom keys targeting key when the bid has `alwaysUseBid` set to `true`', () => { + // mimic a bidderSetting.standard key here for each bid and alwaysUseBid true for every bid $$PREBID_GLOBAL$$._bidsReceived.forEach(bid => { bid.adserverTargeting.custom_ad_id = bid.adId; bid.alwaysUseBid = true; }); $$PREBID_GLOBAL$$.bidderSettings = { - "standard": { + 'standard': { adserverTargeting: [{ - key: "hb_bidder", + key: 'hb_bidder', val: function(bidResponse) { return bidResponse.bidderCode; } }, { - key: "custom_ad_id", + key: 'custom_ad_id', val: function(bidResponse) { return bidResponse.adId; } }, { - key: "hb_pb", + key: 'hb_pb', val: function(bidResponse) { return bidResponse.pbMg; } }, { - key: "foobar", + key: 'foobar', val: function(bidResponse) { return bidResponse.size; } @@ -306,17 +298,15 @@ describe('Unit: Prebid Module', function () { hb_pb: '10.00', hb_adid: '24bd938435ec3fc', hb_bidder: 'appnexus', - custom_ad_id:'24bd938435ec3fc' + custom_ad_id: '24bd938435ec3fc' } }; assert.deepEqual(targeting, expected); $$PREBID_GLOBAL$$.bidderSettings = {}; - }); - it("should not send standard targeting keys when the bid has `sendStandardTargeting` set to `false`", () => { - + it('should not send standard targeting keys when the bid has `sendStandardTargeting` set to `false`', () => { $$PREBID_GLOBAL$$._bidsReceived.forEach(bid => { bid.adserverTargeting.custom_ad_id = bid.adId; bid.sendStandardTargeting = false; @@ -331,15 +321,13 @@ describe('Unit: Prebid Module', function () { }, '/19968336/header-bid-tag1': { foobar: '728x90', - custom_ad_id:'24bd938435ec3fc' + custom_ad_id: '24bd938435ec3fc' } }; assert.deepEqual(targeting, expected); $$PREBID_GLOBAL$$.bidderSettings = {}; - }); - }); describe('getBidResponses', function () { @@ -426,7 +414,6 @@ describe('Unit: Prebid Module', function () { }); it('should set targeting for bids with `alwaysUseBid=true`', function () { - // Make sure we're getting the expected losing bid. assert.equal($$PREBID_GLOBAL$$._bidsReceived[0]['bidderCode'], 'triplelift'); assert.equal($$PREBID_GLOBAL$$._bidsReceived[0]['cpm'], 0.112256); @@ -540,7 +527,7 @@ describe('Unit: Prebid Module', function () { spyLogMessage = sinon.spy(utils, 'logMessage'); inIframe = true; - sinon.stub(utils, "inIframe", () => inIframe); + sinon.stub(utils, 'inIframe', () => inIframe); }); afterEach(function () { @@ -622,7 +609,6 @@ describe('Unit: Prebid Module', function () { }); describe('requestBids', () => { - var adUnitsBackup; beforeEach(() => { @@ -695,7 +681,7 @@ describe('Unit: Prebid Module', function () { var requestObj = { bidsBackHandler: function bidsBackHandlerCallback() { - var test = undefined; + var test; return test.test; } }; @@ -703,7 +689,6 @@ describe('Unit: Prebid Module', function () { expect(() => { $$PREBID_GLOBAL$$.requestBids(requestObj); }).not.to.throw(); - }); it('should call callBids function on adaptermanager', () => { @@ -788,7 +773,7 @@ describe('Unit: Prebid Module', function () { assert.deepEqual($$PREBID_GLOBAL$$._bidsReceived .filter(bid => requestObj2.adUnitCodes.includes(bid.adUnitCode)).length, 7, 'Placements' + ' for previous request have not been cleared of bids'); - assert.deepEqual($$PREBID_GLOBAL$$._adUnitCodes, ["/19968336/header-bid-tag1"], '_adUnitCodes is' + + assert.deepEqual($$PREBID_GLOBAL$$._adUnitCodes, ['/19968336/header-bid-tag1'], '_adUnitCodes is' + ' for first request'); assert.ok($$PREBID_GLOBAL$$._bidsReceived.length > 0, '_bidsReceived contains bids'); assert.deepEqual($$PREBID_GLOBAL$$.getBidResponses(), {}, 'yet getBidResponses returns' + @@ -801,135 +786,135 @@ describe('Unit: Prebid Module', function () { $$PREBID_GLOBAL$$._bidsReceived = getBidResponses(); assert.ok(spyCallBids.calledTwice, 'The second queued request should callBids when the' + ' first request has completed'); - assert.deepEqual($$PREBID_GLOBAL$$._adUnitCodes, ["/19968336/header-bid-tag-0"], '_adUnitCodes is' + + assert.deepEqual($$PREBID_GLOBAL$$._adUnitCodes, ['/19968336/header-bid-tag-0'], '_adUnitCodes is' + 'now for second request'); assert.deepEqual($$PREBID_GLOBAL$$.getBidResponses(), { - "/19968336/header-bid-tag-0": { - "bids": [ - { - "bidderCode": "brightcom", - "width": 300, - "height": 250, - "statusMessage": "Bid available", - "adId": "26e0795ab963896", - "cpm": 0.17, - "ad": "", - "responseTimestamp": 1462919239420, - "requestTimestamp": 1462919238937, - "bidder": "brightcom", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 483, - "pbLg": "0.00", - "pbMg": "0.10", - "pbHg": "0.17", - "pbAg": "0.15", - "size": "300x250", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "brightcom", - "hb_adid": "26e0795ab963896", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" - } - }, - { - "bidderCode": "brealtime", - "width": 300, - "height": 250, - "statusMessage": "Bid available", - "adId": "275bd666f5a5a5d", - "creative_id": 29681110, - "cpm": 0.5, - "adUrl": "http://lax1-ib.adnxs.com/ab?e=wqT_3QLzBKhzAgAAAwDWAAUBCMjAybkFEIPr4YfMvKLoQBjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4mo8EgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBvkgLNASFsU2NQWlFpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCdzNBMTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JHZmNvazFBejFUX1oVKCRQQV80QUVBOVFFBSw8bUFLS2dOU0NEYUFDQUxVQwUVBEwwCQh0T0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFDUWxfYXdpMtAA8KZ3ZUFuSUFRb2lvRFVnZzAu2ALoB-ACx9MB6gIfaHR0cDovL3ByZWJpZC5vcmc6OTk5OS9ncHQuaHRtbIADAIgDAZADAJgDBaADAaoDALADALgDAMADrALIAwDYAwDgAwDoAwD4AwOABACSBAQvanB0mAQAogQKMTAuMS4xMy4zN6gEi-wJsgQICAAQABgAIAC4BADABADIBADSBAsxMC4wLjg1LjIwOA..&s=975cfe6518f064683541240f0d780d93a5f973da&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html", - "responseTimestamp": 1462919239486, - "requestTimestamp": 1462919238941, - "bidder": "brealtime", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 545, - "pbLg": "0.50", - "pbMg": "0.50", - "pbHg": "0.50", - "pbAg": "0.50", - "size": "300x250", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "brealtime", - "hb_adid": "275bd666f5a5a5d", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" - } - }, - { - "bidderCode": "pubmatic", - "width": "300", - "height": "250", - "statusMessage": "Bid available", - "adId": "28f4039c636b6a7", - "adSlot": "39620189@300x250", - "cpm": 5.9396, - "ad": "\r
", - "dealId": "", - "responseTimestamp": 1462919239544, - "requestTimestamp": 1462919238922, - "bidder": "pubmatic", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 622, - "pbLg": "5.00", - "pbMg": "5.90", - "pbHg": "5.93", - "pbAg": "5.90", - "size": "300x250", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "pubmatic", - "hb_adid": "28f4039c636b6a7", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250" - } - }, - { - "bidderCode": "rubicon", - "width": 300, - "height": 600, - "statusMessage": "Bid available", - "adId": "29019e2ab586a5a", - "cpm": 2.74, - "ad": "", - "responseTimestamp": 1462919239860, - "requestTimestamp": 1462919238934, - "bidder": "rubicon", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 926, - "pbLg": "2.50", - "pbMg": "2.70", - "pbHg": "2.74", - "pbAg": "2.70", - "size": "300x600", - "requestId": 654321, - "adserverTargeting": { - "hb_bidder": "rubicon", - "hb_adid": "29019e2ab586a5a", - "hb_pb": "10.00", - "hb_size": "300x600", - "foobar": "300x600" + '/19968336/header-bid-tag-0': { + 'bids': [ + { + 'bidderCode': 'brightcom', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '26e0795ab963896', + 'cpm': 0.17, + 'ad': "", + 'responseTimestamp': 1462919239420, + 'requestTimestamp': 1462919238937, + 'bidder': 'brightcom', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 483, + 'pbLg': '0.00', + 'pbMg': '0.10', + 'pbHg': '0.17', + 'pbAg': '0.15', + 'size': '300x250', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'brightcom', + 'hb_adid': '26e0795ab963896', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' + } + }, + { + 'bidderCode': 'brealtime', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '275bd666f5a5a5d', + 'creative_id': 29681110, + 'cpm': 0.5, + 'adUrl': 'http://lax1-ib.adnxs.com/ab?e=wqT_3QLzBKhzAgAAAwDWAAUBCMjAybkFEIPr4YfMvKLoQBjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4mo8EgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBvkgLNASFsU2NQWlFpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCdzNBMTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JHZmNvazFBejFUX1oVKCRQQV80QUVBOVFFBSw8bUFLS2dOU0NEYUFDQUxVQwUVBEwwCQh0T0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFDUWxfYXdpMtAA8KZ3ZUFuSUFRb2lvRFVnZzAu2ALoB-ACx9MB6gIfaHR0cDovL3ByZWJpZC5vcmc6OTk5OS9ncHQuaHRtbIADAIgDAZADAJgDBaADAaoDALADALgDAMADrALIAwDYAwDgAwDoAwD4AwOABACSBAQvanB0mAQAogQKMTAuMS4xMy4zN6gEi-wJsgQICAAQABgAIAC4BADABADIBADSBAsxMC4wLjg1LjIwOA..&s=975cfe6518f064683541240f0d780d93a5f973da&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html', + 'responseTimestamp': 1462919239486, + 'requestTimestamp': 1462919238941, + 'bidder': 'brealtime', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 545, + 'pbLg': '0.50', + 'pbMg': '0.50', + 'pbHg': '0.50', + 'pbAg': '0.50', + 'size': '300x250', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'brealtime', + 'hb_adid': '275bd666f5a5a5d', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' + } + }, + { + 'bidderCode': 'pubmatic', + 'width': '300', + 'height': '250', + 'statusMessage': 'Bid available', + 'adId': '28f4039c636b6a7', + 'adSlot': '39620189@300x250', + 'cpm': 5.9396, + 'ad': "\r
", + 'dealId': '', + 'responseTimestamp': 1462919239544, + 'requestTimestamp': 1462919238922, + 'bidder': 'pubmatic', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 622, + 'pbLg': '5.00', + 'pbMg': '5.90', + 'pbHg': '5.93', + 'pbAg': '5.90', + 'size': '300x250', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'pubmatic', + 'hb_adid': '28f4039c636b6a7', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250' + } + }, + { + 'bidderCode': 'rubicon', + 'width': 300, + 'height': 600, + 'statusMessage': 'Bid available', + 'adId': '29019e2ab586a5a', + 'cpm': 2.74, + 'ad': '', + 'responseTimestamp': 1462919239860, + 'requestTimestamp': 1462919238934, + 'bidder': 'rubicon', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 926, + 'pbLg': '2.50', + 'pbMg': '2.70', + 'pbHg': '2.74', + 'pbAg': '2.70', + 'size': '300x600', + 'requestId': 654321, + 'adserverTargeting': { + 'hb_bidder': 'rubicon', + 'hb_adid': '29019e2ab586a5a', + 'hb_pb': '10.00', + 'hb_size': '300x600', + 'foobar': '300x600' + } + } + ] } - } - ] - } -}, 'getBidResponses returns info for current bid request'); + }, 'getBidResponses returns info for current bid request'); assert.deepEqual($$PREBID_GLOBAL$$.getAdserverTargeting(), { - "/19968336/header-bid-tag-0": { - "foobar": "300x250", - "hb_size": "300x250", - "hb_pb": "10.00", - "hb_adid": "233bcbee889d46d", - "hb_bidder": "appnexus" - } -}, 'targeting info returned for current placements'); + '/19968336/header-bid-tag-0': { + 'foobar': '300x250', + 'hb_size': '300x250', + 'hb_pb': '10.00', + 'hb_adid': '233bcbee889d46d', + 'hb_bidder': 'appnexus' + } + }, 'targeting info returned for current placements'); resetAuction(); adaptermanager.callBids.restore(); }); @@ -1084,7 +1069,7 @@ describe('Unit: Prebid Module', function () { }); }); - //describe('enableAnalytics', () => { + // describe('enableAnalytics', () => { // let logErrorSpy; // // beforeEach(() => { @@ -1130,7 +1115,7 @@ describe('Unit: Prebid Module', function () { // const returnValue = $$PREBID_GLOBAL$$.enableAnalytics(options); // assert.equal(returnValue, null, 'expected return value'); // }); - //}); + // }); describe('sendTimeoutEvent', () => { it('should emit BID_TIMEOUT for timed out bids', () => { @@ -1201,17 +1186,17 @@ describe('Unit: Prebid Module', function () { const logErrorSpy = sinon.spy(utils, 'logError'); const error = 'Invalid custom price value passed to `setPriceGranularity()`'; const badConfig = { - "buckets" : [{ - "min" : 0, - "max" : 3, - "increment" : 0.01, - }, - { - //missing min prop - "max" : 18, - "increment" : 0.05, - "cap" : true - } + 'buckets': [{ + 'min': 0, + 'max': 3, + 'increment': 0.01, + }, + { + // missing min prop + 'max': 18, + 'increment': 0.05, + 'cap': true + } ] }; @@ -1224,12 +1209,12 @@ describe('Unit: Prebid Module', function () { const setCustomPriceBucket = sinon.spy(bidmanager, 'setCustomPriceBucket'); const setPriceGranularitySpy = sinon.spy(bidmanager, 'setPriceGranularity'); const goodConfig = { - "buckets" : [{ - "min" : 0, - "max" : 3, - "increment" : 0.01, - "cap" : true - } + 'buckets': [{ + 'min': 0, + 'max': 3, + 'increment': 0.01, + 'cap': true + } ] }; @@ -1254,7 +1239,6 @@ describe('Unit: Prebid Module', function () { describe('emit event', () => { it('should call AUCTION_END only once', () => { - resetAuction(); var spyClearAuction = sinon.spy($$PREBID_GLOBAL$$, 'clearAuction'); var clock1 = sinon.useFakeTimers(); @@ -1269,56 +1253,56 @@ describe('Unit: Prebid Module', function () { assert.ok(spyClearAuction.calledOnce, true); $$PREBID_GLOBAL$$._bidsRequested = [{ - "bidderCode": "appnexus", - "requestId": "1863e370099523", - "bidderRequestId": "2946b569352ef2", - "bids": [ + 'bidderCode': 'appnexus', + 'requestId': '1863e370099523', + 'bidderRequestId': '2946b569352ef2', + 'bids': [ { - "bidder": "appnexus", - "params": { - "placementId": "4799418", - "test": "me" + 'bidder': 'appnexus', + 'params': { + 'placementId': '4799418', + 'test': 'me' }, - "placementCode": "/19968336/header-bid-tag1", - "sizes": [[728,90],[970,90]], - "bidId": "392b5a6b05d648", - "bidderRequestId": "2946b569352ef2", - "requestId": "1863e370099523", - "startTime": 1462918897462, - "status": 1 + 'placementCode': '/19968336/header-bid-tag1', + 'sizes': [[728, 90], [970, 90]], + 'bidId': '392b5a6b05d648', + 'bidderRequestId': '2946b569352ef2', + 'requestId': '1863e370099523', + 'startTime': 1462918897462, + 'status': 1 } ], - "start": 1462918897460 + 'start': 1462918897460 }]; $$PREBID_GLOBAL$$._bidsReceived = []; var bid = Object.assign({ - "bidderCode": "appnexus", - "width": 728, - "height": 90, - "statusMessage": "Bid available", - "adId": "24bd938435ec3fc", - "creative_id": 33989846, - "cpm": 0, - "adUrl": "http://lax1-ib.adnxs.com/ab?e=wqT_3QLyBKhyAgAAAwDWAAUBCMjAybkFEOOryfjI7rGNWhjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbJmhBYweAnYABokUB4mt0CgAEBigEDVVNEkgUG8ECYAdgFoAFaqAEBsAEAuAEBwAEDyAEA0AEA2AEA4AEA8AEAigI6dWYoJ2EnLCA0OTQ0NzIsIDE0NjI5MTkyNDApOwEcLHInLCAzMzk4OTg0NjYeAPBvkgLNASFwU2Y1YUFpNjBJY0VFTmJKbWhBWUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCd3lnNTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JJNTJDbGs5VjB6X1oVKCRQQV80QUVBOVFFBSw8bUFLS2dNQ0NENkFDQUxVQwUVBEwwCQh0T0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFfZ2lqYXdpMtAA8KZ3ZUFuSUFRb2lvREFnZzgu2ALoB-ACx9MB6gIfaHR0cDovL3ByZWJpZC5vcmc6OTk5OS9ncHQuaHRtbIADAIgDAZADAJgDBaADAaoDALADALgDAMADrALIAwDYAwDgAwDoAwD4AwOABACSBAQvanB0mAQAogQKMTAuMS4xMy4zN6gEi-wJsgQICAAQABgAIAC4BADABADIBADSBAsxMC4wLjgwLjI0MA..&s=1f584d32c2d7ae3ce3662cfac7ca24e710bc7fd0&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html", - "responseTimestamp": 1462919239342, - "requestTimestamp": 1462919238919, - "bidder": "appnexus", - "adUnitCode": "/19968336/header-bid-tag1", - "timeToRespond": 423, - "pbLg": "5.00", - "pbMg": "10.00", - "pbHg": "10.00", - "pbAg": "10.00", - "size": "728x90", - "alwaysUseBid": true, - "adserverTargeting": { - "hb_bidder": "appnexus", - "hb_adid": "24bd938435ec3fc", - "hb_pb": "10.00", - "hb_size": "728x90", - "foobar": "728x90" + 'bidderCode': 'appnexus', + 'width': 728, + 'height': 90, + 'statusMessage': 'Bid available', + 'adId': '24bd938435ec3fc', + 'creative_id': 33989846, + 'cpm': 0, + 'adUrl': 'http://lax1-ib.adnxs.com/ab?e=wqT_3QLyBKhyAgAAAwDWAAUBCMjAybkFEOOryfjI7rGNWhjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbJmhBYweAnYABokUB4mt0CgAEBigEDVVNEkgUG8ECYAdgFoAFaqAEBsAEAuAEBwAEDyAEA0AEA2AEA4AEA8AEAigI6dWYoJ2EnLCA0OTQ0NzIsIDE0NjI5MTkyNDApOwEcLHInLCAzMzk4OTg0NjYeAPBvkgLNASFwU2Y1YUFpNjBJY0VFTmJKbWhBWUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCd3lnNTRDb0FCcGh5SUFRcVFBUUdZQVFHZ0FRR29BUU93QVFDNUFRQUFBQUFBQU9BX3dRRQkMSEFEZ1A4a0JJNTJDbGs5VjB6X1oVKCRQQV80QUVBOVFFBSw8bUFLS2dNQ0NENkFDQUxVQwUVBEwwCQh0T0FDQU9nQ0FQZ0NBSUFEQVEuLpoCJSFfZ2lqYXdpMtAA8KZ3ZUFuSUFRb2lvREFnZzgu2ALoB-ACx9MB6gIfaHR0cDovL3ByZWJpZC5vcmc6OTk5OS9ncHQuaHRtbIADAIgDAZADAJgDBaADAaoDALADALgDAMADrALIAwDYAwDgAwDoAwD4AwOABACSBAQvanB0mAQAogQKMTAuMS4xMy4zN6gEi-wJsgQICAAQABgAIAC4BADABADIBADSBAsxMC4wLjgwLjI0MA..&s=1f584d32c2d7ae3ce3662cfac7ca24e710bc7fd0&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html', + 'responseTimestamp': 1462919239342, + 'requestTimestamp': 1462919238919, + 'bidder': 'appnexus', + 'adUnitCode': '/19968336/header-bid-tag1', + 'timeToRespond': 423, + 'pbLg': '5.00', + 'pbMg': '10.00', + 'pbHg': '10.00', + 'pbAg': '10.00', + 'size': '728x90', + 'alwaysUseBid': true, + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '24bd938435ec3fc', + 'hb_pb': '10.00', + 'hb_size': '728x90', + 'foobar': '728x90' } }, bidfactory.createBid(2)); @@ -1333,7 +1317,7 @@ describe('Unit: Prebid Module', function () { const adUnitCode = '/19968336/header-bid-tag1'; $$PREBID_GLOBAL$$.addBidResponse(adUnitCode, bid); - assert.equal(spyClearAuction.callCount,1, 'AUCTION_END event emitted more than once'); + assert.equal(spyClearAuction.callCount, 1, 'AUCTION_END event emitted more than once'); clock1.restore(); resetAuction(); @@ -1354,9 +1338,9 @@ describe('Unit: Prebid Module', function () { bids: [{ bidder: 'rubicon', params: { - accountId: "1234", - siteId: "1234", - zoneId: "1234" + accountId: '1234', + siteId: '1234', + zoneId: '1234' } }] }; @@ -1366,12 +1350,10 @@ describe('Unit: Prebid Module', function () { assert.deepEqual($$PREBID_GLOBAL$$.adUnits, adUnits); $$PREBID_GLOBAL$$.removeAdUnit('adUnit1'); assert.deepEqual($$PREBID_GLOBAL$$.adUnits, [adUnit2]); - }); }); describe('getDealTargeting', () => { - beforeEach(() => { resetAuction(); }); @@ -1383,34 +1365,34 @@ describe('Unit: Prebid Module', function () { it('should truncate deal keys', () => { $$PREBID_GLOBAL$$._bidsReceived = [ { - "bidderCode": "appnexusDummyName", - "dealId" : "1234", - "width": 300, - "height": 250, - "statusMessage": "Bid available", - "adId": "233bcbee889d46d", - "creative_id": 29681110, - "cpm": 10, - "adUrl": "http://lax1-ib.adnxs.com/ab?e=wqT_3QL8BKh8AgAAAwDWAAUBCMjAybkFEMLLiJWTu9PsVxjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4190DgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBskgLZASFmU21rZ0FpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCd0EzZ0RnQUVEaUFFRGtBRUJtQUVCb0FFQnFBRURzQUVBdVFFQUFBQUFBQURnUDhFQgkMTEFBNERfSkFRMkxMcEVUMU93XzJRFSggd1AtQUJBUFVCBSxASmdDaW9EVTJnV2dBZ0MxQWcBFgRDOQkIqERBQWdQSUFnUFFBZ1BZQWdQZ0FnRG9BZ0Q0QWdDQUF3RS6aAiUhV1FrbmI63AAcd2VBbklBUW8JXPCVVS7YAugH4ALH0wHqAh9odHRwOi8vcHJlYmlkLm9yZzo5OTk5L2dwdC5odG1sgAMAiAMBkAMAmAMFoAMBqgMAsAMAuAMAwAOsAsgDANgDAOADAOgDAPgDA4AEAJIEBC9qcHSYBACiBAoxMC4xLjEzLjM3qAQAsgQICAAQABgAIAC4BADABADIBADSBAoxMC4wLjg1Ljkx&s=1bf15e8cdc7c0c8c119614c6386ab1496560da39&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html", - "responseTimestamp": 1462919239340, - "requestTimestamp": 1462919238919, - "bidder": "appnexus", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 421, - "pbLg": "5.00", - "pbMg": "10.00", - "pbHg": "10.00", - "pbAg": "10.00", - "size": "300x250", - "alwaysUseBid": true, - "requestId": 123456, - "adserverTargeting": { - "hb_bidder": "appnexus", - "hb_adid": "233bcbee889d46d", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250", - "hb_deal_appnexusDummyName": "1234" + 'bidderCode': 'appnexusDummyName', + 'dealId': '1234', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '233bcbee889d46d', + 'creative_id': 29681110, + 'cpm': 10, + 'adUrl': 'http://lax1-ib.adnxs.com/ab?e=wqT_3QL8BKh8AgAAAwDWAAUBCMjAybkFEMLLiJWTu9PsVxjL84KE1tzG-kkgASotCQAAAQII4D8RAQcQAADgPxkJCQjwPyEJCQjgPykRCaAwuvekAji-B0C-B0gCUNbLkw5YweAnYABokUB4190DgAEBigEDVVNEkgUG8FKYAawCoAH6AagBAbABALgBAcABA8gBANABANgBAOABAPABAIoCOnVmKCdhJywgNDk0NDcyLCAxNDYyOTE5MjQwKTt1ZigncicsIDI5NjgxMTEwLDIeAPBskgLZASFmU21rZ0FpNjBJY0VFTmJMa3c0WUFDREI0Q2N3QURnQVFBUkl2Z2RRdXZla0FsZ0FZSk1IYUFCd0EzZ0RnQUVEaUFFRGtBRUJtQUVCb0FFQnFBRURzQUVBdVFFQUFBQUFBQURnUDhFQgkMTEFBNERfSkFRMkxMcEVUMU93XzJRFSggd1AtQUJBUFVCBSxASmdDaW9EVTJnV2dBZ0MxQWcBFgRDOQkIqERBQWdQSUFnUFFBZ1BZQWdQZ0FnRG9BZ0Q0QWdDQUF3RS6aAiUhV1FrbmI63AAcd2VBbklBUW8JXPCVVS7YAugH4ALH0wHqAh9odHRwOi8vcHJlYmlkLm9yZzo5OTk5L2dwdC5odG1sgAMAiAMBkAMAmAMFoAMBqgMAsAMAuAMAwAOsAsgDANgDAOADAOgDAPgDA4AEAJIEBC9qcHSYBACiBAoxMC4xLjEzLjM3qAQAsgQICAAQABgAIAC4BADABADIBADSBAoxMC4wLjg1Ljkx&s=1bf15e8cdc7c0c8c119614c6386ab1496560da39&referrer=http%3A%2F%2Fprebid.org%3A9999%2Fgpt.html', + 'responseTimestamp': 1462919239340, + 'requestTimestamp': 1462919238919, + 'bidder': 'appnexus', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 421, + 'pbLg': '5.00', + 'pbMg': '10.00', + 'pbHg': '10.00', + 'pbAg': '10.00', + 'size': '300x250', + 'alwaysUseBid': true, + 'requestId': 123456, + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '233bcbee889d46d', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250', + 'hb_deal_appnexusDummyName': '1234' } } ]; @@ -1423,68 +1405,67 @@ describe('Unit: Prebid Module', function () { }); describe('video adserverTag', () => { - var adserverTag = 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/19968336/header-bid-tag-0&impl=s&gdfp_req=1&env=vp&output=xml_vast2&unviewed_position_start=1&url=www.test.com'; var options = { - 'adserver': 'dfp', - 'code': '/19968336/header-bid-tag-0' - }; + 'adserver': 'dfp', + 'code': '/19968336/header-bid-tag-0' + }; beforeEach(() => { resetAuction(); $$PREBID_GLOBAL$$._bidsReceived = [ { - "bidderCode": "appnexusAstDummyName", - "width": 0, - "height": 0, - "statusMessage": "Bid returned empty or error response", - "adId": "233bcbee889d46d", - "requestId": 123456, - "responseTimestamp": 1462919238959, - "requestTimestamp": 1462919238910, - "cpm": 0, - "bidder": "appnexus", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 49, - "pbLg": "0.00", - "pbMg": "0.00", - "pbHg": "0.00", - "pbAg": "0.00", - "pbDg": "0.00", - "pbCg": "", - "adserverTargeting": {} + 'bidderCode': 'appnexusAstDummyName', + 'width': 0, + 'height': 0, + 'statusMessage': 'Bid returned empty or error response', + 'adId': '233bcbee889d46d', + 'requestId': 123456, + 'responseTimestamp': 1462919238959, + 'requestTimestamp': 1462919238910, + 'cpm': 0, + 'bidder': 'appnexus', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 49, + 'pbLg': '0.00', + 'pbMg': '0.00', + 'pbHg': '0.00', + 'pbAg': '0.00', + 'pbDg': '0.00', + 'pbCg': '', + 'adserverTargeting': {} }, { - "bidderCode": "appnexusAst", - "dealId" : "1234", - "width": 300, - "height": 250, - "statusMessage": "Bid available", - "adId": "233bcbee889d46d", - "creative_id": 29681110, - "cpm": 10, - "vastUrl": "http://www.simplevideoad.com/", - "descriptionUrl": "http://www.simplevideoad.com/", - "responseTimestamp": 1462919239340, - "requestTimestamp": 1462919238919, - "bidder": "appnexus", - "adUnitCode": "/19968336/header-bid-tag-0", - "timeToRespond": 421, - "pbLg": "5.00", - "pbMg": "10.00", - "pbHg": "10.00", - "pbAg": "10.00", - "size": "300x250", - "alwaysUseBid": true, - "requestId": 123456, - "adserverTargeting": { - "hb_bidder": "appnexus", - "hb_adid": "233bcbee889d46d", - "hb_pb": "10.00", - "hb_size": "300x250", - "foobar": "300x250", - "hb_deal_appnexusAst": "1234" + 'bidderCode': 'appnexusAst', + 'dealId': '1234', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '233bcbee889d46d', + 'creative_id': 29681110, + 'cpm': 10, + 'vastUrl': 'http://www.simplevideoad.com/', + 'descriptionUrl': 'http://www.simplevideoad.com/', + 'responseTimestamp': 1462919239340, + 'requestTimestamp': 1462919238919, + 'bidder': 'appnexus', + 'adUnitCode': '/19968336/header-bid-tag-0', + 'timeToRespond': 421, + 'pbLg': '5.00', + 'pbMg': '10.00', + 'pbHg': '10.00', + 'pbAg': '10.00', + 'size': '300x250', + 'alwaysUseBid': true, + 'requestId': 123456, + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '233bcbee889d46d', + 'hb_pb': '10.00', + 'hb_size': '300x250', + 'foobar': '300x250', + 'hb_deal_appnexusAst': '1234' } } ]; @@ -1497,9 +1478,9 @@ describe('Unit: Prebid Module', function () { it('should log error when adserver is not dfp', () => { var logErrorSpy = sinon.spy(utils, 'logError'); var options = { - 'adserver': 'anyother', - 'code': '/19968336/header-bid-tag-0' - }; + 'adserver': 'anyother', + 'code': '/19968336/header-bid-tag-0' + }; var masterTagUrl = $$PREBID_GLOBAL$$.buildMasterVideoTagFromAdserverTag(adserverTag, options); assert.ok(logErrorSpy.calledOnce, true); utils.logError.restore(); @@ -1600,7 +1581,7 @@ describe('Unit: Prebid Module', function () { var expectedAdserverTargeting = bids[0].adserverTargeting; var newAdserverTargeting = {}; - for(var key in expectedAdserverTargeting) { + for (var key in expectedAdserverTargeting) { var nkey = (key === 'hb_adid') ? key.toUpperCase() : key; newAdserverTargeting[nkey] = expectedAdserverTargeting[key]; } @@ -1631,11 +1612,11 @@ describe('Unit: Prebid Module', function () { it('should log error when accountId is missing', () => { const options = { - enabled : true, - bidders : ['appnexus'], - timeout : 1000, - adapter : 'prebidServer', - endpoint : 'https://prebid.adnxs.com/pbs/v1/auction' + enabled: true, + bidders: ['appnexus'], + timeout: 1000, + adapter: 'prebidServer', + endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' }; $$PREBID_GLOBAL$$.setS2SConfig(options); @@ -1644,16 +1625,15 @@ describe('Unit: Prebid Module', function () { it('should log error when bidders is missing', () => { const options = { - accountId : '1', - enabled : true, - timeout : 1000, - adapter : 's2s', - endpoint : 'https://prebid.adnxs.com/pbs/v1/auction' + accountId: '1', + enabled: true, + timeout: 1000, + adapter: 's2s', + endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' }; $$PREBID_GLOBAL$$.setS2SConfig(options); assert.ok(logErrorSpy.calledOnce, true); }); }); - }); diff --git a/test/spec/url_spec.js b/test/spec/url_spec.js index 55b7de5b04f..2b60549ef63 100644 --- a/test/spec/url_spec.js +++ b/test/spec/url_spec.js @@ -2,9 +2,7 @@ import {format, parse} from '../../src/url'; import { expect } from 'chai'; describe('helpers.url', () => { - describe('parse()', () => { - let parsed; beforeEach(() => { @@ -42,11 +40,9 @@ describe('helpers.url', () => { it('extracts the host', () => { expect(parsed).to.have.property('host', 'example.com:3000'); }); - }); describe('format()', () => { - it('formats an object in to a URL', () => { expect(format({ protocol: 'http', @@ -63,7 +59,5 @@ describe('helpers.url', () => { hostname: 'example.com' })).to.equal('http://example.com'); }); - }); - }); diff --git a/test/spec/utils_spec.js b/test/spec/utils_spec.js index faa7aaae13a..2bbdcbaf6e6 100755 --- a/test/spec/utils_spec.js +++ b/test/spec/utils_spec.js @@ -4,21 +4,19 @@ var assert = require('assert'); var utils = require('../../src/utils'); describe('Utils', function () { - var obj_string = 's', - obj_number = 1, - obj_object = {}, - obj_array = [], - obj_function = function () {}; + obj_number = 1, + obj_object = {}, + obj_array = [], + obj_function = function () {}; var type_string = 'String', - type_number = 'Number', - type_object = 'Object', - type_array = 'Array', - type_function = 'Function'; + type_number = 'Number', + type_object = 'Object', + type_array = 'Array', + type_function = 'Function'; describe('replaceTokenInString', function () { - it('should replace all given tokens in a String', function () { var tokensToReplace = { foo: 'bar', @@ -81,8 +79,8 @@ describe('Utils', function () { describe('parseQueryStringParameters', function () { it('should append query string to existing using the input obj', function () { var obj = { - a:'1', - b:'2' + a: '1', + b: '2' }; var output = utils.parseQueryStringParameters(obj); @@ -116,18 +114,18 @@ describe('Utils', function () { describe('extend', function () { it('should merge two input object', function () { var target = { - a:'1', - b:'2' + a: '1', + b: '2' }; var source = { - c:'3' + c: '3' }; var expectedResult = { - a:'1', - b:'2', - c:'3' + a: '1', + b: '2', + c: '3' }; var output = Object.assign(target, source); @@ -137,7 +135,7 @@ describe('Utils', function () { it('should merge two input object even though target object is empty', function () { var target = {}; var source = { - c:'3' + c: '3' }; var output = Object.assign(target, source); @@ -146,8 +144,8 @@ describe('Utils', function () { it('just return target object, if the source object is empty', function () { var target = { - a:'1', - b:'2' + a: '1', + b: '2' }; var source = {}; @@ -157,7 +155,6 @@ describe('Utils', function () { }); describe('parseSizesInput', function () { - it('should return query string using multi size array', function () { var sizes = [[728, 90], [970, 90]]; var output = utils.parseSizesInput(sizes); @@ -184,7 +181,6 @@ describe('Utils', function () { }); describe('parseGPTSingleSizeArray', function () { - it('should return size string with input single size array', function () { var size = [300, 250]; var output = utils.parseGPTSingleSizeArray(size); @@ -333,7 +329,6 @@ describe('Utils', function () { var output = utils.isStr(obj_function); assert.deepEqual(output, false); }); - }); describe('isArray', function () { @@ -361,7 +356,6 @@ describe('Utils', function () { var output = utils.isArray(obj_function); assert.deepEqual(output, false); }); - }); describe('isEmpty', function () { @@ -371,7 +365,7 @@ describe('Utils', function () { }); it('should return false with non-empty object', function () { - var obj = { a:'b' }; + var obj = { a: 'b' }; var output = utils.isEmpty(obj); assert.deepEqual(output, false); }); @@ -410,24 +404,24 @@ describe('Utils', function () { }); it('return value array with vaild input object', function () { - var input = { a:'A', b:'B' }; - var callback = function (v) {return v;}; + var input = { a: 'A', b: 'B' }; + var callback = function (v) { return v; }; var output = utils._map(input, callback); assert.deepEqual(output, ['A', 'B']); }); it('return value array with vaild input object_callback func changed 1', function () { - var input = { a:'A', b:'B' }; - var callback = function (v, k) {return v + k;}; + var input = { a: 'A', b: 'B' }; + var callback = function (v, k) { return v + k; }; var output = utils._map(input, callback); assert.deepEqual(output, ['Aa', 'Bb']); }); it('return value array with vaild input object_callback func changed 2', function () { - var input = { a:'A', b:'B' }; - var callback = function (v, k, o) {return o;}; + var input = { a: 'A', b: 'B' }; + var callback = function (v, k, o) { return o; }; var output = utils._map(input, callback); assert.deepEqual(output, [input, input]); @@ -522,13 +516,12 @@ describe('Utils', function () { describe('polyfill test', function () { it('should not add polyfill to array', function() { - var arr = ['hello','world']; + var arr = ['hello', 'world']; var count = 0; - for(var key in arr) { + for (var key in arr) { count++; } - assert.equal(arr.length, count, "Polyfill test fails") + assert.equal(arr.length, count, 'Polyfill test fails') }); }); - }); diff --git a/yarn.lock b/yarn.lock index a64bddaef4d..f47012ba413 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,6 @@ # yarn lockfile v1 -"JSV@>= 4.0.x": - version "4.0.2" - resolved "https://registry.yarnpkg.com/JSV/-/JSV-4.0.2.tgz#d077f6825571f82132f9dffaed587b4029feff57" - abbrev@1, abbrev@1.0.x: version "1.0.9" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" @@ -38,6 +34,10 @@ acorn@^4.0.3: version "4.0.11" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.11.tgz#edcda3bd937e7556410d42ed5860f67399c794c0" +acorn@^5.0.1: + version "5.0.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.0.3.tgz#c460df08491463f028ccb82eab3730bf01087b3d" + adm-zip@~0.4.3: version "0.4.7" resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.7.tgz#8606c2cbf1c426ce8c8ec00174447fd49b6eafc1" @@ -53,9 +53,13 @@ agent-base@2: extend "~3.0.0" semver "~5.0.1" -ajv@^4.9.1: - version "4.11.5" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.5.tgz#b6ee74657b993a01dce44b7944d56f485828d5bd" +ajv-keywords@^1.0.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" + +ajv@^4.7.0, ajv@^4.9.1: + version "4.11.8" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -91,6 +95,10 @@ ansi-escape-sequences@^3.0.0: dependencies: array-back "^1.0.3" +ansi-escapes@^1.1.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" + ansi-regex@^0.2.0, ansi-regex@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9" @@ -111,10 +119,6 @@ ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" -ansi-styles@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.0.0.tgz#cb102df1c56f5123eab8b67cd7b98027a0279178" - anymatch@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" @@ -155,13 +159,13 @@ archy@^1.0.0: resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" are-we-there-yet@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz#80e470e95a084794fe1899262c5667c6e88de1b3" + version "1.1.4" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d" dependencies: delegates "^1.0.0" - readable-stream "^2.0.0 || ^1.1.13" + readable-stream "^2.0.6" -argparse@^1.0.2, argparse@^1.0.7: +argparse@^1.0.7: version "1.0.9" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" dependencies: @@ -174,8 +178,8 @@ arr-diff@^2.0.0: arr-flatten "^1.0.1" arr-flatten@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" + version "1.0.3" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" array-back@^1.0.2, array-back@^1.0.3, array-back@^1.0.4: version "1.0.4" @@ -290,18 +294,18 @@ ast-types@0.8.12: version "0.8.12" resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.8.12.tgz#a0d90e4351bb887716c83fd637ebf818af4adfcc" -ast-types@0.9.6, ast-types@0.x.x: +ast-types@0.9.6: version "0.9.6" resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.6.tgz#102c9e9e9005d3e7e3829bf0c4fa24ee862ee9b9" +ast-types@0.x.x: + version "0.9.11" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.11.tgz#371177bb59232ff5ceaa1d09ee5cad705b1a5aa9" + async-each@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" -async@0.2.x, async@~0.2.10, async@~0.2.6, async@~0.2.9: - version "0.2.10" - resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" - async@0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/async/-/async-0.9.0.tgz#ac3613b1da9bed1b47510bb4651b8931e47146c7" @@ -315,11 +319,15 @@ async@^0.9.0, async@~0.9.0: resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" async@^2.0.1: - version "2.3.0" - resolved "https://registry.yarnpkg.com/async/-/async-2.3.0.tgz#1013d1051047dd320fe24e494d5c66ecaf6147d9" + version "2.4.0" + resolved "https://registry.yarnpkg.com/async/-/async-2.4.0.tgz#4990200f18ea5b837c2cc4f8c031a6985c385611" dependencies: lodash "^4.14.0" +async@~0.2.10, async@~0.2.6: + version "0.2.10" + resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" + async@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/async/-/async-1.0.0.tgz#f8fc04ca3a13784ade9e1641af98578cfbd647a9" @@ -344,7 +352,7 @@ aws4@^1.2.1: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" -babel-code-frame@^6.22.0: +babel-code-frame@^6.16.0, babel-code-frame@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" dependencies: @@ -400,57 +408,6 @@ babel-core@^6.24.1: slash "^1.0.0" source-map "^0.5.0" -babel-core@~5.8.3: - version "5.8.38" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-5.8.38.tgz#1fcaee79d7e61b750b00b8e54f6dfc9d0af86558" - dependencies: - babel-plugin-constant-folding "^1.0.1" - babel-plugin-dead-code-elimination "^1.0.2" - babel-plugin-eval "^1.0.1" - babel-plugin-inline-environment-variables "^1.0.1" - babel-plugin-jscript "^1.0.4" - babel-plugin-member-expression-literals "^1.0.1" - babel-plugin-property-literals "^1.0.1" - babel-plugin-proto-to-assign "^1.0.3" - babel-plugin-react-constant-elements "^1.0.3" - babel-plugin-react-display-name "^1.0.3" - babel-plugin-remove-console "^1.0.1" - babel-plugin-remove-debugger "^1.0.1" - babel-plugin-runtime "^1.0.7" - babel-plugin-undeclared-variables-check "^1.0.2" - babel-plugin-undefined-to-void "^1.1.6" - babylon "^5.8.38" - bluebird "^2.9.33" - chalk "^1.0.0" - convert-source-map "^1.1.0" - core-js "^1.0.0" - debug "^2.1.1" - detect-indent "^3.0.0" - esutils "^2.0.0" - fs-readdir-recursive "^0.1.0" - globals "^6.4.0" - home-or-tmp "^1.0.0" - is-integer "^1.0.4" - js-tokens "1.0.1" - json5 "^0.4.0" - lodash "^3.10.0" - minimatch "^2.0.3" - output-file-sync "^1.1.0" - path-exists "^1.0.0" - path-is-absolute "^1.0.0" - private "^0.1.6" - regenerator "0.8.40" - regexpu "^1.3.0" - repeating "^1.1.2" - resolve "^1.1.6" - shebang-regex "^1.0.0" - slash "^1.0.0" - source-map "^0.5.0" - source-map-support "^0.2.10" - to-fast-properties "^1.0.0" - trim-right "^1.0.0" - try-resolve "^1.0.0" - babel-generator@^6.22.0, babel-generator@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.24.1.tgz#e715f486c58ded25649d888944d52aa07c5d9497" @@ -539,13 +496,6 @@ babel-helpers@^6.22.0, babel-helpers@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-jscs@^2.0.0: - version "2.0.5" - resolved "https://registry.yarnpkg.com/babel-jscs/-/babel-jscs-2.0.5.tgz#0a347046b48145acbca56e8c8ed5f736bc54f9d0" - dependencies: - babel-core "~5.8.3" - lodash.assign "^3.2.0" - babel-loader@6.4.1: version "6.4.1" resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-6.4.1.tgz#0b34112d5b0748a8dcdbf51acf6f9bd42d50b8ca" @@ -567,60 +517,6 @@ babel-plugin-check-es2015-constants@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-constant-folding@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/babel-plugin-constant-folding/-/babel-plugin-constant-folding-1.0.1.tgz#8361d364c98e449c3692bdba51eff0844290aa8e" - -babel-plugin-dead-code-elimination@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/babel-plugin-dead-code-elimination/-/babel-plugin-dead-code-elimination-1.0.2.tgz#5f7c451274dcd7cccdbfbb3e0b85dd28121f0f65" - -babel-plugin-eval@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/babel-plugin-eval/-/babel-plugin-eval-1.0.1.tgz#a2faed25ce6be69ade4bfec263f70169195950da" - -babel-plugin-inline-environment-variables@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/babel-plugin-inline-environment-variables/-/babel-plugin-inline-environment-variables-1.0.1.tgz#1f58ce91207ad6a826a8bf645fafe68ff5fe3ffe" - -babel-plugin-jscript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/babel-plugin-jscript/-/babel-plugin-jscript-1.0.4.tgz#8f342c38276e87a47d5fa0a8bd3d5eb6ccad8fcc" - -babel-plugin-member-expression-literals@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/babel-plugin-member-expression-literals/-/babel-plugin-member-expression-literals-1.0.1.tgz#cc5edb0faa8dc927170e74d6d1c02440021624d3" - -babel-plugin-property-literals@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/babel-plugin-property-literals/-/babel-plugin-property-literals-1.0.1.tgz#0252301900192980b1c118efea48ce93aab83336" - -babel-plugin-proto-to-assign@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/babel-plugin-proto-to-assign/-/babel-plugin-proto-to-assign-1.0.4.tgz#c49e7afd02f577bc4da05ea2df002250cf7cd123" - dependencies: - lodash "^3.9.3" - -babel-plugin-react-constant-elements@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/babel-plugin-react-constant-elements/-/babel-plugin-react-constant-elements-1.0.3.tgz#946736e8378429cbc349dcff62f51c143b34e35a" - -babel-plugin-react-display-name@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/babel-plugin-react-display-name/-/babel-plugin-react-display-name-1.0.3.tgz#754fe38926e8424a4e7b15ab6ea6139dee0514fc" - -babel-plugin-remove-console@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/babel-plugin-remove-console/-/babel-plugin-remove-console-1.0.1.tgz#d8f24556c3a05005d42aaaafd27787f53ff013a7" - -babel-plugin-remove-debugger@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/babel-plugin-remove-debugger/-/babel-plugin-remove-debugger-1.0.1.tgz#fd2ea3cd61a428ad1f3b9c89882ff4293e8c14c7" - -babel-plugin-runtime@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/babel-plugin-runtime/-/babel-plugin-runtime-1.0.7.tgz#bf7c7d966dd56ecd5c17fa1cb253c9acb7e54aaf" - babel-plugin-transform-es2015-arrow-functions@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" @@ -820,16 +716,6 @@ babel-plugin-transform-strict-mode@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-plugin-undeclared-variables-check@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/babel-plugin-undeclared-variables-check/-/babel-plugin-undeclared-variables-check-1.0.2.tgz#5cf1aa539d813ff64e99641290af620965f65dee" - dependencies: - leven "^1.0.2" - -babel-plugin-undefined-to-void@^1.1.6: - version "1.1.6" - resolved "https://registry.yarnpkg.com/babel-plugin-undefined-to-void/-/babel-plugin-undefined-to-void-1.1.6.tgz#7f578ef8b78dfae6003385d8417a61eda06e2f81" - babel-polyfill@^6.13.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d" @@ -919,13 +805,9 @@ babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.24.1: lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon@^5.8.38: - version "5.8.38" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-5.8.38.tgz#ec9b120b11bf6ccd4173a18bf217e60b79859ffd" - babylon@^6.11.0, babylon@^6.15.0: - version "6.16.1" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" + version "6.17.1" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.1.tgz#17f14fddf361b695981fe679385e4f1c01ebd86f" backo2@1.0.2: version "1.0.2" @@ -969,7 +851,7 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" -beeper@^1.0.0, beeper@^1.1.0: +beeper@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809" @@ -1024,7 +906,7 @@ block-stream@*: dependencies: inherits "~2.0.0" -bluebird@^2.9.27, bluebird@^2.9.30, bluebird@^2.9.33: +bluebird@^2.9.27, bluebird@^2.9.30: version "2.11.0" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" @@ -1089,7 +971,7 @@ boom@2.x.x: dependencies: hoek "2.x.x" -brace-expansion@^1.0.0: +brace-expansion@^1.0.0, brace-expansion@^1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59" dependencies: @@ -1162,7 +1044,13 @@ buffers@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb" -builtin-modules@^1.0.0: +bufferstreams@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/bufferstreams/-/bufferstreams-1.1.1.tgz#0161373060ac5988eff99058731114f6e195d51e" + dependencies: + readable-stream "^2.0.2" + +builtin-modules@^1.0.0, builtin-modules@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -1192,10 +1080,20 @@ cache-point@~0.3.3: fs-then-native "^1.0.2" mkdirp "~0.5.1" +caller-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" + dependencies: + callsites "^0.2.0" + callsite@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" +callsites@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" + camelcase-keys@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" @@ -1275,7 +1173,7 @@ chalk@^0.5.0: strip-ansi "^0.3.0" supports-color "^0.2.0" -chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@~1.1.0: +chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -1285,17 +1183,9 @@ chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@~1.1.0: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@~0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.4.0.tgz#5199a3ddcd0c1efe23bc08c1b027b06176e0c64f" - dependencies: - ansi-styles "~1.0.0" - has-color "~0.1.0" - strip-ansi "~0.1.0" - chokidar@^1.0.0, chokidar@^1.4.1: - version "1.6.1" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2" + version "1.7.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" dependencies: anymatch "^1.3.0" async-each "^1.0.0" @@ -1308,6 +1198,10 @@ chokidar@^1.0.0, chokidar@^1.4.1: optionalDependencies: fsevents "^1.0.0" +circular-json@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d" + cli-commands@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/cli-commands/-/cli-commands-0.1.0.tgz#c57cacc406bbcf9ee21646607161ed432ef5a05a" @@ -1317,22 +1211,19 @@ cli-commands@0.1.0: command-line-commands "^1.0.4" command-line-usage "^3.0.5" -cli-table@~0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23" +cli-cursor@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" dependencies: - colors "1.0.3" + restore-cursor "^1.0.1" cli-width@^1.0.1: version "1.1.1" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-1.1.1.tgz#a4d293ef67ebb7b88d4a4d42c0ccf00c4d1e366d" -cli@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/cli/-/cli-1.0.1.tgz#22817534f24bfa4950c34d532d48ecbc621b8c14" - dependencies: - exit "0.1.2" - glob "^7.1.1" +cli-width@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.1.0.tgz#b234ca209b29ef66fc518d9b98d5847b00edf00a" cliui@^2.1.0: version "2.1.0" @@ -1419,14 +1310,6 @@ collect-json@^1.0.1, collect-json@^1.0.7, collect-json@^1.0.8: stream-connect "^1.0.2" stream-via "^1.0.3" -colors@0.6.x: - version "0.6.2" - resolved "https://registry.yarnpkg.com/colors/-/colors-0.6.2.tgz#2423fe6678ac0c5dae8852e5d0e5be08c997abcc" - -colors@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" - colors@^1.1.0: version "1.1.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" @@ -1532,18 +1415,12 @@ commander@2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.3.0.tgz#fd430e889832ec353b9acd1de217c11cb3eef873" -commander@2.9.0, commander@^2.5.0, commander@^2.8.1, commander@^2.9.0, commander@~2.9.0: +commander@2.9.0, commander@^2.5.0, commander@^2.8.1, commander@^2.9.0: version "2.9.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" dependencies: graceful-readlink ">= 1.0.0" -comment-parser@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-0.3.1.tgz#fd657aac8c1492d308c9a6100fc9b49d2435aba1" - dependencies: - readable-stream "^2.0.4" - common-sequence@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/common-sequence/-/common-sequence-1.0.2.tgz#30e07f3f8f6f7f9b3dee854f20b2d39eee086de8" @@ -1620,7 +1497,7 @@ concat-stream@1.5.0: readable-stream "~2.0.0" typedarray "~0.0.5" -concat-stream@^1.4.7, concat-stream@^1.5.1: +concat-stream@^1.4.7, concat-stream@^1.5.1, concat-stream@^1.5.2: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: @@ -1692,15 +1569,15 @@ connect@^2.30.0: vhost "~3.0.1" connect@^3.3.5: - version "3.6.0" - resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.0.tgz#f09a4f7dcd17324b663b725c815bdb1c4158a46e" + version "3.6.1" + resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.1.tgz#b7760693a74f0454face1d9378edb3f885b43227" dependencies: - debug "2.6.1" - finalhandler "1.0.0" + debug "2.6.3" + finalhandler "1.0.1" parseurl "~1.3.1" utils-merge "1.0.0" -console-browserify@1.1.x, console-browserify@^1.1.0: +console-browserify@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" dependencies: @@ -1714,6 +1591,10 @@ constants-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" +contains-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" + content-type@~1.0.1, content-type@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.2.tgz#b7d113aee7a8dd27bd21133c4dc2529df1721eed" @@ -1741,10 +1622,6 @@ cookie@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" -core-js@^1.0.0: - version "1.2.7" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" - core-js@^2.0.1, core-js@^2.1.0, core-js@^2.4.0, core-js@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" @@ -1754,8 +1631,8 @@ core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" coveralls@^2.11.11: - version "2.13.0" - resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-2.13.0.tgz#df933876e8c6f478efb04f4d3ab70dc96b7e5a8e" + version "2.13.1" + resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-2.13.1.tgz#d70bb9acc1835ec4f063ff9dac5423c17b11f178" dependencies: js-yaml "3.6.1" lcov-parse "0.0.10" @@ -1857,17 +1734,13 @@ custom-event@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" -cycle@1.0.x: - version "1.0.3" - resolved "https://registry.yarnpkg.com/cycle/-/cycle-1.0.3.tgz#21e80b2be8580f98b468f379430662b046c34ad2" - d@1: version "1.0.0" resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" dependencies: es5-ext "^0.10.9" -dargs@christian-bromann/dargs: +"dargs@github:christian-bromann/dargs": version "4.0.1" resolved "https://codeload.github.com/christian-bromann/dargs/tar.gz/7d6d4164a7c4106dbd14ef39ed8d95b7b5e9b770" dependencies: @@ -1915,11 +1788,11 @@ debug@0.7.4: version "0.7.4" resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39" -debug@2, debug@2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351" +debug@2, debug@^2.1.1, debug@^2.2.0: + version "2.6.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.6.tgz#a9fa6fbe9ca43cf1e79f73b75c0189cbb7d6db5a" dependencies: - ms "0.7.2" + ms "0.7.3" debug@2.0.0: version "2.0.0" @@ -1927,7 +1800,7 @@ debug@2.0.0: dependencies: ms "0.6.2" -debug@2.2.0, debug@^2.1.1, debug@^2.2.0, debug@~2.2.0: +debug@2.2.0, debug@~2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" dependencies: @@ -1939,6 +1812,12 @@ debug@2.3.3: dependencies: ms "0.7.2" +debug@2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351" + dependencies: + ms "0.7.2" + debug@2.6.3: version "2.6.3" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d" @@ -1955,15 +1834,11 @@ deep-eql@0.1.3, deep-eql@^0.1.3: dependencies: type-detect "0.1.1" -deep-equal@*: - version "1.0.1" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" - deep-extend@~0.4.0, deep-extend@~0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" + version "0.4.2" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" -deep-is@~0.1.2: +deep-is@~0.1.2, deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -2008,7 +1883,7 @@ degenerator@~1.0.0: escodegen "1.x.x" esprima "3.x.x" -del@^2.2.0: +del@^2.0.2, del@^2.2.0: version "2.2.2" resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" dependencies: @@ -2054,14 +1929,6 @@ detect-file@^0.1.0: dependencies: fs-exists-sync "^0.1.0" -detect-indent@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-3.0.1.tgz#9dc5e5ddbceef8325764b9451b02bc6d54084f75" - dependencies: - get-stdin "^4.0.1" - minimist "^1.1.0" - repeating "^1.1.0" - detect-indent@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" @@ -2108,6 +1975,20 @@ dmd@^1.4.1: string-tools "^1.0.0" walk-back "^2.0.1" +doctrine@1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" + dependencies: + esutils "^2.0.2" + isarray "^1.0.0" + +doctrine@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63" + dependencies: + esutils "^2.0.2" + isarray "^1.0.0" + dom-serialize@^2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" @@ -2117,38 +1998,10 @@ dom-serialize@^2.2.0: extend "^3.0.0" void-elements "^2.0.0" -dom-serializer@0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82" - dependencies: - domelementtype "~1.1.1" - entities "~1.1.1" - domain-browser@^1.1.1: version "1.1.7" resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" -domelementtype@1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" - -domelementtype@~1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" - -domhandler@2.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.3.0.tgz#2de59a0822d5027fabff6f032c2b25a2a8abe738" - dependencies: - domelementtype "1" - -domutils@1.5: - version "1.5.1" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf" - dependencies: - dom-serializer "0" - domelementtype "1" - duplexer2@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" @@ -2197,9 +2050,9 @@ end-of-stream@~0.1.5: dependencies: once "~1.3.0" -engine.io-client@1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-1.8.3.tgz#1798ed93451246453d4c6f635d7a201fe940d5ab" +engine.io-client@~1.8.4: + version "1.8.4" + resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-1.8.4.tgz#9fe85dee25853ca6babe25bd2ad68710863e91c2" dependencies: component-emitter "1.2.1" component-inherit "0.0.3" @@ -2225,16 +2078,16 @@ engine.io-parser@1.3.2: has-binary "0.1.7" wtf-8 "1.0.0" -engine.io@1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-1.8.3.tgz#8de7f97895d20d39b85f88eeee777b2bd42b13d4" +engine.io@~1.8.4: + version "1.8.4" + resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-1.8.4.tgz#77bce12b80e5d60429337fec3b0daf691ebc9003" dependencies: accepts "1.3.3" base64id "1.0.0" cookie "0.3.1" debug "2.3.3" engine.io-parser "1.3.2" - ws "1.1.2" + ws "1.1.4" enhanced-resolve@~0.9.0: version "0.9.1" @@ -2248,14 +2101,6 @@ ent@~2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" -entities@1.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-1.0.0.tgz#b2987aa3821347fcde642b24fdfc9e4fb712bf26" - -entities@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" - errno@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.4.tgz#b896e23a9e5e8ba33871fc996abd3635fc9a1c7d" @@ -2276,8 +2121,8 @@ errorhandler@~1.4.2: escape-html "~1.0.3" es5-ext@^0.10.14, es5-ext@^0.10.9, es5-ext@~0.10.14: - version "0.10.15" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.15.tgz#c330a5934c1ee21284a7c081a86e5fd937c91ea6" + version "0.10.18" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.18.tgz#dc239d3dce4c22b9c939aa180878837a3c0b5c92" dependencies: es6-iterator "2" es6-symbol "~3.1" @@ -2339,11 +2184,11 @@ escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" -escape-string-regexp@1.0.2, escape-string-regexp@^1.0.2: +escape-string-regexp@1.0.2, escape-string-regexp@^1.0.0, escape-string-regexp@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz#4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1" -escape-string-regexp@1.0.5, escape-string-regexp@^1.0.0, escape-string-regexp@^1.0.5, escape-string-regexp@~1.0.5: +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5, escape-string-regexp@~1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -2358,7 +2203,7 @@ escodegen@1.7.x, escodegen@1.x.x: optionalDependencies: source-map "~0.2.0" -escope@^3.2.0: +escope@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/escope/-/escope-3.6.0.tgz#e01975e812781a163a6dadfdd80398dc64c889c3" dependencies: @@ -2367,6 +2212,105 @@ escope@^3.2.0: esrecurse "^4.1.0" estraverse "^4.1.1" +eslint-config-standard@^10.2.0: + version "10.2.1" + resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-10.2.1.tgz#c061e4d066f379dc17cd562c64e819b4dd454591" + +eslint-import-resolver-node@^0.2.0: + version "0.2.3" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.2.3.tgz#5add8106e8c928db2cba232bcd9efa846e3da16c" + dependencies: + debug "^2.2.0" + object-assign "^4.0.1" + resolve "^1.1.6" + +eslint-module-utils@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.0.0.tgz#a6f8c21d901358759cdc35dbac1982ae1ee58bce" + dependencies: + debug "2.2.0" + pkg-dir "^1.0.0" + +eslint-plugin-import@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.2.0.tgz#72ba306fad305d67c4816348a4699a4229ac8b4e" + dependencies: + builtin-modules "^1.1.1" + contains-path "^0.1.0" + debug "^2.2.0" + doctrine "1.5.0" + eslint-import-resolver-node "^0.2.0" + eslint-module-utils "^2.0.0" + has "^1.0.1" + lodash.cond "^4.3.0" + minimatch "^3.0.3" + pkg-up "^1.0.0" + +eslint-plugin-node@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-4.2.2.tgz#82959ca9aed79fcbd28bb1b188d05cac04fb3363" + dependencies: + ignore "^3.0.11" + minimatch "^3.0.2" + object-assign "^4.0.1" + resolve "^1.1.7" + semver "5.3.0" + +eslint-plugin-promise@^3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.5.0.tgz#78fbb6ffe047201627569e85a6c5373af2a68fca" + +eslint-plugin-standard@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz#34d0c915b45edc6f010393c7eef3823b08565cf2" + +eslint@^3.0.0: + version "3.19.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc" + dependencies: + babel-code-frame "^6.16.0" + chalk "^1.1.3" + concat-stream "^1.5.2" + debug "^2.1.1" + doctrine "^2.0.0" + escope "^3.6.0" + espree "^3.4.0" + esquery "^1.0.0" + estraverse "^4.2.0" + esutils "^2.0.2" + file-entry-cache "^2.0.0" + glob "^7.0.3" + globals "^9.14.0" + ignore "^3.2.0" + imurmurhash "^0.1.4" + inquirer "^0.12.0" + is-my-json-valid "^2.10.0" + is-resolvable "^1.0.0" + js-yaml "^3.5.1" + json-stable-stringify "^1.0.0" + levn "^0.3.0" + lodash "^4.0.0" + mkdirp "^0.5.0" + natural-compare "^1.4.0" + optionator "^0.8.2" + path-is-inside "^1.0.1" + pluralize "^1.2.1" + progress "^1.1.8" + require-uncached "^1.0.2" + shelljs "^0.7.5" + strip-bom "^3.0.0" + strip-json-comments "~2.0.1" + table "^3.7.8" + text-table "~0.2.0" + user-home "^2.0.0" + +espree@^3.4.0: + version "3.4.3" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.3.tgz#2910b5ccd49ce893c2ffffaab4fd8b3a31b82374" + dependencies: + acorn "^5.0.1" + acorn-jsx "^3.0.0" + espree@~3.1.7: version "3.1.7" resolved "https://registry.yarnpkg.com/espree/-/espree-3.1.7.tgz#fd5deec76a97a5120a9cd3a7cb1177a0923b11d2" @@ -2390,10 +2334,16 @@ esprima@3.x.x, esprima@~3.1.0: version "3.1.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" -esprima@^2.6.0, esprima@~2.7.0: +esprima@^2.6.0: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" +esquery@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.0.tgz#cfba8b57d7fba93f17298a8a006a04cda13d80fa" + dependencies: + estraverse "^4.0.0" + esrecurse@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.1.0.tgz#4713b6536adf7f2ac4f327d559e7756bff648220" @@ -2405,7 +2355,7 @@ estraverse@^1.9.1: version "1.9.3" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" -estraverse@^4.1.0, estraverse@^4.1.1: +estraverse@^4.0.0, estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" @@ -2421,7 +2371,7 @@ estree-walker@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.3.1.tgz#e6b1a51cf7292524e7237c312e5fe6660c1ce1aa" -esutils@^2.0.0, esutils@^2.0.2: +esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" @@ -2468,9 +2418,9 @@ events@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" -exit@0.1.2, exit@0.1.x, exit@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" +exit-hook@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" expand-braces@^0.1.1: version "0.1.2" @@ -2524,8 +2474,8 @@ express-session@~1.11.3: utils-merge "1.0.0" extend@3, extend@^3.0.0, extend@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" + version "3.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" extglob@^0.3.1: version "0.3.2" @@ -2546,10 +2496,6 @@ extsprintf@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" -eyes@0.1.x: - version "0.1.8" - resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" - faker@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/faker/-/faker-3.1.0.tgz#0f908faf4e6ec02524e54a57e432c5c013e08c9f" @@ -2565,6 +2511,10 @@ fast-levenshtein@~1.0.0: version "1.0.7" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-1.0.7.tgz#0178dcdee023b92905193af0959e8a7639cfdcb9" +fast-levenshtein@~2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + faye-websocket@~0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4" @@ -2590,6 +2540,13 @@ figures@^1.3.5: escape-string-regexp "^1.0.5" object-assign "^4.1.0" +file-entry-cache@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" + dependencies: + flat-cache "^1.2.1" + object-assign "^4.0.1" + file-loader@^0.8.1: version "0.8.5" resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-0.8.5.tgz#9275d031fe780f27d47f5f4af02bd43713cc151b" @@ -2615,8 +2572,8 @@ file-uri-to-path@0: resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-0.0.2.tgz#37cdd1b5b905404b3f05e1b23645be694ff70f82" filename-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" + version "2.0.1" + resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" fileset@0.1.x: version "0.1.8" @@ -2664,11 +2621,11 @@ finalhandler@0.4.0: on-finished "~2.3.0" unpipe "~1.0.0" -finalhandler@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.0.0.tgz#b5691c2c0912092f18ac23e9416bde5cd7dc6755" +finalhandler@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.0.1.tgz#bcd15d1689c0e5ed729b6f7f541a6df984117db8" dependencies: - debug "2.6.1" + debug "2.6.3" encodeurl "~1.0.1" escape-html "~1.0.3" on-finished "~2.3.0" @@ -2731,6 +2688,15 @@ flagged-respawn@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-0.3.2.tgz#ff191eddcd7088a675b2610fffc976be9b8074b5" +flat-cache@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96" + dependencies: + circular-json "^0.3.1" + del "^2.0.2" + graceful-fs "^4.1.2" + write "^0.2.1" + for-in@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" @@ -2778,8 +2744,8 @@ form-data@~1.0.0-rc3: mime-types "^2.1.11" form-data@~2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4" + version "2.1.4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" dependencies: asynckit "^0.4.0" combined-stream "^1.0.5" @@ -2828,10 +2794,6 @@ fs-extra@~0.6.1: ncp "~0.4.2" rimraf "~2.2.0" -fs-readdir-recursive@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-0.1.2.tgz#315b4fb8c1ca5b8c47defef319d073dad3568059" - fs-then-native@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/fs-then-native/-/fs-then-native-1.0.2.tgz#ac8d3807c9f1bbd1279607fb228e0ab649bb41fe" @@ -2890,9 +2852,13 @@ ftp@~0.3.5: readable-stream "1.1.x" xregexp "2.0.0" -gauge@~2.7.1: - version "2.7.3" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.3.tgz#1c23855f962f17b3ad3d0dc7443f304542edfe09" +function-bind@^1.0.2: + version "1.1.0" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771" + +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" dependencies: aproba "^1.0.3" console-control-strings "^1.0.0" @@ -2939,8 +2905,8 @@ get-uri@1: readable-stream "2" getpass@^0.1.1: - version "0.1.6" - resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" dependencies: assert-plus "^1.0.0" @@ -2995,7 +2961,7 @@ glob@3.2.3: inherits "2" minimatch "~0.2.11" -glob@5.x, glob@^5.0.1, glob@^5.0.10, glob@^5.0.15: +glob@5.x, glob@^5.0.10, glob@^5.0.15: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" dependencies: @@ -3025,7 +2991,7 @@ glob@^4, glob@^4.3.1: minimatch "^2.0.1" once "^1.3.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.0, glob@^7.1.1: +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.0: version "7.1.1" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" dependencies: @@ -3069,11 +3035,7 @@ global-prefix@^0.1.4: is-windows "^0.2.0" which "^1.2.12" -globals@^6.4.0: - version "6.4.1" - resolved "https://registry.yarnpkg.com/globals/-/globals-6.4.1.tgz#8498032b3b6d1cc81eebc5f79690d8fe29fabf4f" - -globals@^9.0.0: +globals@^9.0.0, globals@^9.14.0: version "9.17.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.17.0.tgz#0c0ca696d9b9bb694d2e5470bd37777caad50286" @@ -3108,7 +3070,7 @@ graceful-fs@^3.0.0, graceful-fs@~3.0.2: dependencies: natives "^1.1.0" -graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6, graceful-fs@^4.1.9: +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -3143,7 +3105,7 @@ gulp-babel@^6.1.2: through2 "^2.0.0" vinyl-sourcemaps-apply "^0.2.0" -gulp-clean@^0.3.1: +gulp-clean@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/gulp-clean/-/gulp-clean-0.3.2.tgz#a347d473acea40182f935587a451941671928102" dependencies: @@ -3169,6 +3131,14 @@ gulp-connect@^2.0.6: gulp-util "^3.0.6" tiny-lr "^0.2.1" +gulp-eslint@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/gulp-eslint/-/gulp-eslint-3.0.1.tgz#04e57e3e18c6974267c12cf6855dc717d4a313bd" + dependencies: + bufferstreams "^1.1.1" + eslint "^3.0.0" + gulp-util "^3.0.6" + gulp-header@^1.7.1: version "1.8.8" resolved "https://registry.yarnpkg.com/gulp-header/-/gulp-header-1.8.8.tgz#4509c64677aab56b5ee8e4669a79b1655933a49e" @@ -3178,15 +3148,6 @@ gulp-header@^1.7.1: object-assign "*" through2 "^2.0.0" -gulp-jscs@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/gulp-jscs/-/gulp-jscs-3.0.2.tgz#dc7fbb01ce2bfc8325bba7cbbf95d65e43530478" - dependencies: - gulp-util "^3.0.4" - jscs "^2.1.1" - through2 "^2.0.0" - tildify "^1.0.0" - gulp-jsdoc-to-markdown@^1.2.1: version "1.2.2" resolved "https://registry.yarnpkg.com/gulp-jsdoc-to-markdown/-/gulp-jsdoc-to-markdown-1.2.2.tgz#bd0e267e3972bc169e7bdb992f967823b023fefd" @@ -3195,17 +3156,6 @@ gulp-jsdoc-to-markdown@^1.2.1: jsdoc-to-markdown "^1.3.4" through2 "^2.0.1" -gulp-jshint@^1.8.4: - version "1.12.0" - resolved "https://registry.yarnpkg.com/gulp-jshint/-/gulp-jshint-1.12.0.tgz#23fbd1bafdd6fbfe61ea64667a74809a961d03de" - dependencies: - gulp-util "^3.0.0" - jshint "^2.7.0" - lodash "^3.0.1" - minimatch "^2.0.1" - rcloader "0.1.2" - through2 "~0.6.1" - gulp-karma@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/gulp-karma/-/gulp-karma-0.0.4.tgz#65cc202483f25369966ed60ff5dba1f6476131bd" @@ -3382,8 +3332,8 @@ handlebars@^3.0.0, handlebars@^3.0.3: uglify-js "~2.3" handlebars@^4.0.1: - version "4.0.6" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.6.tgz#2ce4484850537f9c97a8026d5399b935c4ed4ed7" + version "4.0.8" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.8.tgz#22b875cd3f0e6cbea30314f144e82bc7a72ff420" dependencies: async "^1.4.0" optimist "^0.6.1" @@ -3438,10 +3388,6 @@ has-binary@0.1.7: dependencies: isarray "0.0.1" -has-color@~0.1.0: - version "0.1.7" - resolved "https://registry.yarnpkg.com/has-color/-/has-color-0.1.7.tgz#67144a5260c34fc3cca677d041daf52fe7b78b2f" - has-cors@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39" @@ -3460,6 +3406,12 @@ has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" +has@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" + dependencies: + function-bind "^1.0.2" + hasha@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1" @@ -3502,13 +3454,6 @@ hoek@2.x.x: version "2.16.3" resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" -home-or-tmp@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-1.0.0.tgz#4b9f1e40800c3e50c6c27f781676afcce71f3985" - dependencies: - os-tmpdir "^1.0.1" - user-home "^1.1.1" - home-or-tmp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" @@ -3527,18 +3472,8 @@ homedir-polyfill@^1.0.0: parse-passwd "^1.0.0" hosted-git-info@^2.1.4: - version "2.4.1" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.4.1.tgz#4b0445e41c004a8bd1337773a4ff790ca40318c8" - -htmlparser2@3.8.3, htmlparser2@3.8.x: - version "3.8.3" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.8.3.tgz#996c28b191516a8be86501a7d79757e5c70c1068" - dependencies: - domelementtype "1" - domhandler "2.3" - domutils "1.5" - entities "1.0" - readable-stream "1.1" + version "2.4.2" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.4.2.tgz#0076b9f46a270506ddbaaea56496897460612a67" http-errors@~1.3.1: version "1.3.1" @@ -3599,10 +3534,6 @@ https-proxy-agent@1, https-proxy-agent@1.0.0: debug "2" extend "3" -i@0.3.x: - version "0.3.5" - resolved "https://registry.yarnpkg.com/i/-/i-0.3.5.tgz#1d2b854158ec8169113c6cb7f6b6801e99e211d5" - ibrik@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ibrik/-/ibrik-2.0.0.tgz#89a2434f2a5c82b92166c3d97de3b5636eea2e9c" @@ -3633,6 +3564,14 @@ ieee754@^1.1.4: version "1.1.8" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" +ignore@^3.0.11, ignore@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.0.tgz#3812d22cbe9125f2c2b4915755a1b8abd745a001" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + indent-string@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" @@ -3650,10 +3589,6 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherit@^2.2.2: - version "2.2.6" - resolved "https://registry.yarnpkg.com/inherit/-/inherit-2.2.6.tgz#f1614b06c8544e8128e4229c86347db73ad9788d" - inherits@1: version "1.0.2" resolved "https://registry.yarnpkg.com/inherits/-/inherits-1.0.2.tgz#ca4309dadee6b54cc0b8d247e8d7c7a0975bdc9b" @@ -3670,6 +3605,24 @@ ini@^1.3.4, ini@~1.3.0: version "1.3.4" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" +inquirer@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.12.0.tgz#1ef2bfd63504df0bc75785fff8c2c41df12f077e" + dependencies: + ansi-escapes "^1.1.0" + ansi-regex "^2.0.0" + chalk "^1.0.0" + cli-cursor "^1.0.1" + cli-width "^2.0.0" + figures "^1.3.5" + lodash "^4.3.0" + readline2 "^1.0.1" + run-async "^0.1.0" + rx-lite "^3.1.2" + string-width "^1.0.1" + strip-ansi "^3.0.0" + through "^2.3.6" + inquirer@^0.8.5: version "0.8.5" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.8.5.tgz#dbd740cf6ca3b731296a63ce6f6d961851f336df" @@ -3688,8 +3641,8 @@ interpret@^0.6.4: resolved "https://registry.yarnpkg.com/interpret/-/interpret-0.6.6.tgz#fecd7a18e7ce5ca6abfb953e1f86213a49f1625b" interpret@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.2.tgz#f4f623f0bb7122f15f5717c8e254b8161b5c5b2d" + version "1.0.3" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90" invariant@^2.2.0: version "2.2.2" @@ -3726,7 +3679,7 @@ is-binary-path@^1.0.0: dependencies: binary-extensions "^1.0.0" -is-buffer@^1.0.2: +is-buffer@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" @@ -3766,6 +3719,10 @@ is-fullwidth-code-point@^1.0.0: dependencies: number-is-nan "^1.0.0" +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + is-generator@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/is-generator/-/is-generator-1.0.3.tgz#c14c21057ed36e328db80347966c693f886389f3" @@ -3776,13 +3733,7 @@ is-glob@^2.0.0, is-glob@^2.0.1: dependencies: is-extglob "^1.0.0" -is-integer@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/is-integer/-/is-integer-1.0.6.tgz#5273819fada880d123e1ac00a938e7172dd8d95e" - dependencies: - is-finite "^1.0.0" - -is-my-json-valid@^2.12.0, is-my-json-valid@^2.12.4: +is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.0, is-my-json-valid@^2.12.4: version "2.16.0" resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz#f079dd9bfdae65ee2038aae8acbc86ab109e3693" dependencies: @@ -3839,6 +3790,12 @@ is-relative@^0.2.1: dependencies: is-unc-path "^0.1.1" +is-resolvable@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" + dependencies: + tryit "^1.0.1" + is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -3883,7 +3840,7 @@ isobject@^2.0.0: dependencies: isarray "1.0.0" -isstream@0.1.x, isstream@~0.1.1, isstream@~0.1.2: +isstream@~0.1.1, isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -3930,31 +3887,19 @@ jodid25519@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" dependencies: - jsbn "~0.1.0" - -js-tokens@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-1.0.1.tgz#cc435a5c8b94ad15acb7983140fc80182c89aeae" + jsbn "~0.1.0" js-tokens@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" -js-yaml@3.6.1, js-yaml@3.x: +js-yaml@3.6.1, js-yaml@3.x, js-yaml@^3.5.1: version "3.6.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30" dependencies: argparse "^1.0.7" esprima "^2.6.0" -js-yaml@~3.4.0: - version "3.4.6" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.4.6.tgz#6be1b23f6249f53d293370fd4d1aaa63ce1b4eb0" - dependencies: - argparse "^1.0.2" - esprima "^2.6.0" - inherit "^2.2.2" - js2xmlparser@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-1.0.0.tgz#5a170f2e8d6476ce45405e04823242513782fe30" @@ -3963,50 +3908,6 @@ jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" -jscs-jsdoc@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/jscs-jsdoc/-/jscs-jsdoc-1.3.2.tgz#1f2c82b6ab4b97524da958f46b4e562e0305f9a7" - dependencies: - comment-parser "^0.3.1" - jsdoctypeparser "~1.2.0" - -jscs-preset-wikimedia@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/jscs-preset-wikimedia/-/jscs-preset-wikimedia-1.0.0.tgz#fff563342038fc2e8826b7bb7309c3ae3406fc7e" - -jscs@^2.1.1: - version "2.11.0" - resolved "https://registry.yarnpkg.com/jscs/-/jscs-2.11.0.tgz#6e11ef0caaa07731f9dcc2b2b27d8ecee1ddbcb6" - dependencies: - babel-jscs "^2.0.0" - chalk "~1.1.0" - cli-table "~0.3.1" - commander "~2.9.0" - escope "^3.2.0" - esprima "~2.7.0" - estraverse "^4.1.0" - exit "~0.1.2" - glob "^5.0.1" - htmlparser2 "3.8.3" - js-yaml "~3.4.0" - jscs-jsdoc "^1.3.1" - jscs-preset-wikimedia "~1.0.0" - jsonlint "~1.6.2" - lodash "~3.10.0" - minimatch "~3.0.0" - natural-compare "~1.2.2" - pathval "~0.1.1" - prompt "~0.2.14" - reserved-words "^0.1.1" - resolve "^1.1.6" - strip-bom "^2.0.0" - strip-json-comments "~1.0.2" - to-double-quotes "^2.0.0" - to-single-quotes "^2.0.0" - vow "~0.4.8" - vow-fs "~0.3.4" - xmlbuilder "^3.1.0" - jsdoc-75lb@^3.5.6: version "3.6.0" resolved "https://registry.yarnpkg.com/jsdoc-75lb/-/jsdoc-75lb-3.6.0.tgz#a807119528b4009ccbcab49b7522f63fec6cd0bd" @@ -4079,12 +3980,6 @@ jsdoc2md-stats@^1.0.3: app-usage-stats "^0.4.0" feature-detect-es6 "^1.3.1" -jsdoctypeparser@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/jsdoctypeparser/-/jsdoctypeparser-1.2.0.tgz#e7dedc153a11849ffc5141144ae86a7ef0c25392" - dependencies: - lodash "^3.7.0" - jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" @@ -4093,30 +3988,6 @@ jsesc@~0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" -jshint-stylish@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/jshint-stylish/-/jshint-stylish-2.2.1.tgz#242082a2c035ae03fd81044e0570cc4208cf6e61" - dependencies: - beeper "^1.1.0" - chalk "^1.0.0" - log-symbols "^1.0.0" - plur "^2.1.0" - string-length "^1.0.0" - text-table "^0.2.0" - -jshint@^2.7.0: - version "2.9.4" - resolved "https://registry.yarnpkg.com/jshint/-/jshint-2.9.4.tgz#5e3ba97848d5290273db514aee47fe24cf592934" - dependencies: - cli "~1.0.0" - console-browserify "1.1.x" - exit "0.1.x" - htmlparser2 "3.8.x" - lodash "3.7.x" - minimatch "~3.0.2" - shelljs "0.3.x" - strip-json-comments "1.0.x" - json-loader@^0.5.1: version "0.5.4" resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.4.tgz#8baa1365a632f58a3c46d20175fc6002c96e37de" @@ -4125,7 +3996,7 @@ json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" -json-stable-stringify@^1.0.1: +json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" dependencies: @@ -4139,10 +4010,6 @@ json3@3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" -json5@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/json5/-/json5-0.4.0.tgz#054352e4c4c80c86c0923877d449de176a732c8d" - json5@^0.5.0: version "0.5.1" resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" @@ -4161,13 +4028,6 @@ jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" -jsonlint@~1.6.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/jsonlint/-/jsonlint-1.6.2.tgz#5737045085f55eb455c68b1ff4ebc01bd50e8830" - dependencies: - JSV ">= 4.0.x" - nomnom ">= 1.5.x" - jsonpointer@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" @@ -4330,10 +4190,10 @@ kew@~0.7.0: resolved "https://registry.yarnpkg.com/kew/-/kew-0.7.0.tgz#79d93d2d33363d6fdd2970b335d9141ad591d79b" kind-of@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" dependencies: - is-buffer "^1.0.2" + is-buffer "^1.1.5" klaw@^1.0.0, klaw@~1.3.0: version "1.3.1" @@ -4361,9 +4221,12 @@ lcov-parse@0.0.10: version "0.0.10" resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" -leven@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/leven/-/leven-1.0.2.tgz#9144b6eebca5f1d0680169f1a6770dcea60b75c3" +levn@^0.3.0, levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" levn@~0.2.5: version "0.2.5" @@ -4472,14 +4335,6 @@ lodash._bindcallback@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" -lodash._createassigner@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11" - dependencies: - lodash._bindcallback "^3.0.0" - lodash._isiterateecall "^3.0.0" - lodash.restparam "^3.0.0" - lodash._escapehtmlchar@~2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/lodash._escapehtmlchar/-/lodash._escapehtmlchar-2.4.1.tgz#df67c3bb6b7e8e1e831ab48bfa0795b92afe899d" @@ -4547,14 +4402,6 @@ lodash._stack@^4.0.0: version "4.1.3" resolved "https://registry.yarnpkg.com/lodash._stack/-/lodash._stack-4.1.3.tgz#751aa76c1b964b047e76d14fc72a093fcb5e2dd0" -lodash.assign@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-3.2.0.tgz#3ce9f0234b4b2223e296b8fa0ac1fee8ebca64fa" - dependencies: - lodash._baseassign "^3.0.0" - lodash._createassigner "^3.0.0" - lodash.keys "^3.0.0" - lodash.assign@^4.0.3, lodash.assign@^4.0.6: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" @@ -4575,9 +4422,9 @@ lodash.clone@^4.3.2: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clone/-/lodash.clone-4.5.0.tgz#195870450f5a13192478df4bc3d23d2dea1907b6" -lodash.clonedeep@^4.3.2: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" +lodash.cond@^4.3.0: + version "4.5.2" + resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5" lodash.create@3.1.1: version "3.1.1" @@ -4739,15 +4586,11 @@ lodash@3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.5.0.tgz#19bb3f4d51278f0b8c818ed145c74ecf9fe40e6d" -lodash@3.7.x: - version "3.7.0" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.7.0.tgz#3678bd8ab995057c07ade836ed2ef087da811d45" - -lodash@^3.0.1, lodash@^3.10.0, lodash@^3.10.1, lodash@^3.3.1, lodash@^3.5.0, lodash@^3.7.0, lodash@^3.8.0, lodash@^3.9.3, lodash@~3.10.0: +lodash@^3.10.1, lodash@^3.3.1, lodash@^3.5.0, lodash@^3.8.0: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" -lodash@^4.0.0, lodash@^4.14.0, lodash@^4.16.2, lodash@^4.17.4, lodash@^4.2.0: +lodash@^4.0.0, lodash@^4.14.0, lodash@^4.16.2, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -4775,12 +4618,6 @@ log-driver@1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056" -log-symbols@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-1.0.2.tgz#376ff7b58ea3086a0f09facc74617eca501e1a18" - dependencies: - chalk "^1.0.0" - log4js@^0.6.31: version "0.6.38" resolved "https://registry.yarnpkg.com/log4js/-/log4js-0.6.38.tgz#2c494116695d6fb25480943d3fc872e662a522fd" @@ -4809,7 +4646,11 @@ loud-rejection@^1.0.0: currently-unhandled "^0.4.1" signal-exit "^3.0.0" -lru-cache@2, lru-cache@2.2.x: +lru-cache@2: + version "2.7.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" + +lru-cache@2.2.x: version "2.2.4" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.2.4.tgz#6c658619becf14031d0d0b594b16042ce4dc063d" @@ -4946,10 +4787,14 @@ mime-types@~2.0.1, mime-types@~2.0.3: dependencies: mime-db "~1.12.0" -mime@1.3.4, mime@^1.3.4: +mime@1.3.4: version "1.3.4" resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53" +mime@^1.3.4: + version "1.3.6" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.6.tgz#591d84d3653a6b0b4a3b9df8de5aa8108e72e5e0" + mime@~1.2.11: version "1.2.11" resolved "https://registry.yarnpkg.com/mime/-/mime-1.2.11.tgz#58203eed86e3a5ef17aed2b7d9ebd47f0a60dd10" @@ -4961,18 +4806,24 @@ minimatch@0.3, minimatch@0.x, minimatch@~0.3.0: lru-cache "2" sigmund "~1.0.0" -"minimatch@2 || 3", minimatch@3.0.3, minimatch@^3.0.0, minimatch@^3.0.2, minimatch@~3.0.0, minimatch@~3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" +"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: - brace-expansion "^1.0.0" + brace-expansion "^1.1.7" -minimatch@2.x, minimatch@^2.0.1, minimatch@^2.0.3: +minimatch@2.x, minimatch@^2.0.1: version "2.0.10" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" dependencies: brace-expansion "^1.0.0" +minimatch@3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" + dependencies: + brace-expansion "^1.0.0" + minimatch@~0.2.11: version "0.2.14" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.2.14.tgz#c74e780574f63c6f9a090e90efbe6ef53a6a756a" @@ -4992,6 +4843,10 @@ minimist@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.2.0.tgz#4dffe525dae2b864c66c2e23c6271d7afdecefce" +mkdirp2@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/mkdirp2/-/mkdirp2-1.0.3.tgz#cc8dd8265f1f06e2d8f5b10b6e52f4e050bed21b" + mkdirp@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" @@ -5000,7 +4855,7 @@ mkdirp@0.3.x, mkdirp@~0.3.5: version "0.3.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.5.tgz#de3e5f8961c88c787ee1368df849ac4413eca8d7" -mkdirp@0.5, mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@0.x.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: +mkdirp@0.5, mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: @@ -5016,9 +4871,9 @@ mkpath@1.0.0, mkpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/mkpath/-/mkpath-1.0.0.tgz#ebb3a977e7af1c683ae6fda12b545a6ba6c5853d" -mocha-nightwatch@3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/mocha-nightwatch/-/mocha-nightwatch-3.2.1.tgz#0e810f9c958d91bc3982c5948044a91436182c29" +mocha-nightwatch@3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/mocha-nightwatch/-/mocha-nightwatch-3.2.2.tgz#91bcb9b3bde057dd7677c78125e491e58d66647c" dependencies: browser-stdout "1.3.0" commander "2.9.0" @@ -5093,6 +4948,10 @@ ms@0.7.2: version "0.7.2" resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" +ms@0.7.3: + version "0.7.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.3.tgz#708155a5e44e33f5fd0fc53e81d0d40a91be1fff" + mu2@~0.5.19: version "0.5.21" resolved "https://registry.yarnpkg.com/mu2/-/mu2-0.5.21.tgz#888a8f0fd90eb1cfda9db81476f6e199cc9e58d3" @@ -5114,23 +4973,23 @@ mute-stream@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.4.tgz#a9219960a6d5d5d046597aee51252c6655f7177e" -mute-stream@~0.0.4: - version "0.0.7" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" +mute-stream@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" nan@^2.3.0: - version "2.6.1" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.1.tgz#8c84f7b14c96b89f57fbc838012180ec8ca39a01" + version "2.6.2" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" natives@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.0.tgz#e9ff841418a6b2ec7a495e939984f78f163e6e31" -natural-compare@~1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.2.2.tgz#1f96d60e3141cac1b6d05653ce0daeac763af6aa" +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" -ncp@0.4.x, ncp@~0.4.2: +ncp@~0.4.2: version "0.4.2" resolved "https://registry.yarnpkg.com/ncp/-/ncp-0.4.2.tgz#abcc6cbd3ec2ed2a729ff6e7c1fa8f01784a8574" @@ -5147,8 +5006,8 @@ netmask@~1.0.4: resolved "https://registry.yarnpkg.com/netmask/-/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35" nightwatch@^0.9.5: - version "0.9.14" - resolved "https://registry.yarnpkg.com/nightwatch/-/nightwatch-0.9.14.tgz#897eb2e418b75492c3671e28e8e413abe17cc268" + version "0.9.15" + resolved "https://registry.yarnpkg.com/nightwatch/-/nightwatch-0.9.15.tgz#71a62aa16368e9da09fae800ccb9fb34d036164d" dependencies: chai-nightwatch "~0.1.x" ejs "0.8.3" @@ -5156,7 +5015,7 @@ nightwatch@^0.9.5: lodash.defaultsdeep "4.3.2" minimatch "3.0.3" mkpath "1.0.0" - mocha-nightwatch "3.2.1" + mocha-nightwatch "3.2.2" optimist "0.6.1" proxy-agent "2.0.0" q "1.4.1" @@ -5211,13 +5070,6 @@ node-uuid@~1.4.0, node-uuid@~1.4.7: version "1.4.8" resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" -"nomnom@>= 1.5.x": - version "1.8.1" - resolved "https://registry.yarnpkg.com/nomnom/-/nomnom-1.8.1.tgz#2151f722472ba79e50a76fc125bb8c8f2e4dc2a7" - dependencies: - chalk "~0.4.0" - underscore "~1.6.0" - nopt@3.x: version "3.0.6" resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" @@ -5232,8 +5084,8 @@ nopt@^4.0.1: osenv "^0.1.4" normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: - version "2.3.6" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.6.tgz#498fa420c96401f787402ba21e600def9f981fff" + version "2.3.8" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.8.tgz#d819eda2a9dedbd1ffa563ea4071d936782295bb" dependencies: hosted-git-info "^2.1.4" is-builtin-module "^1.0.0" @@ -5247,12 +5099,12 @@ normalize-path@^2.0.1: remove-trailing-separator "^1.0.1" npmlog@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" + version "4.1.0" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.0.tgz#dc59bee85f64f00ed424efb2af0783df25d1c0b5" dependencies: are-we-there-yet "~1.1.2" console-control-strings "~1.1.0" - gauge "~2.7.1" + gauge "~2.7.3" set-blocking "~2.0.0" null-check@^1.0.0: @@ -5291,7 +5143,7 @@ object-component@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" -object-get@^2.0.0, object-get@^2.0.2, object-get@^2.0.4, object-get@^2.1.0: +object-get@^2.0.0, object-get@^2.0.2, object-get@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/object-get/-/object-get-2.1.0.tgz#722bbdb60039efa47cad3c6dc2ce51a85c02c5ae" @@ -5300,8 +5152,8 @@ object-keys@~0.4.0: resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-0.4.0.tgz#28a6aae7428dd2c3a92f3d95f21335dd204e0336" object-to-spawn-args@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/object-to-spawn-args/-/object-to-spawn-args-1.1.0.tgz#031a200e37db2c3dfc9b98074a0d69a5be253c1c" + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-to-spawn-args/-/object-to-spawn-args-1.1.1.tgz#77da8827f073d011c9e1b173f895781470246785" object-tools@^1.2.1, object-tools@^1.6.1: version "1.6.7" @@ -5349,6 +5201,10 @@ once@~1.3.0: dependencies: wrappy "1" +onetime@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" + open@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc" @@ -5391,6 +5247,17 @@ optionator@^0.5.0: type-check "~0.3.1" wordwrap "~0.0.2" +optionator@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + options@>=0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/options/-/options-0.0.6.tgz#ec22d312806bb53e731773e7cdaefcf1c643128f" @@ -5432,14 +5299,6 @@ osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -output-file-sync@^1.1.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" - dependencies: - graceful-fs "^4.1.4" - mkdirp "^0.5.1" - object-assign "^4.1.0" - "over@>= 0.0.5 < 1": version "0.0.5" resolved "https://registry.yarnpkg.com/over/-/over-0.0.5.tgz#f29852e70fd7e25f360e013a8ec44c82aedb5708" @@ -5525,10 +5384,6 @@ path-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.0.tgz#a0b870729aae214005b7d5032ec2cbbb0fb4451a" -path-exists@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-1.0.0.tgz#d5a8998eb71ef37a74c34eb0d9eba6e878eea081" - path-exists@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" @@ -5543,6 +5398,10 @@ path-is-inside@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" +path-parse@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + path-root-regex@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/path-root-regex/-/path-root-regex-0.1.2.tgz#bfccdc8df5b12dc52c8b43ec38d18d72c04ba96d" @@ -5561,10 +5420,6 @@ path-type@^1.0.0: pify "^2.0.0" pinkie-promise "^2.0.0" -pathval@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/pathval/-/pathval-0.1.1.tgz#08f911cdca9cce5942880da7817bc0b723b66d82" - pause-stream@0.0.11: version "0.0.11" resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" @@ -5620,13 +5475,11 @@ pkg-dir@^1.0.0: dependencies: find-up "^1.0.0" -pkginfo@0.3.x: - version "0.3.1" - resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21" - -pkginfo@0.x.x: - version "0.4.0" - resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.0.tgz#349dbb7ffd38081fcadc0853df687f0c7744cd65" +pkg-up@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-1.0.0.tgz#3e08fb461525c4421624a33b9f7e6d0af5b05a26" + dependencies: + find-up "^1.0.0" plur@^2.1.0: version "2.1.2" @@ -5634,6 +5487,10 @@ plur@^2.1.0: dependencies: irregular-plurals "^1.0.0" +pluralize@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" + prelude-ls@~1.1.0, prelude-ls@~1.1.1, prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -5655,10 +5512,10 @@ process-nextick-args@^1.0.6, process-nextick-args@~1.0.6: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" process@^0.11.0: - version "0.11.9" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.9.tgz#7bd5ad21aa6253e7da8682264f1e11d11c0318c1" + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" -progress@~1.1.8: +progress@^1.1.8, progress@~1.1.8: version "1.1.8" resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" @@ -5672,16 +5529,6 @@ promise.prototype.finally@^1.0.1: dependencies: asap "~2.0.3" -prompt@~0.2.14: - version "0.2.14" - resolved "https://registry.yarnpkg.com/prompt/-/prompt-0.2.14.tgz#57754f64f543fd7b0845707c818ece618f05ffdc" - dependencies: - pkginfo "0.x.x" - read "1.0.x" - revalidator "0.1.x" - utile "0.2.x" - winston "0.8.x" - proxy-agent@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-2.0.0.tgz#57eb5347aa805d74ec681cb25649dba39c933499" @@ -5696,8 +5543,8 @@ proxy-agent@2.0.0: socks-proxy-agent "2" proxyquire@^1.7.10: - version "1.7.11" - resolved "https://registry.yarnpkg.com/proxyquire/-/proxyquire-1.7.11.tgz#13b494eb1e71fb21cc3ebe3699e637d3bec1af9e" + version "1.8.0" + resolved "https://registry.yarnpkg.com/proxyquire/-/proxyquire-1.8.0.tgz#02d514a5bed986f04cbb2093af16741535f79edc" dependencies: fill-keys "^1.0.2" module-not-found-error "^1.0.0" @@ -5776,10 +5623,14 @@ querystring@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" -querystringify@0.0.3, querystringify@0.0.x: +querystringify@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-0.0.3.tgz#0c9d36fbf8c7a4f71eb370857763577a63335be7" +querystringify@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-1.0.0.tgz#6286242112c5b712fa654e526652bf6a13ff05cb" + random-bytes@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/random-bytes/-/random-bytes-1.0.0.tgz#4f68a1dc0ae58bd3fb95848c30324db75d64360b" @@ -5824,19 +5675,6 @@ rc@^1.1.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -rcfinder@~0.1.6: - version "0.1.9" - resolved "https://registry.yarnpkg.com/rcfinder/-/rcfinder-0.1.9.tgz#f3e80f387ddf9ae80ae30a4100329642eae81115" - dependencies: - lodash.clonedeep "^4.3.2" - -rcloader@0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/rcloader/-/rcloader-0.1.2.tgz#a0963a6437d09ef8cb92d932d2dad497b0d1736c" - dependencies: - lodash "~2.4.1" - rcfinder "~0.1.6" - read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" @@ -5852,13 +5690,7 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" -read@1.0.x: - version "1.0.7" - resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4" - dependencies: - mute-stream "~0.0.4" - -readable-stream@1.1, readable-stream@1.1.x, readable-stream@~1.1.8, readable-stream@~1.1.9: +readable-stream@1.1.x, readable-stream@~1.1.8, readable-stream@~1.1.9: version "1.1.14" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" dependencies: @@ -5867,9 +5699,9 @@ readable-stream@1.1, readable-stream@1.1.x, readable-stream@~1.1.8, readable-str isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@2, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6: - version "2.2.8" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.8.tgz#ad28b686f3554c73d39bc32347fa058356624705" +readable-stream@2, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6: + version "2.2.9" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" dependencies: buffer-shims "~1.0.0" core-util-is "~1.0.0" @@ -5915,7 +5747,15 @@ readline2@^0.1.1: mute-stream "0.0.4" strip-ansi "^2.0.1" -recast@0.10.33, recast@^0.10.10: +readline2@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/readline2/-/readline2-1.0.1.tgz#41059608ffc154757b715d9989d199ffbf372e35" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + mute-stream "0.0.5" + +recast@0.10.33: version "0.10.33" resolved "https://registry.yarnpkg.com/recast/-/recast-0.10.33.tgz#942808f7aa016f1fa7142c461d7e5704aaa8d697" dependencies: @@ -5971,8 +5811,12 @@ regenerate@^1.2.1: resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" regenerator-runtime@^0.10.0: - version "0.10.3" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.3.tgz#8c4367a904b51ea62a908ac310bf99ff90a82a3e" + version "0.10.5" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" + +regenerator-runtime@~0.9.5: + version "0.9.6" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.9.6.tgz#d33eb95d0d2001a4be39659707c51b0cb71ce029" regenerator-transform@0.9.11: version "0.9.11" @@ -5982,15 +5826,16 @@ regenerator-transform@0.9.11: babel-types "^6.19.0" private "^0.1.6" -regenerator@0.8.40, regenerator@~0.8.13: - version "0.8.40" - resolved "https://registry.yarnpkg.com/regenerator/-/regenerator-0.8.40.tgz#a0e457c58ebdbae575c9f8cd75127e93756435d8" +regenerator@~0.8.13: + version "0.8.46" + resolved "https://registry.yarnpkg.com/regenerator/-/regenerator-0.8.46.tgz#154c327686361ed52cad69b2545efc53a3d07696" dependencies: commoner "~0.10.3" defs "~1.1.0" esprima-fb "~15001.1001.0-dev-harmony-fb" private "~0.1.5" recast "0.10.33" + regenerator-runtime "~0.9.5" through "~2.3.8" regex-cache@^0.4.2: @@ -6008,16 +5853,6 @@ regexpu-core@^2.0.0: regjsgen "^0.2.0" regjsparser "^0.1.4" -regexpu@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/regexpu/-/regexpu-1.3.0.tgz#e534dc991a9e5846050c98de6d7dd4a55c9ea16d" - dependencies: - esprima "^2.6.0" - recast "^0.10.10" - regenerate "^1.2.1" - regjsgen "^0.2.0" - regjsparser "^0.1.4" - regjsgen@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" @@ -6044,12 +5879,6 @@ repeat-string@^1.5.2: version "1.6.1" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" -repeating@^1.1.0, repeating@^1.1.2: - version "1.1.3" - resolved "https://registry.yarnpkg.com/repeating/-/repeating-1.1.3.tgz#3d4114218877537494f97f77f9785fab810fa4ac" - dependencies: - is-finite "^1.0.0" - repeating@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" @@ -6240,6 +6069,13 @@ require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" +require-uncached@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" + dependencies: + caller-path "^0.1.0" + resolve-from "^1.0.0" + requirejs@^2.1.20: version "2.3.3" resolved "https://registry.yarnpkg.com/requirejs/-/requirejs-2.3.3.tgz#aa59fd3a0287eaf407959a138228044b5dd6a6a3" @@ -6254,10 +6090,6 @@ requizzle@~0.2.1: dependencies: underscore "~1.6.0" -reserved-words@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/reserved-words/-/reserved-words-0.1.1.tgz#6f7c15e5e5614c50da961630da46addc87c0cef2" - resolve-dir@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-0.1.1.tgz#b219259a5602fac5c5c496ad894a6e8cc430261e" @@ -6273,10 +6105,16 @@ resolve-url@~0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" -resolve@1.1.x, resolve@^1.1.6, resolve@^1.1.7, resolve@~1.1.7: +resolve@1.1.x, resolve@~1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" +resolve@^1.1.6, resolve@^1.1.7: + version "1.3.3" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.3.3.tgz#655907c3469a8680dc2de3a275a8fdd69691f0e5" + dependencies: + path-parse "^1.0.5" + response-time@~2.3.1: version "2.3.2" resolved "https://registry.yarnpkg.com/response-time/-/response-time-2.3.2.tgz#ffa71bab952d62f7c1d49b7434355fbc68dffc5a" @@ -6284,9 +6122,12 @@ response-time@~2.3.1: depd "~1.1.0" on-headers "~1.0.1" -revalidator@0.1.x: - version "0.1.8" - resolved "https://registry.yarnpkg.com/revalidator/-/revalidator-0.1.8.tgz#fece61bfa0c1b52a206bd6b18198184bdd523a3b" +restore-cursor@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" + dependencies: + exit-hook "^1.0.0" + onetime "^1.0.0" rewire@2.5.2: version "2.5.2" @@ -6302,7 +6143,7 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@2, rimraf@2.x.x, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.6.1: +rimraf@2, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" dependencies: @@ -6324,6 +6165,16 @@ rndm@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/rndm/-/rndm-1.2.0.tgz#f33fe9cfb52bbfd520aa18323bc65db110a1b76c" +run-async@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" + dependencies: + once "^1.3.0" + +rx-lite@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" + rx@^2.4.3: version "2.5.3" resolved "https://registry.yarnpkg.com/rx/-/rx-2.5.3.tgz#21adc7d80f02002af50dae97fd9dbf248755f566" @@ -6431,13 +6282,13 @@ sha.js@2.2.6: version "2.2.6" resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.2.6.tgz#17ddeddc5f722fb66501658895461977867315ba" -shebang-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" - -shelljs@0.3.x: - version "0.3.0" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.3.0.tgz#3596e6307a781544f591f37da618360f31db57b1" +shelljs@^0.7.5: + version "0.7.7" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.7.tgz#b2f5c77ef97148f4b4f6e22682e10bba8667cff1" + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" sigmund@~1.0.0: version "1.0.1" @@ -6468,6 +6319,10 @@ slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" +slice-ansi@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" + "slice-stream@>= 1.0.0 < 2": version "1.0.0" resolved "https://registry.yarnpkg.com/slice-stream/-/slice-stream-1.0.0.tgz#5b33bd66f013b1a7f86460b03d463dec39ad3ea0" @@ -6497,15 +6352,15 @@ socket.io-adapter@0.5.0: debug "2.3.3" socket.io-parser "2.3.1" -socket.io-client@1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-1.7.3.tgz#b30e86aa10d5ef3546601c09cde4765e381da377" +socket.io-client@1.7.4: + version "1.7.4" + resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-1.7.4.tgz#ec9f820356ed99ef6d357f0756d648717bdd4281" dependencies: backo2 "1.0.2" component-bind "1.0.0" component-emitter "1.2.1" debug "2.3.3" - engine.io-client "1.8.3" + engine.io-client "~1.8.4" has-binary "0.1.7" indexof "0.0.1" object-component "0.0.3" @@ -6523,15 +6378,15 @@ socket.io-parser@2.3.1: json3 "3.3.2" socket.io@^1.4.5: - version "1.7.3" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-1.7.3.tgz#b8af9caba00949e568e369f1327ea9be9ea2461b" + version "1.7.4" + resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-1.7.4.tgz#2f7ecedc3391bf2d5c73e291fe233e6e34d4dd00" dependencies: debug "2.3.3" - engine.io "1.8.3" + engine.io "~1.8.4" has-binary "0.1.7" object-assign "4.1.0" socket.io-adapter "0.5.0" - socket.io-client "1.7.3" + socket.io-client "1.7.4" socket.io-parser "2.3.1" socks-proxy-agent@2: @@ -6550,12 +6405,12 @@ socks@~1.1.5: smart-buffer "^1.0.13" sort-array@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/sort-array/-/sort-array-1.1.1.tgz#9032f6f0be284eecb12af98a3db02612828a66d1" + version "1.1.2" + resolved "https://registry.yarnpkg.com/sort-array/-/sort-array-1.1.2.tgz#b88986053c0170a7f9de63f18a49ec79c24c3e64" dependencies: - array-back "^1.0.3" - object-get "^2.0.4" - typical "^2.4.2" + array-back "^1.0.4" + object-get "^2.1.0" + typical "^2.6.0" source-list-map@~0.1.7: version "0.1.8" @@ -6570,15 +6425,9 @@ source-map-resolve@^0.3.0: source-map-url "~0.3.0" urix "~0.1.0" -source-map-support@^0.2.10: - version "0.2.10" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.2.10.tgz#ea5a3900a1c1cb25096a0ae8cc5c2b4b10ded3dc" - dependencies: - source-map "0.1.32" - source-map-support@^0.4.2: - version "0.4.14" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.14.tgz#9d4463772598b86271b4f523f6c1f4e02a7d6aef" + version "0.4.15" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.15.tgz#03202df65c06d2bd8c7ec2362a193056fef8d3b1" dependencies: source-map "^0.5.6" @@ -6586,12 +6435,6 @@ source-map-url@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.3.0.tgz#7ecaf13b57bcd09da8a40c5d269db33799d4aaf9" -source-map@0.1.32: - version "0.1.32" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.32.tgz#c8b6c167797ba4740a8ea33252162ff08591b266" - dependencies: - amdefine ">=0.0.4" - source-map@^0.1.38, source-map@^0.1.40, source-map@^0.1.41, source-map@~0.1.38, source-map@~0.1.7: version "0.1.43" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346" @@ -6649,8 +6492,8 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" sshpk@^1.7.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.11.0.tgz#2d8d5ebb4a6fab28ffba37fa62a90f4a3ea59d77" + version "1.13.0" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.0.tgz#ff2a3e4fd04497555fed97b39a0fd82fafb3a33c" dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -6667,10 +6510,6 @@ stable@~0.1.3: version "0.1.6" resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.6.tgz#910f5d2aed7b520c6e777499c1f32e139fdecb10" -stack-trace@0.0.x: - version "0.0.9" - resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.9.tgz#a8f6eaeca90674c333e7c43953f275b451510695" - statuses@1, "statuses@>= 1.3.1 < 2", statuses@~1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" @@ -6716,8 +6555,8 @@ stream-handlebars@~0.1.6: object-tools "^1.2.1" stream-http@^2.3.1: - version "2.7.0" - resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.7.0.tgz#cec1f4e3b494bc4a81b451808970f8b20b4ed5f6" + version "2.7.1" + resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.7.1.tgz#546a51741ad5a6b07e9e31b0b10441a917df528a" dependencies: builtin-status-codes "^3.0.0" inherits "^2.0.1" @@ -6743,12 +6582,6 @@ stream-via@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/stream-via/-/stream-via-0.1.1.tgz#0cee5df9c959fb1d3f4eda4819f289d5f9205afc" -string-length@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string-length/-/string-length-1.0.1.tgz#56970fb1c38558e9e70b728bf3de269ac45adfac" - dependencies: - strip-ansi "^3.0.0" - string-replace-webpack-plugin@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/string-replace-webpack-plugin/-/string-replace-webpack-plugin-0.0.3.tgz#82c67448cea95ec002a1bfcfd2fb0195cd12bd24" @@ -6767,7 +6600,7 @@ string-tools@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/string-tools/-/string-tools-1.0.0.tgz#c69a9d5788858997da66f1d923ba7113ea466b5a" -string-width@^1.0.1: +string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" dependencies: @@ -6775,6 +6608,13 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" +string-width@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.0.0.tgz#635c5436cc72a6e0c387ceca278d4e2eec52687e" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^3.0.0" + string_decoder@^0.10.25, string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" @@ -6815,10 +6655,6 @@ strip-ansi@^3.0.0, strip-ansi@^3.0.1: dependencies: ansi-regex "^2.0.0" -strip-ansi@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.1.1.tgz#39e8a98d044d150660abe4a6808acf70bb7bc991" - strip-bom@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-1.0.0.tgz#85b8862f3844b5a6d5ec8467a93598173a36f794" @@ -6832,16 +6668,16 @@ strip-bom@^2.0.0: dependencies: is-utf8 "^0.2.0" +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + strip-indent@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" dependencies: get-stdin "^4.0.1" -strip-json-comments@1.0.x, strip-json-comments@~1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" - strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" @@ -6891,6 +6727,17 @@ table-layout@^0.3.0: typical "^2.6.0" wordwrapjs "^2.0.0-0" +table@^3.7.8: + version "3.8.3" + resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" + dependencies: + ajv "^4.7.0" + ajv-keywords "^1.0.0" + chalk "^1.1.1" + lodash "^4.0.0" + slice-ansi "0.0.4" + string-width "^2.0.0" + taffydb@2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.6.2.tgz#7cbcb64b5a141b6a2efc2c5d2c67b4e150b2a268" @@ -6954,7 +6801,7 @@ test-value@^2.0.0, test-value@^2.1.0: array-back "^1.0.3" typical "^2.6.0" -text-table@^0.2.0: +text-table@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -6972,7 +6819,7 @@ throttleit@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c" -"through2@>=0.6.1 <1.0.0-0", through2@^0.6.1, through2@^0.6.5, through2@~0.6.1: +"through2@>=0.6.1 <1.0.0-0", through2@^0.6.1, through2@^0.6.5: version "0.6.5" resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" dependencies: @@ -7015,8 +6862,8 @@ tildify@^1.0.0: os-homedir "^1.0.0" time-stamp@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.0.1.tgz#9f4bd23559c9365966f3302dbba2b07c6b99b151" + version "1.1.0" + resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3" timers-browserify@^2.0.2: version "2.0.2" @@ -7049,22 +6896,14 @@ to-arraybuffer@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" -to-double-quotes@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-double-quotes/-/to-double-quotes-2.0.0.tgz#aaf231d6fa948949f819301bbab4484d8588e4a7" - -to-fast-properties@^1.0.0, to-fast-properties@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" +to-fast-properties@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" to-iso-string@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/to-iso-string/-/to-iso-string-0.0.2.tgz#4dc19e664dfccbe25bd8db508b00c6da158255d1" -to-single-quotes@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/to-single-quotes/-/to-single-quotes-2.0.1.tgz#7cc29151f0f5f2c41946f119f5932fe554170125" - tough-cookie@>=0.12.0, tough-cookie@~2.3.0: version "2.3.2" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" @@ -7083,13 +6922,13 @@ trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" -trim-right@^1.0.0, trim-right@^1.0.1: +trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" -try-resolve@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/try-resolve/-/try-resolve-1.0.1.tgz#cfde6fabd72d63e5797cfaab873abbe8e700e912" +tryit@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" tryor@~0.1.2: version "0.1.2" @@ -7117,7 +6956,7 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" -type-check@~0.3.1: +type-check@~0.3.1, type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" dependencies: @@ -7156,8 +6995,8 @@ uglify-js@2.4.6: uglify-to-browserify "~1.0.0" uglify-js@^2.6, uglify-js@^2.8.10: - version "2.8.21" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.21.tgz#1733f669ae6f82fc90c7b25ec0f5c783ee375314" + version "2.8.26" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.26.tgz#3a1db8ae0a0aba7f92e1ddadadbd0293d549f90e" dependencies: source-map "~0.5.1" yargs "~3.10.0" @@ -7251,10 +7090,10 @@ urix@^0.1.0, urix@~0.1.0: resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" url-parse@^1.0.5: - version "1.1.8" - resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.8.tgz#7a65b3a8d57a1e86af6b4e2276e34774167c0156" + version "1.1.9" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.9.tgz#c67f1d775d51f0a18911dd7b3ffad27bb9e5bd19" dependencies: - querystringify "0.0.x" + querystringify "~1.0.0" requires-port "1.0.x" url@^0.11.0: @@ -7272,15 +7111,15 @@ url@~0.10.3: querystring "0.2.0" usage-stats@^0.8.2: - version "0.8.2" - resolved "https://registry.yarnpkg.com/usage-stats/-/usage-stats-0.8.2.tgz#d7be5203682e267f7696b354356c8c376aa12542" + version "0.8.5" + resolved "https://registry.yarnpkg.com/usage-stats/-/usage-stats-0.8.5.tgz#5054336ba78b14b8d8f9399fd699708f5cecff69" dependencies: array-back "^1.0.3" cli-commands "0.1.0" core-js "^2.4.1" feature-detect-es6 "^1.3.1" home-path "^1.0.3" - mkdirp "^0.5.1" + mkdirp2 "^1.0.2" req-then "^0.5.1" typical "^2.6.0" uuid "^3.0.0" @@ -7289,6 +7128,12 @@ user-home@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" +user-home@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" + dependencies: + os-homedir "^1.0.0" + useragent@^2.1.6: version "2.1.13" resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.1.13.tgz#bba43e8aa24d5ceb83c2937473e102e21df74c10" @@ -7306,32 +7151,17 @@ util@0.10.3, "util@>=0.10.3 <1", util@^0.10.3: dependencies: inherits "2.0.1" -utile@0.2.x: - version "0.2.1" - resolved "https://registry.yarnpkg.com/utile/-/utile-0.2.1.tgz#930c88e99098d6220834c356cbd9a770522d90d7" - dependencies: - async "~0.2.9" - deep-equal "*" - i "0.3.x" - mkdirp "0.x.x" - ncp "0.4.x" - rimraf "2.x.x" - utils-merge@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8" -uuid@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" - uuid@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" v8flags@^2.0.2: - version "2.0.12" - resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.0.12.tgz#73235d9f7176f8e8833fb286795445f7938d84e5" + version "2.1.1" + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" dependencies: user-home "^1.1.1" @@ -7413,8 +7243,8 @@ vinyl@^1.1.0: replace-ext "0.0.1" vinyl@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.0.1.tgz#1c3b4931e7ac4c1efee743f3b91a74c094407bb6" + version "2.0.2" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.0.2.tgz#0a3713d8d4e9221c58f10ca16c0116c9e25eda7c" dependencies: clone "^1.0.0" clone-buffer "^1.0.0" @@ -7425,8 +7255,8 @@ vinyl@^2.0.0: replace-ext "^1.0.0" vlq@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.1.tgz#14439d711891e682535467f8587c5630e4222a6c" + version "0.2.2" + resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.2.tgz#e316d5257b40b86bb43cb8d5fea5d7f54d6b0ca1" vm-browserify@0.0.4: version "0.0.4" @@ -7438,25 +7268,6 @@ void-elements@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" -vow-fs@~0.3.4: - version "0.3.6" - resolved "https://registry.yarnpkg.com/vow-fs/-/vow-fs-0.3.6.tgz#2d4c59be22e2bf2618ddf597ab4baa923be7200d" - dependencies: - glob "^7.0.5" - uuid "^2.0.2" - vow "^0.4.7" - vow-queue "^0.4.1" - -vow-queue@^0.4.1: - version "0.4.2" - resolved "https://registry.yarnpkg.com/vow-queue/-/vow-queue-0.4.2.tgz#e7fe17160e15c7c4184d1b666a9bc64e18e30184" - dependencies: - vow "~0.4.0" - -vow@^0.4.7, vow@~0.4.0, vow@~0.4.8: - version "0.4.15" - resolved "https://registry.yarnpkg.com/vow/-/vow-0.4.15.tgz#0579163aff6ba0ae05c456b2c0e4ca6373f111b3" - walk-back@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/walk-back/-/walk-back-2.0.1.tgz#554e2a9d874fac47a8cb006bf44c2f0c4998a0a4" @@ -7517,8 +7328,8 @@ webpack-core@~0.6.9: source-map "~0.4.1" webpack-dev-middleware@^1.0.11: - version "1.10.1" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.10.1.tgz#c6b4cf428139cf1aefbe06a0c00fdb4f8da2f893" + version "1.10.2" + resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.10.2.tgz#2e252ce1dfb020dbda1ccb37df26f30ab014dbd1" dependencies: memory-fs "~0.4.1" mime "^1.3.4" @@ -7538,8 +7349,8 @@ webpack-stream@^3.1.0: webpack "^1.12.9" webpack@^1.12.3, webpack@^1.12.9: - version "1.14.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-1.14.0.tgz#54f1ffb92051a328a5b2057d6ae33c289462c823" + version "1.15.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-1.15.0.tgz#4ff31f53db03339e55164a9d468ee0324968fe98" dependencies: acorn "^3.0.0" async "^1.3.0" @@ -7586,10 +7397,10 @@ which@~1.0.5: resolved "https://registry.yarnpkg.com/which/-/which-1.0.9.tgz#460c1da0f810103d0321a9b633af9e575e64486f" wide-align@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad" + version "1.1.2" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" dependencies: - string-width "^1.0.1" + string-width "^1.0.2" window-size@0.1.0: version "0.1.0" @@ -7603,23 +7414,11 @@ window-size@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.2.0.tgz#b4315bb4214a3d7058ebeee892e13fa24d98b075" -winston@0.8.x: - version "0.8.3" - resolved "https://registry.yarnpkg.com/winston/-/winston-0.8.3.tgz#64b6abf4cd01adcaefd5009393b1d8e8bec19db0" - dependencies: - async "0.2.x" - colors "0.6.x" - cycle "1.0.x" - eyes "0.1.x" - isstream "0.1.x" - pkginfo "0.3.x" - stack-trace "0.0.x" - wordwrap@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" -wordwrap@^1.0.0: +wordwrap@^1.0.0, wordwrap@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" @@ -7654,6 +7453,12 @@ wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" +write@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" + dependencies: + mkdirp "^0.5.1" + ws@1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.2.tgz#8a244fa052401e08c9886cf44a85189e1fd4067f" @@ -7661,11 +7466,18 @@ ws@1.1.2: options ">=0.0.5" ultron "1.0.x" +ws@1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.4.tgz#57f40d036832e5f5055662a397c4de76ed66bf61" + dependencies: + options ">=0.0.5" + ultron "1.0.x" + wtf-8@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wtf-8/-/wtf-8-1.0.0.tgz#392d8ba2d0f1c34d1ee2d630f15d0efb68e1048a" -xmlbuilder@3.1.0, xmlbuilder@^3.1.0: +xmlbuilder@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-3.1.0.tgz#2c86888f2d4eade850fa38ca7f7223f7209516e1" dependencies: