Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added manually enter time and date tests and fixed bounding error in …

…jquery.simulate
  • Loading branch information...
commit a23909895ece2f0c8f1a2bf027a28e53e290bbed 1 parent 4ab41d5
@jamesstrate jamesstrate authored
View
26 test/date_picker.js
@@ -81,6 +81,32 @@ $(document).ready(function() {
});
+ test("manually enter date", function() {
+ var coffee = new Backbone.Model({
+ roaster: 'Counter Culture',
+ name: 'Baroida',
+ roastedOn: null,
+ acidic: true
+ });
+
+ var datepicker = new Backbone.UI.DatePicker({
+ model: coffee,
+ content: 'roastedOn'
+ }).render();
+
+ $('body').append(datepicker.el);
+
+ //type in datepicker and check if model updates
+ $(datepicker.el).find('input').simulate("key-sequence", {sequence: "08/24/1981"});
+ $(datepicker.el).find('input').simulate("key-sequence", {sequence: "{enter}"});
+
+ //check model changed
+ equal(coffee.get('roastedOn').getMonth(),'7');
+ equal(coffee.get('roastedOn').getDate(),'24');
+ equal(coffee.get('roastedOn').getFullYear(),'1981');
+
+ });
+
test("format", function() {
var datepicker = new Backbone.UI.DatePicker({
date : new Date(2013, 2, 22),
View
26 test/time_picker.js
@@ -37,6 +37,32 @@ $(document).ready(function() {
});
+ test("manually enter time", function() {
+ var coffee = new Backbone.Model({
+ roaster: 'Counter Culture',
+ name: 'Baroida',
+ roastedOn: null,
+ acidic: true
+ });
+
+ var timepicker = new Backbone.UI.TimePicker({
+ model: coffee,
+ content: 'roastedOn'
+ }).render();
+
+ $('body').append(timepicker.el);
+
+ //type in datepicker and check if model updates
+ $(timepicker.el).find('input').simulate("key-sequence", {sequence: "8:30 pm"});
+ $(timepicker.el).find('input').simulate("key-sequence", {sequence: "{enter}"});
+
+ //check that the model updated
+ equal(coffee.get('roastedOn').getHours(),20);
+ equal(coffee.get('roastedOn').getMinutes(),30);
+
+
+ });
+
test("interval", function() {
var coffee = new Backbone.Model({
View
2  test/vendor/jquery.simulate.key-sequence.js
@@ -84,7 +84,7 @@
// there's a flash of selection when we restore the focus, but I don't know how to avoid that.
$.data(target, 'simulate-keySequence.selection').select();
}else{
- $.data(target, 'simulate-keySequence.selection').bounds('selection');
+ if($.data(target, 'simulate-keySequence.selection')) $.data(target, 'simulate-keySequence.selection').bounds('selection');
}
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.