forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmergeConfig_regression_spec.js
More file actions
59 lines (50 loc) · 1.62 KB
/
Copy pathmergeConfig_regression_spec.js
File metadata and controls
59 lines (50 loc) · 1.62 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
import { expect } from 'chai';
import { newConfig } from 'src/config.js';
describe('mergeConfig priceGranularity regression', function () {
let config;
let getConfig;
let mergeConfig;
beforeEach(function () {
config = newConfig();
getConfig = config.getAnyConfig;
mergeConfig = config.mergeConfig;
});
it('should overwrite string priceGranularity with custom object via mergeConfig', function () {
// 1. Initial state is the default string 'medium'
expect(getConfig('priceGranularity')).to.equal('medium');
// 2. Attempt to apply a custom granularity object via mergeConfig
const customGranularity = {
buckets: [{
precision: 2,
min: 0,
max: 5,
increment: 0.01
}]
};
mergeConfig({
priceGranularity: customGranularity
});
// 3. Verify it changed to 'custom' (internal state)
// In Prebid, when a custom object is set to priceGranularity,
// the property itself becomes 'custom' and the buckets are stored in customPriceBucket.
expect(getConfig('priceGranularity')).to.equal('custom');
expect(getConfig('customPriceBucket')).to.deep.equal(customGranularity);
});
it('should correctly merge mediaTypePriceGranularity with custom objects', function () {
const customGranularity = {
buckets: [{
precision: 2,
min: 0,
max: 5,
increment: 0.01
}]
};
mergeConfig({
mediaTypePriceGranularity: {
video: customGranularity
}
});
const result = getConfig('mediaTypePriceGranularity');
expect(result.video).to.deep.equal(customGranularity);
});
});