Skip to content

Commit 7c2fe92

Browse files
committed
test: add cases for ConfigLoader.stop and disabled configSources
1 parent dc6bc4f commit 7c2fe92

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/ConfigLoader.test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,22 @@ describe('ConfigLoader', () => {
148148

149149
expect(spy.calledOnce).to.be.true; // Should only emit once
150150
});
151+
152+
it('should not emit event if configurationSources is disabled', async () => {
153+
const config = {
154+
configurationSources: {
155+
enabled: false,
156+
},
157+
};
158+
159+
configLoader = new ConfigLoader(config);
160+
const spy = sinon.spy();
161+
configLoader.on('configurationChanged', spy);
162+
163+
await configLoader.reloadConfiguration();
164+
165+
expect(spy.called).to.be.false;
166+
});
151167
});
152168

153169
describe('initialize', () => {
@@ -250,6 +266,28 @@ describe('ConfigLoader', () => {
250266

251267
expect(spy.callCount).to.greaterThan(1);
252268
});
269+
270+
it('should clear the interval when stop is called', async () => {
271+
const mockConfig = {
272+
configurationSources: {
273+
enabled: true,
274+
sources: [
275+
{
276+
type: 'file',
277+
enabled: true,
278+
path: tempConfigFile,
279+
},
280+
],
281+
},
282+
};
283+
284+
const configLoader = new ConfigLoader(mockConfig);
285+
configLoader.reloadTimer = setInterval(() => {}, 1000);
286+
expect(configLoader.reloadTimer).to.not.be.null;
287+
288+
await configLoader.stop();
289+
expect(configLoader.reloadTimer).to.be.null;
290+
});
253291
});
254292

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

0 commit comments

Comments
 (0)