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 19, 2017
1 parent b86644e commit efac464
Showing 1 changed file with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ define([
'uiRegistry',
'Magento_Ui/js/form/client',
'jquery',
'mageUtils'
'mageUtils',
'jquery/ui'
], function (_, registry, Constr, $, utils) {
'use strict';

Expand Down Expand Up @@ -78,8 +79,8 @@ define([

utils.filterFormData = jasmine.createSpy().and.returnValue(data);
utils.serialize = jasmine.createSpy().and.returnValue(data);
$.ajax = jasmine.createSpy();

$.ajax = jasmine.createSpy();
obj.save(data);
expect(utils.filterFormData).toHaveBeenCalledWith(data);
expect(utils.serialize).toHaveBeenCalledWith(data);
Expand All @@ -93,6 +94,56 @@ define([

expect($.ajax).not.toHaveBeenCalled();
});
it('Check call "beforeSave" method. Check "success" ajax callback with success response.' , function () {
var request;

$.ajax = jasmine.createSpy().and.callFake(function (req) {
request = req.success;
});
$.fn.notification = jasmine.createSpy();
obj.urls.beforeSave = 'requestPath';
obj.save();

expect(request({error: false})).toBe(true);
expect($('body').notification).not.toHaveBeenCalledWith('clear');
});

it('Check call "beforeSave" method. Check "success" ajax callback with error response.' , function () {
var request,
notificationArguments;

$.ajax = jasmine.createSpy().and.callFake(function (req) {
request = req.success;
});
$.fn.notification = jasmine.createSpy();
obj.urls.beforeSave = 'requestPath';
obj.save();

notificationArguments = {
error: true,
message: 1,
insertMethod: jasmine.any(Function)
};

expect(request({
error: true,
messages: [1]
})).toBeUndefined();
expect($('body').notification.calls.allArgs()).toEqual([['clear'], ['add', notificationArguments]]);
});
it('Check call "beforeSave" method. Check "complete" ajax callback with error response.' , function () {
var request;

$.ajax = jasmine.createSpy().and.callFake(function (req) {
request = req.complete;
});
$.fn.trigger = jasmine.createSpy();
obj.urls.beforeSave = 'requestPath';
obj.save();

expect(request()).toBeUndefined();
expect($('body').trigger).toHaveBeenCalledWith('processStop');
});
});

describe('"initialize" method', function () {
Expand Down

0 comments on commit efac464

Please sign in to comment.