Parcourir la source

modify test for buttonText to account for new behavior

Adam Shaw il y a 11 ans
Parent
commit
7786cc38c7
1 fichiers modifiés avec 129 ajouts et 55 suppressions
  1. 129 55
      tests/automated/buttonText.js

+ 129 - 55
tests/automated/buttonText.js

@@ -1,6 +1,6 @@
 describe('button text', function() {
 
-  var settings = {};
+  var settings;
 
   beforeEach(function() {
     affix('#cal');
@@ -13,31 +13,28 @@ describe('button text', function() {
     };
   });
 
-  describe('with buttonIcons', function() {
+  describe('with default language', function() {
 
-    describe('when lang is default', function() {
-      it('should have no text', function() {
-        expect($('.fc-button-next')).toHaveText('');
-        expect($('.fc-button-nextYear')).toHaveText('');
-        expect($('.fc-button-prev')).toHaveText('');
-        expect($('.fc-button-prevYear')).toHaveText('');
-      });
-    });
+    describe('with default buttonIcons', function() {
 
-    describe('when lang is not default', function() {
-      it('should have no text', function() {
-        settings.lang = 'nl';
+      it('should contain default text values', function() {
         $('#cal').fullCalendar(settings);
 
+        // will have button icons, to text will be empty
         expect($('.fc-button-next')).toHaveText('');
         expect($('.fc-button-nextYear')).toHaveText('');
         expect($('.fc-button-prev')).toHaveText('');
         expect($('.fc-button-prevYear')).toHaveText('');
+
+        expect($('.fc-button-today')).toHaveText('today');
+        expect($('.fc-button-month')).toHaveText('month');
+        expect($('.fc-button-basicWeek')).toHaveText('week');
+        expect($('.fc-button-agendaWeek')).toHaveText('week');
+        expect($('.fc-button-basicDay')).toHaveText('day');
+        expect($('.fc-button-agendaDay')).toHaveText('day');
       });
-    });
 
-    describe('when buttonText is set to custom value', function() {
-      it('should have no text', function() {
+      it('should contain specified text values', function() {
         settings.buttonText = {
           prev: '<-',
           next: '->',
@@ -50,52 +47,45 @@ describe('button text', function() {
         };
         $('#cal').fullCalendar(settings);
 
-        expect($('.fc-button-next')).toHaveText('');
-        expect($('.fc-button-nextYear')).toHaveText('');
-        expect($('.fc-button-prev')).toHaveText('');
-        expect($('.fc-button-prevYear')).toHaveText('');
-      });
-    });
-  });
+        expect($('.fc-button-next')).toHaveText('->');
+        expect($('.fc-button-nextYear')).toHaveText('-->');
+        expect($('.fc-button-prev')).toHaveText('<-');
+        expect($('.fc-button-prevYear')).toHaveText('<--');
 
-  describe('without buttonIcons', function() {
+        expect($('.fc-button-today')).toHaveText('tidei');
+        expect($('.fc-button-month')).toHaveText('mun');
+        expect($('.fc-button-agendaDay')).toHaveText('dei');
+        expect($('.fc-button-agendaWeek')).toHaveText('wiki');
+        expect($('.fc-button-basicDay')).toHaveText('dei');
+        expect($('.fc-button-basicWeek')).toHaveText('wiki');
+      });
 
-    beforeEach(function() {
-      settings.buttonIcons = {
-        prev: null,
-        next: null,
-        prevYear: null,
-        nextYear: null
-      };
     });
 
-    describe('when lang is default', function() {
+    describe('with buttonIcons turned off', function() {
 
       beforeEach(function() {
-        $('#cal').fullCalendar(settings);
+        settings.buttonIcons = false;
       });
 
-      it('should contain the default text values', function() {
-        expect($('.fc-button-today')).toHaveText('today');
+      it('should contain default text values', function() {
+        $('#cal').fullCalendar(settings);
 
+        // will have actual text now
         expect($('.fc-button-next')).toHaveText('next');
         expect($('.fc-button-nextYear')).toHaveText('next year');
         expect($('.fc-button-prev')).toHaveText('prev');
         expect($('.fc-button-prevYear')).toHaveText('prev year');
 
+        expect($('.fc-button-today')).toHaveText('today');
         expect($('.fc-button-month')).toHaveText('month');
-
         expect($('.fc-button-basicWeek')).toHaveText('week');
         expect($('.fc-button-agendaWeek')).toHaveText('week');
-
         expect($('.fc-button-basicDay')).toHaveText('day');
         expect($('.fc-button-agendaDay')).toHaveText('day');
       });
-    });
-
-    describe('when buttonText is specified', function() {
 
-      beforeEach(function() {
+      it('should contain specified text values', function() {
         settings.buttonText = {
           prev: '<-',
           next: '->',
@@ -107,45 +97,129 @@ describe('button text', function() {
           day: 'dei'
         };
         $('#cal').fullCalendar(settings);
-      });
 
-      it('should contain the specified text values', function() {
+        expect($('.fc-button-next')).toHaveText('->');
+        expect($('.fc-button-nextYear')).toHaveText('-->');
+        expect($('.fc-button-prev')).toHaveText('<-');
+        expect($('.fc-button-prevYear')).toHaveText('<--');
+
         expect($('.fc-button-today')).toHaveText('tidei');
+        expect($('.fc-button-month')).toHaveText('mun');
+        expect($('.fc-button-agendaDay')).toHaveText('dei');
+        expect($('.fc-button-agendaWeek')).toHaveText('wiki');
+        expect($('.fc-button-basicDay')).toHaveText('dei');
+        expect($('.fc-button-basicWeek')).toHaveText('wiki');
+      });
+
+    });
+
+  });
+
+  describe('when lang is not default', function() {
+
+    beforeEach(function() {
+      settings.lang = 'fr';
+    });
+
+    describe('with default buttonIcons', function() {
+
+      it('should contain default text values', function() {
+        $('#cal').fullCalendar(settings);
+
+        // will contain icons, so will contain no text
+        expect($('.fc-button-next')).toHaveText('');
+        expect($('.fc-button-nextYear')).toHaveText('');
+        expect($('.fc-button-prev')).toHaveText('');
+        expect($('.fc-button-prevYear')).toHaveText('');
+
+        expect($('.fc-button-today')).toHaveText('Aujourd\'hui');
+        expect($('.fc-button-month')).toHaveText('Mois');
+        expect($('.fc-button-basicWeek')).toHaveText('Semaine');
+        expect($('.fc-button-agendaWeek')).toHaveText('Semaine');
+        expect($('.fc-button-basicDay')).toHaveText('Jour');
+        expect($('.fc-button-agendaDay')).toHaveText('Jour');
+      });
+
+      it('should contain specified text values', function() {
+        settings.buttonText = {
+          prev: '<-',
+          next: '->',
+          prevYear: '<--',
+          nextYear: '-->',
+          today: 'tidei',
+          month: 'mun',
+          week: 'wiki',
+          day: 'dei'
+        };
+        $('#cal').fullCalendar(settings);
 
         expect($('.fc-button-next')).toHaveText('->');
         expect($('.fc-button-nextYear')).toHaveText('-->');
         expect($('.fc-button-prev')).toHaveText('<-');
         expect($('.fc-button-prevYear')).toHaveText('<--');
 
+        expect($('.fc-button-today')).toHaveText('tidei');
         expect($('.fc-button-month')).toHaveText('mun');
-
         expect($('.fc-button-agendaDay')).toHaveText('dei');
         expect($('.fc-button-agendaWeek')).toHaveText('wiki');
-
         expect($('.fc-button-basicDay')).toHaveText('dei');
         expect($('.fc-button-basicWeek')).toHaveText('wiki');
       });
+
     });
 
-    describe('when lang is not default', function() {
+    describe('with buttonIcons turned off', function() {
 
       beforeEach(function() {
-        settings.lang = 'nl';
-        $('#cal').fullCalendar(settings);
+        settings.buttonIcons = false;
       });
 
-      it('should contain the default text values', function() {
-        expect($('.fc-button-today')).toHaveText('Vandaag');
+      it('should contain default text values', function() {
+        $('#cal').fullCalendar(settings);
 
-        expect($('.fc-button-month')).toHaveText('Maand');
+        // will have the language's actual text now
+        expect($('.fc-button-next')).toHaveText('Suivant');
+        expect($('.fc-button-prev')).toHaveText('Précédent');
+        //// languages files don't have data for prev/next *year*
+        //expect($('.fc-button-nextYear')).toHaveText('Suivant');
+        //expect($('.fc-button-prevYear')).toHaveText('Précédent');
+
+        expect($('.fc-button-today')).toHaveText('Aujourd\'hui');
+        expect($('.fc-button-month')).toHaveText('Mois');
+        expect($('.fc-button-basicWeek')).toHaveText('Semaine');
+        expect($('.fc-button-agendaWeek')).toHaveText('Semaine');
+        expect($('.fc-button-basicDay')).toHaveText('Jour');
+        expect($('.fc-button-agendaDay')).toHaveText('Jour');
+      });
+
+      it('should contain specified text values', function() {
+        settings.buttonText = {
+          prev: '<-',
+          next: '->',
+          prevYear: '<--',
+          nextYear: '-->',
+          today: 'tidei',
+          month: 'mun',
+          week: 'wiki',
+          day: 'dei'
+        };
+        $('#cal').fullCalendar(settings);
 
-        expect($('.fc-button-basicWeek')).toHaveText('Week');
-        expect($('.fc-button-agendaWeek')).toHaveText('Week');
+        expect($('.fc-button-next')).toHaveText('->');
+        expect($('.fc-button-nextYear')).toHaveText('-->');
+        expect($('.fc-button-prev')).toHaveText('<-');
+        expect($('.fc-button-prevYear')).toHaveText('<--');
 
-        expect($('.fc-button-basicDay')).toHaveText('Dag');
-        expect($('.fc-button-agendaDay')).toHaveText('Dag');
+        expect($('.fc-button-today')).toHaveText('tidei');
+        expect($('.fc-button-month')).toHaveText('mun');
+        expect($('.fc-button-agendaDay')).toHaveText('dei');
+        expect($('.fc-button-agendaWeek')).toHaveText('wiki');
+        expect($('.fc-button-basicDay')).toHaveText('dei');
+        expect($('.fc-button-basicWeek')).toHaveText('wiki');
       });
+
     });
+
   });
 
 });