@@ -2,7 +2,13 @@ import * as fs from 'fs';
22
33import { isEqual } from 'lodash' ;
44
5- import { AttributeType , ContextAttributes , IAssignmentDetails , VariationType } from '../src' ;
5+ import {
6+ AttributeType ,
7+ ContextAttributes ,
8+ IAssignmentDetails ,
9+ Variation ,
10+ VariationType ,
11+ } from '../src' ;
612import { IFlagEvaluationDetails } from '../src/flag-evaluation-details-builder' ;
713import { IBanditParametersResponse , IUniversalFlagConfigResponse } from '../src/http-client' ;
814
@@ -20,17 +26,19 @@ const MOCK_PRECOMPUTED_FILENAME = 'precomputed-v1';
2026export const MOCK_PRECOMPUTED_WIRE_FILE = `${ MOCK_PRECOMPUTED_FILENAME } .json` ;
2127export const MOCK_DEOBFUSCATED_PRECOMPUTED_RESPONSE_FILE = `${ MOCK_PRECOMPUTED_FILENAME } -deobfuscated.json` ;
2228
29+ export type AssignmentVariationValue = Variation [ 'value' ] | object ;
30+
2331export interface SubjectTestCase {
2432 subjectKey : string ;
2533 subjectAttributes : Record < string , AttributeType > ;
26- assignment : string | number | boolean | object ;
34+ assignment : AssignmentVariationValue ;
2735 evaluationDetails : IFlagEvaluationDetails ;
2836}
2937
3038export interface IAssignmentTestCase {
3139 flag : string ;
3240 variationType : VariationType ;
33- defaultValue : string | number | boolean | object ;
41+ defaultValue : AssignmentVariationValue ;
3442 subjects : SubjectTestCase [ ] ;
3543}
3644
@@ -85,21 +93,15 @@ export function getTestAssignments(
8593 flagKey : string ,
8694 subjectKey : string ,
8795 subjectAttributes : Record < string , AttributeType > ,
88- defaultValue : string | number | boolean | object ,
89- ) => never ,
96+ defaultValue : AssignmentVariationValue ,
97+ ) => AssignmentVariationValue | IAssignmentDetails < AssignmentVariationValue > ,
9098) : {
9199 subject : SubjectTestCase ;
92- assignment :
93- | string
94- | boolean
95- | number
96- | null
97- | object
98- | IAssignmentDetails < typeof testCase . defaultValue > ;
100+ assignment : AssignmentVariationValue | IAssignmentDetails < AssignmentVariationValue > ;
99101} [ ] {
100102 const assignments : {
101103 subject : SubjectTestCase ;
102- assignment : string | boolean | number | null | object ;
104+ assignment : AssignmentVariationValue ;
103105 } [ ] = [ ] ;
104106 for ( const subject of testCase . subjects ) {
105107 const assignment = assignmentFn (
@@ -121,13 +123,7 @@ const testHelperInstantiationDate = new Date();
121123export function validateTestAssignments (
122124 assignments : {
123125 subject : SubjectTestCase ;
124- assignment :
125- | string
126- | boolean
127- | number
128- | object
129- | null
130- | IAssignmentDetails < string | boolean | number | object > ;
126+ assignment : AssignmentVariationValue | IAssignmentDetails < AssignmentVariationValue > ;
131127 } [ ] ,
132128 flag : string ,
133129 withDetails : boolean ,
0 commit comments