11import { afterAll , beforeEach , describe , expect , test , vi } from "vitest" ;
22
33import { version } from "../package.json" ;
4+ import { FeatureDefinitions } from "../src/client" ;
45import {
56 FEATURES_EXPIRE_MS ,
67 FeaturesClient ,
@@ -36,6 +37,7 @@ function featuresClientFactory() {
3637 newFeaturesClient : function newFeaturesClient (
3738 options ?: FeaturesOptions ,
3839 context ?: any ,
40+ featureList : FeatureDefinitions = [ ] ,
3941 ) {
4042 return new FeaturesClient (
4143 httpClient ,
@@ -45,7 +47,7 @@ function featuresClientFactory() {
4547 other : { eventId : "big-conference1" } ,
4648 ...context ,
4749 } ,
48- [ ] ,
50+ featureList ,
4951 testLogger ,
5052 {
5153 cache,
@@ -302,16 +304,20 @@ describe("FeaturesClient unit tests", () => {
302304 test ( "handled overrides for features not returned by API" , async ( ) => {
303305 // change the response so we can validate that we'll serve the stale cache
304306 const { newFeaturesClient } = featuresClientFactory ( ) ;
307+
305308 // localStorage.clear();
306- const client = newFeaturesClient ( ) ;
309+ const client = newFeaturesClient ( undefined , undefined , [ "featureB" ] ) ;
307310 await client . initialize ( ) ;
308311
309312 let updated = false ;
310313 client . onUpdated ( ( ) => {
311314 updated = true ;
312315 } ) ;
313316
314- expect ( client . getFeatures ( ) . featureB ) . toBeUndefined ( ) ;
317+ expect ( client . getFeatures ( ) . featureB . isEnabled ) . toBe ( false ) ;
318+ expect ( client . getFeatures ( ) . featureB . isEnabledOverride ) . toBe ( null ) ;
319+
320+ expect ( client . getFetchedFeatures ( ) ?. featureB ) . toBeUndefined ( ) ;
315321
316322 client . setFeatureOverride ( "featureB" , true ) ;
317323
0 commit comments