@@ -8,13 +8,13 @@ import {
8
8
JsonObject ,
9
9
JsonValue ,
10
10
OpenFeature ,
11
- OpenFeatureClient ,
12
11
Provider ,
13
12
ProviderFatalError ,
14
13
ProviderStatus ,
15
14
ResolutionDetails ,
16
15
StandardResolutionReasons ,
17
16
} from '../src' ;
17
+ import { OpenFeatureClient } from '../src/client/open-feature-client' ;
18
18
19
19
const BOOLEAN_VALUE = true ;
20
20
const STRING_VALUE = 'val' ;
@@ -382,7 +382,7 @@ describe('OpenFeatureClient', () => {
382
382
// No generic information exists at runtime, but this test has some value in ensuring the generic args still exist in the typings.
383
383
const client = OpenFeature . getClient ( ) ;
384
384
const details : ResolutionDetails < JsonValue > = client . getObjectDetails ( 'flag' , { key : 'value' } ) ;
385
-
385
+
386
386
expect ( details ) . toBeDefined ( ) ;
387
387
} ) ;
388
388
} ) ;
@@ -464,45 +464,45 @@ describe('OpenFeatureClient', () => {
464
464
expect ( details . errorCode ) . toEqual ( ErrorCode . PROVIDER_NOT_READY ) ;
465
465
} ) ;
466
466
} ) ;
467
-
467
+
468
468
describe ( 'Evaluation details structure' , ( ) => {
469
469
const flagKey = 'number-details' ;
470
470
const defaultValue = 1970 ;
471
471
let details : EvaluationDetails < number > ;
472
-
472
+
473
473
describe ( 'Normal execution' , ( ) => {
474
474
beforeEach ( ( ) => {
475
475
const client = OpenFeature . getClient ( ) ;
476
476
details = client . getNumberDetails ( flagKey , defaultValue ) ;
477
-
477
+
478
478
expect ( details ) . toBeDefined ( ) ;
479
479
} ) ;
480
-
480
+
481
481
describe ( 'Requirement 1.4.2, 1.4.3' , ( ) => {
482
482
it ( 'should contain flag value' , ( ) => {
483
483
expect ( details . value ) . toEqual ( NUMBER_VALUE ) ;
484
484
} ) ;
485
485
} ) ;
486
-
486
+
487
487
describe ( 'Requirement 1.4.4' , ( ) => {
488
488
it ( 'should contain flag key' , ( ) => {
489
489
expect ( details . flagKey ) . toEqual ( flagKey ) ;
490
490
} ) ;
491
491
} ) ;
492
-
492
+
493
493
describe ( 'Requirement 1.4.5' , ( ) => {
494
494
it ( 'should contain flag variant' , ( ) => {
495
495
expect ( details . variant ) . toEqual ( NUMBER_VARIANT ) ;
496
496
} ) ;
497
497
} ) ;
498
-
498
+
499
499
describe ( 'Requirement 1.4.6' , ( ) => {
500
500
it ( 'should contain reason' , ( ) => {
501
501
expect ( details . reason ) . toEqual ( REASON ) ;
502
502
} ) ;
503
503
} ) ;
504
504
} ) ;
505
-
505
+
506
506
describe ( 'Abnormal execution' , ( ) => {
507
507
const NON_OPEN_FEATURE_ERROR_MESSAGE = 'A null dereference or something, I dunno.' ;
508
508
const OPEN_FEATURE_ERROR_MESSAGE = "This ain't the flag you're looking for." ;
@@ -522,68 +522,68 @@ describe('OpenFeatureClient', () => {
522
522
} as unknown as Provider ;
523
523
const defaultNumberValue = 123 ;
524
524
const defaultStringValue = 'hey!' ;
525
-
525
+
526
526
beforeEach ( ( ) => {
527
527
OpenFeature . setProvider ( errorProvider ) ;
528
528
client = OpenFeature . getClient ( ) ;
529
529
nonOpenFeatureErrorDetails = client . getNumberDetails ( 'some-flag' , defaultNumberValue ) ;
530
530
openFeatureErrorDetails = client . getStringDetails ( 'some-flag' , defaultStringValue ) ;
531
531
} ) ;
532
-
532
+
533
533
describe ( 'Requirement 1.4.7' , ( ) => {
534
534
describe ( 'OpenFeatureError' , ( ) => {
535
535
it ( 'should contain error code' , ( ) => {
536
536
expect ( openFeatureErrorDetails . errorCode ) . toBeTruthy ( ) ;
537
537
expect ( openFeatureErrorDetails . errorCode ) . toEqual ( ErrorCode . FLAG_NOT_FOUND ) ; // should get code from thrown OpenFeatureError
538
538
} ) ;
539
539
} ) ;
540
-
540
+
541
541
describe ( 'Non-OpenFeatureError' , ( ) => {
542
542
it ( 'should contain error code' , ( ) => {
543
543
expect ( nonOpenFeatureErrorDetails . errorCode ) . toBeTruthy ( ) ;
544
544
expect ( nonOpenFeatureErrorDetails . errorCode ) . toEqual ( ErrorCode . GENERAL ) ; // should fall back to GENERAL
545
545
} ) ;
546
546
} ) ;
547
547
} ) ;
548
-
548
+
549
549
describe ( 'Requirement 1.4.8' , ( ) => {
550
550
it ( 'should contain error reason' , ( ) => {
551
551
expect ( nonOpenFeatureErrorDetails . reason ) . toEqual ( StandardResolutionReasons . ERROR ) ;
552
552
expect ( openFeatureErrorDetails . reason ) . toEqual ( StandardResolutionReasons . ERROR ) ;
553
553
} ) ;
554
554
} ) ;
555
-
555
+
556
556
describe ( 'Requirement 1.4.9' , ( ) => {
557
557
it ( 'must not throw, must return default' , ( ) => {
558
558
nonOpenFeatureErrorDetails = client . getNumberDetails ( 'some-flag' , defaultNumberValue ) ;
559
-
559
+
560
560
expect ( nonOpenFeatureErrorDetails ) . toBeTruthy ( ) ;
561
561
expect ( nonOpenFeatureErrorDetails . value ) . toEqual ( defaultNumberValue ) ;
562
562
} ) ;
563
563
} ) ;
564
-
564
+
565
565
describe ( 'Requirement 1.4.12' , ( ) => {
566
566
describe ( 'OpenFeatureError' , ( ) => {
567
567
it ( 'should contain "error" message' , ( ) => {
568
568
expect ( openFeatureErrorDetails . errorMessage ) . toEqual ( OPEN_FEATURE_ERROR_MESSAGE ) ;
569
569
} ) ;
570
570
} ) ;
571
-
571
+
572
572
describe ( 'Non-OpenFeatureError' , ( ) => {
573
573
it ( 'should contain "error" message' , ( ) => {
574
574
expect ( nonOpenFeatureErrorDetails . errorMessage ) . toEqual ( NON_OPEN_FEATURE_ERROR_MESSAGE ) ;
575
575
} ) ;
576
576
} ) ;
577
577
} ) ;
578
578
} ) ;
579
-
579
+
580
580
describe ( 'Requirement 1.4.13, Requirement 1.4.14' , ( ) => {
581
581
it ( 'should return immutable `flag metadata` as defined by the provider' , ( ) => {
582
582
const flagMetadata = {
583
583
url : 'https://test.dev' ,
584
584
version : '1' ,
585
585
} ;
586
-
586
+
587
587
const flagMetadataProvider = {
588
588
metadata : {
589
589
name : 'flag-metadata' ,
@@ -595,14 +595,14 @@ describe('OpenFeatureClient', () => {
595
595
} ;
596
596
} ) ,
597
597
} as unknown as Provider ;
598
-
598
+
599
599
OpenFeature . setProvider ( flagMetadataProvider ) ;
600
600
const client = OpenFeature . getClient ( ) ;
601
601
const response = client . getBooleanDetails ( 'some-flag' , false ) ;
602
602
expect ( response . flagMetadata ) . toBe ( flagMetadata ) ;
603
603
expect ( Object . isFrozen ( response . flagMetadata ) ) . toBeTruthy ( ) ;
604
604
} ) ;
605
-
605
+
606
606
it ( 'should return empty `flag metadata` because it was not set by the provider' , ( ) => {
607
607
// The mock provider doesn't contain flag metadata
608
608
OpenFeature . setProvider ( MOCK_PROVIDER ) ;
0 commit comments