44 evaluateCondition ,
55 castToContextType ,
66} from "../src/evaluation" ;
7- import type { RenderedCondition , RenderedOverride } from "../src/types" ;
7+ import type { Condition , Override } from "../src/types" ;
88import type { ReplaneLogger } from "../src/client-types" ;
99
1010function createSilentLogger ( ) : ReplaneLogger {
@@ -21,7 +21,7 @@ describe("evaluateCondition", () => {
2121
2222 describe ( "equals operator" , ( ) => {
2323 it ( "should match when values are equal" , ( ) => {
24- const condition : RenderedCondition = {
24+ const condition : Condition = {
2525 operator : "equals" ,
2626 property : "env" ,
2727 value : "production" ,
@@ -30,7 +30,7 @@ describe("evaluateCondition", () => {
3030 } ) ;
3131
3232 it ( "should not match when values differ" , ( ) => {
33- const condition : RenderedCondition = {
33+ const condition : Condition = {
3434 operator : "equals" ,
3535 property : "env" ,
3636 value : "production" ,
@@ -39,7 +39,7 @@ describe("evaluateCondition", () => {
3939 } ) ;
4040
4141 it ( "should return unknown when property is missing" , ( ) => {
42- const condition : RenderedCondition = {
42+ const condition : Condition = {
4343 operator : "equals" ,
4444 property : "env" ,
4545 value : "production" ,
@@ -50,7 +50,7 @@ describe("evaluateCondition", () => {
5050
5151 describe ( "in operator" , ( ) => {
5252 it ( "should match when value is in array" , ( ) => {
53- const condition : RenderedCondition = {
53+ const condition : Condition = {
5454 operator : "in" ,
5555 property : "country" ,
5656 value : [ "US" , "CA" , "MX" ] ,
@@ -59,7 +59,7 @@ describe("evaluateCondition", () => {
5959 } ) ;
6060
6161 it ( "should not match when value is not in array" , ( ) => {
62- const condition : RenderedCondition = {
62+ const condition : Condition = {
6363 operator : "in" ,
6464 property : "country" ,
6565 value : [ "US" , "CA" , "MX" ] ,
@@ -70,7 +70,7 @@ describe("evaluateCondition", () => {
7070
7171 describe ( "not_in operator" , ( ) => {
7272 it ( "should match when value is not in array" , ( ) => {
73- const condition : RenderedCondition = {
73+ const condition : Condition = {
7474 operator : "not_in" ,
7575 property : "country" ,
7676 value : [ "US" , "CA" ] ,
@@ -79,7 +79,7 @@ describe("evaluateCondition", () => {
7979 } ) ;
8080
8181 it ( "should not match when value is in array" , ( ) => {
82- const condition : RenderedCondition = {
82+ const condition : Condition = {
8383 operator : "not_in" ,
8484 property : "country" ,
8585 value : [ "US" , "CA" ] ,
@@ -90,7 +90,7 @@ describe("evaluateCondition", () => {
9090
9191 describe ( "comparison operators" , ( ) => {
9292 it ( "should evaluate less_than correctly" , ( ) => {
93- const condition : RenderedCondition = {
93+ const condition : Condition = {
9494 operator : "less_than" ,
9595 property : "age" ,
9696 value : 18 ,
@@ -101,7 +101,7 @@ describe("evaluateCondition", () => {
101101 } ) ;
102102
103103 it ( "should evaluate less_than_or_equal correctly" , ( ) => {
104- const condition : RenderedCondition = {
104+ const condition : Condition = {
105105 operator : "less_than_or_equal" ,
106106 property : "age" ,
107107 value : 18 ,
@@ -112,7 +112,7 @@ describe("evaluateCondition", () => {
112112 } ) ;
113113
114114 it ( "should evaluate greater_than correctly" , ( ) => {
115- const condition : RenderedCondition = {
115+ const condition : Condition = {
116116 operator : "greater_than" ,
117117 property : "score" ,
118118 value : 100 ,
@@ -123,7 +123,7 @@ describe("evaluateCondition", () => {
123123 } ) ;
124124
125125 it ( "should evaluate greater_than_or_equal correctly" , ( ) => {
126- const condition : RenderedCondition = {
126+ const condition : Condition = {
127127 operator : "greater_than_or_equal" ,
128128 property : "score" ,
129129 value : 100 ,
@@ -134,7 +134,7 @@ describe("evaluateCondition", () => {
134134 } ) ;
135135
136136 it ( "should compare strings lexicographically" , ( ) => {
137- const condition : RenderedCondition = {
137+ const condition : Condition = {
138138 operator : "less_than" ,
139139 property : "version" ,
140140 value : "2.0.0" ,
@@ -147,7 +147,7 @@ describe("evaluateCondition", () => {
147147
148148 describe ( "composite conditions" , ( ) => {
149149 it ( "should evaluate and condition correctly" , ( ) => {
150- const condition : RenderedCondition = {
150+ const condition : Condition = {
151151 operator : "and" ,
152152 conditions : [
153153 { operator : "equals" , property : "env" , value : "production" } ,
@@ -166,7 +166,7 @@ describe("evaluateCondition", () => {
166166 } ) ;
167167
168168 it ( "should return unknown for and when any condition is unknown" , ( ) => {
169- const condition : RenderedCondition = {
169+ const condition : Condition = {
170170 operator : "and" ,
171171 conditions : [
172172 { operator : "equals" , property : "env" , value : "production" } ,
@@ -177,7 +177,7 @@ describe("evaluateCondition", () => {
177177 } ) ;
178178
179179 it ( "should return not_matched for and when any condition fails (even with unknown)" , ( ) => {
180- const condition : RenderedCondition = {
180+ const condition : Condition = {
181181 operator : "and" ,
182182 conditions : [
183183 { operator : "equals" , property : "env" , value : "production" } ,
@@ -188,7 +188,7 @@ describe("evaluateCondition", () => {
188188 } ) ;
189189
190190 it ( "should evaluate or condition correctly" , ( ) => {
191- const condition : RenderedCondition = {
191+ const condition : Condition = {
192192 operator : "or" ,
193193 conditions : [
194194 { operator : "equals" , property : "env" , value : "production" } ,
@@ -201,7 +201,7 @@ describe("evaluateCondition", () => {
201201 } ) ;
202202
203203 it ( "should return matched for or when any condition matches (even with unknown)" , ( ) => {
204- const condition : RenderedCondition = {
204+ const condition : Condition = {
205205 operator : "or" ,
206206 conditions : [
207207 { operator : "equals" , property : "env" , value : "production" } ,
@@ -212,7 +212,7 @@ describe("evaluateCondition", () => {
212212 } ) ;
213213
214214 it ( "should evaluate not condition correctly" , ( ) => {
215- const condition : RenderedCondition = {
215+ const condition : Condition = {
216216 operator : "not" ,
217217 condition : { operator : "equals" , property : "env" , value : "production" } ,
218218 } ;
@@ -221,7 +221,7 @@ describe("evaluateCondition", () => {
221221 } ) ;
222222
223223 it ( "should return unknown for not when inner condition is unknown" , ( ) => {
224- const condition : RenderedCondition = {
224+ const condition : Condition = {
225225 operator : "not" ,
226226 condition : { operator : "equals" , property : "missing" , value : "value" } ,
227227 } ;
@@ -231,7 +231,7 @@ describe("evaluateCondition", () => {
231231
232232 describe ( "segmentation operator" , ( ) => {
233233 it ( "should match when user is in 100% segment" , ( ) => {
234- const condition : RenderedCondition = {
234+ const condition : Condition = {
235235 operator : "segmentation" ,
236236 property : "userId" ,
237237 fromPercentage : 0 ,
@@ -242,7 +242,7 @@ describe("evaluateCondition", () => {
242242 } ) ;
243243
244244 it ( "should not match when user is in 0% segment" , ( ) => {
245- const condition : RenderedCondition = {
245+ const condition : Condition = {
246246 operator : "segmentation" ,
247247 property : "userId" ,
248248 fromPercentage : 0 ,
@@ -253,7 +253,7 @@ describe("evaluateCondition", () => {
253253 } ) ;
254254
255255 it ( "should return unknown when property is missing" , ( ) => {
256- const condition : RenderedCondition = {
256+ const condition : Condition = {
257257 operator : "segmentation" ,
258258 property : "userId" ,
259259 fromPercentage : 0 ,
@@ -264,7 +264,7 @@ describe("evaluateCondition", () => {
264264 } ) ;
265265
266266 it ( "should return unknown when property is null" , ( ) => {
267- const condition : RenderedCondition = {
267+ const condition : Condition = {
268268 operator : "segmentation" ,
269269 property : "userId" ,
270270 fromPercentage : 0 ,
@@ -275,7 +275,7 @@ describe("evaluateCondition", () => {
275275 } ) ;
276276
277277 it ( "should be deterministic for same user and seed" , ( ) => {
278- const condition : RenderedCondition = {
278+ const condition : Condition = {
279279 operator : "segmentation" ,
280280 property : "userId" ,
281281 fromPercentage : 0 ,
@@ -288,7 +288,7 @@ describe("evaluateCondition", () => {
288288 } ) ;
289289
290290 it ( "should distribute users across segments" , ( ) => {
291- const condition50 : RenderedCondition = {
291+ const condition50 : Condition = {
292292 operator : "segmentation" ,
293293 property : "userId" ,
294294 fromPercentage : 0 ,
@@ -320,7 +320,7 @@ describe("evaluateOverrides", () => {
320320 } ) ;
321321
322322 it ( "should return base value when no override matches" , ( ) => {
323- const overrides : RenderedOverride [ ] = [
323+ const overrides : Override [ ] = [
324324 {
325325 name : "prod-override" ,
326326 conditions : [ { operator : "equals" , property : "env" , value : "production" } ] ,
@@ -331,7 +331,7 @@ describe("evaluateOverrides", () => {
331331 } ) ;
332332
333333 it ( "should return override value when conditions match" , ( ) => {
334- const overrides : RenderedOverride [ ] = [
334+ const overrides : Override [ ] = [
335335 {
336336 name : "prod-override" ,
337337 conditions : [ { operator : "equals" , property : "env" , value : "production" } ] ,
@@ -344,7 +344,7 @@ describe("evaluateOverrides", () => {
344344 } ) ;
345345
346346 it ( "should return first matching override" , ( ) => {
347- const overrides : RenderedOverride [ ] = [
347+ const overrides : Override [ ] = [
348348 {
349349 name : "first-override" ,
350350 conditions : [ { operator : "equals" , property : "env" , value : "production" } ] ,
@@ -362,7 +362,7 @@ describe("evaluateOverrides", () => {
362362 } ) ;
363363
364364 it ( "should skip override when any condition is unknown" , ( ) => {
365- const overrides : RenderedOverride [ ] = [
365+ const overrides : Override [ ] = [
366366 {
367367 name : "override-with-unknown" ,
368368 conditions : [
@@ -383,7 +383,7 @@ describe("evaluateOverrides", () => {
383383 } ) ;
384384
385385 it ( "should handle complex nested conditions" , ( ) => {
386- const overrides : RenderedOverride [ ] = [
386+ const overrides : Override [ ] = [
387387 {
388388 name : "complex-override" ,
389389 conditions : [
0 commit comments