forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support native click tracking (prebid#1691)
* Implement native click tracking * Fire based on postMessage in adserver creative * Fix tests, add comments * Require landing page urls on native bid responses * Address code review comments
- Loading branch information
1 parent
7f68db9
commit b454e2b
Showing
6 changed files
with
111 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { expect } from 'chai'; | ||
import { fireNativeTrackers, getNativeTargeting } from 'src/native'; | ||
const utils = require('src/utils'); | ||
|
||
const bid = { | ||
native: { | ||
title: 'Native Creative', | ||
body: 'Cool description great stuff', | ||
cta: 'Do it', | ||
sponsoredBy: 'AppNexus', | ||
clickUrl: 'https://www.link.example', | ||
clickTrackers: ['https://tracker.example'], | ||
impressionTrackers: ['https://impression.example'], | ||
} | ||
}; | ||
|
||
describe('native.js', () => { | ||
let triggerPixelStub; | ||
|
||
beforeEach(() => { | ||
triggerPixelStub = sinon.stub(utils, 'triggerPixel'); | ||
}); | ||
|
||
afterEach(() => { | ||
utils.triggerPixel.restore(); | ||
}); | ||
|
||
it('gets native targeting keys', () => { | ||
const targeting = getNativeTargeting(bid); | ||
expect(targeting.hb_native_title).to.equal(bid.native.title); | ||
expect(targeting.hb_native_body).to.equal(bid.native.body); | ||
expect(targeting.hb_native_linkurl).to.equal(bid.native.clickUrl); | ||
}); | ||
|
||
it('fires impression trackers', () => { | ||
fireNativeTrackers({}, bid); | ||
sinon.assert.calledOnce(triggerPixelStub); | ||
sinon.assert.calledWith(triggerPixelStub, bid.native.impressionTrackers[0]); | ||
}); | ||
|
||
it('fires click trackers', () => { | ||
fireNativeTrackers({ action: 'click' }, bid); | ||
sinon.assert.calledOnce(triggerPixelStub); | ||
sinon.assert.calledWith(triggerPixelStub, bid.native.clickTrackers[0]); | ||
}); | ||
}); |