Permalink
Browse files

add tests to reproduce #152

  • Loading branch information...
1 parent 2cb08b1 commit 87aca0f95bec0928cdebe7ec12721c021ea8c9b4 @jdewit committed Oct 6, 2013
Showing with 21 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +11 −1 spec/js/KeyboardEventsSpec.js
  3. +9 −1 spec/js/TimepickerSpec.js
View
@@ -1,5 +1,6 @@
*.swp
_site/
+.grunt
node_modules
gruntfile.js
_site
@@ -47,6 +47,16 @@ describe('Keyboard events feature', function() {
$input3.remove();
});
+ it('should be able to set time via input', function() {
+
+ $input1.trigger('focus');
+ $input1.autotype('{{back}}{{back}}{{back}}{{back}}{{back}}{{back}}{{back}}{{back}}9:45a{{tab}}');
+
+ expect(tp1.highlightedUnit).not.toBe('minute');
+ expect(tp1.getTime()).toBe('09:45 AM');
+ expect($input1.is(':focus')).toBe(false);
+ });
+
it('should be able to control element by the arrow keys', function() {
tp1.setTime('11:30 AM');
tp1.update();
@@ -160,7 +170,6 @@ describe('Keyboard events feature', function() {
eventCount = 0,
time;
-
tp1.setTime('9:30 AM');
tp1.update();
$input1.parents('div').find('.add-on').click();
@@ -197,6 +206,7 @@ describe('Keyboard events feature', function() {
expect($input1.val()).toBe('');
});
+
it('should allow time to be changed via widget inputs in a modal', function() {
tp2.setTime('9:30 AM');
tp2.update();
View
@@ -97,7 +97,8 @@ describe('Timepicker feature', function() {
it('should have current time by default', function() {
var dTime = new Date(),
hour = dTime.getHours(),
- minutes = dTime.getMinutes();
+ minutes = dTime.getMinutes(),
+ meridian;
if (minutes !== 0) {
minutes = Math.ceil(minutes / tp1.minuteStep) * tp1.minuteStep;
@@ -108,6 +109,12 @@ describe('Timepicker feature', function() {
minutes = 0;
}
+ if (hour < 13) {
+ meridian = 'AM';
+ } else {
+ meridian = 'PM';
+ }
+
if (hour > 12) {
hour = hour - 12;
}
@@ -117,6 +124,7 @@ describe('Timepicker feature', function() {
expect(tp1.hour).toBe(hour);
expect(tp1.minute).toBe(minutes);
+ expect(tp1.meridian).toBe(meridian);
});
it('should not override time with current time if value is already set', function() {

0 comments on commit 87aca0f

Please sign in to comment.