Kaynağa Gözat

Update legacy tests

acerix 7 yıl önce
ebeveyn
işleme
12a8c8aeaf

+ 14 - 18
tests/automated/legacy/titleFormat.js

@@ -2,10 +2,6 @@ describe('titleFormat', function() {
 
   var SELECTOR = '.fc-toolbar h2'
 
-  beforeEach(function() {
-    affix('#cal')
-  })
-
   describe('when default', function() {
 
     var viewWithFormat = [
@@ -17,18 +13,18 @@ describe('titleFormat', function() {
     ]
 
     beforeEach(function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         defaultDate: '2014-06-12',
         titleRangeSeparator: ' - '
       })
     })
 
     it('should have default values', function() {
-      var cal = $('#cal')
+      var cal = $(currentCalendar.el)
 
       for (var i = 0; i < viewWithFormat.length; i++) {
         var crtView = viewWithFormat[i]
-        cal.fullCalendar('changeView', crtView.view)
+        currentCalendar.changeView(crtView.view)
         expect(cal.find(SELECTOR).text()).toMatch(crtView.expected)
       };
     })
@@ -45,7 +41,7 @@ describe('titleFormat', function() {
     ]
 
     beforeEach(function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         defaultDate: '2014-06-12',
         titleRangeSeparator: ' - ',
         views: {
@@ -59,11 +55,11 @@ describe('titleFormat', function() {
     })
 
     it('should have the correct values', function() {
-      var cal = $('#cal')
+      var cal = $(currentCalendar.el)
 
       for (var i = 0; i < viewWithFormat.length; i++) {
         var crtView = viewWithFormat[i]
-        cal.fullCalendar('changeView', crtView.view)
+        currentCalendar.changeView(crtView.view)
         expect(cal.find(SELECTOR).text()).toBe(crtView.expected)
       };
     })
@@ -80,7 +76,7 @@ describe('titleFormat', function() {
     ]
 
     beforeEach(function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         defaultDate: '2014-06-12',
         titleRangeSeparator: ' - ',
         locale: 'fr'
@@ -88,11 +84,11 @@ describe('titleFormat', function() {
     })
 
     it('should have the translated dates', function() {
-      var cal = $('#cal')
+      var cal = $(currentCalendar.el)
 
       for (var i = 0; i < viewWithFormat.length; i++) {
         var crtView = viewWithFormat[i]
-        cal.fullCalendar('changeView', crtView.view)
+        currentCalendar.changeView(crtView.view)
         expect(cal.find(SELECTOR).text()).toBe(crtView.expected)
       };
     })
@@ -101,7 +97,7 @@ describe('titleFormat', function() {
   describe('using custom views', function() {
 
     it('multi-year default only displays year', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         views: {
           multiYear: {
             type: 'basic',
@@ -116,7 +112,7 @@ describe('titleFormat', function() {
     })
 
     it('multi-month default only displays month/year', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         views: {
           multiMonth: {
             type: 'basic',
@@ -131,7 +127,7 @@ describe('titleFormat', function() {
     })
 
     it('multi-week default displays short full date', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         views: {
           multiWeek: {
             type: 'basic',
@@ -146,7 +142,7 @@ describe('titleFormat', function() {
     })
 
     it('multi-day default displays short full date', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         views: {
           multiDay: {
             type: 'basic',
@@ -164,7 +160,7 @@ describe('titleFormat', function() {
   describe('when not all days are shown', function() {
 
     it('doesn\'t include hidden days in the title', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         defaultView: 'agendaWeek',
         defaultDate: '2017-02-13',
         weekends: false,

+ 52 - 33
tests/automated/legacy/views-specific-options.js

@@ -1,32 +1,31 @@
 describe('view-specific options', function() {
-  var options
 
-  beforeEach(function() {
-    options = {
-      header: {
-        left: 'prev,next',
-        center: 'title',
-        right: 'month,basicWeek,basicDay,agendaWeek,agendaDay'
-      },
-      defaultView: 'month',
-      titleFormat: '[default]',
-      views: { }
-    }
-    affix('#cal')
+  pushOptions({
+    header: {
+      left: 'prev,next',
+      center: 'title',
+      right: 'month,basicWeek,basicDay,agendaWeek,agendaDay'
+    },
+    defaultView: 'month',
+    titleFormat: '[default]',
+    views: { }
   })
 
   function testEachView(viewsAndVals) {
-    $('#cal').fullCalendar(options)
     $.each(viewsAndVals, function(view, val) {
-      $('#cal').fullCalendar('changeView', view)
+      currentCalendar.changeView(view)
       expect($('h2')).toHaveText(val)
     })
   }
 
   it('can target a specific view (month)', function() {
-    options.views.month = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        month: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'special!!!',
       basicWeek: 'default',
@@ -37,9 +36,13 @@ describe('view-specific options', function() {
   })
 
   it('can target a specific view (agendaWeek)', function() {
-    options.views.agendaWeek = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        agendaWeek: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'default',
       basicWeek: 'default',
@@ -50,9 +53,13 @@ describe('view-specific options', function() {
   })
 
   it('can target basic views', function() {
-    options.views.basic = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        basic: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'default', // will NOT target month view
       basicWeek: 'special!!!',
@@ -63,9 +70,13 @@ describe('view-specific options', function() {
   })
 
   it('can target agenda views', function() {
-    options.views.agenda = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        agenda: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'default',
       basicWeek: 'default',
@@ -76,9 +87,13 @@ describe('view-specific options', function() {
   })
 
   it('can target week views', function() {
-    options.views.week = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        week: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'default',
       basicWeek: 'special!!!',
@@ -89,9 +104,13 @@ describe('view-specific options', function() {
   })
 
   it('can target day views', function() {
-    options.views.day = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        day: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'default',
       basicWeek: 'default',

+ 5 - 5
tests/automated/legacy/weekNumberTitle.js

@@ -3,7 +3,7 @@ describe('weekNumberTitle', function() {
   var options
 
   beforeEach(function() {
-    affix('#cal')
+
     options = {
       weekNumbers: true
     }
@@ -23,27 +23,27 @@ describe('weekNumberTitle', function() {
       })
 
       it('renders correctly by default', function() {
-        $('#cal').fullCalendar(options)
+        initCalendar()
         expect(getRenderedWeekNumberTitle()).toBe('W')
       })
 
       it('renders correctly when unspecified and when locale is customized', function() {
         options.locale = 'es'
-        $('#cal').fullCalendar(options)
+        initCalendar()
         expect(getRenderedWeekNumberTitle()).toBe('Sm')
       })
 
       it('renders correctly when customized and LTR', function() {
         options.isRTL = false
         options.weekNumberTitle = 'YO'
-        $('#cal').fullCalendar(options)
+        initCalendar()
         expect(getRenderedWeekNumberTitle()).toBe('YO')
       })
 
       it('renders correctly when customized and RTL', function() {
         options.isRTL = true
         options.weekNumberTitle = 'YO'
-        $('#cal').fullCalendar(options)
+        initCalendar()
         expect(getRenderedWeekNumberTitle()).toBe('YO')
       })
     })

+ 3 - 4
tests/automated/legacy/weekNumbers.js

@@ -1,17 +1,16 @@
-
 describe('weekNumbers', function() {
 
   var options
   var counts
 
   beforeEach(function() {
-    affix('#cal')
+
     counts = {}
     options = {}
   })
 
   afterEach(function() {
-    $('#cal').fullCalendar('destroy')
+    initCalendar('destroy')
   })
 
   describe('when using month view', function() {
@@ -338,7 +337,7 @@ describe('weekNumbers', function() {
   function getCounts() {
     var t = {}
 
-    $('#cal').fullCalendar(options)
+    initCalendar()
 
     t.allWeekNumbers = $('.fc-week-number').length
     t.colWeekNumbers = $('.fc-content-skeleton thead td.fc-week-number').length