@ordergroove/offers 2.40.1-alpha-PR-1079-1.0 → 2.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/bundle-report.html +4 -4
- package/dist/offers.js +1 -1
- package/dist/offers.js.map +2 -2
- package/package.json +2 -2
- package/src/core/__tests__/localStorage.spec.js +0 -14
- package/src/core/localStorage.js +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.40.
|
|
3
|
+
"version": "2.40.2",
|
|
4
4
|
"description": "offer state component",
|
|
5
5
|
"author": "Eugenio Lattanzio <eugenio63@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ordergroove/plush-toys#readme",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@ordergroove/offers-templates": "^0.9.6",
|
|
50
50
|
"@types/lodash.memoize": "^4.1.9"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "d2b9d0b60d78396e064037cffebf1cb2a494cd5f"
|
|
53
53
|
}
|
|
@@ -60,7 +60,6 @@ describe('loadState', () => {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
it('should load empty object if preview mode', () => {
|
|
63
|
-
window.og = window.og || {};
|
|
64
63
|
const tmp = window.og.previewMode;
|
|
65
64
|
window.og.previewMode = true;
|
|
66
65
|
expect(loadState()).toEqual({});
|
|
@@ -69,21 +68,10 @@ describe('loadState', () => {
|
|
|
69
68
|
});
|
|
70
69
|
|
|
71
70
|
describe('saveState', () => {
|
|
72
|
-
let cookieSpy;
|
|
73
71
|
let getItemSpy, setItemSpy;
|
|
74
72
|
beforeEach(() => {
|
|
75
73
|
getItemSpy = spyOn(Object.getPrototypeOf(localStorage), 'getItem');
|
|
76
74
|
setItemSpy = spyOn(Object.getPrototypeOf(localStorage), 'setItem');
|
|
77
|
-
cookieSpy = '';
|
|
78
|
-
Object.defineProperty(document, 'cookie', {
|
|
79
|
-
get: function () {
|
|
80
|
-
return cookieSpy;
|
|
81
|
-
},
|
|
82
|
-
set: function (value) {
|
|
83
|
-
cookieSpy = value;
|
|
84
|
-
},
|
|
85
|
-
configurable: true // Ensure property can be redefined in future tests
|
|
86
|
-
});
|
|
87
75
|
});
|
|
88
76
|
|
|
89
77
|
it('should not save empty state', function () {
|
|
@@ -95,7 +83,6 @@ describe('saveState', () => {
|
|
|
95
83
|
it('should not save if same state', function () {
|
|
96
84
|
getItemSpy.and.returnValue(JSON.stringify({ sessionId: 'yum' }));
|
|
97
85
|
saveState({ sessionId: 'yum' });
|
|
98
|
-
expect(cookieSpy).toEqual('og_session_id=yum; path=/; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=Lax');
|
|
99
86
|
expect(getItemSpy).toHaveBeenCalledWith(STORE_ROOT);
|
|
100
87
|
expect(setItemSpy).not.toHaveBeenCalled();
|
|
101
88
|
});
|
|
@@ -103,7 +90,6 @@ describe('saveState', () => {
|
|
|
103
90
|
it('should save if different state', function () {
|
|
104
91
|
const payload = { sessionId: 'yum' };
|
|
105
92
|
saveState(payload);
|
|
106
|
-
expect(cookieSpy).toEqual('og_session_id=yum; path=/; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=Lax');
|
|
107
93
|
expect(getItemSpy).toHaveBeenCalledWith(STORE_ROOT);
|
|
108
94
|
expect(setItemSpy).toHaveBeenCalledWith(STORE_ROOT, JSON.stringify({ sessionId: 'yum' }));
|
|
109
95
|
});
|
package/src/core/localStorage.js
CHANGED
|
@@ -39,13 +39,6 @@ export const serializeState = state => {
|
|
|
39
39
|
|
|
40
40
|
export const saveState = state => {
|
|
41
41
|
if (isPreviewMode()) return;
|
|
42
|
-
if (state && state.sessionId) {
|
|
43
|
-
document.cookie =
|
|
44
|
-
'og_session_id=' +
|
|
45
|
-
encodeURIComponent(state.sessionId) +
|
|
46
|
-
'; path=/; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=Lax';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
42
|
const serializedState = serializeState(state);
|
|
50
43
|
if (serializedState && localStorage.getItem(STORE_ROOT) !== serializedState) {
|
|
51
44
|
localStorage.setItem(STORE_ROOT, serializedState);
|