Skip to content

Commit 5f9bccf

Browse files
committed
test: updated persistence tests
1 parent 4fa287f commit 5f9bccf

3 files changed

Lines changed: 11 additions & 21 deletions

File tree

src/persistence.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export default function _Persistence(mpInstance) {
2020
};
2121

2222
this.initializeStorage = function() {
23+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
24+
return;
25+
}
2326
try {
2427
var storage,
2528
localStorageData = self.getLocalStorage(),
@@ -39,9 +42,6 @@ export default function _Persistence(mpInstance) {
3942
if (!mpInstance._Store.isLocalStorageAvailable) {
4043
mpInstance._Store.SDKConfig.useCookieStorage = true;
4144
}
42-
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
43-
return;
44-
}
4545

4646
// https://go.mparticle.com/work/SQDSDKS-6046
4747
if (mpInstance._Store.isLocalStorageAvailable) {

test/jest/persistence.spec.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ import Store, { IStore } from '../../src/store';
22
import { IMParticleWebSDKInstance } from '../../src/mp-instance';
33
import { SDKInitConfig } from '../../src/sdkRuntimeModels';
44

5-
describe('Persistence store', () => {
5+
describe('Persistence', () => {
66
let store: IStore;
77
let mockMPInstance: IMParticleWebSDKInstance;
88

99
beforeEach(() => {
1010
mockMPInstance = {
1111
_Helpers: {
1212
createMainStorageName: () => 'mprtcl-v4',
13-
Validators: { isFunction: () => true },
14-
extend: Object.assign,
1513
},
1614
_NativeSdkHelpers: {
1715
isWebviewEnabled: () => false,
@@ -31,23 +29,15 @@ describe('Persistence store', () => {
3129
mockMPInstance._Persistence.setLocalStorage();
3230
},
3331
},
34-
Logger: {
35-
verbose: () => {},
36-
warning: () => {},
37-
error: () => {},
38-
},
39-
Identity: {
40-
getCurrentUser: () => ({ getMPID: () => 'mpid' }),
41-
},
4232
} as unknown as IMParticleWebSDKInstance;
4333

4434
store = {} as IStore;
4535
Store.call(store, {} as SDKInitConfig, mockMPInstance, 'apikey');
4636
window.localStorage.removeItem('mprtcl-v4');
4737
});
4838

49-
describe('#noFunctional privacy flag', () => {
50-
describe('true', () => {
39+
describe('#update', () => {
40+
describe('noFunctional privacy flag set to true', () => {
5141
beforeEach(() => {
5242
store.setNoFunctional(true);
5343
store.webviewBridgeEnabled = false;
@@ -74,7 +64,7 @@ describe('Persistence store', () => {
7464
});
7565
});
7666

77-
describe('false', () => {
67+
describe('noFunctional privacy flag set to false', () => {
7868
beforeEach(() => {
7969
store.setNoFunctional(false);
8070
store.webviewBridgeEnabled = false;
@@ -101,7 +91,7 @@ describe('Persistence store', () => {
10191
});
10292
});
10393

104-
describe('is false by default', () => {
94+
describe('noFunctional privacy flag set to false by default', () => {
10595
beforeEach(() => {
10696
// default is false
10797
store.webviewBridgeEnabled = false;

test/src/tests-persistence.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,12 +1949,12 @@ describe('persistence', () => {
19491949
user2.getAllUserAttributes()['ua-1'].should.equal('a');
19501950
});
19511951

1952-
describe('#noFunctional', () => {
1952+
describe('noFunctional privacy flag', () => {
19531953
beforeEach(() => {
19541954
mParticle._resetForTests(MPConfig);
19551955
});
19561956

1957-
describe('true', () => {
1957+
describe('set to true', () => {
19581958
beforeEach(() => {
19591959
mParticle.config.launcherOptions = { noFunctional: true };
19601960
});
@@ -1982,7 +1982,7 @@ describe('persistence', () => {
19821982
});
19831983
});
19841984

1985-
describe('false', () => {
1985+
describe('set to false', () => {
19861986
beforeEach(() => {
19871987
mParticle.config.launcherOptions = { noFunctional: false };
19881988
});

0 commit comments

Comments
 (0)