Skip to content

Commit

Permalink
MAGETWO-54733: Unable to save product with all unchecked values for m…
Browse files Browse the repository at this point in the history
…ultiple select attribute #7687
  • Loading branch information
VladimirZaets committed Jan 17, 2017
1 parent b6c5198 commit 72bd339
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ define([
return _.isString(value) ? value.split(',') : value;
},

/**
* Sets the prepared data to dataSource
* by path, where key is component link to dataSource with
* suffix "-prepared-for-send"
*
* @param {Array} data - current component value
*/
setPrepareToSendData: function (data) {

if (!data.length) {
data = '';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

/* eslint max-nested-callbacks: 0 */
define([
'squire'
], function (Squire) {
'use strict';

var injector = new Squire(),
mocks = {
'Magento_Ui/js/lib/core/events': {
on: jasmine.createSpy()
},
'Magento_Ui/js/lib/registry/registry': {
get: function() {
return {
get: jasmine.createSpy(),
set: jasmine.createSpy()
};
},
create: jasmine.createSpy(),
set: jasmine.createSpy(),
async: jasmine.createSpy()
},
'/mage/utils/wrapper': jasmine.createSpy()
},
obj,
dataScope = 'dataScope';

beforeEach(function (done) {
injector.mock(mocks);
injector.require(['Magento_Ui/js/form/element/multiselect'], function (Constr) {
obj = new Constr({
provider: 'provName',
name: '',
index: '',
dataScope: dataScope
});

done();
});
});

describe('Magento_Ui/js/form/element/multiselect', function () {
describe('"setPrepareToSendData" method', function () {
it('Check method call with empty array as parameter.', function () {
expect(obj.setPrepareToSendData([])).toBeUndefined();
expect(obj.source.set).toHaveBeenCalledWith(dataScope + '-prepared-for-send', '');
});

it('Check method call with array with data as parameter.', function () {
expect(obj.setPrepareToSendData(['1', '2', '3'])).toBeUndefined();
expect(obj.source.set).toHaveBeenCalledWith(dataScope + '-prepared-for-send', ['1', '2', '3']);
});
});
});
});

0 comments on commit 72bd339

Please sign in to comment.