@@ -967,7 +967,11 @@ describe('GoFeatureFlagProvider', () => {
967
967
it ( 'Should change evaluation details if config has changed' , async ( ) => {
968
968
jest . useRealTimers ( ) ;
969
969
let callCount = 0 ;
970
- fetchMock . mockIf ( / ^ h t t p : \/ \/ l o c a l h o s t : 1 0 3 1 \/ v 1 \/ f l a g \/ c o n f i g u r a t i o n / , async ( ) => {
970
+ fetchMock . mockIf ( / ^ h t t p : \/ \/ l o c a l h o s t : 1 0 3 1 \/ v 1 \/ f l a g \/ c o n f i g u r a t i o n / , async ( request ) => {
971
+ // read headers in the request
972
+ const headers = request . headers ;
973
+ console . log ( 'headers' , headers . get ( 'If-None-Match' ) ) ;
974
+
971
975
callCount ++ ;
972
976
if ( callCount <= 1 ) {
973
977
return {
@@ -1077,14 +1081,21 @@ describe('GoFeatureFlagProvider', () => {
1077
1081
} ) ;
1078
1082
1079
1083
it ( 'Should apply a scheduled rollout step' , async ( ) => {
1080
- fetchMock . mockResponseOnce ( getConfigurationEndpointResult ( 'scheduled-rollout' ) , {
1081
- status : 200 ,
1082
- headers : { 'Content-Type' : 'application/json' } ,
1084
+ jest . useRealTimers ( ) ;
1085
+ fetchMock . mockIf ( / ^ h t t p : \/ \/ l o c a l h o s t : 1 0 3 1 \/ v 1 \/ f l a g \/ c o n f i g u r a t i o n / , async ( ) => {
1086
+ const res = getConfigurationEndpointResult ( 'scheduled-rollout' ) ;
1087
+ return {
1088
+ body : res ,
1089
+ status : 200 ,
1090
+ headers : {
1091
+ 'Content-Type' : 'application/json' ,
1092
+ } ,
1093
+ } ;
1083
1094
} ) ;
1084
1095
1085
1096
const provider = new GoFeatureFlagProvider ( {
1086
1097
endpoint : 'http://localhost:1031' ,
1087
- flagChangePollingIntervalMs : 100 ,
1098
+ flagChangePollingIntervalMs : 150 ,
1088
1099
} ) ;
1089
1100
1090
1101
await OpenFeature . setProviderAndWait ( testClientName , provider ) ;
@@ -1105,7 +1116,7 @@ describe('GoFeatureFlagProvider', () => {
1105
1116
} ) ;
1106
1117
1107
1118
it ( 'Should not apply a scheduled rollout in the future' , async ( ) => {
1108
- jest . setSystemTime ( new Date ( '2021-01-01T00 :00:00Z' ) ) ;
1119
+ jest . setSystemTime ( new Date ( '2021-01-01T01 :00:00Z' ) ) ;
1109
1120
fetchMock . mockIf ( / ^ h t t p : \/ \/ l o c a l h o s t : 1 0 3 1 \/ v 1 \/ f l a g \/ c o n f i g u r a t i o n / , async ( ) => {
1110
1121
return {
1111
1122
body : getConfigurationEndpointResult ( 'scheduled-rollout' ) ,
@@ -1452,7 +1463,7 @@ describe('GoFeatureFlagProvider', () => {
1452
1463
} ) ;
1453
1464
} ) ;
1454
1465
1455
- function getConfigurationEndpointResult ( mode = 'default' ) {
1466
+ function getConfigurationEndpointResult ( mode = 'default' ) : string {
1456
1467
const filePath = path . resolve ( __dirname , 'testdata' , 'flag-configuration' , mode + '.json' ) ;
1457
1468
const fileContent = fs . readFileSync ( filePath , 'utf-8' ) ;
1458
1469
return JSON . stringify ( JSON . parse ( fileContent ) ) ;
0 commit comments