Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flagsmith-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { isTraitEvaluationContext, toEvaluationContext, toTraitEvaluationContext
import { ensureTrailingSlash } from './utils/ensureTrailingSlash';
import { SDK_VERSION } from './utils/version';

enum FlagSource {
export enum FlagSource {
"NONE" = "NONE",
"DEFAULT_FLAGS" = "DEFAULT_FLAGS",
"CACHE" = "CACHE",
Expand Down
1 change: 1 addition & 0 deletions index.react-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export const createFlagsmithInstance = ()=>{
eventSource: _EventSource
})
}
export { FlagSource } from './flagsmith-core';
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export default flagsmith;
export const createFlagsmithInstance = ():IFlagsmith=>{
return core({ AsyncStorage, fetch:_fetch, eventSource:_EventSource})
}
export { FlagSource } from './flagsmith-core';
1 change: 1 addition & 0 deletions isomorphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export const createFlagsmithInstance = (): IFlagsmith => {
eventSource: typeof window !=='undefined'?eventSource : null
})
}
export { FlagSource } from './flagsmith-core';
1 change: 1 addition & 0 deletions next-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export default flagsmith;
export const createFlagsmithInstance = ():IFlagsmith=>{
return core({})
}
export { FlagSource } from './flagsmith-core';
29 changes: 29 additions & 0 deletions test/flagsource-export.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { FlagSource } from '../index';
import { FlagSource as FlagSourceIso } from '../isomorphic';

describe('FlagSource Export', () => {

test('should export FlagSource enum with all values', () => {
expect(FlagSource).toBeDefined();
expect(FlagSource.NONE).toBe('NONE');
expect(FlagSource.DEFAULT_FLAGS).toBe('DEFAULT_FLAGS');
expect(FlagSource.CACHE).toBe('CACHE');
expect(FlagSource.SERVER).toBe('SERVER');
});

test('should be usable in runtime value comparisons', () => {
const source = 'NONE' as string;

expect(source === FlagSource.NONE).toBe(true);
expect(source === FlagSource.CACHE).toBe(false);

const mySource: FlagSource = FlagSource.NONE;
expect(mySource).toBe('NONE');
});

test('should export FlagSource from all entry points', () => {
expect(FlagSourceIso).toBeDefined();
expect(FlagSourceIso.NONE).toBe('NONE');
expect(FlagSource.NONE).toBe(FlagSourceIso.NONE);
});
});
7 changes: 1 addition & 6 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ export type ISentryClient = {
} | undefined;


export declare enum FlagSource {
"NONE" = "NONE",
"DEFAULT_FLAGS" = "DEFAULT_FLAGS",
"CACHE" = "CACHE",
"SERVER" = "SERVER",
}
export { FlagSource } from './flagsmith-core';

export declare type LoadingState = {
error: Error | null, // Current error, resets on next attempt to fetch flags
Expand Down