@@ -16,7 +16,8 @@ describe('Facebook Pixel', function() {
1616 standardEvent : 'standard'
1717 } ,
1818 pixelId : '123123123' ,
19- agent : 'test'
19+ agent : 'test' ,
20+ initWithExistingTraits : false
2021 } ;
2122
2223 beforeEach ( function ( ) {
@@ -47,7 +48,6 @@ describe('Facebook Pixel', function() {
4748 describe ( 'before loading' , function ( ) {
4849 beforeEach ( function ( ) {
4950 analytics . stub ( facebookPixel , 'load' ) ;
50- analytics . initialize ( ) ;
5151 } ) ;
5252
5353 afterEach ( function ( ) {
@@ -56,21 +56,48 @@ describe('Facebook Pixel', function() {
5656
5757 describe ( '#initialize' , function ( ) {
5858 it ( 'should call load on initialize' , function ( ) {
59+ analytics . initialize ( ) ;
5960 analytics . called ( facebookPixel . load ) ;
6061 } ) ;
6162
6263 it ( 'should set the correct agent and version' , function ( ) {
64+ analytics . initialize ( ) ;
6365 analytics . equal ( window . fbq . agent , 'test' ) ;
6466 analytics . equal ( window . fbq . version , '2.0' ) ;
6567 } ) ;
6668
6769 it ( 'should set disablePushState to true' , function ( ) {
70+ analytics . initialize ( ) ;
6871 analytics . equal ( window . fbq . disablePushState , true ) ;
6972 } ) ;
7073
7174 it ( 'should create fbq object' , function ( ) {
75+ analytics . initialize ( ) ;
7276 analytics . assert ( window . fbq instanceof Function ) ;
7377 } ) ;
78+
79+ before ( function ( ) {
80+ options . initWithExistingTraits = true ;
81+ } ) ;
82+
83+ after ( function ( ) {
84+ options . initWithExistingTraits = false ;
85+ } ) ;
86+
87+ it ( 'should call init with the user\'s traits if option enabled' , function ( ) {
88+ var payload = {
89+ ct : 'emerald' ,
90+ db : '19910113' ,
91+ fn : 'ash' ,
92+ ge : 'm' ,
93+ ln : 'ketchum' ,
94+ st : 'kanto' ,
95+ zp : 123456
96+ } ;
97+ analytics . stub ( window , 'fbq' ) ;
98+ analytics . initialize ( ) ;
99+ analytics . called ( window . fbq , 'init' , options . pixelId , payload ) ;
100+ } ) ;
74101 } ) ;
75102 } ) ;
76103
@@ -83,23 +110,6 @@ describe('Facebook Pixel', function() {
83110 it ( 'should load' , function ( done ) {
84111 analytics . load ( facebookPixel , done ) ;
85112 } ) ;
86-
87- it ( 'should call init with the user\'s traits' , function ( ) {
88- analytics . called (
89- window . fbq ,
90- 'init' ,
91- options . pixelId ,
92- {
93- ct : 'emerald' ,
94- db : '19910113' ,
95- fn : 'ash' ,
96- ge : 'm' ,
97- ln : 'ketchum' ,
98- st : 'kanto' ,
99- zp : 123456
100- }
101- ) ;
102- } ) ;
103113 } ) ;
104114
105115 describe ( 'after loading' , function ( ) {
0 commit comments