From 916877dc4eeb349423e6c7cfcd2095753d1d8127 Mon Sep 17 00:00:00 2001 From: adams85 <31276480+adams85@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:57:27 +0200 Subject: [PATCH] Add test case to verify that custom base url is respected when config json indicates redirect (#103) --- test/DataGovernanceTests.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/DataGovernanceTests.ts b/test/DataGovernanceTests.ts index 7a887d0..cb2a45a 100644 --- a/test/DataGovernanceTests.ts +++ b/test/DataGovernanceTests.ts @@ -139,6 +139,24 @@ describe("DataGovernance", () => { configService.validateCall(1, customUrl); }); + it("sdk global, custom - should respect custom url when redirect is not forced", async () => { + // In this case + // the first invocation should call https://cdn-custom.configcat.com + // the second invocation should call https://cdn-custom.configcat.com + const configService = new FakeConfigServiceBase(DataGovernance.Global, customUrl); + configService.prepareResponse(customUrl, globalUrl, 1, null); + + let [, config] = await configService.refreshLogicAsync(); + assert.isNull(JSON.parse(config.configJson!)["f"]); + configService.validateCallCount(1); + configService.validateCall(0, customUrl); + + [, config] = await configService.refreshLogicAsync(); + assert.isNull(JSON.parse(config.configJson!)["f"]); + configService.validateCallCount(2); + configService.validateCall(1, customUrl); + }); + it("sdk global, forced", async () => { // In this case // the first invocation should call https://cdn-global.configcat.com