@@ -16,6 +16,19 @@ const bid = {
16
16
}
17
17
} ;
18
18
19
+ const bidWithUndefinedFields = {
20
+ native : {
21
+ title : 'Native Creative' ,
22
+ body : undefined ,
23
+ cta : undefined ,
24
+ sponsoredBy : 'AppNexus' ,
25
+ clickUrl : 'https://www.link.example' ,
26
+ clickTrackers : [ 'https://tracker.example' ] ,
27
+ impressionTrackers : [ 'https://impression.example' ] ,
28
+ javascriptTrackers : '<script src=\"http://www.foobar.js\"></script>'
29
+ }
30
+ } ;
31
+
19
32
describe ( 'native.js' , function ( ) {
20
33
let triggerPixelStub ;
21
34
let insertHtmlIntoIframeStub ;
@@ -37,6 +50,16 @@ describe('native.js', function () {
37
50
expect ( targeting [ CONSTANTS . NATIVE_KEYS . clickUrl ] ) . to . equal ( bid . native . clickUrl ) ;
38
51
} ) ;
39
52
53
+ it ( 'should only include native targeting keys with values' , function ( ) {
54
+ const targeting = getNativeTargeting ( bidWithUndefinedFields ) ;
55
+
56
+ expect ( Object . keys ( targeting ) ) . to . deep . equal ( [
57
+ CONSTANTS . NATIVE_KEYS . title ,
58
+ CONSTANTS . NATIVE_KEYS . sponsoredBy ,
59
+ CONSTANTS . NATIVE_KEYS . clickUrl
60
+ ] ) ;
61
+ } ) ;
62
+
40
63
it ( 'fires impression trackers' , function ( ) {
41
64
fireNativeTrackers ( { } , bid ) ;
42
65
sinon . assert . calledOnce ( triggerPixelStub ) ;
0 commit comments