forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 2
/
adloader_spec.js
31 lines (26 loc) · 977 Bytes
/
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
import * as utils from 'src/utils';
import * as adLoader from 'test/mocks/adloaderStub';
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;
});
});
});