diff --git a/packages/forms/src/fields/card.js b/packages/forms/src/fields/card.js index c5e4144..4bcb403 100644 --- a/packages/forms/src/fields/card.js +++ b/packages/forms/src/fields/card.js @@ -44,7 +44,7 @@ export const month = { { value: '11', label: '11' }, { value: '12', label: '12' }, ], - onValidChange: ({ month, updateFields }) => updateFields({ state: { isValid: !!month } }), + onValidChange: ({ month, updateFields }) => updateFields({ month: { isValid: !!month } }), validateOnBlurAndSubmit: (month) => (month === '' ? 'Selecione.' : null), }; @@ -53,7 +53,7 @@ export const year = { label: 'Ano', autoComplete: 'cc-exp-year', options: getYears(), - onValidChange: ({ year, updateFields }) => updateFields({ state: { isValid: !!year } }), + onValidChange: ({ year, updateFields }) => updateFields({ year: { isValid: !!year } }), validateOnBlurAndSubmit: (year) => (year === '' ? 'Selecione.' : null), }; diff --git a/packages/forms/src/fields/card.test.js b/packages/forms/src/fields/card.test.js index ae98192..c88a003 100644 --- a/packages/forms/src/fields/card.test.js +++ b/packages/forms/src/fields/card.test.js @@ -102,13 +102,13 @@ describe('forms', () => { it('should call updateFields with isValid true if month is not empty', () => { const updateFields = vi.fn(); month.onValidChange({ month: '01', updateFields }); - expect(updateFields).toHaveBeenCalledWith({ state: { isValid: true } }); + expect(updateFields).toHaveBeenCalledWith({ month: { isValid: true } }); }); it('should call updateFields with isValid false if month is empty', () => { const updateFields = vi.fn(); month.onValidChange({ month: '', updateFields }); - expect(updateFields).toHaveBeenCalledWith({ state: { isValid: false } }); + expect(updateFields).toHaveBeenCalledWith({ month: { isValid: false } }); }); }); @@ -152,13 +152,13 @@ describe('forms', () => { it('should call updateFields with isValid true if year is not empty', () => { const updateFields = vi.fn(); year.onValidChange({ year: '99', updateFields }); - expect(updateFields).toHaveBeenCalledWith({ state: { isValid: true } }); + expect(updateFields).toHaveBeenCalledWith({ year: { isValid: true } }); }); it('should call updateFields with isValid false if year is empty', () => { const updateFields = vi.fn(); year.onValidChange({ year: '', updateFields }); - expect(updateFields).toHaveBeenCalledWith({ state: { isValid: false } }); + expect(updateFields).toHaveBeenCalledWith({ year: { isValid: false } }); }); });