@@ -2659,6 +2659,7 @@ describe('lib/optimizely', function() {
2659
2659
} ) ;
2660
2660
2661
2661
describe ( 'when the variation is toggled OFF' , function ( ) {
2662
+ var result ;
2662
2663
beforeEach ( function ( ) {
2663
2664
var experiment = optlyInstance . configObj . experimentKeyMap . test_shared_feature ;
2664
2665
var variation = experiment . variations [ 1 ] ;
@@ -2667,10 +2668,10 @@ describe('lib/optimizely', function() {
2667
2668
variation : variation ,
2668
2669
decisionSource : DECISION_SOURCES . EXPERIMENT ,
2669
2670
} ) ;
2671
+ result = optlyInstance . isFeatureEnabled ( 'shared_feature' , 'user1' , attributes ) ;
2670
2672
} ) ;
2671
2673
2672
2674
it ( 'should return false' , function ( ) {
2673
- var result = optlyInstance . isFeatureEnabled ( 'shared_feature' , 'user1' , attributes ) ;
2674
2675
assert . strictEqual ( result , false ) ;
2675
2676
sinon . assert . calledOnce ( optlyInstance . decisionService . getVariationForFeature ) ;
2676
2677
var feature = optlyInstance . configObj . featureKeyMap . shared_feature ;
@@ -2681,6 +2682,62 @@ describe('lib/optimizely', function() {
2681
2682
attributes
2682
2683
) ;
2683
2684
} ) ;
2685
+
2686
+ it ( 'should dispatch an impression event' , function ( ) {
2687
+ sinon . assert . calledOnce ( eventDispatcher . dispatchEvent ) ;
2688
+ var expectedImpressionEvent = {
2689
+ 'httpVerb' : 'POST' ,
2690
+ 'url' : 'https://logx.optimizely.com/v1/events' ,
2691
+ 'params' : {
2692
+ 'account_id' : '572018' ,
2693
+ 'project_id' : '594001' ,
2694
+ 'visitors' : [
2695
+ {
2696
+ 'snapshots' : [
2697
+ {
2698
+ 'decisions' : [
2699
+ {
2700
+ 'campaign_id' : '599023' ,
2701
+ 'experiment_id' : '599028' ,
2702
+ 'variation_id' : '599027'
2703
+ }
2704
+ ] ,
2705
+ 'events' : [
2706
+ {
2707
+ 'entity_id' : '599023' ,
2708
+ 'timestamp' : 1509489766569 ,
2709
+ 'key' : 'campaign_activated' ,
2710
+ 'uuid' : 'a68cf1ad-0393-4e18-af87-efe8f01a7c9c'
2711
+ }
2712
+ ]
2713
+ }
2714
+ ] ,
2715
+ 'visitor_id' : 'user1' ,
2716
+ 'attributes' : [
2717
+ {
2718
+ 'entity_id' : '594014' ,
2719
+ 'key' : 'test_attribute' ,
2720
+ 'type' : 'custom' ,
2721
+ 'value' : 'test_value' ,
2722
+ } , {
2723
+ 'entity_id' : '$opt_bot_filtering' ,
2724
+ 'key' : '$opt_bot_filtering' ,
2725
+ 'type' : 'custom' ,
2726
+ 'value' : true ,
2727
+ } ,
2728
+ ] ,
2729
+ }
2730
+ ] ,
2731
+ 'revision' : '35' ,
2732
+ 'client_name' : 'node-sdk' ,
2733
+ 'client_version' : enums . NODE_CLIENT_VERSION ,
2734
+ 'anonymize_ip' : true
2735
+ }
2736
+ } ;
2737
+ var callArgs = eventDispatcher . dispatchEvent . getCalls ( ) [ 0 ] . args ;
2738
+ assert . deepEqual ( callArgs [ 0 ] , expectedImpressionEvent ) ;
2739
+ assert . isFunction ( callArgs [ 1 ] ) ;
2740
+ } ) ;
2684
2741
} ) ;
2685
2742
2686
2743
describe ( 'when the variation is missing the toggle' , function ( ) {
0 commit comments