Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/dateparser/dateparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ angular.module('ui.bootstrap.dateparser', [])
format[i] = '$';
}
format = format.join('');
var dupe=format.indexOf(code[0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add spaces around the =

if (dupe>-1){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add spaces between the > and before {

throw new Error('Invalid date format string.');
}

map.push({ index: index, apply: data.apply });
}
Expand Down
8 changes: 8 additions & 0 deletions src/dateparser/test/dateparser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,12 @@ describe('date parser', function () {
it('should not parse if no format is specified', function() {
expect(dateParser.parse('21.08.1951', '')).toBe('21.08.1951');
});

it('should not parse if invalid format is specified', function() {
expect(function(){dateParser.parse('20.12.20190', 'dd.MM.yyyyy');}).toThrow(new Error('Invalid date format string.'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add spaces, i.e. function() { dateParser.parse('20.12.20190', 'dd.MM.yyyyy'); }

});

it('should not parse if invalid value is specified', function() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two tests with the same name?

expect(dateParser.parse('20.12.20190', 'dd.MM.yyyy')).toBeUndefined();
});
});