This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { dateKey, habitWeek, isHabitComplete, isTaskView, numericHabitInputValue, shouldToggleRowSwipe } from './mvp-utils'
|
||||
import { dateKey, defaultView, habitWeek, isHabitComplete, isTaskView, nextHabitSwipeValue, numericHabitInputValue, previousHabitSwipeValue, shouldToggleRowSwipe } from './mvp-utils'
|
||||
|
||||
describe('MVP view utilities', () => {
|
||||
it('formats a local date as YYYY-MM-DD', () => {
|
||||
@@ -29,10 +29,22 @@ describe('MVP view utilities', () => {
|
||||
expect(numericHabitInputValue(4)).toBe(4)
|
||||
})
|
||||
|
||||
it('toggles a row only for a deliberate right swipe', () => {
|
||||
it('uses today as the default landing view', () => {
|
||||
expect(defaultView()).toBe('today')
|
||||
})
|
||||
|
||||
it('increments count habits one swipe at a time and caps at target', () => {
|
||||
expect(nextHabitSwipeValue('numeric', 2, 5)).toBe(3)
|
||||
expect(nextHabitSwipeValue('numeric', 5, 5)).toBe(5)
|
||||
expect(previousHabitSwipeValue('numeric', 3)).toBe(2)
|
||||
expect(previousHabitSwipeValue('numeric', 0)).toBe(0)
|
||||
})
|
||||
|
||||
it('toggles a row for a deliberate mostly-horizontal swipe', () => {
|
||||
expect(shouldToggleRowSwipe(78, 8)).toBe(true)
|
||||
expect(shouldToggleRowSwipe(88, 28)).toBe(true)
|
||||
expect(shouldToggleRowSwipe(-78, 8)).toBe(false)
|
||||
expect(shouldToggleRowSwipe(30, 2)).toBe(false)
|
||||
expect(shouldToggleRowSwipe(80, 35)).toBe(false)
|
||||
expect(shouldToggleRowSwipe(80, 60)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user