Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
  • Loading branch information
thomaspoignant committed Jan 16, 2025
1 parent 622f245 commit 349c551
Showing 1 changed file with 27 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,11 @@ describe('GoFeatureFlagProvider', () => {
flagCacheTTL: 3000,
flagCacheSize: 100,
dataFlushInterval: 1000, // in milliseconds
exporterMetadata: {
nodeJSVersion: '14.17.0',
appVersion: '1.0.0',
identifier: 123,
},
});
const providerName = expect.getState().currentTestName || 'test';
await OpenFeature.setProviderAndWait(providerName, goff);
Expand All @@ -896,9 +901,9 @@ describe('GoFeatureFlagProvider', () => {
userKey: 'user-key',
},
],
meta: { provider: 'open-feature-js-sdk' },
meta: { provider: 'js', openfeature: true, nodeJSVersion: '14.17.0', appVersion: '1.0.0', identifier: 123 },
};
expect(want).toEqual(got);
expect(got).toEqual(want);
});

it('should call the data collector when waiting more than the dataFlushInterval', async () => {
Expand All @@ -912,6 +917,11 @@ describe('GoFeatureFlagProvider', () => {
flagCacheTTL: 3000,
flagCacheSize: 100,
dataFlushInterval: 100, // in milliseconds
exporterMetadata: {
nodeJSVersion: '14.17.0',
appVersion: '1.0.0',
identifier: 123,
},
});
const providerName = expect.getState().currentTestName || 'test';
await OpenFeature.setProviderAndWait(providerName, goff);
Expand All @@ -934,6 +944,11 @@ describe('GoFeatureFlagProvider', () => {
flagCacheTTL: 3000,
flagCacheSize: 100,
dataFlushInterval: 100, // in milliseconds
exporterMetadata: {
nodeJSVersion: '14.17.0',
appVersion: '1.0.0',
identifier: 123,
},
});
const providerName = expect.getState().currentTestName || 'test';
await OpenFeature.setProviderAndWait(providerName, goff);
Expand Down Expand Up @@ -962,6 +977,11 @@ describe('GoFeatureFlagProvider', () => {
flagCacheTTL: 3000,
flagCacheSize: 100,
dataFlushInterval: 200, // in milliseconds
exporterMetadata: {
nodeJSVersion: '14.17.0',
appVersion: '1.0.0',
identifier: 123,
},
});
const providerName = expect.getState().currentTestName || 'test';
await OpenFeature.setProviderAndWait(providerName, goff);
Expand All @@ -988,6 +1008,11 @@ describe('GoFeatureFlagProvider', () => {
flagCacheTTL: 3000,
flagCacheSize: 100,
dataFlushInterval: 2000, // in milliseconds
exporterMetadata: {
nodeJSVersion: '14.17.0',
appVersion: '1.0.0',
identifier: 123,
},
},
testLogger,
);
Expand All @@ -1003,51 +1028,6 @@ describe('GoFeatureFlagProvider', () => {
'Error: impossible to send the data to the collector: Error: Request failed with status code 500',
);
});

it('should call the data collector with exporter metadata', async () => {
const flagName = 'random-flag';
const targetingKey = 'user-key';
const dns = `${endpoint}v1/feature/${flagName}/eval`;

axiosMock.onPost(dns).reply(200, validBoolResponse);
const goff = new GoFeatureFlagProvider({
endpoint,
flagCacheTTL: 3000,
flagCacheSize: 100,
dataFlushInterval: 1000, // in milliseconds
exporterMetadata: {
nodeJSVersion: '14.17.0',
appVersion: '1.0.0',
identifier: 123,
},
});
const providerName = expect.getState().currentTestName || 'test';
await OpenFeature.setProviderAndWait(providerName, goff);
const cli = OpenFeature.getClient(providerName);
await cli.getBooleanDetails(flagName, false, { targetingKey });
await cli.getBooleanDetails(flagName, false, { targetingKey });
await OpenFeature.close();
const collectorCalls = axiosMock.history['post'].filter((i) => i.url === dataCollectorEndpoint);
expect(collectorCalls.length).toBe(1);
const got = JSON.parse(collectorCalls[0].data);
expect(isNaN(got.events[0].creationDate)).toBe(false);
const want = {
events: [
{
contextKind: 'user',
kind: 'feature',
creationDate: got.events[0].creationDate,
default: false,
key: 'random-flag',
value: true,
variation: 'trueVariation',
userKey: 'user-key',
},
],
meta: { provider: 'js', openfeature: true, nodeJSVersion: '14.17.0', appVersion: '1.0.0', identifier: 123 },
};
expect(want).toEqual(got);
});
});
describe('polling', () => {
it('should_stop_calling_flag_change_if_receive_404', async () => {
Expand Down

0 comments on commit 349c551

Please sign in to comment.