@@ -11,7 +11,9 @@ import EppoClient from './eppo-client';
11
11
12
12
describe ( 'EppoClient Precomputed Mode' , ( ) => {
13
13
// Read both configurations for test reference
14
- const precomputedConfigurationWire = readMockConfigurationWireResponse ( MOCK_PRECOMPUTED_WIRE_FILE ) ;
14
+ const precomputedConfigurationWire = readMockConfigurationWireResponse (
15
+ MOCK_PRECOMPUTED_WIRE_FILE ,
16
+ ) ;
15
17
const initialConfiguration = Configuration . fromString ( precomputedConfigurationWire ) ;
16
18
17
19
let client : EppoClient ;
@@ -21,7 +23,7 @@ describe('EppoClient Precomputed Mode', () => {
21
23
beforeEach ( ( ) => {
22
24
mockAssignmentLogger = { logAssignment : jest . fn ( ) } as jest . Mocked < IAssignmentLogger > ;
23
25
mockBanditLogger = { logBanditAction : jest . fn ( ) } as jest . Mocked < IBanditLogger > ;
24
-
26
+
25
27
// Create EppoClient with precomputed configuration
26
28
client = new EppoClient ( {
27
29
sdkKey : 'test-key' ,
@@ -33,7 +35,7 @@ describe('EppoClient Precomputed Mode', () => {
33
35
enablePolling : false ,
34
36
} ,
35
37
} ) ;
36
-
38
+
37
39
client . setAssignmentLogger ( mockAssignmentLogger ) ;
38
40
client . setBanditLogger ( mockBanditLogger ) ;
39
41
} ) ;
@@ -67,29 +69,40 @@ describe('EppoClient Precomputed Mode', () => {
67
69
expect ( result ) . toEqual ( { key : 'value' , number : 123 } ) ;
68
70
expect ( mockAssignmentLogger . logAssignment ) . toHaveBeenCalledTimes ( 1 ) ;
69
71
} ) ;
70
-
72
+
71
73
it ( 'correctly evaluates flag with extra logging' , ( ) => {
72
- const result = client . getStringAssignment ( 'string-flag-with-extra-logging' , 'test-subject-key' , { } , 'default' ) ;
74
+ const result = client . getStringAssignment (
75
+ 'string-flag-with-extra-logging' ,
76
+ 'test-subject-key' ,
77
+ { } ,
78
+ 'default' ,
79
+ ) ;
73
80
expect ( result ) . toBe ( 'red' ) ;
74
81
expect ( mockAssignmentLogger . logAssignment ) . toHaveBeenCalledTimes ( 1 ) ;
75
82
} ) ;
76
83
77
84
it ( 'logs bandit evaluation for flag with bandit data' , ( ) => {
78
85
const banditActions = {
79
- ' show_red_button' : {
86
+ show_red_button : {
80
87
expectedConversion : 0.23 ,
81
88
expectedRevenue : 15.75 ,
82
89
category : 'promotion' ,
83
- placement : 'home_screen'
84
- }
90
+ placement : 'home_screen' ,
91
+ } ,
85
92
} ;
86
-
87
- const result = client . getBanditAction ( 'string-flag' , 'test-subject-key' , { } , banditActions , 'default' ) ;
88
-
93
+
94
+ const result = client . getBanditAction (
95
+ 'string-flag' ,
96
+ 'test-subject-key' ,
97
+ { } ,
98
+ banditActions ,
99
+ 'default' ,
100
+ ) ;
101
+
89
102
expect ( result . variation ) . toBe ( 'red' ) ;
90
103
expect ( result . action ) . toBe ( 'show_red_button' ) ;
91
104
expect ( mockBanditLogger . logBanditAction ) . toHaveBeenCalledTimes ( 1 ) ;
92
-
105
+
93
106
const call = mockBanditLogger . logBanditAction . mock . calls [ 0 ] [ 0 ] ;
94
107
expect ( call . bandit ) . toBe ( 'recommendation-model-v1' ) ;
95
108
expect ( call . action ) . toBe ( 'show_red_button' ) ;
@@ -99,27 +112,42 @@ describe('EppoClient Precomputed Mode', () => {
99
112
} ) ;
100
113
101
114
it ( 'returns default values for nonexistent flags' , ( ) => {
102
- const stringResult = client . getStringAssignment ( 'nonexistent-flag' , 'test-subject-key' , { } , 'default-string' ) ;
115
+ const stringResult = client . getStringAssignment (
116
+ 'nonexistent-flag' ,
117
+ 'test-subject-key' ,
118
+ { } ,
119
+ 'default-string' ,
120
+ ) ;
103
121
expect ( stringResult ) . toBe ( 'default-string' ) ;
104
-
105
- const boolResult = client . getBooleanAssignment ( 'nonexistent-flag' , 'test-subject-key' , { } , true ) ;
122
+
123
+ const boolResult = client . getBooleanAssignment (
124
+ 'nonexistent-flag' ,
125
+ 'test-subject-key' ,
126
+ { } ,
127
+ true ,
128
+ ) ;
106
129
expect ( boolResult ) . toBe ( true ) ;
107
-
130
+
108
131
const intResult = client . getIntegerAssignment ( 'nonexistent-flag' , 'test-subject-key' , { } , 100 ) ;
109
132
expect ( intResult ) . toBe ( 100 ) ;
110
133
} ) ;
111
134
112
135
it ( 'correctly handles assignment details' , ( ) => {
113
- const details = client . getStringAssignmentDetails ( 'string-flag' , 'test-subject-key' , { } , 'default' ) ;
114
-
136
+ const details = client . getStringAssignmentDetails (
137
+ 'string-flag' ,
138
+ 'test-subject-key' ,
139
+ { } ,
140
+ 'default' ,
141
+ ) ;
142
+
115
143
expect ( details . variation ) . toBe ( 'red' ) ;
116
144
expect ( details . evaluationDetails . variationKey ) . toBe ( 'variation-123' ) ;
117
-
145
+
118
146
// Assignment should be logged
119
147
expect ( mockAssignmentLogger . logAssignment ) . toHaveBeenCalledTimes ( 1 ) ;
120
148
const call = mockAssignmentLogger . logAssignment . mock . calls [ 0 ] [ 0 ] ;
121
149
expect ( call . allocation ) . toBe ( 'allocation-123' ) ;
122
150
expect ( call . featureFlag ) . toBe ( 'string-flag' ) ;
123
151
expect ( call . subject ) . toBe ( 'test-subject-key' ) ;
124
152
} ) ;
125
- } ) ;
153
+ } ) ;
0 commit comments