diff options
| author | Igor Minar | 2010-10-25 22:05:38 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2010-10-26 13:47:50 -0700 | 
| commit | 4c61fc01f9c251c39f540316cc82332bc8b3f370 (patch) | |
| tree | cfebbf7045b02dc15f520cd970795e947f5ab88f /test/FiltersSpec.js | |
| parent | 4fdab3765919e9fffc6d2f84e74754b1012997be (diff) | |
| download | angular.js-4c61fc01f9c251c39f540316cc82332bc8b3f370.tar.bz2 | |
Add TzDate to angular-mocks.js
TzDate is a Date-like type that is independent from the timezone
settings of the machine on which TzDate instances are created.
This property makes it ideal for testing code that deals with
timezones in a manner that makes the code portable between timezones.
Closes #81
Diffstat (limited to 'test/FiltersSpec.js')
| -rw-r--r-- | test/FiltersSpec.js | 28 | 
1 files changed, 11 insertions, 17 deletions
| diff --git a/test/FiltersSpec.js b/test/FiltersSpec.js index 6bbc09ae..4dd108ac 100644 --- a/test/FiltersSpec.js +++ b/test/FiltersSpec.js @@ -87,18 +87,11 @@ describe('filter', function(){    });    describe('date', function(){ -    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 -    morning.getTimezoneOffset = -      noon.getTimezoneOffset = -        midnight.getTimezoneOffset = -          function() {return 7 * 60;}; + +    var morning  = new TzDate(+5, '2010-09-03T12:05:08Z'); //7am +    var noon =     new TzDate(+5, '2010-09-03T17:05:08Z'); //12pm +    var midnight = new TzDate(+5, '2010-09-03T05:05:08Z'); //12am +      it('should ignore falsy inputs', function() {        expect(filter.date(null)).toEqual(null); @@ -116,16 +109,17 @@ describe('filter', function(){      });      it('should accept format', function() { +      expect(filter.date(morning, "yy-MM-dd HH:mm:ss")). +                           toEqual('10-09-03 07:05:08'); +        expect(filter.date(midnight, "yyyy-M-d h=H:m:saZ")). -                           toEqual('2010-9-3 12=0:5:8am0700'); +                           toEqual('2010-9-3 12=0:5:8am0500');        expect(filter.date(midnight, "yyyy-MM-dd hh=HH:mm:ssaZ")). -                           toEqual('2010-09-03 12=00:05:08am0700'); +                           toEqual('2010-09-03 12=00:05:08am0500');        expect(filter.date(noon, "yyyy-MM-dd hh=HH:mm:ssaZ")). -                       toEqual('2010-09-03 12=12:05:08pm0700'); - +                       toEqual('2010-09-03 12=12:05:08pm0500');      });    });  }); - | 
