Răsfoiți Sursa

Reusing specs + finding els using fc-view as reference

David Asabina 11 ani în urmă
părinte
comite
5333aa0d06
1 a modificat fișierele cu 42 adăugiri și 96 ștergeri
  1. 42 96
      tests/automated/dayNamesShort.js

+ 42 - 96
tests/automated/dayNamesShort.js

@@ -1,5 +1,15 @@
 describe('short day names', function() {
 describe('short day names', function() {
   var settings = {};
   var settings = {};
+  var dayClasses = [
+    '.fc-sun',
+    '.fc-mon',
+    '.fc-tue',
+    '.fc-wed',
+    '.fc-thu',
+    '.fc-fri',
+    '.fc-sat'
+  ];
+  var languages = [ 'es', 'fr', 'de', 'zh-cn', 'es' ];
 
 
   beforeEach(function() {
   beforeEach(function() {
     affix('#cal');
     affix('#cal');
@@ -7,118 +17,54 @@ describe('short day names', function() {
     }
     }
   });
   });
 
 
-  describe('when view is agendaWeek', function() {
-    describe('when lang is default', function() {
+  ['month', 'agendaWeek', 'basicWeek'].forEach(function(viewClass, index, viewClasses) {
+    describe('when view is ' + viewClass, function() {
       beforeEach(function() {
       beforeEach(function() {
-        moment.lang('en');
-        settings.defaultView = 'agendaWeek';
+        settings.defaultView = viewClass;
       });
       });
-
-      it('should be in English, starting on Sunday', function() {
-        $('#cal').fullCalendar(settings);
-        var weekdays = moment.weekdaysShort();
-
-        var dayClasses = [
-          '.fc-sun',
-          '.fc-mon',
-          '.fc-tue',
-          '.fc-wed',
-          '.fc-thu',
-          '.fc-fri',
-          '.fc-sat'
-        ];
-
-        //expect($('.fc-agenda-days thead .fc-sun')[0]).toContainText(weekdays[0]);
-        $.each(dayClasses, function(index, cls) {
-          (function(){
-            expect($('.fc-agenda-days thead ' + cls)[0]).toContainText(weekdays[index]);
-          })();
-          //console.log('dealing with ' + cls);
-        });
-      });
-    });
   
   
-    describe('when lang is not default', function() {
-      var languages = [ 'es', 'fr', 'de', 'zh-cn', 'es' ];
-  
-      $.each(languages, function(index, language) {
-        it('should be in the selected language and corresponding order', function() {
-          settings.lang = language;
+      describe('when lang is default', function() {
+        it('should be in English', function() {
+          moment.lang('en');
           $('#cal').fullCalendar(settings);
           $('#cal').fullCalendar(settings);
-  
-          moment.lang(language);
-          var dow = moment.langData(language)._week.dow
           var weekdays = moment.weekdaysShort();
           var weekdays = moment.weekdaysShort();
   
   
-          $('.fc-day-header').each(function(index, item) {
-            expect(item).toContainText(weekdays[(index + dow) % 7]);
+          dayClasses.forEach(function(cls, index, classes) {
+            expect($('.fc-view thead ' + cls)[0]).toContainText(weekdays[index]);
           });
           });
         });
         });
       });
       });
-    });
-  
-    describe('when specified', function() {
-      it('should contain the specified names in the given order', function() {
-        var days = [
-          'Hovjaj', 'maSjaj', 'veSjaj', 'mechjaj', 'parmaqjaj', 'HoSjaj'
-        ]
-        settings.dayNamesShort = days;
-        $('#cal').fullCalendar(settings);
-
-        $('.fc-day-header').each(function(index, item) {
-          expect(item).toContainText(days[index]);
-        });
-      });
-    });
-  });
-
-  describe('when view is month', function() {
-    describe('when lang is default', function() {
-      beforeEach(function() {
-        moment.lang('en');
-      });
-
-      it('should be in English, starting on Sunday', function() {
-        $('#cal').fullCalendar(settings);
-        var weekdays = moment.weekdaysShort();
-
-        $('.fc-day-header').each(function(index, item) {
-          expect(item).toHaveText(weekdays[index]);
+    
+      describe('when lang is not default', function() {
+        languages.forEach(function(language, index, languages) {
+          it('should be in the selected language', function() {
+            settings.lang = language;
+            $('#cal').fullCalendar(settings);
+    
+            moment.lang(language);
+            var dow = moment.langData(language)._week.dow
+            var weekdays = moment.weekdaysShort();
+    
+            dayClasses.forEach(function(cls, index, classes) {
+              expect($('.fc-view thead ' + cls)[0]).toContainText(weekdays[index]);
+            });
+          });
         });
         });
       });
       });
-    });
-  
-    describe('when lang is not default', function() {
-      var languages = [ 'es', 'fr', 'de', 'zh-cn', 'es' ];
-  
-      $.each(languages, function(index, language) {
-        it('should be in the selected language and corresponding order', function() {
-          settings.lang = language;
+    
+      describe('when specified', function() {
+        it('should contain the specified names in the given order', function() {
+          var days = [
+            'Hovjaj', 'maSjaj', 'veSjaj', 'mechjaj', 'parmaqjaj', 'HoSjaj'
+          ]
+          settings.dayNamesShort = days;
           $('#cal').fullCalendar(settings);
           $('#cal').fullCalendar(settings);
   
   
-          moment.lang(language);
-          var dow = moment.langData(language)._week.dow
-          var weekdays = moment.weekdaysShort();
-  
-          $('.fc-day-header').each(function(index, item) {
-            expect(item).toContainText(weekdays[(index + dow) % 7]);
+          dayClasses.forEach(function(cls, index, classes) {
+            expect($('.fc-view thead ' + cls)[0]).toContainText(days[index]);
           });
           });
         });
         });
       });
       });
     });
     });
-  
-    describe('when specified', function() {
-      it('should contain the specified names in the given order', function() {
-        var days = [
-          'Hovjaj', 'maSjaj', 'veSjaj', 'mechjaj', 'parmaqjaj', 'HoSjaj'
-        ]
-        settings.dayNamesShort = days;
-        $('#cal').fullCalendar(settings);
-
-        $('.fc-day-header').each(function(index, item) {
-          expect(item).toContainText(days[index]);
-        });
-      });
-    });
   });
   });
 });
 });