Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
test(datepicker): test that changing time updates model
Browse files Browse the repository at this point in the history
- Add unit test for changing the time and verifying that the model updates

Closes #5073
  • Loading branch information
bgrohman authored and wesleycho committed Dec 14, 2015
1 parent e6474f0 commit a49ce8e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/datepicker/test/datepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,24 @@ describe('datepicker', function() {
expect(inputEl.val()).toBe('10-January-1983');
});
});

describe('custom format with time', function() {
beforeEach(inject(function() {
var wrapElement = $compile('<div><input type="text" ng-model="date" uib-datepicker-popup="MMM-d-yyyy h:mm a" is-open="false"><div>')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
}));

it('updates the model correctly when the input value changes', function() {
$rootScope.date = new Date(2015, 10, 24, 10, 0);
$rootScope.$digest();
expect(inputEl.val()).toBe('Nov-24-2015 10:00 AM');

inputEl.val('Nov-24-2015 11:00 AM').trigger('input');
$rootScope.$digest();
expect($rootScope.date).toEqual(new Date(2015, 10, 24, 11, 0));
});
});

describe('dynamic custom format', function() {
beforeEach(inject(function() {
Expand Down

0 comments on commit a49ce8e

Please sign in to comment.