From 15fc899f05fbfe978f6716f3ec035c93091d5db3 Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Mon, 25 Aug 2014 17:38:36 -0700 Subject: [PATCH] fixes to make the latest automated tests work in the IEs --- build/karma.conf.js | 6 ---- tests/automated/eventLimit-popover.js | 4 ++- tests/automated/external-dnd.js | 48 +++++++++++++++++---------- tests/lib/jasmine-ext.js | 11 +++--- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/build/karma.conf.js b/build/karma.conf.js index fcb90a8..01d2b08 100644 --- a/build/karma.conf.js +++ b/build/karma.conf.js @@ -44,12 +44,6 @@ module.exports = function(config) { '../dist/fullcalendar.css', '../tests/base.css', - // For IE8 testing. Because it can't handle running all the tests at once. - // Comment out the *.js line and run karma with each of the lines below. - //'../tests/automated/{a,b,c,d,e,f,g,h,i,j,k,l}*.js' - //'../tests/automated/{m,n}*.js' // mostly moment tests - //'../tests/automated/{o,p,q,r,s,t,u,v,w,x,y,z}*.js' - '../tests/automated/*.js' ], diff --git a/tests/automated/eventLimit-popover.js b/tests/automated/eventLimit-popover.js index d32573d..603852d 100644 --- a/tests/automated/eventLimit-popover.js +++ b/tests/automated/eventLimit-popover.js @@ -94,7 +94,9 @@ describe('eventLimit popover', function() { it('closes when user clicks the X', function() { init(); expect($('.fc-more-popover')).toBeVisible(); - $('.fc-more-popover .fc-close').simulate('click'); + $('.fc-more-popover .fc-close') + .simulate('click') + .trigger('click'); // needed this for IE8 for some reason expect($('.fc-more-popover')).not.toBeVisible(); }); diff --git a/tests/automated/external-dnd.js b/tests/automated/external-dnd.js index d0b81e4..6dcaf2e 100644 --- a/tests/automated/external-dnd.js +++ b/tests/automated/external-dnd.js @@ -46,9 +46,11 @@ describe('external drag and drop', function() { $('#sidebar .event1').remove(); $('#cal').fullCalendar('next'); $('#cal').fullCalendar('prev'); - $('#sidebar .event2').simulate('drag-n-drop', { - dropTarget: getMonthCell(1, 3) - }); + setTimeout(function() { // needed for IE8 + $('#sidebar .event2').simulate('drag-n-drop', { + dropTarget: getMonthCell(1, 3) + }); + }, 0); } else if (callCnt === 1) { expect(date).toEqualMoment('2014-08-06'); @@ -58,9 +60,11 @@ describe('external drag and drop', function() { }; $('#cal').fullCalendar(options); - $('#sidebar .event1').simulate('drag-n-drop', { - dropTarget: getMonthCell(1, 3) - }); + setTimeout(function() { // needed for IE8 + $('#sidebar .event1').simulate('drag-n-drop', { + dropTarget: getMonthCell(1, 3) + }); + }, 0); }); }); @@ -81,9 +85,11 @@ describe('external drag and drop', function() { $('#sidebar .event1').remove(); $('#cal').fullCalendar('next'); $('#cal').fullCalendar('prev'); - $('#sidebar .event2').simulate('drag-n-drop', { - dropTarget: $('.fc-slats tr:eq(2)') // middle is 1:00am on 2014-08-20 - }); + setTimeout(function() { // needed for IE8, for firing the second time, for some reason + $('#sidebar .event2').simulate('drag-n-drop', { + dropTarget: $('.fc-slats tr:eq(2)') // middle is 1:00am on 2014-08-20 + }); + }, 0); } else if (callCnt === 1) { expect(date).toEqualMoment('2014-08-20T01:00:00'); @@ -93,9 +99,11 @@ describe('external drag and drop', function() { }; $('#cal').fullCalendar(options); - $('#sidebar .event1').simulate('drag-n-drop', { - dropTarget: $('.fc-slats tr:eq(2)') // middle is 1:00am on 2014-08-20 - }); + setTimeout(function() { // needed for IE8 + $('#sidebar .event1').simulate('drag-n-drop', { + dropTarget: $('.fc-slats tr:eq(2)') // middle is 1:00am on 2014-08-20 + }); + }, 0); }); it('works with timezone as "local"', function(done) { // for issue 2225 @@ -105,9 +113,11 @@ describe('external drag and drop', function() { done(); }; $('#cal').fullCalendar(options); - $('#sidebar .event1').simulate('drag-n-drop', { - dropTarget: $('.fc-slats tr:eq(2)') // middle is 1:00am on 2014-08-20, LOCAL TIME - }); + setTimeout(function() { // needed for IE8 + $('#sidebar .event1').simulate('drag-n-drop', { + dropTarget: $('.fc-slats tr:eq(2)') // middle is 1:00am on 2014-08-20, LOCAL TIME + }); + }, 0); }); it('works with timezone as "UTC"', function(done) { // for issue 2225 @@ -117,9 +127,11 @@ describe('external drag and drop', function() { done(); }; $('#cal').fullCalendar(options); - $('#sidebar .event1').simulate('drag-n-drop', { - dropTarget: $('.fc-slats tr:eq(2)') // middle is 1:00am on 2014-08-20, LOCAL TIME - }); + setTimeout(function() { // needed for IE8 + $('#sidebar .event1').simulate('drag-n-drop', { + dropTarget: $('.fc-slats tr:eq(2)') // middle is 1:00am on 2014-08-20, LOCAL TIME + }); + }, 0); }); }); diff --git a/tests/lib/jasmine-ext.js b/tests/lib/jasmine-ext.js index ea622c0..ac2ef45 100644 --- a/tests/lib/jasmine-ext.js +++ b/tests/lib/jasmine-ext.js @@ -64,9 +64,10 @@ beforeEach(function() { compare: function(actual) { var elm = $(actual); var result = { - pass: elm.width() !== elm[0].clientWidth || - elm.height() !== elm[0].clientHeight + pass: elm[0].scrollWidth - 1 > elm[0].clientWidth || // -1 !!! + elm[0].scrollHeight - 1 > elm[0].clientHeight // -1 !!! }; + // !!! - IE was reporting a scrollWidth/scrollHeight 1 pixel taller than what it was :( return result; } }; @@ -101,7 +102,8 @@ beforeEach(function() { var otherBounds = getBounds(expected); var result = { pass: subjectBounds && otherBounds && - subjectBounds.right <= otherBounds.left + Math.round(subjectBounds.right) <= Math.round(otherBounds.left) + // need to round because IE was giving weird fractions }; if (!result.pass) { result.message = 'Element is not to the left of the other element'; @@ -117,7 +119,8 @@ beforeEach(function() { var otherBounds = getBounds(expected); var result = { pass: subjectBounds && otherBounds && - subjectBounds.left >= otherBounds.right + Math.round(subjectBounds.left) >= Math.round(otherBounds.right) + // need to round because IE was giving weird fractions }; if (!result.pass) { result.message = 'Element is not to the right of the other element';