|
|
@@ -1,5 +1,6 @@
|
|
|
|
|
|
describe('unselectAuto', function() {
|
|
|
+ var View = $.fullCalendar.View;
|
|
|
var options;
|
|
|
|
|
|
beforeEach(function() {
|
|
|
@@ -18,18 +19,47 @@ describe('unselectAuto', function() {
|
|
|
options.unselectAuto = true;
|
|
|
});
|
|
|
|
|
|
- it('unselects the current selection when clicking elsewhere in DOM', function() {
|
|
|
- $('#cal').fullCalendar(options);
|
|
|
- $('#cal').fullCalendar('select', '2014-12-01', '2014-12-03');
|
|
|
+ describe('when clicking away', function() {
|
|
|
+ it('unselects the current selection when clicking elsewhere in DOM', function(done) {
|
|
|
+ options.unselect = function(ev, view) {
|
|
|
+ expect($('.fc-highlight').length).toBe(0);
|
|
|
|
|
|
- expect($('.fc-highlight').length).toBeGreaterThan(0);
|
|
|
+ expect('currentTarget' in ev).toBe(true); // a JS event
|
|
|
+ expect(view instanceof View).toBe(true);
|
|
|
|
|
|
- $('#otherthing')
|
|
|
- .simulate('mousedown')
|
|
|
- .simulate('mouseup')
|
|
|
- .simulate('click');
|
|
|
+ done();
|
|
|
+ };
|
|
|
+
|
|
|
+ $('#cal').fullCalendar(options);
|
|
|
+ $('#cal').fullCalendar('select', '2014-12-01', '2014-12-03');
|
|
|
+
|
|
|
+ expect($('.fc-highlight').length).toBeGreaterThan(0);
|
|
|
+
|
|
|
+ $('#otherthing')
|
|
|
+ .simulate('mousedown')
|
|
|
+ .simulate('mouseup')
|
|
|
+ .simulate('click');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('when clicking another date', function() {
|
|
|
+ it('unselects the current selection when clicking elsewhere in DOM', function(done) {
|
|
|
+ options.unselect = function(ev, view) {
|
|
|
+ expect($('.fc-highlight').length).toBe(0);
|
|
|
+
|
|
|
+ expect('currentTarget' in ev).toBe(true); // a JS event
|
|
|
+ expect(view instanceof View).toBe(true);
|
|
|
+
|
|
|
+ done();
|
|
|
+ };
|
|
|
+
|
|
|
+ $('#cal').fullCalendar(options);
|
|
|
+ $('#cal').fullCalendar('select', '2014-12-01', '2014-12-03');
|
|
|
+
|
|
|
+ expect($('.fc-highlight').length).toBeGreaterThan(0);
|
|
|
|
|
|
- expect($('.fc-highlight').length).toBe(0);
|
|
|
+ $('.fc-day[data-date="2014-12-04"]').simulate('drag');
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
|