Skip to content

Commit 2465603

Browse files
committed
AC-1453: Fix Static/Unit test
- Fix static tests
1 parent 69c1645 commit 2465603

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

dev/tests/js/jasmine/tests/lib/mage/form.test.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,28 @@ define([
1111
], function ($) {
1212
'use strict';
1313

14-
/*
15-
* jQuery ui version 1.9.2 belongs to the adminhtml.
16-
*
17-
* This test will fail on frontend since mage/backend/form only belongs to backend.
18-
*/
1914
describe('Test for mage/form jQuery plugin', function () {
2015
var id = 'edit_form',
2116
elementId = '#' + id;
17+
2218
beforeEach(function () {
2319
var element = $('<form id="' + id + '" action="action/url" method="GET" target="_self" ></form>');
20+
2421
element.appendTo('body');
2522
});
2623
afterEach(function () {
2724
$(elementId).remove();
2825
});
2926
it('check if form can be initialized', function () {
3027
var form = $(elementId).form();
28+
3129
expect(form.is(':mage-form')).toBeTruthy();
3230
});
3331
it('check get handlers', function () {
3432
var form = $(elementId).form(),
3533
handlersData = form.form('option', 'handlersData'),
3634
handlers = [];
35+
3736
$.each(handlersData, function (key) {
3837
handlers.push(key);
3938
});
@@ -46,6 +45,7 @@ define([
4645
target: form.attr('target'),
4746
method: form.attr('method')
4847
};
48+
4949
form.data('mageForm')._storeAttribute('action');
5050
form.data('mageForm')._storeAttribute('target');
5151
form.data('mageForm')._storeAttribute('method');
@@ -57,6 +57,7 @@ define([
5757
var form = $(elementId).form(),
5858
submitted = false,
5959
handlersData = form.form('option', 'handlersData');
60+
6061
form.on('submit', function (e) {
6162
submitted = true;
6263
e.stopImmediatePropagation();
@@ -78,6 +79,7 @@ define([
7879
arg: 'value'
7980
}
8081
};
82+
8183
form.data('mageForm')._storeAttribute('action');
8284
expect(form.data('mageForm')._getActionUrl(testArgs)).toBe(action + '/arg/value/');
8385
expect(form.data('mageForm')._getActionUrl(testUrl)).toBe(testUrl);
@@ -103,6 +105,7 @@ define([
103105
}
104106
},
105107
processedData = form.data('mageForm')._processData(testSimpleData);
108+
106109
expect(form.data('mageForm').oldAttributes.action).toBe(initialFormAttrs.action);
107110
expect(form.data('mageForm').oldAttributes.target).toBe(initialFormAttrs.target);
108111
expect(form.data('mageForm').oldAttributes.method).toBe(initialFormAttrs.method);
@@ -140,6 +143,7 @@ define([
140143
method: 'POST'
141144
},
142145
resultData = $.extend(true, {}, testHandler, beforeSubmitData, eventData);
146+
143147
form.data('mageForm')._storeAttribute('action');
144148
resultData = form.data('mageForm')._processData(resultData);
145149
testForm.prop(resultData);
@@ -162,6 +166,7 @@ define([
162166
save: {}
163167
}
164168
});
169+
165170
form.data('mageForm')._storeAttribute('action');
166171
form.data('mageForm')._storeAttribute('target');
167172
form.data('mageForm')._storeAttribute('method');
@@ -218,7 +223,9 @@ define([
218223
method = $.mage.form._proto._buildURL,
219224
quantity = dataProvider.length,
220225
i = 0;
226+
221227
expect(quantity).toBeTruthy();
228+
222229
for (i; i < quantity; i++) {
223230
expect(dataProvider[i].expected).toBe(method.apply(null, dataProvider[i].params));
224231
}

0 commit comments

Comments
 (0)