diff options
| author | Misko Hevery | 2010-10-16 21:36:49 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-10-16 21:43:28 -0700 |
| commit | b96f7369516bbc4f20c82f709a0ae623659905bb (patch) | |
| tree | 9c5d2cb8b74d576b490c0491673645798058182c /test | |
| parent | f8865459d554ef372cf732da26014dbe74275da8 (diff) | |
| download | angular.js-b96f7369516bbc4f20c82f709a0ae623659905bb.tar.bz2 | |
fixed date formater and make it work on ie
Diffstat (limited to 'test')
| -rw-r--r-- | test/FiltersSpec.js | 29 |
1 files changed, 21 insertions, 8 deletions
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'); + }); |
