Skip to content

Commit

Permalink
add tests to reproduce #152
Browse files Browse the repository at this point in the history
  • Loading branch information
jdewit committed Oct 6, 2013
1 parent 2cb08b1 commit 87aca0f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
*.swp
_site/
.grunt
node_modules
gruntfile.js
_site
Expand Down
12 changes: 11 additions & 1 deletion spec/js/KeyboardEventsSpec.js
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 9 additions & 1 deletion spec/js/TimepickerSpec.js
Expand Up @@ -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;
Expand All @@ -108,6 +109,12 @@ describe('Timepicker feature', function() {
minutes = 0;
}

if (hour < 13) {
meridian = 'AM';
} else {
meridian = 'PM';
}

if (hour > 12) {
hour = hour - 12;
}
Expand All @@ -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() {
Expand Down

0 comments on commit 87aca0f

Please sign in to comment.