@@ -26,6 +26,11 @@ import configValidator from './utils/config_validator';
26
26
import eventProcessorConfigValidator from './utils/event_processor_config_validator' ;
27
27
import OptimizelyUserContext from './optimizely_user_context' ;
28
28
import { LOG_MESSAGES } from './utils/enums' ;
29
+ import { OdpSegmentManager } from './core/odp/odp_segment_manager' ;
30
+ import { BrowserLRUCache } from './utils/lru_cache' ;
31
+ import { OdpConfig } from './core/odp/odp_config' ;
32
+ import { OdpSegmentApiManager } from './core/odp/odp_segment_api_manager' ;
33
+ import { BrowserRequestHandler } from './utils/http_request_handler/browser_request_handler' ;
29
34
30
35
var LocalStoragePendingEventsDispatcher = eventProcessor . LocalStoragePendingEventsDispatcher ;
31
36
@@ -637,37 +642,103 @@ describe('javascript-sdk (Browser)', function() {
637
642
sinon . assert . calledWith ( logger . log , optimizelyFactory . enums . LOG_LEVEL . INFO , LOG_MESSAGES . ODP_DISABLED ) ;
638
643
} ) ;
639
644
640
- it ( 'should accept a custom cache size' , ( ) => {
641
- // TODO
642
- } )
645
+ it ( 'should accept a valid custom cache size' , ( ) => {
646
+ const client = optimizelyFactory . createInstance ( {
647
+ datafile : testData . getTestProjectConfigWithFeatures ( ) ,
648
+ errorHandler : fakeErrorHandler ,
649
+ eventDispatcher : fakeEventDispatcher ,
650
+ eventBatchSize : null ,
651
+ logger : logger ,
652
+ odpServiceConfig : {
653
+ odpSegmentsCacheSize : 10 ,
654
+ } ,
655
+ } ) ;
656
+
657
+ sinon . assert . calledWith (
658
+ logger . log ,
659
+ optimizelyFactory . enums . LOG_LEVEL . DEBUG ,
660
+ 'Provisioning cache with maxSize of 10'
661
+ ) ;
662
+ } ) ;
643
663
644
664
it ( 'should accept a custom cache timeout' , ( ) => {
645
- // TODO
646
- } )
665
+ const client = optimizelyFactory . createInstance ( {
666
+ datafile : testData . getTestProjectConfigWithFeatures ( ) ,
667
+ errorHandler : fakeErrorHandler ,
668
+ eventDispatcher : fakeEventDispatcher ,
669
+ eventBatchSize : null ,
670
+ logger : logger ,
671
+ odpServiceConfig : {
672
+ odpSegmentsCacheTimeout : 10 ,
673
+ } ,
674
+ } ) ;
675
+
676
+ sinon . assert . calledWith (
677
+ logger . log ,
678
+ optimizelyFactory . enums . LOG_LEVEL . DEBUG ,
679
+ 'Provisioning cache with timeout of 10'
680
+ ) ;
681
+ } ) ;
647
682
648
683
it ( 'should accept both a custom cache size and timeout' , ( ) => {
649
- // TODO
650
- } )
684
+ const client = optimizelyFactory . createInstance ( {
685
+ datafile : testData . getTestProjectConfigWithFeatures ( ) ,
686
+ errorHandler : fakeErrorHandler ,
687
+ eventDispatcher : fakeEventDispatcher ,
688
+ eventBatchSize : null ,
689
+ logger : logger ,
690
+ odpServiceConfig : {
691
+ odpSegmentsCacheSize : 10 ,
692
+ odpSegmentsCacheTimeout : 10 ,
693
+ } ,
694
+ } ) ;
651
695
652
- it ( 'should accept a valid custom cache' , ( ) => {
653
- // TODO
654
- } )
696
+ sinon . assert . calledWith (
697
+ logger . log ,
698
+ optimizelyFactory . enums . LOG_LEVEL . DEBUG ,
699
+ 'Provisioning cache with maxSize of 10'
700
+ ) ;
701
+
702
+ sinon . assert . calledWith (
703
+ logger . log ,
704
+ optimizelyFactory . enums . LOG_LEVEL . DEBUG ,
705
+ 'Provisioning cache with timeout of 10'
706
+ ) ;
707
+ } ) ;
655
708
656
709
it ( 'should accept a valid custom odp segment manager' , ( ) => {
710
+ const segmentManager = new OdpSegmentManager (
711
+ new OdpConfig ( ) ,
712
+ new BrowserLRUCache ( ) ,
713
+ new OdpSegmentApiManager ( new BrowserRequestHandler ( ) , logger ) ,
714
+ logger
715
+ ) ;
716
+
717
+ const client = optimizelyFactory . createInstance ( {
718
+ datafile : testData . getTestProjectConfigWithFeatures ( ) ,
719
+ errorHandler : fakeErrorHandler ,
720
+ eventDispatcher : fakeEventDispatcher ,
721
+ eventBatchSize : null ,
722
+ logger : logger ,
723
+ odpServiceConfig : {
724
+ odpSegmentManager : segmentManager ,
725
+ } ,
726
+ } ) ;
727
+
657
728
// TODO
658
- } )
729
+ } ) ;
659
730
660
731
it ( 'should accept a valid custom odp event manager' , ( ) => {
661
732
// TODO
662
- } )
733
+ } ) ;
663
734
664
735
it ( 'should send an odp event with sendOdpEvent' , ( ) => {
665
736
// TODO
666
- } )
737
+ } ) ;
667
738
668
739
it ( 'should log an error when attempting to send an odp event when odp is disabled' , ( ) => {
669
740
// TODO
670
- } )
741
+ } ) ;
671
742
} ) ;
672
743
} ) ;
673
744
} ) ;
0 commit comments