11/**
2- * Copyright 2024, Optimizely
2+ * Copyright 2024-2025 , Optimizely
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -83,24 +83,8 @@ describe('getBatchEventProcessor', () => {
8383 expect ( MockBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . retryConfig ) . toBe ( undefined ) ;
8484 } ) ;
8585
86- it ( 'uses retry when retryOptions is provided' , ( ) => {
87- const options = {
88- eventDispatcher : getMockEventDispatcher ( ) ,
89- retryOptions : { } ,
90- defaultFlushInterval : 1000 ,
91- defaultBatchSize : 10 ,
92- } ;
93-
94- const processor = getBatchEventProcessor ( options ) ;
95-
96- expect ( Object . is ( processor , MockBatchEventProcessor . mock . instances [ 0 ] ) ) . toBe ( true ) ;
97- const usedRetryConfig = MockBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . retryConfig ;
98- expect ( usedRetryConfig ) . not . toBe ( undefined ) ;
99- expect ( usedRetryConfig ?. backoffProvider ) . not . toBe ( undefined ) ;
100- } ) ;
101-
10286 it ( 'uses the correct maxRetries value when retryOptions is provided' , ( ) => {
103- const options1 = {
87+ const options = {
10488 eventDispatcher : getMockEventDispatcher ( ) ,
10589 defaultFlushInterval : 1000 ,
10690 defaultBatchSize : 10 ,
@@ -109,34 +93,24 @@ describe('getBatchEventProcessor', () => {
10993 } ,
11094 } ;
11195
112- const processor1 = getBatchEventProcessor ( options1 ) ;
113- expect ( Object . is ( processor1 , MockBatchEventProcessor . mock . instances [ 0 ] ) ) . toBe ( true ) ;
96+ const processor = getBatchEventProcessor ( options ) ;
97+ expect ( Object . is ( processor , MockBatchEventProcessor . mock . instances [ 0 ] ) ) . toBe ( true ) ;
11498 expect ( MockBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . retryConfig ?. maxRetries ) . toBe ( 10 ) ;
115-
116- const options2 = {
117- eventDispatcher : getMockEventDispatcher ( ) ,
118- defaultFlushInterval : 1000 ,
119- defaultBatchSize : 10 ,
120- retryOptions : { } ,
121- } ;
122-
123- const processor2 = getBatchEventProcessor ( options2 ) ;
124- expect ( Object . is ( processor2 , MockBatchEventProcessor . mock . instances [ 1 ] ) ) . toBe ( true ) ;
125- expect ( MockBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . retryConfig ) . not . toBe ( undefined ) ;
126- expect ( MockBatchEventProcessor . mock . calls [ 1 ] [ 0 ] . retryConfig ?. maxRetries ) . toBe ( undefined ) ;
12799 } ) ;
128100
129101 it ( 'uses exponential backoff with default parameters when retryOptions is provided without backoff values' , ( ) => {
130102 const options = {
131103 eventDispatcher : getMockEventDispatcher ( ) ,
132104 defaultFlushInterval : 1000 ,
133105 defaultBatchSize : 10 ,
134- retryOptions : { } ,
106+ retryOptions : { maxRetries : 2 } ,
135107 } ;
136108
137109 const processor = getBatchEventProcessor ( options ) ;
138110 expect ( Object . is ( processor , MockBatchEventProcessor . mock . instances [ 0 ] ) ) . toBe ( true ) ;
139111
112+ expect ( MockBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . retryConfig ?. maxRetries ) . toBe ( 2 ) ;
113+
140114 const backoffProvider = MockBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . retryConfig ?. backoffProvider ;
141115 expect ( backoffProvider ) . not . toBe ( undefined ) ;
142116 const backoff = backoffProvider ?.( ) ;
@@ -149,11 +123,14 @@ describe('getBatchEventProcessor', () => {
149123 eventDispatcher : getMockEventDispatcher ( ) ,
150124 defaultFlushInterval : 1000 ,
151125 defaultBatchSize : 10 ,
152- retryOptions : { minBackoff : 1000 , maxBackoff : 2000 } ,
126+ retryOptions : { maxRetries : 2 , minBackoff : 1000 , maxBackoff : 2000 } ,
153127 } ;
154128
155129 const processor = getBatchEventProcessor ( options ) ;
156130 expect ( Object . is ( processor , MockBatchEventProcessor . mock . instances [ 0 ] ) ) . toBe ( true ) ;
131+
132+ expect ( MockBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . retryConfig ?. maxRetries ) . toBe ( 2 ) ;
133+
157134 const backoffProvider = MockBatchEventProcessor . mock . calls [ 0 ] [ 0 ] . retryConfig ?. backoffProvider ;
158135
159136 expect ( backoffProvider ) . not . toBe ( undefined ) ;
0 commit comments