@@ -2659,6 +2659,7 @@ describe('lib/optimizely', function() {
26592659 } ) ;
26602660
26612661 describe ( 'when the variation is toggled OFF' , function ( ) {
2662+ var result ;
26622663 beforeEach ( function ( ) {
26632664 var experiment = optlyInstance . configObj . experimentKeyMap . test_shared_feature ;
26642665 var variation = experiment . variations [ 1 ] ;
@@ -2667,10 +2668,10 @@ describe('lib/optimizely', function() {
26672668 variation : variation ,
26682669 decisionSource : DECISION_SOURCES . EXPERIMENT ,
26692670 } ) ;
2671+ result = optlyInstance . isFeatureEnabled ( 'shared_feature' , 'user1' , attributes ) ;
26702672 } ) ;
26712673
26722674 it ( 'should return false' , function ( ) {
2673- var result = optlyInstance . isFeatureEnabled ( 'shared_feature' , 'user1' , attributes ) ;
26742675 assert . strictEqual ( result , false ) ;
26752676 sinon . assert . calledOnce ( optlyInstance . decisionService . getVariationForFeature ) ;
26762677 var feature = optlyInstance . configObj . featureKeyMap . shared_feature ;
@@ -2681,6 +2682,62 @@ describe('lib/optimizely', function() {
26812682 attributes
26822683 ) ;
26832684 } ) ;
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+ } ) ;
26842741 } ) ;
26852742
26862743 describe ( 'when the variation is missing the toggle' , function ( ) {
0 commit comments