From a256a463399c73df7e24a56d1316743ba4e1eb09 Mon Sep 17 00:00:00 2001 From: rahuldimri <107100022+rahuldimri@users.noreply.github.com> Date: Wed, 15 Jun 2022 00:14:00 +0530 Subject: [PATCH] Test case: add a test case for Pull request #228 --- src/ng-pipes/pipes/date/time-ago.spec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ng-pipes/pipes/date/time-ago.spec.ts b/src/ng-pipes/pipes/date/time-ago.spec.ts index 5a38d953..b2231261 100644 --- a/src/ng-pipes/pipes/date/time-ago.spec.ts +++ b/src/ng-pipes/pipes/date/time-ago.spec.ts @@ -44,6 +44,9 @@ describe('TimeAgoPipe', () => { const fewYearsAgoString = 5 + ' years ago'; const fewYearsAgoDate = new Date(new Date().setDate(new Date().getDate() - 365 * 5)); + + const invalidDateMessage = "Invalid date"; + const invalidDateStr = "2022-02-21T019Z"; beforeAll(() => { pipe = new TimeAgoPipe(); @@ -116,4 +119,9 @@ describe('TimeAgoPipe', () => { it('should support moment.js last week', () => { expect(pipe.transform(moment().subtract(10, 'days'))).toEqual('last week'); }); + + + it('should throw invalid date for incorrect date string', () => { + expect(pipe.transform(invalidDateStr)).toEqual(invalidDateMessage); + }); });