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