浏览代码

easier color testing in automated tests, more bg event color tests

Adam Shaw 11 年之前
父节点
当前提交
eb4ec97d59
共有 2 个文件被更改,包括 43 次插入8 次删除
  1. 38 8
      tests/automated/background-events.js
  2. 5 0
      tests/lib/dom-utils.js

+ 38 - 8
tests/automated/background-events.js

@@ -332,7 +332,7 @@ describe('background events', function() {
 				color: 'red'
 				color: 'red'
 			} ];
 			} ];
 			options.eventAfterAllRender = function() {
 			options.eventAfterAllRender = function() {
-				expect($('.fc-bgevent').css('background-color')).toMatch(/red|rgb\(255, 0, 0\)/);
+				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
 			$('#cal').fullCalendar(options);
 			$('#cal').fullCalendar(options);
@@ -345,7 +345,7 @@ describe('background events', function() {
 				backgroundColor: 'red'
 				backgroundColor: 'red'
 			} ];
 			} ];
 			options.eventAfterAllRender = function() {
 			options.eventAfterAllRender = function() {
-				expect($('.fc-bgevent').css('background-color')).toMatch(/red|rgb\(255, 0, 0\)/);
+				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
 			$('#cal').fullCalendar(options);
 			$('#cal').fullCalendar(options);
@@ -360,7 +360,7 @@ describe('background events', function() {
 				} ]
 				} ]
 			} ];
 			} ];
 			options.eventAfterAllRender = function() {
 			options.eventAfterAllRender = function() {
-				expect($('.fc-bgevent').css('background-color')).toMatch(/red|rgb\(255, 0, 0\)/);
+				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
 			$('#cal').fullCalendar(options);
 			$('#cal').fullCalendar(options);
@@ -375,7 +375,7 @@ describe('background events', function() {
 				} ]
 				} ]
 			} ];
 			} ];
 			options.eventAfterAllRender = function() {
 			options.eventAfterAllRender = function() {
-				expect($('.fc-bgevent').css('background-color')).toMatch(/red|rgb\(255, 0, 0\)/);
+				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
 			$('#cal').fullCalendar(options);
 			$('#cal').fullCalendar(options);
@@ -717,7 +717,7 @@ describe('background events', function() {
 				color: 'red'
 				color: 'red'
 			} ];
 			} ];
 			options.eventAfterAllRender = function() {
 			options.eventAfterAllRender = function() {
-				expect($('.fc-bgevent').css('background-color')).toMatch(/red|rgb\(255, 0, 0\)/);
+				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
 			$('#cal').fullCalendar(options);
 			$('#cal').fullCalendar(options);
@@ -730,7 +730,7 @@ describe('background events', function() {
 				backgroundColor: 'red'
 				backgroundColor: 'red'
 			} ];
 			} ];
 			options.eventAfterAllRender = function() {
 			options.eventAfterAllRender = function() {
-				expect($('.fc-bgevent').css('background-color')).toMatch(/red|rgb\(255, 0, 0\)/);
+				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
 			$('#cal').fullCalendar(options);
 			$('#cal').fullCalendar(options);
@@ -745,7 +745,7 @@ describe('background events', function() {
 				} ]
 				} ]
 			} ];
 			} ];
 			options.eventAfterAllRender = function() {
 			options.eventAfterAllRender = function() {
-				expect($('.fc-bgevent').css('background-color')).toMatch(/red|rgb\(255, 0, 0\)/);
+				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
 			$('#cal').fullCalendar(options);
 			$('#cal').fullCalendar(options);
@@ -760,7 +760,37 @@ describe('background events', function() {
 				} ]
 				} ]
 			} ];
 			} ];
 			options.eventAfterAllRender = function() {
 			options.eventAfterAllRender = function() {
-				expect($('.fc-bgevent').css('background-color')).toMatch(/red|rgb\(255, 0, 0\)/);
+				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
+				done();
+			};
+			$('#cal').fullCalendar(options);
+		});
+
+		it('is affected by global eventColor', function(done) {
+			options.eventColor = 'red';
+			options.eventSources = [ {
+				events: [ {
+					start: '2014-11-04T01:00:00',
+					rendering: 'background'
+				} ]
+			} ];
+			options.eventAfterAllRender = function() {
+				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
+				done();
+			};
+			$('#cal').fullCalendar(options);
+		});
+
+		it('is affected by global eventBackgroundColor', function(done) {
+			options.eventBackgroundColor = 'red';
+			options.eventSources = [ {
+				events: [ {
+					start: '2014-11-04T01:00:00',
+					rendering: 'background'
+				} ]
+			} ];
+			options.eventAfterAllRender = function() {
+				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
 			$('#cal').fullCalendar(options);
 			$('#cal').fullCalendar(options);

+ 5 - 0
tests/lib/dom-utils.js

@@ -1,4 +1,9 @@
 
 
+var RED_REGEX = /red|rgb\(255,\s*0,\s*0\)/;
+var GREEN_REGEX = /green|rgb\(0,\s*255,\s*0\)/;
+var BLUE_REGEX = /blue|rgb\(0,\s*0,\s*255\)/;
+
+
 function getStockScrollbarWidths(dir) {
 function getStockScrollbarWidths(dir) {
 	var el = $('<div><div style="position:relative"/></div>')
 	var el = $('<div><div style="position:relative"/></div>')
 		.css({
 		.css({