feat: swipe complete, list archive, today habits and calendar subscriptions
ci / docker (push) Successful in 3m20s
ci / docker (push) Successful in 3m20s
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { dateKey, habitWeek, isHabitComplete, isTaskView, numericHabitInputValue, shouldToggleHabitSwipe } from './mvp-utils'
|
||||
import { dateKey, habitWeek, isHabitComplete, isTaskView, numericHabitInputValue, shouldToggleRowSwipe } from './mvp-utils'
|
||||
|
||||
describe('MVP view utilities', () => {
|
||||
it('formats a local date as YYYY-MM-DD', () => {
|
||||
@@ -29,10 +29,10 @@ describe('MVP view utilities', () => {
|
||||
expect(numericHabitInputValue(4)).toBe(4)
|
||||
})
|
||||
|
||||
it('toggles a habit only for a deliberate horizontal swipe', () => {
|
||||
expect(shouldToggleHabitSwipe(78, 8)).toBe(true)
|
||||
expect(shouldToggleHabitSwipe(-78, 8)).toBe(false)
|
||||
expect(shouldToggleHabitSwipe(30, 2)).toBe(false)
|
||||
expect(shouldToggleHabitSwipe(80, 35)).toBe(false)
|
||||
it('toggles a row only for a deliberate right swipe', () => {
|
||||
expect(shouldToggleRowSwipe(78, 8)).toBe(true)
|
||||
expect(shouldToggleRowSwipe(-78, 8)).toBe(false)
|
||||
expect(shouldToggleRowSwipe(30, 2)).toBe(false)
|
||||
expect(shouldToggleRowSwipe(80, 35)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -35,6 +35,6 @@ export function numericHabitInputValue(input: number | string | undefined) {
|
||||
return Number.isFinite(value) && value >= 0 ? value : null
|
||||
}
|
||||
|
||||
export function shouldToggleHabitSwipe(deltaX: number, deltaY: number) {
|
||||
export function shouldToggleRowSwipe(deltaX: number, deltaY: number) {
|
||||
return deltaX >= 64 && Math.abs(deltaY) <= 24 && deltaX > Math.abs(deltaY) * 1.5
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user