Added test case to check the thrown error message if input is incorrect date

This commit is contained in:
Changhao 2022-05-17 15:07:56 -07:00
parent e58b983b6f
commit ef8ead4ddb

View File

@ -65,6 +65,18 @@ describe('parseType', () => {
expect(() => parseType({ type: 'date', value: '2019-12-32' })).toThrow();
expect(() => parseType({ type: 'date', value: '2019-02-31' })).toThrow();
});
it('Throws on incorrect dates and checks the error message', () => {
expect(() => parseType({ type: 'date', value: '2019-213-23' })).toThrow(
'Invalid format, expected an ISO compatible date'
);
expect(() => parseType({ type: 'date', value: '-212' })).toThrow(
'Invalid format, expected an ISO compatible date'
);
expect(() => parseType({ type: 'date', value: '2020-02-31' })).toThrow(
'Invalid format, expected an ISO compatible date'
);
});
});
describe('Datetime', () => {