@@ -16,8 +16,7 @@ describe('Hotjar Unit', function() {
1616 var hotjar ;
1717 var customOptions ;
1818 var options = {
19- hjid : 485778 ,
20- hjPlaceholderPolyfill : true
19+ hjid : 485778
2120 } ;
2221
2322 beforeEach ( function ( ) {
@@ -28,8 +27,7 @@ describe('Hotjar Unit', function() {
2827 analytics . add ( hotjar ) ;
2928
3029 customOptions = {
31- hjid : 485778 ,
32- hjPlaceholderPolyfill : false
30+ hjid : 485778
3331 } ;
3432 } ) ;
3533
@@ -46,7 +44,6 @@ describe('Hotjar Unit', function() {
4644 Hotjar ,
4745 Integration ( 'Hotjar' )
4846 . option ( 'hjid' , null )
49- . option ( 'hjPlaceholderPolyfill' , true )
5047 ) ;
5148 } ) ;
5249
@@ -68,8 +65,7 @@ describe('Hotjar Unit', function() {
6865 hotjar . initialize ( ) ;
6966 analytics . deepEqual ( window . _hjSettings , {
7067 hjid : options . hjid ,
71- hjsv : 6 ,
72- hjPlaceholderPolyfill : true
68+ hjsv : 6
7369 } ) ;
7470 analytics . assert ( typeof window . hj === 'function' ) ;
7571 } ) ;
@@ -79,11 +75,6 @@ describe('Hotjar Unit', function() {
7975 testInvalidInitialize ( customOptions ) ;
8076 } ) ;
8177
82- it ( 'should reject an invalid hjPlaceholderPolyfill boolean' , function ( ) {
83- customOptions . hjPlaceholderPolyfill = 1 ;
84- testInvalidInitialize ( customOptions ) ;
85- } ) ;
86-
8778 function testInvalidInitialize ( invalidOptions ) {
8879 hotjar . options = invalidOptions ;
8980 analytics . stub ( hotjar , 'ready' ) ;
@@ -124,5 +115,39 @@ describe('Hotjar Unit', function() {
124115 analytics . didNotCall ( window . hj ) ;
125116 } ) ;
126117 } ) ;
118+
119+ describe ( '#track' , function ( ) {
120+ beforeEach ( function ( ) {
121+ analytics . stub ( hotjar , 'debug' ) ;
122+ analytics . stub ( window , 'hj' ) ;
123+ } ) ;
124+
125+ afterEach ( function ( ) {
126+ analytics . reset ( ) ;
127+ } ) ;
128+
129+ it ( 'should send event without properties' , function ( ) {
130+ analytics . stub ( window , 'hj' ) ;
131+ var event = 'the_event' ;
132+ analytics . track ( event ) ;
133+ analytics . called ( window . hj , 'event' , event ) ;
134+ } ) ;
135+
136+ it ( 'should send event with properties' , function ( ) {
137+ analytics . stub ( window , 'hj' ) ;
138+ var event = 'the_event' ;
139+ var properties = { a : 'a' , b : 'b' , c : [ ] } ;
140+ analytics . track ( event , properties ) ;
141+ analytics . called ( window . hj , 'event' , event , properties ) ;
142+ } ) ;
143+
144+ it ( 'should not send nameless event' , function ( ) {
145+ var properties = { a : 'a' , b : 'b' , c : [ ] } ;
146+ analytics . track ( undefined , properties ) ;
147+
148+ analytics . called ( hotjar . debug , 'event name is required' ) ;
149+ analytics . didNotCall ( window . hj ) ;
150+ } ) ;
151+ } ) ;
127152 } ) ;
128153} ) ;
0 commit comments