Skip to content

Commit 8db5c2f

Browse files
committed
Merge remote-tracking branch 'origin/port-2752' into port-2752
2 parents d9a3cf5 + 62520af commit 8db5c2f

File tree

3 files changed

+67
-16
lines changed

3 files changed

+67
-16
lines changed

app/code/Magento/Catalog/view/frontend/web/js/product/storage/storage-service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ define([
4747
* @param {*} data
4848
*/
4949
add: function (data) {
50-
if (!utils.compare(data, this.data()).equal) {
50+
if (!_.isEmpty(data) && !utils.compare(data, this.data()).equal) {
5151
this.data(_.extend(utils.copy(this.data()), data));
5252
}
5353
},

dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function failedRequestDataProvider(): array
125125
return [
126126
[
127127
'ids' => [],
128-
'constraint' => self::equalTo(['Please select item(s).']),
128+
'constraint' => self::equalTo(['An item needs to be selected. Select and try again.']),
129129
'messageType' => MessageInterface::TYPE_ERROR,
130130
],
131131
[
@@ -135,7 +135,7 @@ public function failedRequestDataProvider(): array
135135
],
136136
[
137137
'ids' => null,
138-
'constraint' => self::equalTo(['Please select item(s).']),
138+
'constraint' => self::equalTo(['An item needs to be selected. Select and try again.']),
139139
'messageType' => MessageInterface::TYPE_ERROR,
140140
]
141141
];

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/storage/storage-service.test.js

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,11 @@ define([
1212

1313
var injector = new Squire(),
1414
mocks = {
15-
'Magento_Catalog/js/product/storage/ids-storage': {
16-
name: 'IdsStorage',
17-
initialize: jasmine.createSpy().and.returnValue({})
18-
},
1915
'Magento_Catalog/js/product/storage/data-storage': {},
2016
'Magento_Catalog/js/product/storage/ids-storage-compare': {}
2117
},
22-
obj;
23-
24-
beforeEach(function (done) {
25-
injector.mock(mocks);
26-
injector.require(['Magento_Catalog/js/product/storage/storage-service'], function (insance) {
27-
obj = insance;
28-
done();
29-
});
30-
});
18+
obj,
19+
utils;
3120

3221
afterEach(function () {
3322
try {
@@ -43,6 +32,19 @@ define([
4332
},
4433
storage;
4534

35+
beforeEach(function (done) {
36+
injector.mock(mocks);
37+
injector.require([
38+
'Magento_Catalog/js/product/storage/ids-storage',
39+
'Magento_Catalog/js/product/storage/storage-service',
40+
'mageUtils'
41+
], function (IdsStorage, instance, mageUtils) {
42+
obj = instance;
43+
utils = mageUtils;
44+
done();
45+
});
46+
});
47+
4648
describe('"createStorage" method', function () {
4749
it('create new storage', function () {
4850
obj.processSubscribers = jasmine.createSpy();
@@ -73,5 +75,54 @@ define([
7375
expect(typeof obj.getStorage(config.namespace)).toBe('object');
7476
});
7577
});
78+
describe('"add" method', function () {
79+
var storageValue;
80+
81+
beforeEach(function () {
82+
storage = new obj.createStorage(config);
83+
storageValue = {
84+
'property1': 1
85+
};
86+
87+
storage.set(storageValue);
88+
});
89+
90+
it('method exists', function () {
91+
expect(storage.add).toBeDefined();
92+
expect(typeof storage.add).toEqual('function');
93+
});
94+
95+
it('update value', function () {
96+
spyOn(utils, 'copy').and.callThrough();
97+
expect(storage.get()).toEqual(storageValue);
98+
99+
storageValue = {
100+
'property2': 2
101+
};
102+
103+
storage.add(storageValue);
104+
105+
expect(utils.copy).toHaveBeenCalled();
106+
expect(storage.get()).toEqual(
107+
{
108+
'property1': 1,
109+
'property2': 2
110+
}
111+
);
112+
});
113+
114+
it('add empty value', function () {
115+
spyOn(utils, 'copy').and.callThrough();
116+
117+
storage.add({});
118+
119+
expect(utils.copy).not.toHaveBeenCalled();
120+
expect(storage.get()).toEqual(
121+
{
122+
'property1': 1
123+
}
124+
);
125+
});
126+
});
76127
});
77128
});

0 commit comments

Comments
 (0)