Browse Source

latest jasmine-jquery and jasmine-fixture

Adam Shaw 12 years ago
parent
commit
ceb13bb0c5
4 changed files with 33 additions and 21 deletions
  1. 2 2
      bower.json
  2. 2 2
      readme.md
  3. 9 9
      tests/automated/isRTL.js
  4. 20 8
      tests/lib/jasmine-ext.js

+ 2 - 2
bower.json

@@ -6,7 +6,7 @@
     "jquery": "~1.10.2",
     "jquery-ui": "~1.10.3",
     "jquery-simulate": "*",
-    "jasmine-jquery": "~1.7.0",
-    "jasmine-fixture": "~1.0.8"
+    "jasmine-jquery": "~2.0.3",
+    "jasmine-fixture": "~1.2.0"
   }
 }

+ 2 - 2
readme.md

@@ -48,9 +48,9 @@ If you want to clean up the generated files, run:
 Automated Testing
 -----------------
 
-To run automated tests, you must first install [karma] globally:
+To run automated tests, you must first install [karma] globally, as well as some karma plugins:
 
-	npm install -g karma
+	npm install -g karma karma-jasmine karma-phantomjs-launcher
 
 Then, assuming all your source files have been built (via `grunt dev` or `watch`), you can run the tests from a browser:
 

+ 9 - 9
tests/automated/isRTL.js

@@ -19,15 +19,15 @@ describe('isRTL tests', function() {
 		});
 		it('should have prev in left', function() {
 			var fcHeaderLeft = $(cal).find('.fc-header-left')[0];
-			expect(fcHeaderLeft).toContain('.fc-button-prev');
+			expect(fcHeaderLeft).toContainElement('.fc-button-prev');
 		});
 		it('should have today in center', function() {
 			var fcHeaderCenter = $(cal).find('.fc-header-center')[0];
-			expect(fcHeaderCenter).toContain('.fc-button-today');
+			expect(fcHeaderCenter).toContainElement('.fc-button-today');
 		});
 		it('should have next in right', function() {
 			var fcHeaderRight = $(cal).find('.fc-header-right')[0];
-			expect(fcHeaderRight).toContain('.fc-button-next');
+			expect(fcHeaderRight).toContainElement('.fc-button-next');
 		});
 	});
 
@@ -46,15 +46,15 @@ describe('isRTL tests', function() {
 		});
 		it('should have prev in left', function() {
 			var fcHeaderLeft = $(cal).find('.fc-header-left')[0];
-			expect(fcHeaderLeft).toContain('.fc-button-prev');
+			expect(fcHeaderLeft).toContainElement('.fc-button-prev');
 		});
 		it('should have today in center', function() {
 			var fcHeaderCenter = $(cal).find('.fc-header-center')[0];
-			expect(fcHeaderCenter).toContain('.fc-button-today');
+			expect(fcHeaderCenter).toContainElement('.fc-button-today');
 		});
 		it('should have next in right', function() {
 			var fcHeaderRight = $(cal).find('.fc-header-right')[0];
-			expect(fcHeaderRight).toContain('.fc-button-next');
+			expect(fcHeaderRight).toContainElement('.fc-button-next');
 		});
 	});
 
@@ -73,15 +73,15 @@ describe('isRTL tests', function() {
 		});
 		it('should have prev in left', function() {
 			var fcHeaderLeft = $(cal).find('.fc-header-left')[0];
-			expect(fcHeaderLeft).toContain('.fc-button-prev');
+			expect(fcHeaderLeft).toContainElement('.fc-button-prev');
 		});
 		it('should have today in center', function() {
 			var fcHeaderCenter = $(cal).find('.fc-header-center')[0];
-			expect(fcHeaderCenter).toContain('.fc-button-today');
+			expect(fcHeaderCenter).toContainElement('.fc-button-today');
 		});
 		it('should have next in right', function() {
 			var fcHeaderRight = $(cal).find('.fc-header-right')[0];
-			expect(fcHeaderRight).toContain('.fc-button-next');
+			expect(fcHeaderRight).toContainElement('.fc-button-next');
 		});
 	});
 

+ 20 - 8
tests/lib/jasmine-ext.js

@@ -1,15 +1,27 @@
 
 beforeEach(function() {
-	this.addMatchers({
-		toEqualMoment: function(expected) {
-			return $.fullCalendar.moment(this.actual).format() ===
-				$.fullCalendar.moment(expected).format();
+	jasmine.addMatchers({
+		toEqualMoment: function() {
+			return {
+				compare: function(actual, expected) {
+					return {
+						pass: $.fullCalendar.moment(actual).format() ===
+							$.fullCalendar.moment(expected).format()
+					};
+				}
+			};
 		},
 		toEqualNow: function() {
-			return Math.abs(
-				$.fullCalendar.moment(this.actual) -
-				new Date()
-			) < 1000; // within a second of current datetime
+			return {
+				compare: function(actual) {
+					return {
+						pass: Math.abs(
+								$.fullCalendar.moment(actual) -
+								new Date()
+							) < 1000 // within a second of current datetime
+					};
+				}
+			};
 		}
 	});
 });