소스 검색

tests for new moment behavior

Adam Shaw 11 년 전
부모
커밋
6d49c30f05
2개의 변경된 파일29개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      tests/automated/moment-formatting.js
  2. 23 0
      tests/automated/moment-query.js

+ 6 - 0
tests/automated/moment-formatting.js

@@ -65,4 +65,10 @@ describe('moment date formatting', function() {
 		//expect(s2).toEqual('Tue 6(:00)am');
 	});
 
+	it('should not allow custom fullCalendar formatting for moments created natively', function() {
+		var mom = moment.utc('2014-11-11T12:00:00');
+		var s = mom.format('MMMM Do YYYY, h(:mm)');
+		expect(s).toEqual('November 11th 2014, 12(:00)');
+	});
+
 });

+ 23 - 0
tests/automated/moment-query.js

@@ -40,6 +40,14 @@
 				m2 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00+05:00');
 				expect(m1.isSame(m2)).toBe(true);
 			});
+
+			describe('when called on a native moment', function() {
+				it('returns true when the dates are the same, but different zone-ambiguation', function() {
+					var m1 = moment.parseZone('2014-08-25T06:00:00+00:00');
+					var m2 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00');
+					expect(m1.isSame(m2)).toBe(true);
+				});
+			});
 		});
 
 		describe('when units are provided', function() {
@@ -172,6 +180,21 @@
 				});
 			});
 		});
+
+		it('returns false when on same ambiguous day', function() {
+			var mom = $.fullCalendar.moment.parseZone('2014-11-11T12:00:00+00:00');
+			var other = $.fullCalendar.moment.parseZone('2014-11-11');
+			var res = mom.isAfter(other);
+			expect(res).toBe(false);
+		});
+		describe('when called on a native moment', function() {
+			it('returns true, even when an ambiguous day would make it false', function() {
+				var mom = moment.parseZone('2014-11-11T12:00:00+00:00');
+				var other = $.fullCalendar.moment.parseZone('2014-11-11');
+				var res = mom.isAfter(other);
+				expect(res).toBe(true);
+			});
+		});
 	});
 
 })();