This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { dateKey, moveDueDate } from './mvp-utils'
|
||||
import { dateKey, isTaskView, moveDueDate } from './mvp-utils'
|
||||
|
||||
describe('MVP view utilities', () => {
|
||||
it('normalizes to UTC so stored due_at stays stable in every local timezone', () => {
|
||||
@@ -8,4 +8,9 @@ describe('MVP view utilities', () => {
|
||||
const newly = moveDueDate(null, '2026-09-09')
|
||||
expect(newly).toBe('2026-09-09T09:00:00.000Z')
|
||||
})
|
||||
|
||||
it('identifies only task-backed views as task data loaders', () => {
|
||||
expect(['tasks', 'today', 'upcoming'].filter(isTaskView)).toEqual(['tasks', 'today', 'upcoming'])
|
||||
expect(['calendar', 'habits', 'settings', 'trash'].filter(isTaskView)).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -39,3 +39,7 @@ export function mergePage<T>(page: T[] | { items?: T[]; next_cursor?: string | n
|
||||
if (Array.isArray(page)) return { items: page, nextCursor: null }
|
||||
return { items: page.items ?? [], nextCursor: page.next_cursor ?? null }
|
||||
}
|
||||
|
||||
export function isTaskView(view: string) {
|
||||
return view === 'tasks' || view === 'today' || view === 'upcoming'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user