File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
packages/0/src/composables/useDate Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -295,6 +295,23 @@ describe('useDate', () => {
295295 expect ( result . month ) . toBe ( 8 ) // August
296296 } )
297297
298+ it ( 'should keep days when adding months' , ( ) => {
299+ const result1 = adapter . addMonths ( testDate , - 1 )
300+
301+ expect ( result1 . month ) . toBe ( 5 ) // May
302+ expect ( result1 . day ) . toBe ( 15 )
303+
304+ const result2 = adapter . addMonths ( adapter . parseISO ( '2024-01-31' ) , 1 )
305+
306+ expect ( result2 . month ) . toBe ( 2 ) // February
307+ expect ( result2 . day ) . toBe ( 29 )
308+
309+ const result3 = adapter . addMonths ( result2 , 1 )
310+
311+ expect ( result3 . month ) . toBe ( 3 ) // March
312+ expect ( result3 . day ) . toBe ( 29 )
313+ } )
314+
298315 it ( 'should handle negative amounts' , ( ) => {
299316 const result = adapter . addDays ( testDate , - 5 )
300317
You can’t perform that action at this time.
0 commit comments