Skip to content

Commit f3b2cb8

Browse files
committed
unit test to safeguard _reset functionality
1 parent ca2fcb9 commit f3b2cb8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/featureToggles.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,8 @@ module.exports = {
15561556
FeatureToggles,
15571557

15581558
_: {
1559+
DEFAULT_REDIS_CHANNEL,
1560+
DEFAULT_REDIS_KEY,
15591561
SCOPE_ROOT_KEY,
15601562
CONFIG_KEY,
15611563
CONFIG_INFO_KEY,

test/featureToggles.test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { fallbackValuesFromInfos, stateFromInfos } = require("./__common__/fromIn
1212

1313
const {
1414
FeatureToggles,
15-
_: { SCOPE_ROOT_KEY, CONFIG_KEY, CONFIG_INFO_KEY },
15+
_: { DEFAULT_REDIS_CHANNEL, DEFAULT_REDIS_KEY, SCOPE_ROOT_KEY, CONFIG_KEY, CONFIG_INFO_KEY },
1616
} = featureTogglesModule;
1717

1818
const { readFile: readFileSpy } = require("fs");
@@ -215,6 +215,20 @@ describe("feature toggles test", () => {
215215
});
216216
});
217217

218+
describe("internal apis", () => {
219+
// NOTE: this internal API is used for the plugin uniqueName configuration processing
220+
test("_reset", async () => {
221+
const uniqueName = "bla-blu-testing";
222+
toggles._reset({ uniqueName });
223+
224+
expect(toggles.__redisChannel).toBe([DEFAULT_REDIS_CHANNEL, uniqueName].join("-"));
225+
expect(toggles.__redisKey).toBe([DEFAULT_REDIS_KEY, uniqueName].join("-"));
226+
227+
expect(loggerSpy.warning).not.toHaveBeenCalled();
228+
expect(loggerSpy.error).not.toHaveBeenCalled();
229+
});
230+
});
231+
218232
describe("basic apis", () => {
219233
test("initializeFeatureToggles", async () => {
220234
await toggles.initializeFeatures({ config: mockConfig });

0 commit comments

Comments
 (0)