2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-22 03:40:36 +03:00

feat: add prop formatter to replace the object usage of format

This commit is contained in:
mengxiong10
2020-10-20 16:07:13 +08:00
parent 7763a8d0aa
commit 5d3d54705f
5 changed files with 97 additions and 72 deletions
+52 -52
View File
@@ -92,7 +92,58 @@ exports[`DatePicker prop: clearable 1`] = `
</div>
`;
exports[`DatePicker prop: custom format 1`] = `
exports[`DatePicker prop: editable 1`] = `
<div
class="mx-datepicker"
>
<div
class="mx-input-wrapper"
>
<input
autocomplete="off"
class="mx-input"
name="date"
placeholder=""
readonly="readonly"
type="text"
/>
<i
class="mx-icon-clear"
>
<icon-close-stub />
</i>
<i
class="mx-icon-calendar"
>
<icon-calendar-stub />
</i>
</div>
<popup-stub
appendtobody="true"
>
<!---->
<div
class="mx-datepicker-content"
>
<!---->
<div
class="mx-datepicker-body"
>
<div />
</div>
<!---->
</div>
</popup-stub>
</div>
`;
exports[`DatePicker prop: formatter 1`] = `
<table
class="mx-table mx-table-date"
>
@@ -580,54 +631,3 @@ exports[`DatePicker prop: custom format 1`] = `
</tbody>
</table>
`;
exports[`DatePicker prop: editable 1`] = `
<div
class="mx-datepicker"
>
<div
class="mx-input-wrapper"
>
<input
autocomplete="off"
class="mx-input"
name="date"
placeholder=""
readonly="readonly"
type="text"
/>
<i
class="mx-icon-clear"
>
<icon-close-stub />
</i>
<i
class="mx-icon-calendar"
>
<icon-calendar-stub />
</i>
</div>
<popup-stub
appendtobody="true"
>
<!---->
<div
class="mx-datepicker-content"
>
<!---->
<div
class="mx-datepicker-body"
>
<div />
</div>
<!---->
</div>
</popup-stub>
</div>
`;
+2 -2
View File
@@ -135,14 +135,14 @@ describe('DatePicker', () => {
expect(input.value).toBe('2019/10/10');
});
it('prop: custom format', () => {
it('prop: formatter', () => {
wrapper = mount(DatePicker, {
propsData: {
valueType: 'format',
value: '13/10/2019',
open: true,
type: 'week',
format: {
formatter: {
stringify(date) {
return format(date, 'dd/MM/yyyy');
},