forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadloader_spec.js
42 lines (35 loc) · 1.37 KB
/
adloader_spec.js
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
import * as utils from 'src/utils.js';
import * as adLoader from 'test/mocks/adloaderStub.js';
describe('adLoader', function () {
let utilsinsertElementStub;
let utilsLogErrorStub;
beforeEach(function () {
utilsinsertElementStub = sinon.stub(utils, 'insertElement');
utilsLogErrorStub = sinon.stub(utils, 'logError');
});
afterEach(function () {
utilsinsertElementStub.restore();
utilsLogErrorStub.restore();
});
describe('loadExternalScript', function () {
it('requires moduleCode to be included on the request', function () {
adLoader.loadExternalScript('someURL');
expect(utilsLogErrorStub.called).to.be.true;
expect(utilsinsertElementStub.called).to.be.false;
});
it('only allows whitelisted vendors to load scripts', function () {
adLoader.loadExternalScript('someURL', 'criteo');
expect(utilsLogErrorStub.called).to.be.false;
expect(utilsinsertElementStub.called).to.be.true;
});
it('should not load cached script again', function() {
adLoader.loadExternalScript('someURL', 'criteo');
expect(utilsinsertElementStub.called).to.be.false;
});
it('callback function can be passed to the function', function() {
let callback = function() {};
adLoader.loadExternalScript('someURL1', 'criteo', callback);
expect(utilsinsertElementStub.called).to.be.true;
});
});
});