Skip to content

Commit c5ece6f

Browse files
committed
test: updated jest test for persitence
1 parent 2445dc8 commit c5ece6f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

test/jest/persistence.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('Persistence', () => {
1313
store = {} as IStore;
1414
mockMPInstance = {
1515
_Helpers: {
16-
createMainStorageName: () => 'mprtcl-v4',
16+
createMainStorageName: () => 'mprtcl-v4_'+ 'test-workspace-token',
1717
isObject,
1818
},
1919
_NativeSdkHelpers: {
@@ -33,6 +33,7 @@ describe('Persistence', () => {
3333
} as unknown as IMParticleWebSDKInstance;
3434

3535
Store.call(store, {} as SDKInitConfig, mockMPInstance, 'apikey');
36+
store.processConfig({ workspaceToken: 'test-workspace-token' } as SDKInitConfig);
3637

3738
store.isLocalStorageAvailable = true;
3839
store.SDKConfig.useCookieStorage = true;
@@ -94,7 +95,7 @@ describe('Persistence', () => {
9495

9596
expect(setCookieSpy).toHaveBeenCalled();
9697
expect(setLocalStorageSpy).toHaveBeenCalled();
97-
expect(window.localStorage.getItem(encodeURIComponent(store.storageName))).not.toBeNull();
98+
expect(window.localStorage.getItem(encodeURIComponent(store.storageName))).toBeNull();
9899
});
99100

100101
it('should write to localStorage when useCookieStorage is false', () => {
@@ -129,7 +130,7 @@ describe('Persistence', () => {
129130

130131
expect(setCookieSpy).toHaveBeenCalled();
131132
expect(setLocalStorageSpy).toHaveBeenCalled();
132-
expect(window.localStorage.getItem(encodeURIComponent(store.storageName))).not.toBeNull();
133+
expect(window.localStorage.getItem(encodeURIComponent(store.storageName))).toBeNull();
133134
});
134135

135136
it('should write to localStorage by default when useCookieStorage is false', () => {

0 commit comments

Comments
 (0)