@@ -30,6 +30,7 @@ import EppoPrecomputedClient, {
3030 PrecomputedFlagsRequestParameters ,
3131 Subject ,
3232} from './eppo-precomputed-client' ;
33+ import { applicationLogger } from '..' ;
3334
3435describe ( 'EppoPrecomputedClient E2E test' , ( ) => {
3536 const precomputedConfigurationWire = readMockConfigurationWireResponse (
@@ -52,6 +53,7 @@ describe('EppoPrecomputedClient E2E test', () => {
5253 subjectKey : 'test-subject' ,
5354 subjectAttributes : { attr1 : 'value1' } ,
5455 } ;
56+
5557 beforeEach ( async ( ) => {
5658 storage = new MemoryOnlyConfigurationStore < PrecomputedFlag > ( ) ;
5759 storage . setFormat ( FormatEnum . PRECOMPUTED ) ;
@@ -110,6 +112,52 @@ describe('EppoPrecomputedClient E2E test', () => {
110112 } ) ;
111113 } ) ;
112114
115+ describe ( 'store initialization logged errors' , ( ) => {
116+ let mockError : jest . SpyInstance ;
117+
118+ beforeEach ( ( ) => {
119+ mockError = jest . spyOn ( applicationLogger , 'error' ) ;
120+ } ) ;
121+
122+ afterEach ( ( ) => {
123+ mockError . mockRestore ( ) ;
124+ } ) ;
125+
126+ it ( 'logs error when initialized with store without salt' , ( ) => {
127+ const emptyStore = new MemoryOnlyConfigurationStore < PrecomputedFlag > ( ) ;
128+ new EppoPrecomputedClient ( {
129+ precomputedFlagStore : emptyStore ,
130+ subject : {
131+ subjectKey : '' ,
132+ subjectAttributes : { } ,
133+ } ,
134+ } ) ;
135+ expect ( mockError ) . not . toHaveBeenCalledWith (
136+ 'EppoPrecomputedClient requires a precomputedFlagStore with a salt if requestParameters are not provided' ,
137+ ) ;
138+ } ) ;
139+
140+ it ( 'logs error when initialized with store without salt' , ( ) => {
141+ const nonemptyStore = new MemoryOnlyConfigurationStore < PrecomputedFlag > ( ) ;
142+ // Incorrectly initialized: no salt, not set to initialized
143+ jest . spyOn ( nonemptyStore , 'getKeys' ) . mockReturnValue ( [ 'some-key' ] ) ;
144+
145+ new EppoPrecomputedClient ( {
146+ precomputedFlagStore : nonemptyStore ,
147+ subject : {
148+ subjectKey : '' ,
149+ subjectAttributes : { } ,
150+ } ,
151+ } ) ;
152+ expect ( mockError ) . toHaveBeenCalledWith (
153+ '[Eppo SDK] EppoPrecomputedClient requires an initialized precomputedFlagStore if requestParameters are not provided' ,
154+ ) ;
155+ expect ( mockError ) . toHaveBeenCalledWith (
156+ '[Eppo SDK] EppoPrecomputedClient requires a precomputedFlagStore with a salt if requestParameters are not provided' ,
157+ ) ;
158+ } ) ;
159+ } ) ;
160+
113161 describe ( 'setLogger' , ( ) => {
114162 let flagStorage : IConfigurationStore < PrecomputedFlag > ;
115163 let subject : Subject ;
0 commit comments