Skip to content

Commit

Permalink
add back in stickysession once belter updated
Browse files Browse the repository at this point in the history
  • Loading branch information
cgdibble committed Jan 23, 2024
1 parent b87b37a commit 2db61f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ export function getClientMetadataID(): ?string {
return getSDKAttribute(SDK_SETTINGS.CLIENT_METADATA_ID);
}

function getSDKStorage(): Storage {
export function getSDKStorage(): Storage {
return getStorage({
name: getNamespace(),
stickySessionId: getClientMetadataID() || "",
});
}

Expand Down
14 changes: 13 additions & 1 deletion src/session.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @flow */
import { describe, it, afterEach, expect, vi } from "vitest";
import { getCurrentScript, memoize } from "@krakenjs/belter/src";
import { getCurrentScript, memoize, getStorage } from "@krakenjs/belter/src";

import { makeMockScriptElement } from "../test/helpers";

Expand All @@ -9,6 +9,7 @@ import {
getStorageID,
getSessionState,
getClientMetadataID,
getSDKStorage,
} from "./session";

const clientId = "foobar123";
Expand Down Expand Up @@ -64,4 +65,15 @@ describe("session cases", () => {
const result = getClientMetadataID();
expect(result).toEqual(mockMerchantIds);
});

it("uses getStorage to retrieve the storage", () => {
// $FlowIgnore
getStorage = vi.fn();

Check failure on line 71 in src/session.test.js

View workflow job for this annotation

GitHub Actions / main

'getStorage' is read-only
getSDKStorage();

expect(getStorage).toBeCalledWith({
name: expect.any(String),
stickySessionId: expect.any(String),
});
});
});

0 comments on commit 2db61f4

Please sign in to comment.