Selaa lähdekoodia

modified month view spec to test monthname in agendaDay and basicDay views

David Asabina 11 vuotta sitten
vanhempi
sitoutus
3337519414
1 muutettua tiedostoa jossa 64 lisäystä ja 57 poistoa
  1. 64 57
      tests/automated/monthNames.js

+ 64 - 57
tests/automated/monthNames.js

@@ -15,79 +15,86 @@ describe('month name', function() {
     moment.lang('en'); // reset moment's global language
     moment.lang('en'); // reset moment's global language
   });
   });
 
 
-  describe('when view is month', function() {
-    beforeEach(function() {
-      settings.defaultView = 'month';
-    });
-
-    describe('when lang is default', function() {
+  ['month', 'agendaDay', 'basicDay'].forEach(function(viewClass, index, viewClasses) {
+    describe('when view is ' + viewClass, function() {
       beforeEach(function() {
       beforeEach(function() {
-        settings.lang = 'en';
-        moment.lang('en')
+        settings.defaultView = viewClass;
       });
       });
-
-      moment.months().forEach(function(month, index, months) {
-        it('should be ' + months[index], function(done) {
-          settings.now = moment(referenceDate).add('months', index);
-          settings.eventAfterAllRender = function() {
-            expect($('.fc-header-title')[0]).toContainText(moment.months()[index]);
-            done();
-          };
-
-          $('#cal').fullCalendar(settings);
-        });
-      });
-    });
-
-    languages.forEach(function(language, index, languages) {
-      describe('when lang is ' + language, function() {
+  
+      describe('when lang is default', function() {
         beforeEach(function() {
         beforeEach(function() {
-          settings.lang = language;
-          moment.lang(language)
+          settings.lang = 'en';
+          moment.lang('en')
         });
         });
-
+  
         moment.months().forEach(function(month, index, months) {
         moment.months().forEach(function(month, index, months) {
-          it('should be the translated name for ' + months[index], function(done) {
+          it('should be ' + months[index], function(done) {
             settings.now = moment(referenceDate).add('months', index);
             settings.now = moment(referenceDate).add('months', index);
             settings.eventAfterAllRender = function() {
             settings.eventAfterAllRender = function() {
               expect($('.fc-header-title')[0]).toContainText(moment.months()[index]);
               expect($('.fc-header-title')[0]).toContainText(moment.months()[index]);
               done();
               done();
             };
             };
-            
+  
             $('#cal').fullCalendar(settings);
             $('#cal').fullCalendar(settings);
           });
           });
         });
         });
       });
       });
-    });
-
-    describe('when names are specified', function() {
-      var months = [
-        'I',
-        'II',
-        'III',
-        'IV',
-        'V',
-        'VI',
-        'VII',
-        'IIX',
-        'IX',
-        'X',
-        'XI',
-        'XII'
-      ];
-
-      months.forEach(function(month, index, months) {
-        it('should be the translated name for ' + months[index], function(done) {
-          settings.now = moment(referenceDate).add('months', index);
-          settings.monthNames = months;
-          settings.eventAfterAllRender = function() {
-            expect($('.fc-header-title')[0]).toContainText(month);
-            done();
-          };
-          
-          $('#cal').fullCalendar(settings);
+  
+      languages.forEach(function(language, index, languages) {
+        describe('when lang is ' + language, function() {
+          beforeEach(function() {
+            settings.lang = language;
+            moment.lang(language)
+          });
+  
+          moment.months().forEach(function(month, index, months) {
+            it('should be the translated name for ' + months[index], function(done) {
+              settings.now = moment(referenceDate).add('months', index);
+              settings.eventAfterAllRender = function() {
+                if(viewClass == 'month') {
+                  expect($('.fc-header-title')[0]).toContainText(moment.months()[index]);
+                } else {
+                  expect($('.fc-header-title')[0]).toHaveText(settings.now.format('LL'));
+                }
+                done();
+              };
+              
+              $('#cal').fullCalendar(settings);
+            });
+          });
+        });
+      });
+  
+      describe('when names are specified', function() {
+        var months = [
+          'I',
+          'II',
+          'III',
+          'IV',
+          'V',
+          'VI',
+          'VII',
+          'IIX',
+          'IX',
+          'X',
+          'XI',
+          'XII'
+        ];
+  
+        months.forEach(function(month, index, months) {
+          it('should be the translated name for ' + months[index], function(done) {
+            settings.now = moment(referenceDate).add('months', index);
+            settings.monthNames = months;
+            settings.eventAfterAllRender = function() {
+              expect($('.fc-header-title')[0]).toContainText(month);
+              done();
+            };
+            
+            $('#cal').fullCalendar(settings);
+          });
         });
         });
       });
       });
     });
     });
   });
   });
+
 });
 });