fix: reset completed numeric habits from check button
ci / docker (push) Successful in 7m21s

This commit is contained in:
2026-09-07 17:00:43 +08:00
parent a1cb780774
commit 6ca613f5fa
3 changed files with 15 additions and 5 deletions
+8 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { calendarModeLabel, clampFabPosition, countdownDayText, countdownKindLabel, dateKey, defaultView, habitWeek, isFabDrag, isHabitComplete, isHabitScheduledToday, isTaskView, nextHabitSwipeValue, numericHabitInputValue, previousHabitSwipeValue, quickTaskFields, shouldToggleRowSwipe } from './mvp-utils'
import { calendarModeLabel, clampFabPosition, countdownDayText, countdownKindLabel, dateKey, defaultView, habitButtonValue, habitWeek, isFabDrag, isHabitComplete, isHabitScheduledToday, isTaskView, nextHabitSwipeValue, numericHabitInputValue, previousHabitSwipeValue, quickTaskFields, shouldToggleRowSwipe } from './mvp-utils'
describe('MVP view utilities', () => {
it('formats a local date as YYYY-MM-DD', () => {
@@ -63,6 +63,13 @@ describe('MVP view utilities', () => {
expect(previousHabitSwipeValue('numeric', 0)).toBe(0)
})
it('resets a completed numeric habit when its round button is clicked again', () => {
expect(habitButtonValue('numeric', 2, 3)).toBe(3)
expect(habitButtonValue('numeric', 3, 3)).toBe(0)
expect(habitButtonValue('boolean', 0, 1)).toBe(1)
expect(habitButtonValue('boolean', 1, 1)).toBe(0)
})
it('renders countdown labels from date-only day values', () => {
expect(countdownDayText(8)).toBe('还有 8 天')
expect(countdownDayText(0)).toBe('就是今天')