diff --git a/src/__tests__/helpers.browser.test.ts b/src/__tests__/helpers.browser.test.ts index 5c061bd..feabf04 100644 --- a/src/__tests__/helpers.browser.test.ts +++ b/src/__tests__/helpers.browser.test.ts @@ -12,7 +12,7 @@ import { initSplitSdk, splitSdk, } from '../asyncActions'; -import { ERROR_GETSTATUS_NO_INITSPLITSDK, ERROR_TRACK_NO_INITSPLITSDK, WARN_GETSTATUS_NO_CLIENT } from '../constants'; +import { ERROR_TRACK_NO_INITSPLITSDK } from '../constants'; /** Test targets */ import { @@ -182,17 +182,10 @@ describe('getStatus', () => { }); it('should return the default status if the SDK was not initialized', () => { - const errorSpy = jest.spyOn(console, 'error'); - expect(getStatus()).toEqual(STATUS_INITIAL); - expect(errorSpy).toBeCalledWith(ERROR_GETSTATUS_NO_INITSPLITSDK); - - errorSpy.mockRestore(); }); it('should return the status of the client associated to the provided key', () => { - const logSpy = jest.spyOn(console, 'log'); - initSplitSdk({ config: sdkBrowserConfig }); getTreatments({ key: 'user_2', splitNames: ['split_1'] }); (splitSdk.factory as any).client().__emitter__.emit(Event.SDK_READY); @@ -209,12 +202,7 @@ describe('getStatus', () => { expect(getStatus('user_2')).toEqual(USER_2_STATUS); expect(getStatus({ matchingKey: 'user_2', bucketingKey: '' })).toEqual(USER_2_STATUS); - expect(logSpy).not.toBeCalled(); - // Non-existing client expect(getStatus('non_existing_key')).toEqual(STATUS_INITIAL); - expect(logSpy).toBeCalledWith(WARN_GETSTATUS_NO_CLIENT); - - logSpy.mockRestore(); }); }); diff --git a/src/constants.ts b/src/constants.ts index a77c90a..a2d00cb 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -52,12 +52,8 @@ export const ERROR_TRACK_NO_INITSPLITSDK = errorNoInitSplitSdk('"track"'); export const ERROR_MANAGER_NO_INITSPLITSDK = errorNoInitSplitSdk('the manager'); -export const ERROR_GETSTATUS_NO_INITSPLITSDK = errorNoInitSplitSdk('"getStatus"'); - export const ERROR_SELECTOR_NO_SPLITSTATE = '[ERROR] To use selectors, "splitState" param must be a proper splitio piece of state'; export const ERROR_GETT_NO_PARAM_OBJECT = '[ERROR] "getTreatments" must be called with a param object containing a valid splitNames or flagSets properties'; export const WARN_FEATUREFLAGS_AND_FLAGSETS = '[WARN] Both splitNames and flagSets properties were provided. flagSets will be ignored'; - -export const WARN_GETSTATUS_NO_CLIENT = '[WARN] No client found for the provided key'; diff --git a/src/helpers.ts b/src/helpers.ts index 94c05b4..740afce 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -1,6 +1,6 @@ import { splitSdk, getClient } from './asyncActions'; import { IStatus, ITrackParams } from './types'; -import { ERROR_TRACK_NO_INITSPLITSDK, ERROR_MANAGER_NO_INITSPLITSDK, ERROR_GETSTATUS_NO_INITSPLITSDK, WARN_GETSTATUS_NO_CLIENT } from './constants'; +import { ERROR_TRACK_NO_INITSPLITSDK, ERROR_MANAGER_NO_INITSPLITSDK } from './constants'; import { __getStatus, matching } from './utils'; /** @@ -106,13 +106,7 @@ export function getStatus(key?: SplitIO.SplitKey): IStatus { const isMainClient = splitSdk.isDetached || !stringKey || stringKey === matching((splitSdk.config as SplitIO.IBrowserSettings).core.key); const client = isMainClient ? splitSdk.factory.client() : splitSdk.sharedClients[stringKey]; - if (client) { - return __getStatus(client); - } else { - console.log(WARN_GETSTATUS_NO_CLIENT); - } - } else { - console.error(ERROR_GETSTATUS_NO_INITSPLITSDK); + if (client) return __getStatus(client); } // Default status if SDK is not initialized or client is not found