forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appnexusKeywords_spec.js
70 lines (65 loc) · 1.8 KB
/
appnexusKeywords_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
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
import {transformBidderParamKeywords} from '../../libraries/appnexusUtils/anKeywords.js';
import {expect} from 'chai/index.js';
import * as utils from '../../src/utils.js';
describe('transformBidderParamKeywords', function () {
it('returns an array of objects when keyvalue is an array', function () {
let keywords = {
genre: ['rock', 'pop']
};
let result = transformBidderParamKeywords(keywords);
expect(result).to.deep.equal([{
key: 'genre',
value: ['rock', 'pop']
}]);
});
it('returns an array of objects when keyvalue is a string', function () {
let keywords = {
genre: 'opera'
};
let result = transformBidderParamKeywords(keywords);
expect(result).to.deep.equal([{
key: 'genre',
value: ['opera']
}]);
});
it('returns an array of objects when keyvalue is a number', function () {
let keywords = {
age: 15
};
let result = transformBidderParamKeywords(keywords);
expect(result).to.deep.equal([{
key: 'age',
value: ['15']
}]);
});
it('returns an array of objects when using multiple keys with values of differing types', function () {
let keywords = {
genre: 'classical',
mix: ['1', 2, '3', 4],
age: 10
};
let result = transformBidderParamKeywords(keywords);
expect(result).to.deep.equal([{
key: 'genre',
value: ['classical']
}, {
key: 'mix',
value: ['1', '2', '3', '4']
}, {
key: 'age',
value: ['10']
}]);
});
it('returns an array of objects when the keyvalue uses an empty string', function () {
let keywords = {
test: [''],
test2: ''
};
let result = transformBidderParamKeywords(keywords);
expect(result).to.deep.equal([{
key: 'test',
}, {
key: 'test2',
}]);
});
});