|
| 1 | +(function() { |
| 2 | + |
| 3 | +var Calendar = kendo.ui.Calendar, |
| 4 | + instance, |
| 5 | + div; |
| 6 | + |
| 7 | +describe("kendo.ui.Calendar selection", function () { |
| 8 | + beforeEach(function() { |
| 9 | + |
| 10 | + div = $("<div />").appendTo(Mocha.fixture); |
| 11 | + }); |
| 12 | + afterEach(function() { |
| 13 | + |
| 14 | + instance.destroy(); |
| 15 | + kendo.destroy(Mocha.fixture); |
| 16 | + }); |
| 17 | + |
| 18 | + $.fn.press = function(x, y, ctrlKey, metaKey) { |
| 19 | + return triggerEvent(this, "mousedown", { |
| 20 | + pageX: x, |
| 21 | + pageY: y, |
| 22 | + ctrlKey: ctrlKey, |
| 23 | + metaKey: metaKey |
| 24 | + }); |
| 25 | + }; |
| 26 | + |
| 27 | + $.fn.move = function(x, y, ctrlKey, metaKey) { |
| 28 | + return triggerEvent(this, "mousemove", { |
| 29 | + pageX: x, |
| 30 | + pageY: y, |
| 31 | + ctrlKey: ctrlKey, |
| 32 | + metaKey: metaKey |
| 33 | + }); |
| 34 | + }; |
| 35 | + |
| 36 | + $.fn.tap = function(info) { |
| 37 | + return triggerEvent(this, "click", info); |
| 38 | + }; |
| 39 | + |
| 40 | + $.fn.release = function(info) { |
| 41 | + info = $.extend({}, info); |
| 42 | + return triggerEvent(this, "mouseup", info); |
| 43 | + }; |
| 44 | + |
| 45 | + function triggerEvent(element, type, info) { |
| 46 | + element.trigger($.Event(type, info)); |
| 47 | + |
| 48 | + return element; |
| 49 | + }; |
| 50 | + |
| 51 | + it("disabled dates are not selected with drag to select", function() { |
| 52 | + instance = new Calendar(div, { |
| 53 | + selectable: "multiple", |
| 54 | + disableDates: ["we"] |
| 55 | + }), |
| 56 | + selectable = instance.selectable, |
| 57 | + firstSelectee = $(instance.element.find("tr:eq(2) td:has(.k-link)")[0]), |
| 58 | + secondSelectee = instance.element.find("tr:eq(3) td:has(.k-link)").last(), |
| 59 | + position = secondSelectee.offset(); |
| 60 | + |
| 61 | + firstSelectee.tap().press().move(position.left, position.top).release(); |
| 62 | + |
| 63 | + assert.isOk(instance.element.find("td.k-state-selected").length); |
| 64 | + assert.isOk(!instance.element.find("td.k-state-selected.k-state-disabled").length); |
| 65 | + }); |
| 66 | + |
| 67 | + }); |
| 68 | +}()); |
0 commit comments