diff options
| author | Di Peng | 2011-07-14 12:02:01 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-07-20 17:06:56 -0700 | 
| commit | 3af1e7ca2ee8c2acd69e5bcbb3ffc1bf51239285 (patch) | |
| tree | e354ff465d7f29e419591dd12fb7c9f48bd8bb81 /test/FiltersSpec.js | |
| parent | 0fbaa2f12ab96328fe2e7b4b9f3ec0c8d7f30e37 (diff) | |
| download | angular.js-3af1e7ca2ee8c2acd69e5bcbb3ffc1bf51239285.tar.bz2 | |
feat(filter.date): add support for default datetime formats in en
- add support for full,long, medium, short datetime formats in en
Breaks MMMMM. now we don't support MMMMM anymore as old implementation differs
from Unicode Locale Data format we are following.
- removed support for fullDateTime and fullTime as it means too much
trouble with full timeZone names
- added docs for the new features
Diffstat (limited to 'test/FiltersSpec.js')
| -rw-r--r-- | test/FiltersSpec.js | 78 | 
1 files changed, 69 insertions, 9 deletions
| diff --git a/test/FiltersSpec.js b/test/FiltersSpec.js index 594428f6..6bcdb511 100644 --- a/test/FiltersSpec.js +++ b/test/FiltersSpec.js @@ -111,8 +111,10 @@ describe('filter', function() {      });      it('should handle mailto:', function() { -      expect(linky("mailto:me@example.com").html).toEqual('<a href="mailto:me@example.com">me@example.com</a>'); -      expect(linky("me@example.com").html).toEqual('<a href="mailto:me@example.com">me@example.com</a>'); +      expect(linky("mailto:me@example.com").html). +                      toEqual('<a href="mailto:me@example.com">me@example.com</a>'); +      expect(linky("me@example.com").html). +                      toEqual('<a href="mailto:me@example.com">me@example.com</a>');        expect(linky("send email to me@example.com, but").html).          toEqual('send email to <a href="mailto:me@example.com">me@example.com</a>, but');      }); @@ -123,6 +125,9 @@ describe('filter', function() {      var morning  = new TzDate(+5, '2010-09-03T12:05:08.000Z'); //7am      var noon =     new TzDate(+5, '2010-09-03T17:05:08.000Z'); //12pm      var midnight = new TzDate(+5, '2010-09-03T05:05:08.000Z'); //12am +    var earlyDate = new TzDate(+5, '0001-09-03T05:05:08.000Z'); +    var timZoneDate = new TzDate(+5, '2010-09-03T05:05:08.000Z', +                                     'Mon Sep 3 2010 00:05:08 GMT+0500 (XYZ)'); //12am      it('should ignore falsy inputs', function() {        expect(filter.date(null)).toBeNull(); @@ -141,24 +146,79 @@ describe('filter', function() {      it('should accept various format strings', function() {        expect(filter.date(morning, "yy-MM-dd HH:mm:ss")). -                           toEqual('10-09-03 07:05:08'); +                      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:8am0500'); +                      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:08am0500'); +                      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:08pm0500'); +                      toEqual('2010-09-03 12=12:05:08pm0500'); + +      expect(filter.date(timZoneDate, "yyyy-MM-dd hh=HH:mm:ss a z")). +                      toEqual('2010-09-03 12=00:05:08 am XYZ');        expect(filter.date(noon, "EEE, MMM d, yyyy")). -                       toEqual('Fri, Sep 3, 2010'); +                      toEqual('Fri, Sep 3, 2010'); + +      expect(filter.date(noon, "EEEE, MMMM dd, yyyy")). +                      toEqual('Friday, September 03, 2010'); + +      expect(filter.date(earlyDate, "MMMM dd, y")). +                      toEqual('September 03, 1'); +    }); + +    it('should accept default formats', function() { + +      expect(filter.date(timZoneDate, "long")). +                      toEqual('September 3, 2010 12:05:08 am XYZ'); + +      expect(filter.date(noon, "medium")). +                      toEqual('Sep 3, 2010 12:05:08 pm'); + +      expect(filter.date(noon, "short")). +                      toEqual('9/3/10 12:05 pm'); + +      expect(filter.date(noon, "fullDate")). +                      toEqual('Friday, September 3, 2010'); + +      expect(filter.date(noon, "longDate")). +                      toEqual('September 3, 2010'); -      expect(filter.date(noon, "EEEE, MMMMM dd, yyyy")). -                       toEqual('Friday, September 03, 2010'); +      expect(filter.date(noon, "mediumDate")). +                      toEqual('Sep 3, 2010'); + +      expect(filter.date(noon, "shortDate")). +                      toEqual('9/3/10'); + +      expect(filter.date(timZoneDate, "longTime")). +                      toEqual('12:05:08 am XYZ'); + +      expect(filter.date(noon, "mediumTime")). +                      toEqual('12:05:08 pm'); + +      expect(filter.date(noon, "shortTime")). +                      toEqual('12:05 pm'); +    }); + + +    it('should parse timezone identifier from various toString values', function() { +      //chrome and firefox format +      expect(filter.date(new TzDate(+5, '2010-09-03T17:05:08.000Z', +                                    'Mon Sep 3 2010 17:05:08 GMT+0500 (XYZ)'), "z")).toBe('XYZ'); + +      //opera format +      expect(filter.date(new TzDate(+5, '2010-09-03T17:05:08.000Z', +                                    '2010-09-03T17:05:08Z'), "z")).toBe('0500'); + +      //ie 8 format +      expect(filter.date(new TzDate(+5, '2010-09-03T17:05:08.000Z', +                                    'Mon Sep 3 17:05:08 XYZ 2010'), "z")).toBe('XYZ');      }); +      it('should be able to parse ISO 8601 dates/times using', function() {        var isoString = '2010-09-03T05:05:08.872Z';        expect(filter.date(isoString)). | 
