From aff2f08f9aa48319def50d4a9baea86e8cb7374a Mon Sep 17 00:00:00 2001 From: Justin Willis Date: Fri, 28 Apr 2017 11:11:05 -0500 Subject: [PATCH] test(datetime): add unit tests to make sure we return a string when we should (#11431) * test(datetime): add e2e test with no format provided * test(datetime): add test to check output is a string * test(datetime): add e2e test with no format provided * test(datetime): add test to check output is a string * test(datetime): add unit tests to make sure we return a string when we should --- .../test/basic/pages/root-page/root-page.html | 5 +++ src/components/datetime/test/datetime.spec.ts | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/components/datetime/test/basic/pages/root-page/root-page.html b/src/components/datetime/test/basic/pages/root-page/root-page.html index b4a83e53b9..a594a3a4c0 100644 --- a/src/components/datetime/test/basic/pages/root-page/root-page.html +++ b/src/components/datetime/test/basic/pages/root-page/root-page.html @@ -109,4 +109,9 @@ + + No displayFormat: {{noFormatDate}} + + + diff --git a/src/components/datetime/test/datetime.spec.ts b/src/components/datetime/test/datetime.spec.ts index 847d8c32f7..802e74d0bd 100644 --- a/src/components/datetime/test/datetime.spec.ts +++ b/src/components/datetime/test/datetime.spec.ts @@ -139,6 +139,39 @@ describe('DateTime', () => { expect(columns[1].options[12].disabled).toEqual(true); }); + + it('should always return a string', () => { + datetime.monthValues = '6,7,8'; + datetime.dayValues = '01,02,03,04,05,06,08,09,10, 11, 12, 13, 31'; + datetime.yearValues = '2014,2015'; + + datetime.registerOnChange((value: string) => { + expect(value).toEqual(jasmine.any(String)); + }); + }); + + it('should return a string when setValue is passed an object', zoned(() => { + const dateTimeData = { + hour: { + text: '12', + value: 12, + }, + minute: { + text: '09', + value: 9, + }, + ampm: { + text: 'pm', + value: 'pm', + }, + }; + + datetime.setValue(dateTimeData); + + datetime.registerOnChange((value: string) => { + expect(value).toEqual(jasmine.any(String)); + }); + })); }); describe('writeValue', () => {