forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaaxBlockmeter_spec.js
More file actions
58 lines (48 loc) · 1.73 KB
/
aaxBlockmeter_spec.js
File metadata and controls
58 lines (48 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {aaxBlockmeterRtdModule} from '../../../modules/aaxBlockmeterRtdProvider.js';
import * as sinon from 'sinon';
import {assert} from 'chai';
let sandbox;
let getTargetingDataSpy;
const config = {
dataProviders: [{
'name': 'aaxBlockmeter',
'params': {
'pub': 'publisher_id',
}
}]
};
describe('aaxBlockmeter realtime module', function () {
beforeEach(function () {
sandbox = sinon.createSandbox();
window.aax = window.aax || {};
window.aax.getTargetingData = getTargetingDataSpy = sandbox.spy();
});
afterEach(function () {
sandbox.restore();
window.aax = {};
});
it('init should return false when config is empty', function () {
assert.equal(aaxBlockmeterRtdModule.init({}), false);
});
it('init should return false when config.params id is empty', function () {
assert.equal(aaxBlockmeterRtdModule.init({params: {}}), false);
});
it('init should return true when config.params.pub is not string', function () {
assert.equal(aaxBlockmeterRtdModule.init({params: {pub: 12345}}), false);
});
it('init should return true when config.params.pub id is passed and is string typed', function () {
assert.equal(aaxBlockmeterRtdModule.init(config.dataProviders[0]), true);
});
describe('getTargetingData should work correctly', function () {
it('should return ad unit codes when ad units are present', function () {
const codes = ['code1', 'code2'];
assert.deepEqual(aaxBlockmeterRtdModule.getTargetingData(codes), {
code1: {'atk': 'code1'},
code2: {'atk': 'code2'},
});
});
it('should call aax.getTargetingData if loaded', function () {
aaxBlockmeterRtdModule.getTargetingData([], config.dataProviders[0], null);
});
});
});