forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadqueryIdSystem_spec.js
More file actions
83 lines (75 loc) · 2.52 KB
/
adqueryIdSystem_spec.js
File metadata and controls
83 lines (75 loc) · 2.52 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import {adqueryIdSubmodule, storage} from 'modules/adqueryIdSystem.js';
import {server} from 'test/mocks/xhr.js';
import sinon from 'sinon';
import {attachIdSystem} from '../../../modules/userId/index.js';
import {createEidsArray} from '../../../modules/userId/eids.js';
import {expect} from 'chai/index.mjs';
const config = {
storage: {
type: 'html5',
},
};
describe('AdqueryIdSystem', function () {
describe('qid submodule', () => {
it('should expose a "name" property containing qid', () => {
expect(adqueryIdSubmodule.name).to.equal('qid');
});
it('should expose a "gvlid" property containing the GVL ID 902', () => {
expect(adqueryIdSubmodule.gvlid).to.equal(902);
});
});
describe('getId', function () {
let getDataFromLocalStorageStub;
beforeEach(function () {
getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
});
afterEach(function () {
getDataFromLocalStorageStub.restore();
});
it('gets a adqueryId', function () {
const config = {
params: {}
};
const callbackSpy = sinon.spy();
const callback = adqueryIdSubmodule.getId(config).callback;
callback(callbackSpy);
const request = server.requests[0];
expect(request.url).to.contain(`https://bidder.adquery.io/prebid/qid`);
request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ qid: 'qid_string' }));
expect(callbackSpy.lastCall.lastArg).to.deep.equal('qid_string');
});
it('allows configurable id url', function () {
const config = {
params: {
url: 'https://bidder2.adquery.io'
}
};
const callbackSpy = sinon.spy();
const callback = adqueryIdSubmodule.getId(config).callback;
callback(callbackSpy);
const request = server.requests[0];
expect(request.url).to.contains('https://bidder2.adquery.io');
request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ qid: 'testqid' }));
expect(callbackSpy.lastCall.lastArg).to.deep.equal('testqid');
});
});
describe('eid', () => {
before(() => {
attachIdSystem(adqueryIdSubmodule);
});
it('qid', function() {
const userId = {
qid: 'some-random-id-value'
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'adquery.io',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
});
});
})
});