From b96f7369516bbc4f20c82f709a0ae623659905bb Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 16 Oct 2010 21:36:49 -0700 Subject: fixed date formater and make it work on ie --- test/FiltersSpec.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'test/FiltersSpec.js') diff --git a/test/FiltersSpec.js b/test/FiltersSpec.js index e5d1b8f4..cec504a6 100644 --- a/test/FiltersSpec.js +++ b/test/FiltersSpec.js @@ -87,21 +87,34 @@ describe('filter', function(){ }); describe('date', function(){ - var date = angular.String.toDate('2010-10-13T14:45:23Z'); + var morning = angular.String.toDate('2010-09-03T23:05:08Z'); + var midnight = angular.String.toDate('2010-09-03T23:05:08Z'); + var noon = angular.String.toDate('2010-09-03T23:05:08Z'); + morning.setHours(7); + noon.setHours(12); + midnight.setHours(0); //butt-ugly hack: force the date to be 2pm PDT for locale testing - date.setHours(14); - date.getTimezoneOffset = function() { return 7 * 60; }; - + morning.getTimezoneOffset = + noon.getTimezoneOffset = + midnight.getTimezoneOffset = + function() { return 7 * 60; }; it('should do basic filter', function() { - expect(filter.date(date)).toEqual(date.toLocaleDateString()); - expect(filter.date(date, '')).toEqual(date.toLocaleDateString()); + expect(filter.date(noon)).toEqual(noon.toLocaleDateString()); + expect(filter.date(noon, '')).toEqual(noon.toLocaleDateString()); }); it('should accept format', function() { - expect(filter.date(date, "yyyy-MM-dd HH:mm:ss")).toEqual('2010-10-13 14:45:23'); - expect(filter.date(date, "yy-MM-dd KK:mm:ssaZ")).toEqual('10-10-13 02:45:23pm0700'); + expect(filter.date(midnight, "yyyy-M-d h=H:m:saZ")). + toEqual('2010-9-3 12=0:5:8am0700'); + + expect(filter.date(midnight, "yyyy-MM-dd hh=HH:mm:ssaZ")). + toEqual('2010-09-03 12=00:05:08am0700'); + + expect(filter.date(noon, "yyyy-MM-dd hh=HH:mm:ssaZ")). + toEqual('2010-09-03 12=12:05:08pm0700'); + }); -- cgit v1.2.3