Browse Source

more test suite enhancements

Adam Shaw 9 years ago
parent
commit
fbdeb1ffa4

+ 49 - 0
tests/automated-better/Geom.js

@@ -0,0 +1,49 @@
+
+var Geom = {
+
+	getRectCenter: function(rect) {
+		return this.buildPoint(
+			rect.left + rect.width / 2,
+			rect.top + rect.height / 2
+		);
+	},
+
+	intersectRects: function(rect0, rect1) {
+		return this.buildRectViaEdges(
+			Math.max(rect0.left, rect1.left),
+			Math.max(rect0.top, rect1.top),
+			Math.min(rect0.right, rect1.right),
+			Math.min(rect0.bottom, rect1.bottom)
+		);
+	},
+
+	buildRectViaDims: function(left, top, width, height) {
+		return {
+			left: left,
+			top: top,
+			width: width,
+			height: height,
+			right: x + width,
+			bottom: y + height
+		};
+	},
+
+	buildRectViaEdges: function(left, top, right, bottom) {
+		return {
+			left: left,
+			top: top,
+			width: right - left,
+			height: bottom - top,
+			right: right,
+			bottom: bottom
+		};
+	},
+
+	buildPoint: function(left, top) {
+		return {
+			left: left,
+			top: top
+		};
+	}
+
+};

+ 12 - 8
tests/automated-better/event-rendering/EventRenderUtils.js

@@ -2,27 +2,31 @@
 var EventRenderUtils = {
 var EventRenderUtils = {
 
 
 	expectIsStart: function(bool) {
 	expectIsStart: function(bool) {
-		var els = $('.fc-event');
-		expect(els).toHaveLength(1);
+		var el = this.getSingleEl();
 
 
 		if (bool) {
 		if (bool) {
-			expect(els).toHaveClass('fc-start');
+			expect(el).toHaveClass('fc-start');
 		}
 		}
 		else {
 		else {
-			expect(els).not.toHaveClass('fc-start');
+			expect(el).not.toHaveClass('fc-start');
 		}
 		}
 	},
 	},
 
 
 	expectIsEnd: function(bool) {
 	expectIsEnd: function(bool) {
-		var els = $('.fc-event');
-		expect(els).toHaveLength(1);
+		var el = this.getSingleEl();
 
 
 		if (bool) {
 		if (bool) {
-			expect(els).toHaveClass('fc-end');
+			expect(el).toHaveClass('fc-end');
 		}
 		}
 		else {
 		else {
-			expect(els).not.toHaveClass('fc-end');
+			expect(el).not.toHaveClass('fc-end');
 		}
 		}
+	},
+
+	getSingleEl: function() {
+		var els = $('.fc-event');
+		expect(els).toHaveLength(1);
+		return els;
 	}
 	}
 
 
 };
 };

+ 23 - 0
tests/automated-better/globals.js

@@ -1,4 +1,27 @@
 
 
+// Jasmine Enhancements
+// ---------------------------------------------------------------------------------------------------------------------
+
+/*
+Give it/fit the ability to return promises
+*/
+[ 'it', 'fit' ].forEach(function(funcName) {
+	var origFunc = window[funcName];
+
+	window[funcName] = function(description, runFunc) {
+		origFunc(description, function(done) {
+			var res = runFunc(done);
+			if (res && res.then) {
+				res.then(done);
+			}
+			else {
+				done();
+			}
+		});
+	};
+});
+
+
 // Setup / Teardown
 // Setup / Teardown
 // ---------------------------------------------------------------------------------------------------------------------
 // ---------------------------------------------------------------------------------------------------------------------