@ordergroove/offers 2.21.5-alpha-PR-516-2.0 → 2.21.7
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 +27 -0
- package/dist/bundle-report.html +1 -1
- package/dist/examples.js +2 -2
- package/dist/examples.js.map +1 -1
- package/dist/offers.js.map +1 -1
- package/package.json +3 -3
- package/src/core/__tests__/localStorage.spec.js +35 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.7",
|
|
4
4
|
"description": "offer state component",
|
|
5
5
|
"author": "Eugenio Lattanzio <eugenio63@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ordergroove/plush-toys#readme",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@ordergroove/js-utils": "^1.0.3",
|
|
50
|
-
"@ordergroove/offers-templates": "^0.3.
|
|
50
|
+
"@ordergroove/offers-templates": "^0.3.18"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "fa3c9abe256716893b2f9d59afdfefb84ebac6a0"
|
|
53
53
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { STORE_ROOT, listenLocalStorageChanges, serializeState, saveState } from '../localStorage';
|
|
1
|
+
import { STORE_ROOT, listenLocalStorageChanges, serializeState, saveState, loadState } from '../localStorage';
|
|
2
2
|
import { LOCAL_STORAGE_CHANGE, LOCAL_STORAGE_CLEAR } from '../constants';
|
|
3
3
|
|
|
4
4
|
describe('serializeState', () => {
|
|
@@ -34,6 +34,40 @@ describe('serializeState', () => {
|
|
|
34
34
|
);
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
|
+
|
|
38
|
+
describe('loadState', () => {
|
|
39
|
+
let getItemSpy, setItemSpy;
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
getItemSpy = spyOn(Object.getPrototypeOf(localStorage), 'getItem');
|
|
42
|
+
setItemSpy = spyOn(Object.getPrototypeOf(localStorage), 'setItem');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should return undefined on empty state', () => {
|
|
46
|
+
expect(loadState()).toBe(undefined);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should return undefined on empty state', () => {
|
|
50
|
+
const yum = {
|
|
51
|
+
sessionId: 'yum',
|
|
52
|
+
optedin: 'yum2',
|
|
53
|
+
optedout: 'yum3',
|
|
54
|
+
productOffer: 'yum4',
|
|
55
|
+
firstOrderPlaceDate: 'yum5',
|
|
56
|
+
productToSubscribe: 'yum6'
|
|
57
|
+
};
|
|
58
|
+
getItemSpy.and.callFake(() => JSON.stringify(yum));
|
|
59
|
+
expect(loadState()).toEqual(yum);
|
|
60
|
+
expect(getItemSpy).toHaveBeenCalledWith(STORE_ROOT);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should load empty object if preview mode', () => {
|
|
64
|
+
const tmp = window.og.previewMode;
|
|
65
|
+
window.og.previewMode = true;
|
|
66
|
+
expect(loadState()).toEqual({});
|
|
67
|
+
window.og.previewMode = tmp;
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
37
71
|
describe('saveState', () => {
|
|
38
72
|
let getItemSpy, setItemSpy;
|
|
39
73
|
beforeEach(() => {
|