Transition isodatetomiddleendian filter tests
Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/bce574b5 Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/bce574b5 Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/bce574b5 Branch: refs/heads/master Commit: bce574b53fd3bf3b02b24d9a39a66f14a8d3085d Parents: e092e0f Author: Michael Joyce <[email protected]> Authored: Fri Aug 1 13:47:50 2014 -0700 Committer: Michael Joyce <[email protected]> Committed: Mon Aug 4 15:01:02 2014 -0700 ---------------------------------------------------------------------- .../test/spec/filters/isodatetomiddleendian.js | 46 ++++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/bce574b5/ocw-ui/frontend-new/test/spec/filters/isodatetomiddleendian.js ---------------------------------------------------------------------- diff --git a/ocw-ui/frontend-new/test/spec/filters/isodatetomiddleendian.js b/ocw-ui/frontend-new/test/spec/filters/isodatetomiddleendian.js index 72ab650..966b333 100644 --- a/ocw-ui/frontend-new/test/spec/filters/isodatetomiddleendian.js +++ b/ocw-ui/frontend-new/test/spec/filters/isodatetomiddleendian.js @@ -30,9 +30,47 @@ describe('Filter: ISODateToMiddleEndian', function () { ISODateToMiddleEndian = $filter('ISODateToMiddleEndian'); })); - it('should return the input prefixed with "ISODateToMiddleEndian filter:"', function () { - var text = 'angularjs'; - expect(ISODateToMiddleEndian(text)).toBe('ISODateToMiddleEndian filter: ' + text); - }); + describe('ISODateToMiddleEndian', function() { + it('should replace the ISO Date/Time stamp', function() { + inject(function($filter) { + var filter = $filter('ISODateToMiddleEndian'); + expect(filter('2012-01-02T00:00:00')).toEqual('01/02/2012'); + }); + }); + it('should replace the modified ISO Date/Time stamp', function() { + inject(function($filter) { + var filter = $filter('ISODateToMiddleEndian'); + expect(filter('2012-01-02 00:00:00')).toEqual('01/02/2012'); + }); + }); + + it('should replace the ISO Date stamp', function() { + inject(function($filter) { + var filter = $filter('ISODateToMiddleEndian'); + expect(filter('2012-01-02')).toEqual('01/02/2012'); + }); + }); + + it('should replace leading and trailing whitespace', function() { + inject(function($filter) { + var filter = $filter('ISODateToMiddleEndian'); + expect(filter(' 2012-01-02T00:00:00 ')).toEqual('01/02/2012'); + }); + }); + + it('should do nothing when the date format has the incorrect number of hyphens', function() { + inject(function($filter) { + var filter = $filter('ISODateToMiddleEndian'); + expect(filter('2012-234T234')).toEqual('2012-234T234') + }); + }); + + it('should do nothing when the date format has no hyphens', function() { + inject(function($filter) { + var filter = $filter('ISODateToMiddleEndian'); + expect(filter('2012234T234')).toEqual('2012234T234') + }); + }); + }); });
