Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test fixes #2301

Merged
merged 1 commit into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions test/spec/modules/audienceNetworkBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { expect } from 'chai';

import { spec } from 'modules/audienceNetworkBidAdapter';
import * as utils from 'src/utils';

const {
code,
Expand Down Expand Up @@ -117,6 +118,15 @@ describe('AudienceNetwork adapter', () => {
});

describe('buildRequests', () => {
let isSafariBrowserStub;
before(() => {
isSafariBrowserStub = sinon.stub(utils, 'isSafariBrowser');
});

after(() => {
isSafariBrowserStub.restore();
});

it('can build URL for IAB unit', () => {
expect(buildRequests([{
bidder,
Expand Down Expand Up @@ -191,23 +201,13 @@ describe('AudienceNetwork adapter', () => {
});

it('can build URL on Safari that includes a cachebuster param', () => {
const { userAgent } = navigator;
Object.defineProperty(navigator, 'userAgent', {
value: 'safari',
writable: true
});

isSafariBrowserStub.returns(true);
expect(buildRequests([{
bidder,
bidId: requestId,
sizes: [[300, 250]],
params: { placementId }
}])[0].data).to.contain('&cb=');

Object.defineProperty(navigator, 'userAgent', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh this is pretty nasty.

value: userAgent,
writable: false
});
});
});

Expand Down
15 changes: 9 additions & 6 deletions test/spec/modules/eplanningAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import eplAnalyticsAdapter from 'modules/eplanningAnalyticsAdapter';
import includes from 'core-js/library/fn/array/includes';
import { expect } from 'chai';
import {parse as parseURL} from 'src/url';
let adaptermanager = require('src/adaptermanager');
let events = require('src/events');
let constants = require('src/constants.json');
Expand Down Expand Up @@ -112,16 +114,17 @@ describe('eplanning analytics adapter', () => {
events.emit(constants.EVENTS.AUCTION_END, {auctionId: pauctionId});

// Step 7: Find the request data sent (filtering other hosts)
requests = requests.filter(req => req.url.includes(initOptions.host));

requests = requests.filter(req => {
return req.url.indexOf(initOptions.host) > -1;
});
expect(requests.length).to.equal(1);

expect(requests[0].url.includes(initOptions.host + initOptions.ci));
expect(requests[0].url.includes('https://ads.ar.e-planning.net/hba/1/12345?d='));
expect(includes([initOptions.host + initOptions.ci], requests[0].url));
expect(includes(['https://ads.ar.e-planning.net/hba/1/12345?d='], requests[0].url));

let info = requests[0].url;
let purl = new URL(info);
let eplData = JSON.parse(decodeURIComponent(purl.searchParams.get('d')));
let purl = parseURL(info);
let eplData = JSON.parse(decodeURIComponent(purl.search.d));

// Step 8 check that 6 events were sent
expect(eplData.length).to.equal(6);
Expand Down