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
This commit is contained in:
Justin Willis
2017-04-28 11:11:05 -05:00
committed by GitHub
parent 539901da83
commit aff2f08f9a
2 changed files with 38 additions and 0 deletions

View File

@@ -109,4 +109,9 @@
<ion-datetime displayFormat="HH:mm:ss" [(ngModel)]="time"></ion-datetime>
</ion-item>
<ion-item>
<ion-label>No displayFormat: {{noFormatDate}}</ion-label>
<ion-datetime [(ngModel)]="noFormatDate"></ion-datetime>
</ion-item>
</ion-content>

View File

@@ -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', () => {