Skip to content

Commit 39a7974

Browse files
committed
test: improve ConfigLoader.start coverage
1 parent a029d5e commit 39a7974

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/ConfigLoader.test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,49 @@ describe('ConfigLoader', () => {
204204

205205
expect(spy.calledOnce).to.be.true;
206206
});
207+
208+
it('should clear an existing reload interval if it exists', async () => {
209+
const mockConfig = {
210+
configurationSources: {
211+
enabled: true,
212+
sources: [
213+
{
214+
type: 'file',
215+
enabled: true,
216+
path: tempConfigFile,
217+
},
218+
],
219+
},
220+
};
221+
222+
const configLoader = new ConfigLoader(mockConfig);
223+
configLoader.reloadTimer = setInterval(() => {}, 1000);
224+
await configLoader.start();
225+
226+
expect(configLoader.reloadTimer).to.be.null;
227+
});
228+
229+
it('should run reloadConfiguration multiple times on short reload interval', async () => {
230+
const mockConfig = {
231+
configurationSources: {
232+
enabled: true,
233+
sources: [
234+
{
235+
type: 'file',
236+
enabled: true,
237+
path: tempConfigFile,
238+
},
239+
],
240+
reloadIntervalSeconds: 0.001,
241+
},
242+
};
243+
244+
const configLoader = new ConfigLoader(mockConfig);
245+
const spy = sinon.spy(configLoader, 'reloadConfiguration');
246+
await configLoader.start();
247+
248+
expect(spy.callCount).to.greaterThan(1);
249+
});
207250
});
208251

209252
describe('loadRemoteConfig', () => {

0 commit comments

Comments
 (0)