@@ -215,9 +215,14 @@ describe('EppoJSClient E2E test', () => {
215
215
expectedAssignments,
216
216
} : IAssignmentTestCase ) => {
217
217
console . log ( `---- Test Case for ${ experiment } Experiment ----` ) ;
218
- const assignments = subjectsWithAttributes
219
- ? getAssignmentsWithSubjectAttributes ( subjectsWithAttributes , experiment , valueType )
220
- : getAssignments ( subjects , experiment , valueType ) ;
218
+
219
+ const assignments = getAssignmentsWithSubjectAttributes (
220
+ subjectsWithAttributes
221
+ ? subjectsWithAttributes
222
+ : subjects . map ( ( subject ) => ( { subjectKey : subject } ) ) ,
223
+ experiment ,
224
+ valueType ,
225
+ ) ;
221
226
222
227
switch ( valueType ) {
223
228
case ValueTestType . BoolType : {
@@ -249,43 +254,11 @@ describe('EppoJSClient E2E test', () => {
249
254
} ) ;
250
255
} ) ;
251
256
252
- function getAssignments (
253
- subjects : string [ ] ,
254
- experiment : string ,
255
- valueTestType : ValueTestType = ValueTestType . StringType ,
256
- ) : ( EppoValue | null ) [ ] {
257
- return subjects . map ( ( subjectKey ) => {
258
- switch ( valueTestType ) {
259
- case ValueTestType . BoolType : {
260
- const ba = globalClient . getBoolAssignment ( subjectKey , experiment ) ;
261
- if ( ba === null ) return null ;
262
- return EppoValue . Bool ( ba ) ;
263
- }
264
- case ValueTestType . NumericType : {
265
- const na = globalClient . getNumericAssignment ( subjectKey , experiment ) ;
266
- if ( na === null ) return null ;
267
- return EppoValue . Numeric ( na ) ;
268
- }
269
- case ValueTestType . StringType : {
270
- const sa = globalClient . getStringAssignment ( subjectKey , experiment ) ;
271
- if ( sa === null ) return null ;
272
- return EppoValue . String ( sa ) ;
273
- }
274
- case ValueTestType . JSONType : {
275
- const sa = globalClient . getJSONStringAssignment ( subjectKey , experiment ) ;
276
- const oa = globalClient . getParsedJSONAssignment ( subjectKey , experiment ) ;
277
- if ( oa == null || sa === null ) return null ;
278
- return EppoValue . JSON ( sa , oa ) ;
279
- }
280
- }
281
- } ) ;
282
- }
283
-
284
257
function getAssignmentsWithSubjectAttributes (
285
258
subjectsWithAttributes : {
286
259
subjectKey : string ;
287
260
// eslint-disable-next-line @typescript-eslint/no-explicit-any
288
- subjectAttributes : Record < string , any > ;
261
+ subjectAttributes ? : Record < string , any > ;
289
262
} [ ] ,
290
263
experiment : string ,
291
264
valueTestType : ValueTestType = ValueTestType . StringType ,
0 commit comments