Skip to content

Commit

Permalink
fix(uiDateMask): lock date-fns version (2.0.0-alpha.7) and fix date m…
Browse files Browse the repository at this point in the history
…ask tests
  • Loading branch information
assisrafael committed Jun 18, 2018
1 parent dbfe5ff commit a785dc9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"license": "MIT",
"dependencies": {
"br-validations": "^0.3.1",
"date-fns": "^2.0.0-alpha.7",
"moment": "^2.8.4",
"date-fns": "2.0.0-alpha.7",
"string-mask": "^0.3.0"
},
"devDependencies": {
Expand Down
24 changes: 12 additions & 12 deletions src/global/date/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ function isISODateString(date) {
.test(date.toString());
}

function DateMaskDirective($locale) {
var dateFormatMapByLocale = {
'pt-br': 'DD/MM/YYYY',
'es-ar': 'DD/MM/YYYY',
'es-mx': 'DD/MM/YYYY',
'es' : 'DD/MM/YYYY',
'en-us': 'MM/DD/YYYY',
'en' : 'MM/DD/YYYY',
'fr-fr': 'DD/MM/YYYY',
'fr' : 'DD/MM/YYYY',
'ru' : 'DD.MM.YYYY'
};
var dateFormatMapByLocale = {
'pt-br': 'DD/MM/YYYY',
'es-ar': 'DD/MM/YYYY',
'es-mx': 'DD/MM/YYYY',
'es' : 'DD/MM/YYYY',
'en-us': 'MM/DD/YYYY',
'en' : 'MM/DD/YYYY',
'fr-fr': 'DD/MM/YYYY',
'fr' : 'DD/MM/YYYY',
'ru' : 'DD.MM.YYYY'
};

function DateMaskDirective($locale) {
var dateFormat = dateFormatMapByLocale[$locale.id] || 'YYYY-MM-DD';

return {
Expand Down
6 changes: 3 additions & 3 deletions src/global/date/date.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('uiDateMask', function() {
expect(input.getAttribute('value')).toEqual(formatedDateAsString);
}

expect(value.evaluate('dateMask.toString()')).toEqual(parseDate(formatedDateAsString, 'YYYY-MM-DD', new Date()).toString());
expect(value.evaluate('dateMask.toISOString()')).toEqual(parseDate(formatedDateAsString, 'YYYY-MM-DD', new Date()).toISOString());

for (i = 7; i >= 0; i--) {
input.sendKeys(protractor.Key.BACK_SPACE);
Expand Down Expand Up @@ -60,7 +60,7 @@ describe('uiDateMask', function() {
});

it('should be valid if the model is a valid date', function() {
var inputKeysToSend = '19991231';
var inputKeysToSend = '12311999';

var input = element(by.model('dateMask')),
valid = element(by.binding('form.dateMaskInput.$error'));
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('uiDateMask', function() {
expect(input.getAttribute('value')).toEqual(formatedDateAsString);
}

expect(value.evaluate('dateMask.toString()')).toEqual(parseDate(formatedDateAsString, 'DD/MM/YYYY', new Date()).toString());
expect(value.evaluate('dateMask.toISOString()')).toEqual(parseDate(formatedDateAsString, 'DD/MM/YYYY', new Date()).toISOString());

for (i = 7; i >= 0; i--) {
input.sendKeys(protractor.Key.BACK_SPACE);
Expand Down
2 changes: 1 addition & 1 deletion src/global/date/date.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('ui-date-mask', function() {
});

var model = input.controller('ngModel');
expect(model.$viewValue).toBe(date.toLocaleDateString());
expect(model.$viewValue).toBe('12/31/1999');
});

it('should use specified mask', function() {
Expand Down

0 comments on commit a785dc9

Please sign in to comment.