mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
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:
@@ -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>
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user