Skip to content

Commit efac464

Browse files
committed
MAGETWO-54733: Unable to save product with all unchecked values for multiple select attribute #7687
1 parent b86644e commit efac464

File tree

1 file changed

+53
-2
lines changed
  • dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form

1 file changed

+53
-2
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/client.test.js

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ define([
1212
'uiRegistry',
1313
'Magento_Ui/js/form/client',
1414
'jquery',
15-
'mageUtils'
15+
'mageUtils',
16+
'jquery/ui'
1617
], function (_, registry, Constr, $, utils) {
1718
'use strict';
1819

@@ -78,8 +79,8 @@ define([
7879

7980
utils.filterFormData = jasmine.createSpy().and.returnValue(data);
8081
utils.serialize = jasmine.createSpy().and.returnValue(data);
81-
$.ajax = jasmine.createSpy();
8282

83+
$.ajax = jasmine.createSpy();
8384
obj.save(data);
8485
expect(utils.filterFormData).toHaveBeenCalledWith(data);
8586
expect(utils.serialize).toHaveBeenCalledWith(data);
@@ -93,6 +94,56 @@ define([
9394

9495
expect($.ajax).not.toHaveBeenCalled();
9596
});
97+
it('Check call "beforeSave" method. Check "success" ajax callback with success response.' , function () {
98+
var request;
99+
100+
$.ajax = jasmine.createSpy().and.callFake(function (req) {
101+
request = req.success;
102+
});
103+
$.fn.notification = jasmine.createSpy();
104+
obj.urls.beforeSave = 'requestPath';
105+
obj.save();
106+
107+
expect(request({error: false})).toBe(true);
108+
expect($('body').notification).not.toHaveBeenCalledWith('clear');
109+
});
110+
111+
it('Check call "beforeSave" method. Check "success" ajax callback with error response.' , function () {
112+
var request,
113+
notificationArguments;
114+
115+
$.ajax = jasmine.createSpy().and.callFake(function (req) {
116+
request = req.success;
117+
});
118+
$.fn.notification = jasmine.createSpy();
119+
obj.urls.beforeSave = 'requestPath';
120+
obj.save();
121+
122+
notificationArguments = {
123+
error: true,
124+
message: 1,
125+
insertMethod: jasmine.any(Function)
126+
};
127+
128+
expect(request({
129+
error: true,
130+
messages: [1]
131+
})).toBeUndefined();
132+
expect($('body').notification.calls.allArgs()).toEqual([['clear'], ['add', notificationArguments]]);
133+
});
134+
it('Check call "beforeSave" method. Check "complete" ajax callback with error response.' , function () {
135+
var request;
136+
137+
$.ajax = jasmine.createSpy().and.callFake(function (req) {
138+
request = req.complete;
139+
});
140+
$.fn.trigger = jasmine.createSpy();
141+
obj.urls.beforeSave = 'requestPath';
142+
obj.save();
143+
144+
expect(request()).toBeUndefined();
145+
expect($('body').trigger).toHaveBeenCalledWith('processStop');
146+
});
96147
});
97148

98149
describe('"initialize" method', function () {

0 commit comments

Comments
 (0)