chore: fix date construction for consistency across different envs
This commit is contained in:
parent
9f2c4f6987
commit
d7e5cd7305
4 changed files with 19 additions and 19 deletions
|
|
@ -12,7 +12,7 @@ or a float). The modelValue can(and is recommended to) be used as both input val
|
||||||
output value of the `<lion-field>`
|
output value of the `<lion-field>`
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
- For a date input: a String '20/01/1999' will be converted to new Date('1999-01-20')
|
- For a date input: a String '20/01/1999' will be converted to new Date('1999/01/20')
|
||||||
- For a number input: a formatted String '1.234,56' will be converted to a Number: 1234.56
|
- For a number input: a formatted String '1.234,56' will be converted to a Number: 1234.56
|
||||||
|
|
||||||
### formattedValue
|
### formattedValue
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ output value of the `<lion-field>`.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
- For a date input: a String '20/01/1999' will be converted to new Date('1999-01-20')
|
- For a date input: a String '20/01/1999' will be converted to new Date('1999/01/20')
|
||||||
- For a number input: a formatted String '1.234,56' will be converted to a Number: 1234.56
|
- For a number input: a formatted String '1.234,56' will be converted to a Number: 1234.56
|
||||||
|
|
||||||
### formattedValue
|
### formattedValue
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export const FormatMixin = dedupeMixin(
|
||||||
* output value of the <lion-field>
|
* output value of the <lion-field>
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* - For a date input: a String '20/01/1999' will be converted to new Date('1999-01-20')
|
* - For a date input: a String '20/01/1999' will be converted to new Date('1999/01/20')
|
||||||
* - For a number input: a formatted String '1.234,56' will be converted to a Number: 1234.56
|
* - For a number input: a formatted String '1.234,56' will be converted to a Number: 1234.56
|
||||||
*/
|
*/
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
|
|
||||||
|
|
@ -130,23 +130,23 @@ describe('LionValidate', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('provides minDate() to allow only dates earlier then min', () => {
|
it('provides minDate() to allow only dates earlier then min', () => {
|
||||||
expect(minDate(new Date('2018-02-03'), new Date('2018-02-02'))).to.be.true;
|
expect(minDate(new Date('2018-02-03'), new Date('2018/02/02'))).to.be.true;
|
||||||
expect(minDate(new Date('2018-02-01'), new Date('2018-02-02'))).to.be.false;
|
expect(minDate(new Date('2018-02-01'), new Date('2018/02/02'))).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('provides maxDate() to allow only dates before max', () => {
|
it('provides maxDate() to allow only dates before max', () => {
|
||||||
expect(maxDate(new Date('2018-02-01'), new Date('2018-02-02'))).to.be.true;
|
expect(maxDate(new Date('2018-02-01'), new Date('2018/02/02'))).to.be.true;
|
||||||
expect(maxDate(new Date('2018-02-03'), new Date('2018-02-02'))).to.be.false;
|
expect(maxDate(new Date('2018-02-03'), new Date('2018/02/02'))).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('provides minMaxDate() to allow only dates between min and max', () => {
|
it('provides minMaxDate() to allow only dates between min and max', () => {
|
||||||
const minMaxSetting = {
|
const minMaxSetting = {
|
||||||
min: new Date('2018-02-02'),
|
min: new Date('2018/02/02'),
|
||||||
max: new Date('2018-02-04'),
|
max: new Date('2018/02/04'),
|
||||||
};
|
};
|
||||||
expect(minMaxDate(new Date('2018-02-03'), minMaxSetting)).to.be.true;
|
expect(minMaxDate(new Date('2018/02/03'), minMaxSetting)).to.be.true;
|
||||||
expect(minMaxDate(new Date('2018-02-01'), minMaxSetting)).to.be.false;
|
expect(minMaxDate(new Date('2018/02/01'), minMaxSetting)).to.be.false;
|
||||||
expect(minMaxDate(new Date('2018-02-05'), minMaxSetting)).to.be.false;
|
expect(minMaxDate(new Date('2018/02/05'), minMaxSetting)).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('provides {isDate, minDate, maxDate, minMaxDate}Validator factory function for all types', () => {
|
it('provides {isDate, minDate, maxDate, minMaxDate}Validator factory function for all types', () => {
|
||||||
|
|
@ -155,20 +155,20 @@ describe('LionValidate', () => {
|
||||||
smokeTestValidator(
|
smokeTestValidator(
|
||||||
'minDate',
|
'minDate',
|
||||||
minDateValidator,
|
minDateValidator,
|
||||||
new Date('2018-02-03'),
|
new Date('2018/02/03'),
|
||||||
new Date('2018-02-02'),
|
new Date('2018/02/02'),
|
||||||
);
|
);
|
||||||
smokeTestValidator(
|
smokeTestValidator(
|
||||||
'maxDate',
|
'maxDate',
|
||||||
maxDateValidator,
|
maxDateValidator,
|
||||||
new Date('2018-02-01'),
|
new Date('2018/02/01'),
|
||||||
new Date('2018-02-02'),
|
new Date('2018/02/02'),
|
||||||
);
|
);
|
||||||
const minMaxSetting = {
|
const minMaxSetting = {
|
||||||
min: new Date('2018-02-02'),
|
min: new Date('2018/02/02'),
|
||||||
max: new Date('2018-02-04'),
|
max: new Date('2018/02/04'),
|
||||||
};
|
};
|
||||||
smokeTestValidator('minMaxDate', minMaxDateValidator, new Date('2018-02-03'), minMaxSetting);
|
smokeTestValidator('minMaxDate', minMaxDateValidator, new Date('2018/02/03'), minMaxSetting);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue