Skip to content

Commit 351ba45

Browse files
Fix date
Signed-off-by: Thomas Poignant <[email protected]>
1 parent 291bd84 commit 351ba45

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

libs/providers/go-feature-flag/src/lib/go-feature-flag-provider.test.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,11 @@ describe('GoFeatureFlagProvider', () => {
967967
it('Should change evaluation details if config has changed', async () => {
968968
jest.useRealTimers();
969969
let callCount = 0;
970-
fetchMock.mockIf(/^http:\/\/localhost:1031\/v1\/flag\/configuration/, async () => {
970+
fetchMock.mockIf(/^http:\/\/localhost:1031\/v1\/flag\/configuration/, async (request) => {
971+
// read headers in the request
972+
const headers = request.headers;
973+
console.log('headers', headers.get('If-None-Match'));
974+
971975
callCount++;
972976
if (callCount <= 1) {
973977
return {
@@ -1077,14 +1081,24 @@ describe('GoFeatureFlagProvider', () => {
10771081
});
10781082

10791083
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(/^http:\/\/localhost:1031\/v1\/flag\/configuration/, async () => {
1086+
const res = getConfigurationEndpointResult('scheduled-rollout');
1087+
// Keep the console.log for debugging as in the original code
1088+
console.log('res', res);
1089+
console.log('date', new Date());
1090+
return {
1091+
body: res,
1092+
status: 200,
1093+
headers: {
1094+
'Content-Type': 'application/json',
1095+
},
1096+
};
10831097
});
10841098

10851099
const provider = new GoFeatureFlagProvider({
10861100
endpoint: 'http://localhost:1031',
1087-
flagChangePollingIntervalMs: 100,
1101+
flagChangePollingIntervalMs: 150,
10881102
});
10891103

10901104
await OpenFeature.setProviderAndWait(testClientName, provider);
@@ -1452,7 +1466,7 @@ describe('GoFeatureFlagProvider', () => {
14521466
});
14531467
});
14541468

1455-
function getConfigurationEndpointResult(mode = 'default') {
1469+
function getConfigurationEndpointResult(mode = 'default'): string {
14561470
const filePath = path.resolve(__dirname, 'testdata', 'flag-configuration', mode + '.json');
14571471
const fileContent = fs.readFileSync(filePath, 'utf-8');
14581472
return JSON.stringify(JSON.parse(fileContent));

0 commit comments

Comments
 (0)