21 lines
1001 B
TypeScript
21 lines
1001 B
TypeScript
import { describe, expect, it } from 'vitest'
|
||
import { formatApiErrorDetail, nextTotalAfterLocalTaskAdd } from './mvp-utils'
|
||
|
||
describe('UI bugfix helpers', () => {
|
||
it('formats FastAPI validation arrays into readable messages', () => {
|
||
expect(formatApiErrorDetail([
|
||
{ loc: ['body', 'lunar_day'], msg: 'Input should be less than or equal to 30' },
|
||
{ loc: ['body', 'title'], msg: 'String should have at least 1 character' },
|
||
])).toBe('lunar_day:Input should be less than or equal to 30;title:String should have at least 1 character')
|
||
})
|
||
|
||
it('formats nested API detail objects instead of [object Object]', () => {
|
||
expect(formatApiErrorDetail({ detail: [{ loc: ['body', 'event_date'], msg: 'Input should be a valid date' }] })).toBe('event_date:Input should be a valid date')
|
||
})
|
||
|
||
it('increments the visible total after a local quick-add insert', () => {
|
||
expect(nextTotalAfterLocalTaskAdd(0)).toBe(1)
|
||
expect(nextTotalAfterLocalTaskAdd(49)).toBe(50)
|
||
})
|
||
})
|