Skip to content

Commit de7269d

Browse files
author
Jack Carrig
committed
Merge branch 'master' of https://github.com/perka/backbone-ui
2 parents 5d6ba0d + a239098 commit de7269d

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

test/date_picker.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,32 @@ $(document).ready(function() {
8181

8282
});
8383

84+
test("manually enter date", function() {
85+
var coffee = new Backbone.Model({
86+
roaster: 'Counter Culture',
87+
name: 'Baroida',
88+
roastedOn: null,
89+
acidic: true
90+
});
91+
92+
var datepicker = new Backbone.UI.DatePicker({
93+
model: coffee,
94+
content: 'roastedOn'
95+
}).render();
96+
97+
$('body').append(datepicker.el);
98+
99+
//type in datepicker and check if model updates
100+
$(datepicker.el).find('input').simulate("key-sequence", {sequence: "08/24/1981"});
101+
$(datepicker.el).find('input').simulate("key-sequence", {sequence: "{enter}"});
102+
103+
//check model changed
104+
equal(coffee.get('roastedOn').getMonth(),'7');
105+
equal(coffee.get('roastedOn').getDate(),'24');
106+
equal(coffee.get('roastedOn').getFullYear(),'1981');
107+
108+
});
109+
84110
test("format", function() {
85111
var datepicker = new Backbone.UI.DatePicker({
86112
date : new Date(2013, 2, 22),

test/time_picker.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@ $(document).ready(function() {
3737

3838
});
3939

40+
test("manually enter time", function() {
41+
var coffee = new Backbone.Model({
42+
roaster: 'Counter Culture',
43+
name: 'Baroida',
44+
roastedOn: null,
45+
acidic: true
46+
});
47+
48+
var timepicker = new Backbone.UI.TimePicker({
49+
model: coffee,
50+
content: 'roastedOn'
51+
}).render();
52+
53+
$('body').append(timepicker.el);
54+
55+
//type in datepicker and check if model updates
56+
$(timepicker.el).find('input').simulate("key-sequence", {sequence: "8:30 pm"});
57+
$(timepicker.el).find('input').simulate("key-sequence", {sequence: "{enter}"});
58+
59+
//check that the model updated
60+
equal(coffee.get('roastedOn').getHours(),20);
61+
equal(coffee.get('roastedOn').getMinutes(),30);
62+
63+
64+
});
65+
4066
test("interval", function() {
4167

4268
var coffee = new Backbone.Model({

test/vendor/jquery.simulate.key-sequence.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
// there's a flash of selection when we restore the focus, but I don't know how to avoid that.
8585
$.data(target, 'simulate-keySequence.selection').select();
8686
}else{
87-
$.data(target, 'simulate-keySequence.selection').bounds('selection');
87+
if($.data(target, 'simulate-keySequence.selection')) $.data(target, 'simulate-keySequence.selection').bounds('selection');
8888
}
8989
});
9090
}

0 commit comments

Comments
 (0)