Sfoglia il codice sorgente

Update legacy tests

acerix 7 anni fa
parent
commit
d1b3ac63c5

+ 15 - 17
tests/automated/legacy/weekNumberTitle.js

@@ -1,12 +1,7 @@
 describe('weekNumberTitle', function() {
 describe('weekNumberTitle', function() {
 
 
-  var options
-
-  beforeEach(function() {
-
-    options = {
-      weekNumbers: true
-    }
+  pushOptions({
+    weekNumbers: true
   })
   })
 
 
   function getRenderedWeekNumberTitle() {
   function getRenderedWeekNumberTitle() {
@@ -18,8 +13,8 @@ describe('weekNumberTitle', function() {
   [ 'basicWeek', 'agendaWeek' ].forEach(function(viewName) {
   [ 'basicWeek', 'agendaWeek' ].forEach(function(viewName) {
     describe('when views is ' + viewName, function() {
     describe('when views is ' + viewName, function() {
 
 
-      beforeEach(function() {
-        options.defaultView = viewName
+      pushOptions({
+        defaultView: viewName
       })
       })
 
 
       it('renders correctly by default', function() {
       it('renders correctly by default', function() {
@@ -28,22 +23,25 @@ describe('weekNumberTitle', function() {
       })
       })
 
 
       it('renders correctly when unspecified and when locale is customized', function() {
       it('renders correctly when unspecified and when locale is customized', function() {
-        options.locale = 'es'
-        initCalendar()
+        initCalendar({
+          locale: 'es'
+        })
         expect(getRenderedWeekNumberTitle()).toBe('Sm')
         expect(getRenderedWeekNumberTitle()).toBe('Sm')
       })
       })
 
 
       it('renders correctly when customized and LTR', function() {
       it('renders correctly when customized and LTR', function() {
-        options.isRTL = false
-        options.weekNumberTitle = 'YO'
-        initCalendar()
+        initCalendar({
+          isRTL: false,
+          weekNumberTitle: 'YO'
+        })
         expect(getRenderedWeekNumberTitle()).toBe('YO')
         expect(getRenderedWeekNumberTitle()).toBe('YO')
       })
       })
 
 
       it('renders correctly when customized and RTL', function() {
       it('renders correctly when customized and RTL', function() {
-        options.isRTL = true
-        options.weekNumberTitle = 'YO'
-        initCalendar()
+        initCalendar({
+          isRTL: true,
+          weekNumberTitle: 'YO'
+        })
         expect(getRenderedWeekNumberTitle()).toBe('YO')
         expect(getRenderedWeekNumberTitle()).toBe('YO')
       })
       })
     })
     })

+ 85 - 43
tests/automated/legacy/weekNumbers.js

@@ -1,29 +1,27 @@
 describe('weekNumbers', function() {
 describe('weekNumbers', function() {
 
 
-  var options
   var counts
   var counts
 
 
   beforeEach(function() {
   beforeEach(function() {
-
     counts = {}
     counts = {}
-    options = {}
   })
   })
 
 
   afterEach(function() {
   afterEach(function() {
-    initCalendar('destroy')
+    currentCalendar.destroy()
   })
   })
 
 
   describe('when using month view', function() {
   describe('when using month view', function() {
 
 
-    beforeEach(function() {
-      options.defaultView = 'month'
-      options.fixedWeekCount = true // will make 6 rows
+    pushOptions({
+      defaultView: 'month',
+      fixedWeekCount: true // will make 6 rows
     })
     })
 
 
     describe('with default weekNumbers', function() { // which is false!
     describe('with default weekNumbers', function() { // which is false!
 
 
       describe('and default weekNumbersWithinDays', function() {
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
+          initCalendar()
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -31,7 +29,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to false', function() {
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -39,7 +39,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to true', function() {
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -49,12 +51,15 @@ describe('weekNumbers', function() {
 
 
     describe('with weekNumbers to false', function() {
     describe('with weekNumbers to false', function() {
 
 
-      beforeEach(function() {
-        options.weekNumbers = false
+      pushOptions({
+        weekNumbers: false
       })
       })
 
 
       describe('and default weekNumbersWithinDays', function() {
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -62,7 +67,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to false', function() {
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -70,7 +77,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to true', function() {
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -80,12 +89,13 @@ describe('weekNumbers', function() {
 
 
     describe('with weekNumbers to true', function() {
     describe('with weekNumbers to true', function() {
 
 
-      beforeEach(function() {
-        options.weekNumbers = true
+      pushOptions({
+        weekNumbers: true
       })
       })
 
 
       describe('and default weekNumbersWithinDays', function() {
       describe('and default weekNumbersWithinDays', function() {
         it('should display week numbers along the side only', function() {
         it('should display week numbers along the side only', function() {
+          initCalendar()
           counts = getCounts()
           counts = getCounts()
           // TODO: Is it possible to remove class fc-week-number from
           // TODO: Is it possible to remove class fc-week-number from
           // headers and fillers, bringing allWeekNumbers down to 6?
           // headers and fillers, bringing allWeekNumbers down to 6?
@@ -97,7 +107,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to false', function() {
       describe('and weekNumbersWithinDays set to false', function() {
         it('should display week numbers along the side only', function() {
         it('should display week numbers along the side only', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           counts = getCounts()
           // TODO: Is it possible to remove class fc-week-number from
           // TODO: Is it possible to remove class fc-week-number from
           // headers and fillers, bringing allWeekNumbers down to 6?
           // headers and fillers, bringing allWeekNumbers down to 6?
@@ -109,7 +121,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to true', function() {
       describe('and weekNumbersWithinDays set to true', function() {
         it('should display week numbers in the day cells only', function() {
         it('should display week numbers in the day cells only', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.colWeekNumbers).toEqual(0)
           expect(counts.colWeekNumbers).toEqual(0)
           expect(counts.cellWeekNumbers).toEqual(6)
           expect(counts.cellWeekNumbers).toEqual(6)
@@ -123,14 +137,15 @@ describe('weekNumbers', function() {
 
 
   describe('when using basicWeek view', function() {
   describe('when using basicWeek view', function() {
 
 
-    beforeEach(function() {
-      options.defaultView = 'basicWeek'
+    pushOptions({
+      defaultView: 'basicWeek'
     })
     })
 
 
     describe('with default weekNumbers', function() {
     describe('with default weekNumbers', function() {
 
 
       describe('and default weekNumbersWithinDays', function() {
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
+          initCalendar()
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -138,7 +153,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to false', function() {
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -146,7 +163,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to true', function() {
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -156,12 +175,13 @@ describe('weekNumbers', function() {
 
 
     describe('with weekNumbers to false', function() {
     describe('with weekNumbers to false', function() {
 
 
-      beforeEach(function() {
-        options.weekNumbers = false
+      pushOptions({
+        weekNumbers: false
       })
       })
 
 
       describe('and default weekNumbersWithinDays', function() {
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
+          initCalendar()
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -169,7 +189,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to false', function() {
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -177,7 +199,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to true', function() {
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -187,12 +211,13 @@ describe('weekNumbers', function() {
 
 
     describe('with weekNumbers to true', function() {
     describe('with weekNumbers to true', function() {
 
 
-      beforeEach(function() {
-        options.weekNumbers = true
+      pushOptions({
+        weekNumbers: true
       })
       })
 
 
       describe('and default weekNumbersWithinDays', function() {
       describe('and default weekNumbersWithinDays', function() {
         it('should display week numbers along the side only', function() {
         it('should display week numbers along the side only', function() {
+          initCalendar()
           counts = getCounts()
           counts = getCounts()
           // TODO: Is it possible to remove class fc-week-number from
           // TODO: Is it possible to remove class fc-week-number from
           // headers and fillers, bringing allWeekNumbers down to 1?
           // headers and fillers, bringing allWeekNumbers down to 1?
@@ -204,7 +229,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to false', function() {
       describe('and weekNumbersWithinDays set to false', function() {
         it('should display week numbers along the side only', function() {
         it('should display week numbers along the side only', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           counts = getCounts()
           // TODO: Is it possible to remove class fc-week-number from
           // TODO: Is it possible to remove class fc-week-number from
           // headers and fillers, bringing allWeekNumbers down to 1?
           // headers and fillers, bringing allWeekNumbers down to 1?
@@ -216,7 +243,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to true', function() {
       describe('and weekNumbersWithinDays set to true', function() {
         it('should display week numbers in the day cells only', function() {
         it('should display week numbers in the day cells only', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.colWeekNumbers).toEqual(0)
           expect(counts.colWeekNumbers).toEqual(0)
           expect(counts.cellWeekNumbers).toEqual(1)
           expect(counts.cellWeekNumbers).toEqual(1)
@@ -230,14 +259,15 @@ describe('weekNumbers', function() {
 
 
   describe('when using an agenda view', function() {
   describe('when using an agenda view', function() {
 
 
-    beforeEach(function() {
-      options.defaultView = 'agendaWeek'
+    pushOptions({
+      defaultView: 'agendaWeek'
     })
     })
 
 
     describe('with default weekNumbers', function() {
     describe('with default weekNumbers', function() {
 
 
       describe('and default weekNumbersWithinDays', function() {
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
+          initCalendar()
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -245,7 +275,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to false', function() {
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -253,7 +285,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to true', function() {
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -263,12 +297,13 @@ describe('weekNumbers', function() {
 
 
     describe('with weekNumbers to false', function() {
     describe('with weekNumbers to false', function() {
 
 
-      beforeEach(function() {
-        options.weekNumbers = false
+      pushOptions({
+        weekNumbers: false
       })
       })
 
 
       describe('and default weekNumbersWithinDays', function() {
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
+          initCalendar()
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -276,7 +311,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to false', function() {
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -284,7 +321,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to true', function() {
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
           expect(counts.allWeekNumbers).toEqual(0)
         })
         })
@@ -294,12 +333,13 @@ describe('weekNumbers', function() {
 
 
     describe('with weekNumbers to true', function() {
     describe('with weekNumbers to true', function() {
 
 
-      beforeEach(function() {
-        options.weekNumbers = true
+      pushOptions({
+        weekNumbers: true
       })
       })
 
 
       describe('and default weekNumbersWithinDays', function() {
       describe('and default weekNumbersWithinDays', function() {
         it('should display week numbers in the top left corner only', function() {
         it('should display week numbers in the top left corner only', function() {
+          initCalendar()
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(1)
           expect(counts.allWeekNumbers).toEqual(1)
           expect(counts.colWeekNumbers).toEqual(0)
           expect(counts.colWeekNumbers).toEqual(0)
@@ -310,7 +350,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to false', function() {
       describe('and weekNumbersWithinDays set to false', function() {
         it('should display week numbers in the top left corner only', function() {
         it('should display week numbers in the top left corner only', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(1)
           expect(counts.allWeekNumbers).toEqual(1)
           expect(counts.colWeekNumbers).toEqual(0)
           expect(counts.colWeekNumbers).toEqual(0)
@@ -321,7 +363,9 @@ describe('weekNumbers', function() {
 
 
       describe('and weekNumbersWithinDays set to true', function() {
       describe('and weekNumbersWithinDays set to true', function() {
         it('should display week numbers in the top left corner only', function() {
         it('should display week numbers in the top left corner only', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(1)
           expect(counts.allWeekNumbers).toEqual(1)
           expect(counts.colWeekNumbers).toEqual(0)
           expect(counts.colWeekNumbers).toEqual(0)
@@ -337,8 +381,6 @@ describe('weekNumbers', function() {
   function getCounts() {
   function getCounts() {
     var t = {}
     var t = {}
 
 
-    initCalendar()
-
     t.allWeekNumbers = $('.fc-week-number').length
     t.allWeekNumbers = $('.fc-week-number').length
     t.colWeekNumbers = $('.fc-content-skeleton thead td.fc-week-number').length
     t.colWeekNumbers = $('.fc-content-skeleton thead td.fc-week-number').length
     t.cellWeekNumbers = $('.fc-content-skeleton thead .fc-day-top span.fc-week-number').length
     t.cellWeekNumbers = $('.fc-content-skeleton thead .fc-day-top span.fc-week-number').length