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

adagioAnalyticsAdapter: fix unconsistent tests #4417

Merged
merged 1 commit into from
Dec 2, 2019
Merged
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
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);
});
});
});