Skip to content
This repository was archived by the owner on Dec 26, 2019. It is now read-only.

Commit 67b7738

Browse files
committed
add test for customParser
1 parent 9a115bd commit 67b7738

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/unit/components/bootstrap-datepicker-test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,32 @@ test('displays date with custom format when format is set', function(assert) {
4242
assert.equal(this.$().val(), '31.Dec.14');
4343
});
4444

45+
test('resets date when input is cleared', function(assert) {
46+
this.subject({
47+
value: new Date(2014, 11, 31)
48+
});
49+
50+
assert.ok(this.$().datepicker('getDate'), 'initial value is set');
51+
52+
this.$().val('');
53+
this.$().trigger('input');
54+
55+
assert.equal(this.$().datepicker('getDate'), null, 'value is reset when input is cleared');
56+
});
57+
58+
test('should use customParser if provided', function(assert) {
59+
assert.expect(1);
60+
61+
this.subject({
62+
value: '2015-09-14T16:59:01+02:00',
63+
customParser: function(value) {
64+
return new Date(value);
65+
}
66+
});
67+
68+
assert.equal(this.$().val(), '09/14/2015');
69+
});
70+
4571
test('sets dates provided by value (multidate, default multidateSeparator)', function(assert) {
4672
this.subject({
4773
value: [new Date(2015, 0, 13), new Date(2015, 0, 7), new Date(2015, 0, 15)],

0 commit comments

Comments
 (0)