Skip to content

Commit 68bced2

Browse files
committed
MAGETWO-59718: Date sets to 2020 year after save
- Added Jasmine unit tests
1 parent 3ba577e commit 68bced2

File tree

2 files changed

+22
-3
lines changed
  • app/code/Magento/Ui/view/base/web/js/form/element
  • dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element

2 files changed

+22
-3
lines changed

app/code/Magento/Ui/view/base/web/js/form/element/date.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ define([
196196

197197
newFormat = format.replace(/yy|y/gi, 'YYYY'); // replace the year
198198
newFormat = newFormat.replace(/dd|d/g, 'DD'); // replace the date
199-
newFormat = newFormat.replace(/mm|m/g, 'MM'); //replace the month
199+
newFormat = newFormat.replace(/mm|m/gi, 'MM'); //replace the month
200200

201201
return newFormat;
202202
}

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
/*eslint max-nested-callbacks: 0*/
77

88
define([
9-
'Magento_Ui/js/form/element/date'
10-
], function (DateElement) {
9+
'Magento_Ui/js/form/element/date',
10+
'mageUtils'
11+
], function (DateElement, utils) {
1112
'use strict';
1213

1314
describe('Magento_Ui/js/form/element/date', function () {
@@ -19,5 +20,23 @@ define([
1920
};
2021
model = new DateElement(params);
2122
});
23+
24+
it('Check convertToMomentFormat function', function () {
25+
var format,
26+
momentFormat;
27+
28+
format = 'M/d/yy';
29+
momentFormat = 'MM/DD/YYYY';
30+
expect(model.convertToMomentFormat(format)).toBe(momentFormat);
31+
});
32+
33+
it('Check prepareDateTimeFormats function', function () {
34+
spyOn(model, 'convertToMomentFormat');
35+
spyOn(utils, 'normalizeDate');
36+
model.prepareDateTimeFormats();
37+
expect(model.convertToMomentFormat).toHaveBeenCalled();
38+
expect(utils.normalizeDate).toHaveBeenCalled();
39+
});
40+
2241
});
2342
});

0 commit comments

Comments
 (0)