Skip to content

Commit

Permalink
adagioAnalyticsAdapter: fix inconsistent tests (prebid#4417)
Browse files Browse the repository at this point in the history
  • Loading branch information
osazos authored and afewcc committed Dec 10, 2019
1 parent 069e710 commit ef53685
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions test/spec/modules/adagioAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ let adapterManager = require('src/adapterManager').default;
let events = require('src/events');
let constants = require('src/constants.json');

describe.skip('adagio analytics adapter', () => {
describe('adagio analytics adapter', () => {
let xhr;
let requests;
let sandbox
let adagioQueuePushSpy;

beforeEach(() => {
sandbox = sinon.createSandbox();
Expand All @@ -19,10 +20,17 @@ describe.skip('adagio analytics adapter', () => {
xhr.onCreate = request => requests.push(request);
sandbox.stub(events, 'getEvents').returns([]);

const w = utils.getWindowTop();

adapterManager.registerAnalyticsAdapter({
code: 'adagio',
adapter: adagioAnalyticsAdapter
});

w.ADAGIO = w.ADAGIO || {};
w.ADAGIO.queue = w.ADAGIO.queue || [];

adagioQueuePushSpy = sandbox.spy(w.ADAGIO.queue, 'push');
});

afterEach(() => {
Expand Down Expand Up @@ -89,28 +97,25 @@ describe.skip('adagio analytics adapter', () => {
// Step 3: Send auction end event
events.emit(constants.EVENTS.AUCTION_END, {});

expect(w.ADAGIO.queue).length(3);

let o = w.ADAGIO.queue.shift();
expect(o).to.not.be.undefined;
expect(o.action).to.equal('pb-analytics-event');
expect(o.ts).to.not.be.undefined;
expect(o.data).to.not.be.undefined;
expect(o.data).to.deep.equal({eventName: constants.EVENTS.BID_REQUESTED, args: bidRequest});

o = w.ADAGIO.queue.shift();
expect(o).to.not.be.undefined;
expect(o.action).to.equal('pb-analytics-event');
expect(o.ts).to.not.be.undefined;
expect(o.data).to.not.be.undefined;
expect(o.data).to.deep.equal({eventName: constants.EVENTS.BID_RESPONSE, args: bidResponse});

o = w.ADAGIO.queue.shift();
expect(o).to.not.be.undefined;
expect(o.action).to.equal('pb-analytics-event');
expect(o.ts).to.not.be.undefined;
expect(o.data).to.not.be.undefined;
expect(o.data).to.deep.equal({eventName: constants.EVENTS.AUCTION_END, args: {}});
sandbox.assert.callCount(adagioQueuePushSpy, 3);

const call0 = adagioQueuePushSpy.getCall(0);
expect(call0.args[0].action).to.equal('pb-analytics-event');
expect(call0.args[0].ts).to.not.be.undefined;
expect(call0.args[0].data).to.not.be.undefined;
expect(call0.args[0].data).to.deep.equal({eventName: constants.EVENTS.BID_REQUESTED, args: bidRequest});

const call1 = adagioQueuePushSpy.getCall(1);
expect(call1.args[0].action).to.equal('pb-analytics-event');
expect(call1.args[0].ts).to.not.be.undefined;
expect(call1.args[0].data).to.not.be.undefined;
expect(call1.args[0].data).to.deep.equal({eventName: constants.EVENTS.BID_RESPONSE, args: bidResponse});

const call2 = adagioQueuePushSpy.getCall(2);
expect(call2.args[0].action).to.equal('pb-analytics-event');
expect(call2.args[0].ts).to.not.be.undefined;
expect(call2.args[0].data).to.not.be.undefined;
expect(call2.args[0].data).to.deep.equal({eventName: constants.EVENTS.AUCTION_END, args: {}});
});
});

Expand Down Expand Up @@ -177,7 +182,7 @@ describe.skip('adagio analytics adapter', () => {

utils.getWindowTop.restore();

expect(utils.getWindowTop().ADAGIO.queue).length(0);
sandbox.assert.callCount(adagioQueuePushSpy, 0);
});
});
});

0 comments on commit ef53685

Please sign in to comment.