diff options
| author | Igor Minar | 2012-03-26 23:38:20 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-03-28 16:30:30 -0700 |
| commit | ac4318a2fa5c6d306dbc19466246292a81767fca (patch) | |
| tree | a8d9d0ff164516b153bf4c9142d1c9fb17315008 /test/ng | |
| parent | bb2fa6f63f0a4a08d4a3a5439d1ab6d9ddfd917e (diff) | |
| download | angular.js-ac4318a2fa5c6d306dbc19466246292a81767fca.tar.bz2 | |
refactor(fromJson/date filter): move date string logic to date filter
Breaks angular.fromJson which doesn't deserialize date strings into date objects.
This was done to make fromJson compatible with JSON.parse.
If you do require the old behavior - if at all neeeded then because of
json deserialization of XHR responses - then please create a custom
$http transform:
$httpProvider.defaults.transformResponse.push(function(data) {
// recursively parse dates from data object here
// see code removed in this diff for hints
});
Closes #202
Diffstat (limited to 'test/ng')
| -rw-r--r-- | test/ng/filter/filtersSpec.js | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/test/ng/filter/filtersSpec.js b/test/ng/filter/filtersSpec.js index 98651c58..9ea200a3 100644 --- a/test/ng/filter/filtersSpec.js +++ b/test/ng/filter/filtersSpec.js @@ -267,14 +267,34 @@ describe('filters', function() { toEqual('12:05 PM'); }); - it('should be able to parse ISO 8601 dates/times using', function() { - var isoString = '2010-09-03T05:05:08.872Z'; - expect(date(isoString)). - toEqual(date(isoString, 'mediumDate')); - }); - it('should parse format ending with non-replaced string', function() { expect(date(morning, 'yy/xxx')).toEqual('10/xxx'); }); + + + it('should support various iso8061 date strings as input', function() { + var format = 'yyyy-MM ss'; + + //full ISO8061 + expect(date('2003-09-10T13:02:03.000Z', format)).toEqual('2003-09 03'); + + expect(date('2003-09-10T13:02:03.000+00:00', format)).toEqual('2003-09 03'); + + expect(date('2003-09-10T13:02:03-08:00', format)).toEqual('2003-09 03'); + + expect(date('20030910T033203-0930', format)).toEqual('2003-09 03'); + + //no millis + expect(date('2003-09-10T13:02:03Z', format)).toEqual('2003-09 03'); + + //no seconds + expect(date('2003-09-10T13:02Z', format)).toEqual('2003-09 00'); + + //no minutes + expect(date('2003-09-10T13Z', format)).toEqual('2003-09 00'); + + //no time + expect(date('2003-09-10', format)).toEqual('2003-09 00'); + }); }); }); |
