Skip to content

Commit 29d0de7

Browse files
committed
chore: add tests
1 parent ef0e849 commit 29d0de7

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

packages/sdk/tests/index.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,6 +2581,33 @@ describe("restoreReplaneClient", () => {
25812581
mockServer.close();
25822582
});
25832583

2584+
it("should not throw error when SDK key and baseUrl are missing", async () => {
2585+
const snapshot: ReplaneSnapshot<Record<string, unknown>> = {
2586+
configs: [{ name: "config1", value: "snapshot-value", overrides: [] }],
2587+
};
2588+
2589+
const client = restoreReplaneClient({
2590+
snapshot,
2591+
connection: {
2592+
sdkKey: undefined as unknown as string,
2593+
baseUrl: undefined as unknown as string,
2594+
fetchFn: mockServer.fetchFn,
2595+
logger: silentLogger,
2596+
},
2597+
});
2598+
2599+
// Should work with snapshot data even though connection is invalid
2600+
expect(client.get("config1")).toBe("snapshot-value");
2601+
2602+
// Give time for the background streaming to fail
2603+
await sync();
2604+
2605+
// Should still work after streaming failure
2606+
expect(client.get("config1")).toBe("snapshot-value");
2607+
2608+
client.close();
2609+
});
2610+
25842611
it("should restore from snapshot and connect for live updates", async () => {
25852612
const snapshot: ReplaneSnapshot<Record<string, unknown>> = {
25862613
configs: [{ name: "config1", value: "snapshot-value", overrides: [] }],

0 commit comments

Comments
 (0)