Skip to content

Commit

Permalink
fix: Broken import after config cat upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Reining <[email protected]>
  • Loading branch information
lukas-reining committed Jun 27, 2023
1 parent 4428669 commit d5a40c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 4 additions & 5 deletions libs/providers/config-cat/src/lib/config-cat-provider.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { ConfigCatProvider } from './config-cat-provider';
import { OpenFeature, ParseError, ProviderEvents, TypeMismatchError } from '@openfeature/js-sdk';
import { ParseError, ProviderEvents, TypeMismatchError } from '@openfeature/js-sdk';
import {
createConsoleLogger,
createFlagOverridesFromMap,
HookEvents,
IConfigCatClient,
ISetting,
LogLevel,
OverrideBehaviour,
PollingMode,
ProjectConfig,
} from 'configcat-js';

import { IEventEmitter } from 'configcat-common/lib/EventEmitter';
Expand Down Expand Up @@ -104,13 +103,13 @@ describe('ConfigCatProvider', () => {

it('should emit PROVIDER_CONFIGURATION_CHANGED event', () => {
const handler = jest.fn();
const eventData = new ProjectConfig(1, {});
const eventData = { settings: { myFlag: {} as ISetting } };

provider.events.addHandler(ProviderEvents.ConfigurationChanged, handler);
configCatEmitter.emit('configChanged', eventData);

expect(handler).toHaveBeenCalledWith({
metadata: eventData,
flagsChanged: ['myFlag'],
});
});

Expand Down
6 changes: 4 additions & 2 deletions libs/providers/config-cat/src/lib/config-cat-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ConfigCatProvider implements Provider {
const originalParameters = this.clientParameters;
originalParameters[2] ??= {};

const options = originalParameters[2]
const options = originalParameters[2];
const oldSetupHooks = options.setupHooks;

options.setupHooks = (hooks) => {
Expand All @@ -50,7 +50,9 @@ export class ConfigCatProvider implements Provider {
});

hooks.on('configChanged', (projectConfig) =>
this.events.emit(ProviderEvents.ConfigurationChanged, { metadata: { ...projectConfig } })
this.events.emit(ProviderEvents.ConfigurationChanged, {
flagsChanged: Object.keys(projectConfig.settings),
})
);

hooks.on('clientError', (message: string, error) =>
Expand Down

0 comments on commit d5a40c9

Please sign in to comment.